WIP(teams): various fixes

This commit is contained in:
SabreCat
2022-02-07 20:22:57 -06:00
parent e312ea943f
commit 82d3545c08
4 changed files with 34 additions and 22 deletions

View File

@@ -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,24 +132,27 @@ 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) {
const index = findIndex(this.group.members, member => member._id === userId); if (userId !== this.user._id) {
const { completedDate } = this.task.group.assignedUsers[userId]; const index = findIndex(this.group.members, member => member._id === userId);
let completedDateString; const { completedDate } = this.task.group.assignedUsers[userId];
if (completedDate && moment().diff(completedDate, 'days') > 0) { let completedDateString;
completedDateString = `Last completed ${moment(completedDate).format('M/D/YY')}`; if (completedDate && moment().diff(completedDate, 'days') > 0) {
} else { completedDateString = `Last completed ${moment(completedDate).format('M/D/YY')}`;
completedDateString = `Completed today at ${moment(completedDate).format('h:mm A')}`; } else {
completedDateString = `Completed today at ${moment(completedDate).format('h:mm A')}`;
}
completionsArray.push({
userId,
userName: this.group.members[index].auth.local.username,
completed: this.task.group.assignedUsers[userId].completed,
completedDate,
completedDateString,
completedToday: moment().diff(completedDate, 'days') === 0,
});
} }
completionsArray.push({
userId,
userName: this.group.members[index].auth.local.username,
completed: this.task.group.assignedUsers[userId].completed,
completedDate,
completedDateString,
completedToday: moment().diff(completedDate, 'days') === 0,
});
} }
return completionsArray; return completionsArray;
}, },

View File

@@ -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;

View File

@@ -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",

View File

@@ -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.');
} }
rollbackUser = await User.findOne({ _id: task.group.completedBy.userId }); 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 = {}; task.group.completedBy = {};
} }