chore(task): move cover image setter to store
This commit is contained in:
parent
fad72e091b
commit
ee3965eae9
2 changed files with 9 additions and 5 deletions
|
@ -83,7 +83,7 @@
|
||||||
class="attachment-info-meta-button"
|
class="attachment-info-meta-button"
|
||||||
@click.prevent.stop="setCoverImage(task.coverImageAttachmentId === a.id ? null : a)"
|
@click.prevent.stop="setCoverImage(task.coverImageAttachmentId === a.id ? null : a)"
|
||||||
>
|
>
|
||||||
{{
|
{{
|
||||||
task.coverImageAttachmentId === a.id
|
task.coverImageAttachmentId === a.id
|
||||||
? $t('task.attachment.unsetAsCover')
|
? $t('task.attachment.unsetAsCover')
|
||||||
: $t('task.attachment.setAsCover')
|
: $t('task.attachment.setAsCover')
|
||||||
|
@ -257,10 +257,7 @@ function copyUrl(attachment: IAttachment) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function setCoverImage(attachment: IAttachment | null) {
|
async function setCoverImage(attachment: IAttachment | null) {
|
||||||
const task = await taskStore.update({
|
const task = await taskStore.setCoverImage(props.task, attachment)
|
||||||
...props.task,
|
|
||||||
coverImageAttachmentId: attachment ? attachment.id : 0,
|
|
||||||
})
|
|
||||||
emit('task-changed', task)
|
emit('task-changed', task)
|
||||||
success({message: t('task.attachment.successfullyChangedCoverImage')})
|
success({message: t('task.attachment.successfullyChangedCoverImage')})
|
||||||
}
|
}
|
||||||
|
|
|
@ -409,6 +409,13 @@ export const useTaskStore = defineStore('task', {
|
||||||
cancel()
|
cancel()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async setCoverImage(task: ITask, attachment: IAttachment | null) {
|
||||||
|
return this.update({
|
||||||
|
...task,
|
||||||
|
coverImageAttachmentId: attachment ? attachment.id : 0,
|
||||||
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue