mirror of
https://github.com/wassname/HackFlowy.git
synced 2026-08-03 12:31:01 +08:00
Fixed indenting, up and down arrows, basic sorting
This commit is contained in:
@@ -18,8 +18,7 @@ define(
|
||||
Marionette
|
||||
) {
|
||||
|
||||
// The tree's root: a simple collection view that renders
|
||||
// a recursive tree structure for each item in the collection
|
||||
// renders recursive tree structure for each item in collection
|
||||
var ListView = Backbone.Marionette.CollectionView.extend({
|
||||
|
||||
el: $("#main .children"),
|
||||
@@ -33,9 +32,7 @@ define(
|
||||
initialize: function () {
|
||||
var self = this;
|
||||
|
||||
Tasks = new List();
|
||||
|
||||
// this.listenTo(this.collection, 'add', this.renderTask);
|
||||
this.collection = Tasks = new List();
|
||||
|
||||
/** Load demo data **/
|
||||
function loadDemoData() {
|
||||
@@ -50,7 +47,6 @@ define(
|
||||
if (children.length === 0)
|
||||
loadDemoData();
|
||||
else {
|
||||
this.collection = {models:Tasks.filter({'parentId':0})};
|
||||
this.render();
|
||||
}
|
||||
}
|
||||
@@ -60,7 +56,8 @@ define(
|
||||
error: function () {
|
||||
|
||||
// switch to localforage database if server isn't present and fetch again
|
||||
window.hackflowyOffline=true;
|
||||
// from there
|
||||
window.hackflowyOffline = true;
|
||||
$('#header').append('<div class="alert-box secondary round">Running in offline mode, data may be lost </div>');
|
||||
Tasks.fetch({
|
||||
success: success,
|
||||
@@ -74,63 +71,8 @@ define(
|
||||
|
||||
// Only show direct children
|
||||
filter: function (child, index, collection) {
|
||||
return child.get('parentId') === 0;
|
||||
},
|
||||
|
||||
// render: function () {
|
||||
// var models = Tasks.filter({'parentId':0});
|
||||
//
|
||||
// _.each(models, function(model, index) {
|
||||
// var taskView = new this.childView({
|
||||
// model: model,
|
||||
// collection: model.collection
|
||||
// });
|
||||
// var a = taskView.render();
|
||||
// this.$el.append(a.el);
|
||||
// }, this);
|
||||
//
|
||||
// this.triggerMethod('render', this);
|
||||
// return this;
|
||||
// },
|
||||
|
||||
renderTask: function (task) {
|
||||
var taskView = new TaskView({
|
||||
model: task
|
||||
});
|
||||
var a = taskView.render();
|
||||
this.$el.append(a.el);
|
||||
//
|
||||
// if (a.model.get('parentId') === 0) {
|
||||
// // insert it at the end of the top-level items
|
||||
// this.$el.append(a.el);
|
||||
// } else {
|
||||
//
|
||||
// // TODO use dom nesting instead of data attributes
|
||||
// var parent = $('*[data-id="' + a.model.get('parentId') + '"]').parents('li:first');
|
||||
// var siblings = parent.find('.children:first li');
|
||||
// var editingSibling = siblings.filter('.editing:first');
|
||||
//
|
||||
// if (editingSibling.length > 0){
|
||||
// // insert it after open sibling
|
||||
// a.$el.insertAfter(editingSibling);
|
||||
// }
|
||||
// else if (parent.length > 0) {
|
||||
// // insert under parent
|
||||
// a.$el.appendTo(parent.find('.children:first'));
|
||||
// } else {
|
||||
// // we have an orphan :(
|
||||
// // insert at root for lack of a better option
|
||||
// this.$el.append(a.el);
|
||||
//
|
||||
// // TODO deal with loading order
|
||||
// console.error("Parent not rendered yet: ", {
|
||||
// selector: parent.selector,
|
||||
// task: task
|
||||
// });
|
||||
//
|
||||
// }
|
||||
// }
|
||||
}
|
||||
return child.get('parentId') === 0;
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user