From: Zachary Vance Date: Thu, 28 May 2015 01:22:55 +0000 (-0700) Subject: Hide root node X-Git-Url: https://git.za3k.com/?a=commitdiff_plain;h=9d34adea8ba0dfedc38e97e4148e9eaa761fa7a4;p=flowy.git Hide root node --- diff --git a/dist/flowy.css b/dist/flowy.css index 7cdb9fd..149322e 100644 --- a/dist/flowy.css +++ b/dist/flowy.css @@ -32,6 +32,15 @@ body { #todo-list { width: 80%; } +#todo-list > .todo { + /* Root doesn't get displayed */ +} +#todo-list > .todo > .text { + display: none; +} +#todo-list > .todo > .bullets > .todo { + margin-left: 0px; +} .with-dropshadow { box-shadow: 0 2px 12px rgba(0, 0, 0, 0.6); } diff --git a/dist/flowy.js b/dist/flowy.js index 2590c9f..eb63bd2 100644 --- a/dist/flowy.js +++ b/dist/flowy.js @@ -846,6 +846,13 @@ var TodoModel = Backbone.Model.extend({ }, outdent: function() { // After parent, then nothing + var parent = this.getParent(); + if (! parent || parent.isRoot()) return undefined; + var grandparent = parent.getParent(); + return this.moveTo({ + parent: grandparent, + index: grandparent.findChild(parent.id)+1, + }); }, isRoot: function() { return this.id === this.collection.rootId; @@ -987,7 +994,7 @@ var testTodos = [ ]; var todos = new FlowyDocModel({ -}); +rootId: 0}); var appDefaults = { list: todos }; var AppView = Backbone.View.extend({ @@ -1055,7 +1062,7 @@ var AppView = Backbone.View.extend({ return; } var view = new TodoView({model: todo}); - if (todo.isTopLevel()) { + if (todo.isRoot()) { this.setView(todo, view); this.$("#todo-list").append(view.render().el); } else if (todo.isParentLoaded(this) && todo.getParent().findChild(todo.id) >= 0 /* because move/insert is nonatomic */) { diff --git a/dist/flowy.unwrapped.js b/dist/flowy.unwrapped.js index c964b08..e52810d 100644 --- a/dist/flowy.unwrapped.js +++ b/dist/flowy.unwrapped.js @@ -845,6 +845,13 @@ var TodoModel = Backbone.Model.extend({ }, outdent: function() { // After parent, then nothing + var parent = this.getParent(); + if (! parent || parent.isRoot()) return undefined; + var grandparent = parent.getParent(); + return this.moveTo({ + parent: grandparent, + index: grandparent.findChild(parent.id)+1, + }); }, isRoot: function() { return this.id === this.collection.rootId; @@ -986,7 +993,7 @@ var testTodos = [ ]; var todos = new FlowyDocModel({ -}); +rootId: 0}); var appDefaults = { list: todos }; var AppView = Backbone.View.extend({ @@ -1054,7 +1061,7 @@ var AppView = Backbone.View.extend({ return; } var view = new TodoView({model: todo}); - if (todo.isTopLevel()) { + if (todo.isRoot()) { this.setView(todo, view); this.$("#todo-list").append(view.render().el); } else if (todo.isParentLoaded(this) && todo.getParent().findChild(todo.id) >= 0 /* because move/insert is nonatomic */) { diff --git a/src/css/flowy.less b/src/css/flowy.less index 617e7ae..30f39c8 100644 --- a/src/css/flowy.less +++ b/src/css/flowy.less @@ -38,6 +38,14 @@ body { #todo-list { width: 80%; + > .todo { /* Root doesn't get displayed */ + > .text { + display: none; + } + > .bullets > .todo { + margin-left: 0px; + } + } } .with-dropshadow { diff --git a/src/models/todo.js b/src/models/todo.js index 7241572..b58241c 100644 --- a/src/models/todo.js +++ b/src/models/todo.js @@ -152,6 +152,13 @@ var TodoModel = Backbone.Model.extend({ }, outdent: function() { // After parent, then nothing + var parent = this.getParent(); + if (! parent || parent.isRoot()) return undefined; + var grandparent = parent.getParent(); + return this.moveTo({ + parent: grandparent, + index: grandparent.findChild(parent.id)+1, + }); }, isRoot: function() { return this.id === this.collection.rootId; diff --git a/src/views/app.js b/src/views/app.js index c1a0c35..1fca40c 100644 --- a/src/views/app.js +++ b/src/views/app.js @@ -56,7 +56,7 @@ var testTodos = [ ]; var todos = new FlowyDocModel({ -}); +rootId: 0}); var appDefaults = { list: todos }; var AppView = Backbone.View.extend({ @@ -124,7 +124,7 @@ var AppView = Backbone.View.extend({ return; } var view = new TodoView({model: todo}); - if (todo.isTopLevel()) { + if (todo.isRoot()) { this.setView(todo, view); this.$("#todo-list").append(view.render().el); } else if (todo.isParentLoaded(this) && todo.getParent().findChild(todo.id) >= 0 /* because move/insert is nonatomic */) {