mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
WIP(teams): various fixes
This commit is contained in:
@@ -39,13 +39,13 @@
|
|||||||
v-if="task.group.assignedUsers"
|
v-if="task.group.assignedUsers"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
v-if="completionsCount"
|
v-if="assignedUsersCount > 1 && completionsCount && !showStatus"
|
||||||
class="mr-1"
|
class="mr-1"
|
||||||
>
|
>
|
||||||
{{ completionsCount }}/{{ assignedUsersCount }}
|
{{ completionsCount }}/{{ assignedUsersCount }}
|
||||||
</span>
|
</span>
|
||||||
<a
|
<a
|
||||||
v-if="!showStatus"
|
v-if="assignedUsersCount > 1 && !showStatus"
|
||||||
class="blue-10"
|
class="blue-10"
|
||||||
@click="showStatus = !showStatus"
|
@click="showStatus = !showStatus"
|
||||||
>
|
>
|
||||||
@@ -132,8 +132,10 @@ export default {
|
|||||||
}, 0);
|
}, 0);
|
||||||
},
|
},
|
||||||
completionsList () {
|
completionsList () {
|
||||||
|
if (this.assignedUsersCount === 1) return [];
|
||||||
const completionsArray = [];
|
const completionsArray = [];
|
||||||
for (const userId of this.assignedUsersKeys) {
|
for (const userId of this.assignedUsersKeys) {
|
||||||
|
if (userId !== this.user._id) {
|
||||||
const index = findIndex(this.group.members, member => member._id === userId);
|
const index = findIndex(this.group.members, member => member._id === userId);
|
||||||
const { completedDate } = this.task.group.assignedUsers[userId];
|
const { completedDate } = this.task.group.assignedUsers[userId];
|
||||||
let completedDateString;
|
let completedDateString;
|
||||||
@@ -151,6 +153,7 @@ export default {
|
|||||||
completedToday: moment().diff(completedDate, 'days') === 0,
|
completedToday: moment().diff(completedDate, 'days') === 0,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return completionsArray;
|
return completionsArray;
|
||||||
},
|
},
|
||||||
message () {
|
message () {
|
||||||
|
|||||||
@@ -869,6 +869,7 @@
|
|||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import { v4 as uuid } from 'uuid';
|
import { v4 as uuid } from 'uuid';
|
||||||
import isEmpty from 'lodash/isEmpty';
|
import isEmpty from 'lodash/isEmpty';
|
||||||
|
import keys from 'lodash/keys';
|
||||||
import { mapState, mapGetters, mapActions } from '@/libs/store';
|
import { mapState, mapGetters, mapActions } from '@/libs/store';
|
||||||
|
|
||||||
import positiveIcon from '@/assets/svg/positive.svg';
|
import positiveIcon from '@/assets/svg/positive.svg';
|
||||||
@@ -1059,7 +1060,10 @@ export default {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (this.task.group.completedBy.userId === this.user._id) return false;
|
if (this.task.group.completedBy.userId === this.user._id) return false;
|
||||||
if (this.teamManagerAccess && !this.task.group.assignedUsers) return false;
|
if (this.teamManagerAccess) {
|
||||||
|
if (!this.task.group.assignedUsers) return false;
|
||||||
|
if (keys(this.task.group.assignedUsers).length === 1) return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (this.isOpenTask) return false;
|
if (this.isOpenTask) return false;
|
||||||
|
|||||||
@@ -178,10 +178,10 @@
|
|||||||
"assignedToUser": "Assigned to <strong>@<%- userName %></strong>",
|
"assignedToUser": "Assigned to <strong>@<%- userName %></strong>",
|
||||||
"assignedToMembers": "Assigned to <strong><%= userCount %> users</strong>",
|
"assignedToMembers": "Assigned to <strong><%= userCount %> users</strong>",
|
||||||
"assignedToYouAndMembers": "Assigned to <strong>you and <%= userCount %> users</strong>",
|
"assignedToYouAndMembers": "Assigned to <strong>you and <%= userCount %> users</strong>",
|
||||||
"youAreAssigned": "Assigned to you",
|
"youAreAssigned": "Assigned to <strong>you</strong>",
|
||||||
"taskIsUnassigned": "This task is unassigned",
|
"taskIsUnassigned": "This task is unassigned",
|
||||||
"unassigned": "Unassigned",
|
"unassigned": "Unassigned",
|
||||||
"chooseTeamMember": "Choose a team member",
|
"chooseTeamMember": "Search for a team member",
|
||||||
"confirmUnClaim": "Are you sure you want to unclaim this task?",
|
"confirmUnClaim": "Are you sure you want to unclaim this task?",
|
||||||
"confirmNeedsWork": "Are you sure you want to mark this task as needing work?",
|
"confirmNeedsWork": "Are you sure you want to mark this task as needing work?",
|
||||||
"userRequestsApproval": "<strong><%- userName %></strong> requests approval",
|
"userRequestsApproval": "<strong><%- userName %></strong> requests approval",
|
||||||
|
|||||||
@@ -328,7 +328,7 @@ async function handleTeamTask (task, delta, direction) {
|
|||||||
*/
|
*/
|
||||||
async function scoreTask (user, task, direction, req, res) {
|
async function scoreTask (user, task, direction, req, res) {
|
||||||
if (task.type === 'daily' || task.type === 'todo') {
|
if (task.type === 'daily' || task.type === 'todo') {
|
||||||
if (task.group.id && task.group.assignedUsers) {
|
if (task.group.id && task.group.assignedUsers && task.group.assignedUsers[user._id]) {
|
||||||
if (task.group.assignedUsers[user._id].completed && direction === 'up') {
|
if (task.group.assignedUsers[user._id].completed && direction === 'up') {
|
||||||
throw new NotAuthorized(res.t('sessionOutdated'));
|
throw new NotAuthorized(res.t('sessionOutdated'));
|
||||||
} else if (!task.group.assignedUsers[user._id].completed && direction === 'down') {
|
} else if (!task.group.assignedUsers[user._id].completed && direction === 'down') {
|
||||||
@@ -363,7 +363,12 @@ async function scoreTask (user, task, direction, req, res) {
|
|||||||
) {
|
) {
|
||||||
throw new BadRequest('Cannot uncheck task you did not complete if not a manager.');
|
throw new BadRequest('Cannot uncheck task you did not complete if not a manager.');
|
||||||
}
|
}
|
||||||
|
if (task.group.assignedUsers && _.keys(task.group.assignedUsers).length === 1) {
|
||||||
|
const rollbackUserId = _.keys(task.group.assignedUsers)[0];
|
||||||
|
rollbackUser = await User.findOne({ _id: rollbackUserId });
|
||||||
|
} else {
|
||||||
rollbackUser = await User.findOne({ _id: task.group.completedBy.userId });
|
rollbackUser = await User.findOne({ _id: task.group.completedBy.userId });
|
||||||
|
}
|
||||||
task.group.completedBy = {};
|
task.group.completedBy = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user