fix(task): setting a priority was not properly saved
continuous-integration/drone/push Build is passing Details

This commit is contained in:
kolaente 2022-10-05 16:02:44 +02:00
parent 31e39aa6c8
commit fd71de4b5d
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 49 additions and 21 deletions

View File

@ -80,6 +80,7 @@ describe('Task', () => {
describe('Task Detail View', () => {
beforeEach(() => {
TaskCommentFactory.truncate()
LabelTaskFactory.truncate()
})
it('Shows all task details', () => {
@ -417,5 +418,27 @@ describe('Task', () => {
cy.get('.global-notification')
.should('contain', 'Success')
})
it('Can set a priority for a task', () => {
const tasks = TaskFactory.create(1, {
id: 1,
})
cy.visit(`/tasks/${tasks[0].id}`)
cy.get('.task-view .action-buttons .button')
.contains('Set Priority')
.click()
cy.get('.task-view .columns.details .column')
.contains('Priority')
.get('.select select')
.select('Urgent')
cy.get('.global-notification')
.should('contain', 'Success')
cy.get('.task-view .columns.details .column')
.contains('Priority')
.get('.select select')
.should('have.value', '4')
})
})
})

View File

@ -39,7 +39,7 @@
</div>
<priority-select
:disabled="!canWrite"
@update:model-value="saveTask"
@update:model-value="setPriority"
ref="priority"
v-model="task.priority"/>
</div>
@ -443,7 +443,7 @@ import TaskModel, {TASK_DEFAULT_COLOR} from '@/models/task'
import type {ITask} from '@/modelTypes/ITask'
import type {IList} from '@/modelTypes/IList'
import {PRIORITIES} from '@/constants/priorities'
import {PRIORITIES, type Priority} from '@/constants/priorities'
import {RIGHTS} from '@/constants/rights'
import BaseButton from '@/components/base/BaseButton.vue'
@ -676,21 +676,19 @@ function setFieldActive(fieldName: keyof typeof activeFields) {
}
async function saveTask(args?: {
task: ITask,
showNotification?: boolean,
undoCallback?: () => void,
}) {
const {
task: currentTask,
showNotification,
undoCallback,
} = {
...{
task: cloneDeep(task),
showNotification: true,
},
...args,
}
task: ITask,
undoCallback?: () => void,
}) {
const {
task: currentTask,
undoCallback,
} = {
...{
task: cloneDeep(task),
},
...args,
}
if (!canWrite.value) {
return
}
@ -711,10 +709,6 @@ async function saveTask(args?: {
Object.assign(task, newTask)
setActiveFields()
if (!showNotification) {
return
}
let actions = []
if (undoCallback !== null) {
actions = [{
@ -760,6 +754,17 @@ async function toggleFavorite() {
Object.assign(task, newTask)
await namespaceStore.loadNamespacesIfFavoritesDontExist()
}
async function setPriority(priority: Priority) {
const newTask: ITask = {
...task,
priority,
}
return saveTask({
task: newTask,
})
}
</script>
<style lang="scss" scoped>