]> git.za3k.com Git - flowy.git/commitdiff
Hide root node
authorZachary Vance <vanceza@gmail.com>
Thu, 28 May 2015 01:22:55 +0000 (18:22 -0700)
committerZachary Vance <vanceza@gmail.com>
Thu, 28 May 2015 01:22:55 +0000 (18:22 -0700)
dist/flowy.css
dist/flowy.js
dist/flowy.unwrapped.js
src/css/flowy.less
src/models/todo.js
src/views/app.js

index 7cdb9fdce5ba9e7bdbf96d6329c2682adcdedbe4..149322e796bbe3aab840449f77fd9e1a6e3acbc9 100644 (file)
@@ -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);
 }
index 2590c9fa472f42986c8ff432cf09cb6350e56f32..eb63bd2d98feae0e5dc0a46c840925656ebd4c93 100644 (file)
@@ -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 */) {
index c964b08e2a93d48a801987315eee36530134f854..e52810da96c98099b45f53e6538c6c890a7ed48b 100644 (file)
@@ -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 */) {
index 617e7aef5ca0718e843147ec9978a7a2925d8c67..30f39c8b4a524cbd838b1ad503b96b46b295a473 100644 (file)
@@ -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 {
index 72415724f17607de03c73e6bd5acc2f3953b6de3..b58241ce4bdb1a66d4e95607c47025c81f1b1aca 100644 (file)
@@ -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;
index c1a0c35a526c1c05f2f27dd04a6b29bd7baf6359..1fca40c735487cc6f287b2f408ec0af13fa52897 100644 (file)
@@ -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 */) {