mirror of
https://github.com/wassname/HackFlowy.git
synced 2026-09-11 11:50:25 +08:00
isfolded column, uuid instead of int for id
This commit is contained in:
@@ -18,6 +18,22 @@ localforageBackbone
|
||||
model: Task,
|
||||
offlineSync: Backbone.localforage.sync("tasks"),
|
||||
|
||||
|
||||
/** Override backbone parse **/
|
||||
// parse: function(models){
|
||||
// if (this._isModel(models))
|
||||
// return models;
|
||||
// var parsedModels =[];
|
||||
// for (var i = 0; i < models.length; i++) {
|
||||
// if (this._isModel(models[i]))
|
||||
// parsedModels.push(models[i]);
|
||||
// else
|
||||
// parsedModels.push(new this.model(models[i]));
|
||||
// }
|
||||
// return parsedModels;
|
||||
//
|
||||
// },
|
||||
|
||||
initialize: function(){
|
||||
// update order on add, remove.
|
||||
// Ref: http://stackoverflow.com/a/11665085/221742
|
||||
@@ -53,8 +69,9 @@ localforageBackbone
|
||||
/** Updated priority of each member of list **/
|
||||
updateModelPriority: function() {
|
||||
this.each(function(model, index) {
|
||||
if (model)
|
||||
model.set('priority', index);
|
||||
if (model && model.get('priority')!==index)
|
||||
model.save({'priority': index});
|
||||
|
||||
}, this);
|
||||
},
|
||||
|
||||
@@ -71,8 +88,8 @@ localforageBackbone
|
||||
},
|
||||
|
||||
/** sort by priority then created date **/
|
||||
comporator: function(child){
|
||||
return [child.get('priority'), child.get('createdAt')];
|
||||
comparator: function(child){
|
||||
return [child.get('priority')];
|
||||
},
|
||||
|
||||
url: '/tasks'
|
||||
|
||||
Reference in New Issue
Block a user