mirror of
https://github.com/wassname/HackFlowy.git
synced 2026-06-28 16:10:05 +08:00
Fixed tasks' parent update
This commit is contained in:
@@ -9,7 +9,7 @@ Backbone
|
||||
var TaskModel = Backbone.Model.extend({
|
||||
|
||||
defaults: {
|
||||
parentId: 0,
|
||||
parent: 0,
|
||||
content: '',
|
||||
isCompleted: 0
|
||||
},
|
||||
|
||||
@@ -37,8 +37,8 @@ TaskView
|
||||
model: task
|
||||
});
|
||||
var a = taskView.render();
|
||||
if (a.model.get('parentId')!=0)
|
||||
a.$el.insertAfter($('*[data-id="'+a.model.get('parentId')+'"]').parents('li:first'));
|
||||
if (a.model.get('parent')!=0)
|
||||
a.$el.insertAfter($('*[data-id="'+a.model.get('parent')+'"]').parents('li:first'));
|
||||
else
|
||||
this.$el.append(a.el);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ app.get('/tasks', function(req,res){
|
||||
app.post('/tasks', function(req,res){
|
||||
Tasks.create({
|
||||
content: req.body.content,
|
||||
parent: parseInt(req.body.parent_id) || 0,
|
||||
parent: parseInt(req.body.parent) || 0,
|
||||
isCompleted: false
|
||||
}).success(function(task){
|
||||
res.send(task);
|
||||
@@ -41,6 +41,7 @@ app.put('/tasks/:id', function(req,res){
|
||||
console.log(req.body.isCompleted);
|
||||
Tasks.find(req.params.id).success(function(task){
|
||||
task.content = req.body.content;
|
||||
task.parent = parseInt(req.body.parent) || 0,
|
||||
task.isCompleted = req.body.isCompleted == 1;
|
||||
task.save().success(function(task){
|
||||
res.send(task);
|
||||
|
||||
Reference in New Issue
Block a user