From 5af8241682332cacb5ae8e2669e3a297949fb915 Mon Sep 17 00:00:00 2001 From: Is Isilon Date: Fri, 29 Jan 2016 11:10:30 +0800 Subject: [PATCH 1/6] readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3b599d0..0b65207 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/abhshkdz/HackFlowy?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -An open-source [Workflowy](http://workflowy.com) clone. +An open-source [Workflowy](http://workflowy.com) clone. [Demo here](http://wassname.github.io/HackFlowy/). ![](https://dl.dropbox.com/u/19398876/screenshots/043.png) From 68d73eb2457bc675e7b20bb4bb9f869868dc8a2e Mon Sep 17 00:00:00 2001 From: Is Isilon Date: Fri, 29 Jan 2016 11:12:33 +0800 Subject: [PATCH 2/6] readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0b65207..c8fc68d 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/abhshkdz/HackFlowy?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -An open-source [Workflowy](http://workflowy.com) clone. [Demo here](http://wassname.github.io/HackFlowy/). +An open-source [Workflowy](http://workflowy.com) clone. [Static demo available here](http://wassname.github.io/HackFlowy/). ![](https://dl.dropbox.com/u/19398876/screenshots/043.png) From 5ca28942e6c8bb9d15e31aaa0bb574c058a501db Mon Sep 17 00:00:00 2001 From: Is Isilon Date: Fri, 29 Jan 2016 12:57:14 +0800 Subject: [PATCH 3/6] Let page grow in length --- public/sass/app.scss | 4 ++-- public/stylesheets/app.css | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/public/sass/app.scss b/public/sass/app.scss index 0f61331..d2f4bec 100644 --- a/public/sass/app.scss +++ b/public/sass/app.scss @@ -53,12 +53,12 @@ body { background-color: $lightgrey; #hackflowy { background-color: white; - height: 1000px; + min-height: 1000px; margin: 75px 100px; box-shadow: 0px 0px 10px 5px #ccc; padding: 60px 60px; #main { - height: 880px; + min-height: 880px; border-top: 1px solid #eee; border-bottom: 1px solid #eee; #name { diff --git a/public/stylesheets/app.css b/public/stylesheets/app.css index bbffa74..fdbdde4 100644 --- a/public/stylesheets/app.css +++ b/public/stylesheets/app.css @@ -5543,14 +5543,14 @@ body { /* line 54, ../sass/app.scss */ body #hackflowy { background-color: white; - height: 1000px; + min-height: 1000px; margin: 75px 100px; box-shadow: 0px 0px 10px 5px #cccccc; padding: 60px 60px; } /* line 60, ../sass/app.scss */ body #hackflowy #main { - height: 880px; + min-height: 880px; border-top: 1px solid #eeeeee; border-bottom: 1px solid #eeeeee; } @@ -5775,4 +5775,4 @@ border-right: 15px solid transparent; .task-completed{ text-decoration: line-through; -} \ No newline at end of file +} From 84a86facfcda7661ade70add238cfc89c65a1294 Mon Sep 17 00:00:00 2001 From: Is Isilon Date: Fri, 29 Jan 2016 13:08:18 +0800 Subject: [PATCH 4/6] Add defaults to model --- db/models/task.js | 7 ++++--- db/seed/initial_tasks.js | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/db/models/task.js b/db/models/task.js index 4e3eb86..251a2ea 100644 --- a/db/models/task.js +++ b/db/models/task.js @@ -5,10 +5,11 @@ module.exports = { task = orm.define('Tasks', { id : {type: Sequelize.INTEGER, primaryKey: true, autoIncrement: true}, content : {type: Sequelize.TEXT, allowNull: false}, - parent : Sequelize.INTEGER, - isCompleted: Sequelize.BOOLEAN, + parentId : {type: Sequelize.INTEGER, defaultValue: 0}, + isCompleted: {type: Sequelize.BOOLEAN, defaultValue: false}, + priority : {type: Sequelize.INTEGER, defaultValue: 0}, createdAt : Sequelize.DATE, - updatedAt : Sequelize.DATE + updatedAt : Sequelize.DATE, }); orm.sync(); diff --git a/db/seed/initial_tasks.js b/db/seed/initial_tasks.js index 8090b48..a494b23 100644 --- a/db/seed/initial_tasks.js +++ b/db/seed/initial_tasks.js @@ -7,7 +7,7 @@ Tasks.destroy({where: {}}).then(function() { {content: 'Welcome to HackFlowy!', isCompleted: false}, {content: 'An open-source WorkFlowy clone', isCompleted: false}, {content: 'Built using Backbone + Socket.IO', isCompleted: false}, - {content: 'I pulled this together in a few hours to learn Backbone', isCompleted: false}, + {content: 'Desyncr pulled this together in a few hours to learn Backbone', isCompleted: false}, {content: 'Feel free to try it out and hack on it', isCompleted: false}, {content: 'Good Luck!', isCompleted: false} ]); From 68cd74e692b47377b76e4d5c9581ce70d0b44526 Mon Sep 17 00:00:00 2001 From: Is Isilon Date: Fri, 29 Jan 2016 13:53:06 +0800 Subject: [PATCH 5/6] Added to footer --- public/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/index.html b/public/index.html index dfe5a04..3bd47d7 100644 --- a/public/index.html +++ b/public/index.html @@ -34,7 +34,7 @@ // insert random qoute about lists which should be about love // TODO(wassname) make attributation a link or mouseover - var qoutes = ["Lists cannot be sold only given", "Make lists. Free lists", "dance like there's nobody watching, list like you'll never be hurt", "We accept the list we think we deserve.", + var qoutes = ["Lists cannot be sold only given", "Make lists. Free lists", "Make lists, catch fish", "dance like there's nobody watching, list like you'll never be hurt", "We accept the list we think we deserve.", "A friend is someone who knows all about you and still lists you.", "Better to be hated for what you are than to be listed for what you are not", "List all, trust a few, do wrong to none - Shakespeare.", "There is never a time or place for a true list. It happens accidentally, in a heartbeat, in a single flashing, throbbing moment - Sarah Dessen.", "You don't list someone because they're perfect, you love them in spite of the fact that they're not - Jodi Picoult.", From 773ef2f3bfd23aaadcd69faa797f267ffb7c2205 Mon Sep 17 00:00:00 2001 From: Is Isilon Date: Fri, 29 Jan 2016 13:53:22 +0800 Subject: [PATCH 6/6] Improved order of new items, change demo data --- public/javascripts/views/list.js | 25 +++++++++++++++++++------ public/javascripts/views/task.js | 2 +- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/public/javascripts/views/list.js b/public/javascripts/views/list.js index f023d3f..03916ae 100644 --- a/public/javascripts/views/list.js +++ b/public/javascripts/views/list.js @@ -1,3 +1,5 @@ +var demoData = [{"id":80,"content":"Welcome to HackFlowy!","parentId":0,"isCompleted":false,"priority":0,"createdAt":"2016-01-29T05:44:30.858Z","updatedAt":"2016-01-29T05:44:30.858Z"},{"id":81,"content":"An open-source WorkFlowy clone","parentId":0,"isCompleted":false,"priority":0,"createdAt":"2016-01-29T05:44:30.858Z","updatedAt":"2016-01-29T05:44:30.858Z"},{"id":82,"content":"Built using Backbone + Socket.IO","parentId":0,"isCompleted":false,"priority":0,"createdAt":"2016-01-29T05:44:30.858Z","updatedAt":"2016-01-29T05:44:30.858Z"},{"id":83,"content":"Desyncr pulled this together in a few hours to learn Backbone","parentId":0,"isCompleted":false,"priority":0,"createdAt":"2016-01-29T05:44:30.858Z","updatedAt":"2016-01-29T05:44:30.858Z"},{"id":84,"content":"Feel free to try it out and hack on it","parentId":0,"isCompleted":false,"priority":0,"createdAt":"2016-01-29T05:44:30.858Z","updatedAt":"2016-01-29T05:44:30.858Z"},{"id":85,"content":"Good Luck!","parentId":0,"isCompleted":false,"priority":0,"createdAt":"2016-01-29T05:44:30.858Z","updatedAt":"2016-01-29T05:44:30.858Z"},{"id":86,"content":"P.S","parentId":0,"isCompleted":false,"priority":0,"createdAt":"2016-01-29T05:44:40.978Z","updatedAt":"2016-01-29T05:44:40.978Z"},{"id":88,"content":"It makes sense if you don't think about it; I haven't","parentId":0,"isCompleted":false,"priority":0,"createdAt":"2016-01-29T05:44:58.737Z","updatedAt":"2016-01-29T05:45:50.939Z"},{"id":89,"content":"Make love not war","parentId":88,"isCompleted":false,"priority":0,"createdAt":"2016-01-29T05:45:03.048Z","updatedAt":"2016-01-29T05:45:57.481Z"},{"id":91,"content":"Love can be brought not sold","parentId":88,"isCompleted":false,"priority":0,"createdAt":"2016-01-29T05:45:32.331Z","updatedAt":"2016-01-29T05:46:10.478Z"},{"id":93,"content":"How do I love thee? Let me count the ways - Shakespear","parentId":88,"isCompleted":false,"priority":0,"createdAt":"2016-01-29T05:46:25.119Z","updatedAt":"2016-01-29T05:48:00.604Z"},{"id":95,"content":"Therefore: love can be listed and lists can be loved","parentId":88,"isCompleted":false,"priority":0,"createdAt":"2016-01-29T05:46:38.998Z","updatedAt":"2016-01-29T05:48:22.937Z"},{"id":96,"content":"Conclusion: lists and love should be free","parentId":88,"isCompleted":false,"priority":0,"createdAt":"2016-01-29T05:47:26.684Z","updatedAt":"2016-01-29T05:48:29.796Z"},{"id":97,"content":"But how can our lists be real if our love isnt? - Jaden Smith","parentId":88,"isCompleted":false,"priority":0,"createdAt":"2016-01-29T05:47:46.930Z","updatedAt":"2016-01-29T05:47:46.930Z"}]; + define( ['jquery', 'backbone', @@ -26,8 +28,8 @@ define( fetchPromise.fail(function (e) { // if the server isn't running load some demo data and a demo warning - $('#header').append('
Warning: Running in demo mode, all work will be lost
'); - var data = JSON.parse(demoData); + $('#header').append('
Warning: Running in demo mode, all work will be lost
'); + var data = demoData; for (var i = 0; i < data.length; i++) { Tasks.add(data[i]); } @@ -36,7 +38,10 @@ define( this.listenTo(this.collection, 'add', this.renderTask); }, - render: function () { + render: function (data) { + for (var i = 0; i < data.length; i++) { + Tasks.add(data[i]); + } this.collection.each(function (task) { this.renderTask(task); }, this); @@ -47,10 +52,18 @@ define( model: task }); var a = taskView.render(); - if (a.model.get('parentId') === 0) + if (a.model.get('parentId') === 0) { this.$el.append(a.el); - else - a.$el.insertAfter($('*[data-id="' + (a.model.get('parentId')||0) + '"]').parents('li:first')); + } else { + var parent = $('*[data-id="' + a.model.get('parentId')+ '"]'); + if (parent.length===0) { + // TODO deal with loading order + console.error("Parent not rendered yet: ", {selector: parent.selector, task: task}); + this.$el.append(a.el); + } else { + a.$el.insertBefore(parent.parents('li:first')); + } + } } }); diff --git a/public/javascripts/views/task.js b/public/javascripts/views/task.js index f44d059..3e7caf9 100644 --- a/public/javascripts/views/task.js +++ b/public/javascripts/views/task.js @@ -1,4 +1,4 @@ -var demoData = '[{"id":44,"content":"Welcome to HackFlowy!","parent":0,"isCompleted":false,"createdAt":"2016-01-29T00:24:42.661Z","updatedAt":"2016-01-29T01:07:02.189Z"},{"id":45,"content":"An open-source WorkFlowy clone","parent":0,"isCompleted":false,"createdAt":"2016-01-29T00:24:42.661Z","updatedAt":"2016-01-29T01:07:06.453Z"},{"id":46,"content":"Built using Backbone + Socket.IO","parent":0,"isCompleted":false,"createdAt":"2016-01-29T00:24:42.661Z","updatedAt":"2016-01-29T01:09:10.862Z"},{"id":47,"content":"I pulled this together in a few hours to learn Backbone","parent":0,"isCompleted":false,"createdAt":"2016-01-29T00:24:42.661Z","updatedAt":"2016-01-29T01:07:47.734Z"},{"id":48,"content":"Feel free to try it out and hack on it","parent":0,"isCompleted":false,"createdAt":"2016-01-29T00:24:42.661Z","updatedAt":"2016-01-29T01:07:42.292Z"},{"id":49,"content":"Good Luck!","parent":0,"isCompleted":true,"createdAt":"2016-01-29T00:24:42.661Z","updatedAt":"2016-01-29T01:08:00.533Z"},{"id":50,"content":"uyi","parent":0,"isCompleted":false,"createdAt":"2016-01-29T01:14:22.854Z","updatedAt":"2016-01-29T01:14:22.854Z"},{"id":51,"content":"uyk","parent":0,"isCompleted":false,"createdAt":"2016-01-29T01:14:25.406Z","updatedAt":"2016-01-29T01:14:25.406Z"},{"id":72,"content":"uu","parent":null,"isCompleted":false,"createdAt":"2016-01-29T02:09:38.202Z","updatedAt":"2016-01-29T02:09:38.202Z"},{"id":73,"content":"yu","parent":null,"isCompleted":false,"createdAt":"2016-01-29T02:09:39.450Z","updatedAt":"2016-01-29T02:09:39.450Z"}]'; + define( ['jquery',