mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
fix(tasks): more lock icon revision, no error on manager uncheck
This commit is contained in:
@@ -1046,17 +1046,17 @@ export default {
|
||||
showTaskLockIcon () {
|
||||
if (this.isUser) return false;
|
||||
if (this.isGroupTask) {
|
||||
if (this.isOpenTask) {
|
||||
if (!this.task.completed) return false;
|
||||
if (this.task.completed) {
|
||||
if (this.task.group.completedBy === this.user._id) return false;
|
||||
if (this.teamManagerAccess) return false;
|
||||
return true;
|
||||
}
|
||||
if (this.isOpenTask) return false;
|
||||
if (this.task.group.assignedUsers.indexOf(this.user._id) !== -1) return false;
|
||||
if (
|
||||
this.task.group.assignedUsers.length > 0
|
||||
&& this.task.group.assignedUsers.indexOf(this.user._id) === -1
|
||||
) return true;
|
||||
if (this.teamManagerAccess) return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
@@ -337,22 +337,6 @@ async function scoreTask (user, task, direction, req, res) {
|
||||
}
|
||||
|
||||
let localTask;
|
||||
|
||||
if (task.group.id && !task.userId && task.group.assignedUsers.length > 0) {
|
||||
// Task is being scored from team board, and a user copy should exist
|
||||
if (!task.group.assignedUsers.includes(user._id)) {
|
||||
throw new BadRequest('Task has not been assigned to this user.');
|
||||
}
|
||||
|
||||
localTask = await Tasks.Task.findOne(
|
||||
{ userId: user._id, 'group.taskId': task._id },
|
||||
).exec();
|
||||
if (!localTask) throw new NotFound('Task not found.');
|
||||
}
|
||||
|
||||
const wasCompleted = task.completed;
|
||||
const firstTask = !user.achievements.completedTask;
|
||||
let delta;
|
||||
let rollbackUser;
|
||||
|
||||
if (
|
||||
@@ -372,8 +356,22 @@ async function scoreTask (user, task, direction, req, res) {
|
||||
}
|
||||
rollbackUser = await User.findOne({ _id: task.group.completedBy });
|
||||
task.group.completedBy = undefined;
|
||||
} else if (task.group.id && !task.userId && task.group.assignedUsers.length > 0) {
|
||||
// Task is being scored from team board, and a user copy should exist
|
||||
if (!task.group.assignedUsers.includes(user._id)) {
|
||||
throw new BadRequest('Task has not been assigned to this user.');
|
||||
}
|
||||
|
||||
localTask = await Tasks.Task.findOne(
|
||||
{ userId: user._id, 'group.taskId': task._id },
|
||||
).exec();
|
||||
if (!localTask) throw new NotFound('Task not found.');
|
||||
}
|
||||
|
||||
const wasCompleted = task.completed;
|
||||
const firstTask = !user.achievements.completedTask;
|
||||
let delta;
|
||||
|
||||
if (rollbackUser) {
|
||||
delta = shared.ops.scoreTask({ task, user: rollbackUser, direction }, req, res.analytics);
|
||||
await rollbackUser.save();
|
||||
|
||||
Reference in New Issue
Block a user