fix "push to bottom" for user tasks in API (#12659)

Also:
- Fix the test for this which has been equally broken.
- Simplify apidoc position info and make consistent in similar routes.
- Replace non-ascii characters in apidoc comment.
This commit is contained in:
Alys
2020-10-18 01:58:48 +10:00
committed by GitHub
parent 9061a59fc2
commit 8b1c009990
4 changed files with 13 additions and 11 deletions

View File

@@ -794,9 +794,9 @@ api.scoreTask = {
* @apiGroup Task
*
* @apiParam (Path) {String} taskId The task _id or alias
* @apiParam (Path) {Number} position Where to move the task. 0 = top of the list.
é -1 = bottom of the list.
é (-1 means push to bottom). First position is 0
* @apiParam (Path) {Number} position Where to move the task.
* 0 = top of the list ("push to top").
* -1 = bottom of the list ("push to bottom").
*
* @apiSuccess {Array} data The new tasks order for the specific type that the taskID belongs to.
*
@@ -837,9 +837,8 @@ api.moveTask = {
pullQuery.$pull[`tasksOrder.${task.type}s`] = task.id;
await user.update(pullQuery).exec();
// Handle push to bottom
let position = to;
if (to === -1) position = [`tasksOrder.${task.type}s`].length - 1;
if (to === -1) position = order.length - 1; // push to bottom
const updateQuery = { $push: {} };
updateQuery.$push[`tasksOrder.${task.type}s`] = {