mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-01 23:40:25 +00:00
parent
dc63eff41d
commit
caa2f26003
2 changed files with 2 additions and 16 deletions
|
|
@ -55,8 +55,7 @@ habitrpg.directive('habitrpgSortable', ['User', function(User) {
|
||||||
var taskType = angular.element(ui.item[0]).scope().task.type + 's';
|
var taskType = angular.element(ui.item[0]).scope().task.type + 's';
|
||||||
var startIndex = ui.item.data('startIndex');
|
var startIndex = ui.item.data('startIndex');
|
||||||
var task = User.user[taskType][startIndex];
|
var task = User.user[taskType][startIndex];
|
||||||
// FIXME - this is a really inconsistent way of API handling. we need to fix the batch-update route
|
User.user.ops.sortTask({params:{id:task.id},query:{from:startIndex, to:ui.item.index()}});
|
||||||
User.log({op: 'sortTask', data: _.defaults({from: startIndex, to: ui.item.index()}, task)});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -153,21 +153,8 @@ api.deleteTask = function(req, res, next) {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// api.updateTask // handled in Shared.ops
|
// api.updateTask // handled in Shared.ops
|
||||||
|
|
||||||
// api.addTask // handled in Shared.ops
|
// api.addTask // handled in Shared.ops
|
||||||
|
// api.sortTask // handled in Shared.ops #TODO updated api, mention in docs
|
||||||
api.sortTask = function(req, res, next) {
|
|
||||||
api.verifyTaskExists(req, res, function(){
|
|
||||||
var id = req.params.id;
|
|
||||||
var to = req.body.to, from = req.body.from, type = req.body.type;
|
|
||||||
var user = res.locals.user;
|
|
||||||
user[type+'s'].splice(to, 0, user[type+'s'].splice(from, 1)[0]);
|
|
||||||
user.save(function(err, saved) {
|
|
||||||
if (err) return res.json(500, {err: err});
|
|
||||||
return res.json(200, saved.toJSON()[type+'s']);
|
|
||||||
});
|
|
||||||
})
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue