fix(task): setting a priority was not properly saved
This commit is contained in:
parent
31e39aa6c8
commit
fd71de4b5d
2 changed files with 49 additions and 21 deletions
|
@ -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')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -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'
|
||||
|
@ -677,20 +677,18 @@ 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,
|
||||
}
|
||||
|
||||
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>
|
||||
|
|
Loading…
Reference in a new issue