Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,13 @@ export default {
}

const personId = eventData.person_id
const selectedTaskIds = [eventData.task_id]
const taskIds = [eventData.task_id]

// for entity lists
if (assign) {
this.$store.commit('ASSIGN_TASKS', { selectedTaskIds, personId })
this.$store.commit('ASSIGN_TASKS', { taskIds, personId })
} else {
this.$store.commit('UNASSIGN_TASKS', selectedTaskIds)
this.$store.commit('UNASSIGN_TASKS', taskIds)
}
},

Expand Down
15 changes: 15 additions & 0 deletions src/components/tops/ActionPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,14 @@
{{ $t('tasks.assignation_disclaimer') }}
</router-link>
</div>
<div
class="flexrow-item mb05 assignation-error"
v-if="errors.taskAssignation"
>
<p class="is-danger has-text-centered">
{{ $t('tasks.assignation_error') }}
</p>
</div>
<div
class="flexrow-item is-wide flexrow"
v-if="
Expand Down Expand Up @@ -943,6 +951,7 @@ export default {
},
errors: {
assetDeletion: false,
taskAssignation: false,
taskDeletion: false,
conceptDeletion: false,
editDeletion: false,
Expand Down Expand Up @@ -1315,10 +1324,12 @@ export default {
? this.selectedPersonId
: this.user.id
this.loading.assignation = true
this.errors.taskAssignation = false
try {
await this.assignSelectedTasks({ personId })
this.$refs['assignation-field']?.clear()
} catch (err) {
this.errors.taskAssignation = true
console.error(err)
} finally {
this.loading.assignation = false
Expand Down Expand Up @@ -1789,6 +1800,10 @@ export default {
overflow-x: auto;
overflow-y: hidden;
}
.is-danger {
color: #ff3860;
font-style: italic;
}

.menu-item {
cursor: pointer;
Expand Down
1 change: 1 addition & 0 deletions src/locales/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -1718,6 +1718,7 @@ export default {
assignation_disclaimer: 'If people are missing from the list, it means they are not listed in the team.',
assign_explaination: 'Select a person to assign...',
assignation_warning: 'Warning: you won\'t see the result because you are hiding assignments',
assignation_error: 'There was a problem assigning this person to the selected tasks. Not all tasks were assigned.',
back_to_list: 'back to list',
bigger: 'Widen task panel',
big_thumbnails: 'Show big thumbnails',
Expand Down
24 changes: 18 additions & 6 deletions src/store/modules/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -643,8 +643,20 @@ const actions = {

assignSelectedTasks({ commit, state }, { personId, taskIds }) {
const selectedTaskIds = taskIds || Array.from(state.selectedTasks.keys())
return tasksApi.assignTasks(personId, selectedTaskIds).then(() => {
commit(ASSIGN_TASKS, { selectedTaskIds, personId })
return tasksApi.assignTasks(personId, selectedTaskIds).then(response => {
const successfulTaskIds = response.map(task => task.id)
const failedTaskIds = selectedTaskIds.filter(
taskId => !successfulTaskIds.includes(taskId)
)
commit(ASSIGN_TASKS, { taskIds: successfulTaskIds, personId })
if (failedTaskIds.length) {
const error = new Error(
`Failed to assign ${failedTaskIds.length} task(s). Task IDs: ${failedTaskIds.join(', ')}`
)
error.failedTaskIds = failedTaskIds
error.successfulTaskIds = successfulTaskIds
throw error
}
})
},

Expand Down Expand Up @@ -1180,8 +1192,8 @@ const mutations = {
}
},

[ASSIGN_TASKS](state, { selectedTaskIds, personId }) {
selectedTaskIds.forEach(taskId => {
[ASSIGN_TASKS](state, { taskIds, personId }) {
taskIds.forEach(taskId => {
const task = state.taskMap.get(taskId)
if (task && !task.assignees.find(assigneeId => assigneeId === personId)) {
task.assignees.push(personId)
Expand All @@ -1190,8 +1202,8 @@ const mutations = {
})
},

[UNASSIGN_TASKS](state, selectedTaskIds) {
selectedTaskIds.forEach(taskId => {
[UNASSIGN_TASKS](state, taskIds) {
taskIds.forEach(taskId => {
const task = state.taskMap.get(taskId)
if (task) {
task.assignees = []
Expand Down