2020-11-22 17:32:35 +01:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<h3>
|
|
|
|
<span class="icon is-grey">
|
|
|
|
<icon icon="align-left"/>
|
|
|
|
</span>
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('task.attributes.description') }}
|
2020-11-22 17:32:35 +01:00
|
|
|
<transition name="fade">
|
|
|
|
<span class="is-small is-inline-flex" v-if="loading && saving">
|
|
|
|
<span class="loader is-inline-block mr-2"></span>
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('misc.saving') }}
|
2020-11-22 17:32:35 +01:00
|
|
|
</span>
|
2021-09-08 11:59:46 +02:00
|
|
|
<span class="is-small has-text-success" v-else-if="!loading && saved">
|
2020-11-22 17:32:35 +01:00
|
|
|
<icon icon="check"/>
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('misc.saved') }}
|
2020-11-22 17:32:35 +01:00
|
|
|
</span>
|
|
|
|
</transition>
|
|
|
|
</h3>
|
|
|
|
<editor
|
|
|
|
:is-edit-enabled="canWrite"
|
|
|
|
:upload-callback="attachmentUpload"
|
|
|
|
:upload-enabled="true"
|
|
|
|
@change="save"
|
2021-06-24 01:24:57 +02:00
|
|
|
:placeholder="$t('task.description.placeholder')"
|
|
|
|
:empty-text="$t('task.description.empty')"
|
2021-08-20 18:56:50 +02:00
|
|
|
:show-save="true"
|
|
|
|
v-model="task.description"
|
|
|
|
/>
|
2020-11-22 17:32:35 +01:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-07-25 15:27:15 +02:00
|
|
|
import LoadingComponent from '@/components/misc/loading.vue'
|
|
|
|
import ErrorComponent from '@/components/misc/error.vue'
|
2020-11-22 17:32:35 +01:00
|
|
|
|
|
|
|
import {LOADING} from '@/store/mutation-types'
|
|
|
|
import {mapState} from 'vuex'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'description',
|
|
|
|
components: {
|
|
|
|
editor: () => ({
|
2021-07-25 15:27:15 +02:00
|
|
|
component: import('@/components/input/editor.vue'),
|
2020-11-22 17:32:35 +01:00
|
|
|
loading: LoadingComponent,
|
|
|
|
error: ErrorComponent,
|
|
|
|
timeout: 60000,
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
task: {description: ''},
|
|
|
|
saved: false,
|
|
|
|
saving: false, // Since loading is global state, this variable ensures we're only showing the saving icon when saving the description.
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: mapState({
|
|
|
|
loading: LOADING,
|
|
|
|
}),
|
|
|
|
props: {
|
|
|
|
value: {
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
attachmentUpload: {
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
canWrite: {
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
value(newVal) {
|
|
|
|
this.task = newVal
|
|
|
|
},
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.task = this.value
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
save() {
|
|
|
|
this.saving = true
|
|
|
|
|
|
|
|
this.$store.dispatch('tasks/update', this.task)
|
2021-08-06 23:45:46 +02:00
|
|
|
.then(t => {
|
|
|
|
this.task = t
|
|
|
|
this.$emit('input', t)
|
2020-11-22 17:32:35 +01:00
|
|
|
this.saved = true
|
|
|
|
setTimeout(() => {
|
|
|
|
this.saved = false
|
|
|
|
}, 2000)
|
|
|
|
})
|
|
|
|
.catch(e => {
|
2021-06-22 22:07:57 +02:00
|
|
|
this.error(e)
|
2020-11-22 17:32:35 +01:00
|
|
|
})
|
|
|
|
.finally(() => {
|
|
|
|
this.saving = false
|
|
|
|
})
|
2021-07-17 23:21:46 +02:00
|
|
|
},
|
2020-11-22 17:32:35 +01:00
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|