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