Merge pull request #304 from Alys/pushToBottom-sortFix

add support for pushTaskToBottom to help with To-Do sort order bug
This commit is contained in:
Alice Harris
2014-09-12 14:05:55 +10:00
3 changed files with 14 additions and 4 deletions
+5 -1
View File
@@ -521,7 +521,11 @@ api.wrap = (user, main=true) ->
return cb?({code:404, message: i18n.t('messageTaskNotFound', req.language)}) unless task
return cb?('?to=__&from=__ are required') unless to? and from?
tasks = user["#{task.type}s"]
tasks.splice to, 0, tasks.splice(from, 1)[0]
movedTask = tasks.splice(from, 1)[0]
if to == -1 # we've used the Push To Bottom feature
tasks.push(movedTask)
else # any other sort method uses only positive 'to' values
tasks.splice(to, 0, movedTask)
cb? null, tasks
updateTask: (req, cb) ->