-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Group plans reorder tasks #8358
Group plans reorder tasks #8358
Conversation
let order = group.tasksOrder[`${task.type}s`]; | ||
let currentIndex = order.indexOf(task._id); | ||
|
||
// If for some reason the task isn't ordered (should never happen), push it in the new position |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible to abstract this logic so that we don't duplicate code between group and user (and maybe challenges) tasks reordering?
let taskId = req.params.taskId; | ||
let task = await Tasks.Task.findOne({ | ||
_id: taskId, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing .exec()
Challenge task reordering is much desired.
…On Wed, 4 Jan 2017, 15:08 Matteo Pagliazzi ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In website/server/controllers/api-v3/tasks/groups.js
<#8358 (review)>
:
> +
+ if (!task) {
+ throw new NotFound(res.t('taskNotFound'));
+ }
+
+ if (task.type === 'todo' && task.completed) throw new BadRequest(res.t('cantMoveCompletedTodo'));
+
+ let group = await Group.getGroup({user, groupId: task.group.id, fields: requiredGroupFields});
+ if (!group) throw new NotFound(res.t('groupNotFound'));
+
+ if (group.leader !== user._id) throw new NotAuthorized(res.t('onlyGroupLeaderCanEditTasks'));
+
+ let order = group.tasksOrder[`${task.type}s`];
+ let currentIndex = order.indexOf(task._id);
+
+ // If for some reason the task isn't ordered (should never happen), push it in the new position
is it possible to abstract this logic so that we don't duplicate code
between group and user (and maybe challenges) tasks reordering?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#8358 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABbTATRnM4Kujuj_U1OHA3_e3CAtCwooks5rO7W9gaJpZM4LZMVq>
.
|
1b5509c
to
89e85ad
Compare
Updated. |
Looks good 👍 a unit test for the move task would be perfect but feel free to merge it without |
* Added move route for group tasks * Added group task reorder to front end * Added syncing with group task order * Fixed linting issues * Added missing exec and abstracted move code * Added unit test for moveTask
Fixes put_issue_url_here
Changes
UUID: