diff --git a/dist/habitrpg-shared.js b/dist/habitrpg-shared.js index 2c49ba9df9..fef9014d0a 100644 --- a/dist/habitrpg-shared.js +++ b/dist/habitrpg-shared.js @@ -13290,7 +13290,7 @@ api.wrap = function(user, main) { return typeof cb === "function" ? cb(null, user.todos) : void 0; }, sortTask: function(req, cb) { - var from, id, task, tasks, to, _ref; + var from, id, movedTask, task, tasks, to, _ref; id = req.params.id; _ref = req.query, to = _ref.to, from = _ref.from; task = user.tasks[id]; @@ -13304,7 +13304,12 @@ api.wrap = function(user, main) { return typeof cb === "function" ? cb('?to=__&from=__ are required') : void 0; } tasks = user["" + task.type + "s"]; - tasks.splice(to, 0, tasks.splice(from, 1)[0]); + movedTask = tasks.splice(from, 1)[0]; + if (to === -1) { + tasks.push(movedTask); + } else { + tasks.splice(to, 0, movedTask); + } return typeof cb === "function" ? cb(null, tasks) : void 0; }, updateTask: function(req, cb) { diff --git a/locales/en/tasks.json b/locales/en/tasks.json index 5c8867419b..b7ea696f5e 100644 --- a/locales/en/tasks.json +++ b/locales/en/tasks.json @@ -61,5 +61,6 @@ "fortifyText": "Fortify will return all your tasks to a neutral (yellow) state, as if you'd just added them, and top your Health off to full. Consider this an option of last resort! Red tasks provide good incentive to improve. But if all that red fills you with despair, and the beginning of each new day proves lethal, spend the Gems and catch a reprieve!", "sureDelete": "Are you sure you want to delete this task?", "streakCoins": "Streak Bonus!", - "pushTaskToTop": "Push task to top" + "pushTaskToTop": "Push task to top", + "pushTaskToBottom": "Push task to bottom" } diff --git a/script/index.coffee b/script/index.coffee index b58af72004..cbd64cd8dd 100644 --- a/script/index.coffee +++ b/script/index.coffee @@ -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) ->