fix(task): setting a priority was not properly saved

This commit is contained in:
kolaente 2022-10-05 16:02:44 +02:00
parent 31e39aa6c8
commit fd71de4b5d
No known key found for this signature in database
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', () => { describe('Task Detail View', () => {
beforeEach(() => { beforeEach(() => {
TaskCommentFactory.truncate() TaskCommentFactory.truncate()
LabelTaskFactory.truncate()
}) })
it('Shows all task details', () => { it('Shows all task details', () => {
@ -417,5 +418,27 @@ describe('Task', () => {
cy.get('.global-notification') cy.get('.global-notification')
.should('contain', 'Success') .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> </div>
<priority-select <priority-select
:disabled="!canWrite" :disabled="!canWrite"
@update:model-value="saveTask" @update:model-value="setPriority"
ref="priority" ref="priority"
v-model="task.priority"/> v-model="task.priority"/>
</div> </div>
@ -443,7 +443,7 @@ import TaskModel, {TASK_DEFAULT_COLOR} from '@/models/task'
import type {ITask} from '@/modelTypes/ITask' import type {ITask} from '@/modelTypes/ITask'
import type {IList} from '@/modelTypes/IList' import type {IList} from '@/modelTypes/IList'
import {PRIORITIES} from '@/constants/priorities' import {PRIORITIES, type Priority} from '@/constants/priorities'
import {RIGHTS} from '@/constants/rights' import {RIGHTS} from '@/constants/rights'
import BaseButton from '@/components/base/BaseButton.vue' import BaseButton from '@/components/base/BaseButton.vue'
@ -676,21 +676,19 @@ function setFieldActive(fieldName: keyof typeof activeFields) {
} }
async function saveTask(args?: { async function saveTask(args?: {
task: ITask, task: ITask,
showNotification?: boolean, undoCallback?: () => void,
undoCallback?: () => void, }) {
}) { const {
const { task: currentTask,
task: currentTask, undoCallback,
showNotification, } = {
undoCallback, ...{
} = { task: cloneDeep(task),
...{ },
task: cloneDeep(task), ...args,
showNotification: true, }
},
...args,
}
if (!canWrite.value) { if (!canWrite.value) {
return return
} }
@ -711,10 +709,6 @@ async function saveTask(args?: {
Object.assign(task, newTask) Object.assign(task, newTask)
setActiveFields() setActiveFields()
if (!showNotification) {
return
}
let actions = [] let actions = []
if (undoCallback !== null) { if (undoCallback !== null) {
actions = [{ actions = [{
@ -760,6 +754,17 @@ async function toggleFavorite() {
Object.assign(task, newTask) Object.assign(task, newTask)
await namespaceStore.loadNamespacesIfFavoritesDontExist() await namespaceStore.loadNamespacesIfFavoritesDontExist()
} }
async function setPriority(priority: Priority) {
const newTask: ITask = {
...task,
priority,
}
return saveTask({
task: newTask,
})
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>