diff --git a/public/js/directives/directives.js b/public/js/directives/directives.js index be8982f076..467395752f 100644 --- a/public/js/directives/directives.js +++ b/public/js/directives/directives.js @@ -55,8 +55,7 @@ habitrpg.directive('habitrpgSortable', ['User', function(User) { var taskType = angular.element(ui.item[0]).scope().task.type + 's'; var startIndex = ui.item.data('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.log({op: 'sortTask', data: _.defaults({from: startIndex, to: ui.item.index()}, task)}); + User.user.ops.sortTask({params:{id:task.id},query:{from:startIndex, to:ui.item.index()}}); } }); } diff --git a/src/controllers/user.js b/src/controllers/user.js index c66d3ff29e..23c5130e51 100644 --- a/src/controllers/user.js +++ b/src/controllers/user.js @@ -153,21 +153,8 @@ api.deleteTask = function(req, res, next) { */ // api.updateTask // handled in Shared.ops - // api.addTask // handled in Shared.ops - -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']); - }); - }) -}; +// api.sortTask // handled in Shared.ops #TODO updated api, mention in docs /* ------------------------------------------------------------------------