Fixed tasks' parent update

This commit is contained in:
DC*
2014-08-17 01:19:46 -03:00
parent d7b943d8ad
commit 7b6a87a58b
3 changed files with 5 additions and 4 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ Backbone
var TaskModel = Backbone.Model.extend({
defaults: {
parentId: 0,
parent: 0,
content: '',
isCompleted: 0
},
+2 -2
View File
@@ -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);
}
+2 -1
View File
@@ -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);