2019-04-29 23:41:39 +02:00
|
|
|
<template>
|
2021-11-13 15:13:56 +01:00
|
|
|
<card
|
|
|
|
class="taskedit"
|
|
|
|
:title="$t('list.list.editTask')"
|
|
|
|
@close="$emit('close')"
|
|
|
|
:has-close="true"
|
|
|
|
>
|
2019-11-03 13:44:40 +01:00
|
|
|
<form @submit.prevent="editTaskSubmit()">
|
|
|
|
<div class="field">
|
2021-06-24 01:24:57 +02:00
|
|
|
<label class="label" for="tasktext">{{ $t('task.attributes.title') }}</label>
|
2019-11-03 13:44:40 +01:00
|
|
|
<div class="control">
|
2020-07-14 21:26:05 +02:00
|
|
|
<input
|
2021-01-17 18:57:57 +01:00
|
|
|
:class="{ disabled: taskService.loading }"
|
2021-08-20 17:00:03 +02:00
|
|
|
:disabled="taskService.loading || null"
|
2020-09-05 22:35:52 +02:00
|
|
|
@change="editTaskSubmit()"
|
|
|
|
class="input"
|
|
|
|
id="tasktext"
|
|
|
|
type="text"
|
|
|
|
v-focus
|
2021-01-17 18:57:57 +01:00
|
|
|
v-model="taskEditTask.title"
|
|
|
|
/>
|
2019-11-03 13:44:40 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="field">
|
2021-06-24 01:24:57 +02:00
|
|
|
<label class="label" for="taskdescription">{{ $t('task.attributes.description') }}</label>
|
2019-11-03 13:44:40 +01:00
|
|
|
<div class="control">
|
2020-07-14 21:26:05 +02:00
|
|
|
<editor
|
2020-09-05 22:35:52 +02:00
|
|
|
:preview-is-default="false"
|
|
|
|
id="taskdescription"
|
2021-06-24 01:24:57 +02:00
|
|
|
:placeholder="$t('task.description.placeholder')"
|
2020-09-05 22:35:52 +02:00
|
|
|
v-if="editorActive"
|
|
|
|
v-model="taskEditTask.description"
|
2020-07-14 21:26:05 +02:00
|
|
|
/>
|
2019-11-03 13:44:40 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2019-04-29 23:41:39 +02:00
|
|
|
|
2021-06-24 01:24:57 +02:00
|
|
|
<strong>{{ $t('task.attributes.reminders') }}</strong>
|
2021-01-17 18:57:57 +01:00
|
|
|
<reminders
|
|
|
|
@change="editTaskSubmit()"
|
|
|
|
v-model="taskEditTask.reminderDates"
|
|
|
|
/>
|
2019-04-29 23:41:39 +02:00
|
|
|
|
2019-11-03 13:44:40 +01:00
|
|
|
<div class="field">
|
2021-06-24 01:24:57 +02:00
|
|
|
<label class="label">{{ $t('task.attributes.labels') }}</label>
|
2019-11-03 13:44:40 +01:00
|
|
|
<div class="control">
|
2021-04-18 19:16:40 +02:00
|
|
|
<edit-labels
|
|
|
|
:task-id="taskEditTask.id"
|
|
|
|
v-model="taskEditTask.labels"
|
2021-01-17 18:57:57 +01:00
|
|
|
/>
|
2019-11-03 13:44:40 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2019-10-19 18:27:31 +02:00
|
|
|
|
2019-11-03 13:44:40 +01:00
|
|
|
<div class="field">
|
2021-06-24 01:24:57 +02:00
|
|
|
<label class="label">{{ $t('task.attributes.color') }}</label>
|
2019-11-03 13:44:40 +01:00
|
|
|
<div class="control">
|
2021-01-17 18:57:57 +01:00
|
|
|
<color-picker v-model="taskEditTask.hexColor" />
|
2019-11-03 13:44:40 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2019-04-30 22:18:06 +02:00
|
|
|
|
2021-01-17 18:57:57 +01:00
|
|
|
<x-button
|
|
|
|
:loading="taskService.loading"
|
|
|
|
class="is-fullwidth"
|
|
|
|
@click="editTaskSubmit()"
|
|
|
|
>
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('misc.save') }}
|
2021-01-17 18:57:57 +01:00
|
|
|
</x-button>
|
2021-04-18 19:16:40 +02:00
|
|
|
|
|
|
|
<router-link
|
|
|
|
class="mt-2 has-text-centered is-block"
|
|
|
|
:to="{name: 'task.detail', params: {id: taskEditTask.id}}"
|
|
|
|
>
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('task.openDetail') }}
|
2021-04-18 19:16:40 +02:00
|
|
|
</router-link>
|
2019-11-03 13:44:40 +01:00
|
|
|
</form>
|
2021-11-13 15:13:56 +01:00
|
|
|
</card>
|
2019-04-29 23:41:39 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-08-23 21:18:29 +02:00
|
|
|
import AsyncEditor from '@/components/input/AsyncEditor'
|
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
import ListService from '../../services/list'
|
|
|
|
import TaskService from '../../services/task'
|
|
|
|
import TaskModel from '../../models/task'
|
2021-09-10 16:21:33 +02:00
|
|
|
import priorities from '../../models/constants/priorities'
|
2020-09-05 22:35:52 +02:00
|
|
|
import EditLabels from './partials/editLabels'
|
|
|
|
import Reminders from './partials/reminders'
|
|
|
|
import ColorPicker from '../input/colorPicker'
|
2019-04-29 23:41:39 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
export default {
|
|
|
|
name: 'edit-task',
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
listId: this.$route.params.id,
|
2021-09-08 11:59:38 +02:00
|
|
|
listService: new ListService(),
|
|
|
|
taskService: new TaskService(),
|
2019-04-29 23:41:39 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
priorities: priorities,
|
|
|
|
list: {},
|
|
|
|
editorActive: false,
|
2021-09-08 11:59:38 +02:00
|
|
|
newTask: new TaskModel(),
|
2020-09-05 22:35:52 +02:00
|
|
|
isTaskEdit: false,
|
|
|
|
taskEditTask: TaskModel,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
components: {
|
|
|
|
ColorPicker,
|
|
|
|
Reminders,
|
|
|
|
EditLabels,
|
2021-08-23 21:18:29 +02:00
|
|
|
editor: AsyncEditor,
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
|
|
|
props: {
|
|
|
|
task: {
|
|
|
|
type: TaskModel,
|
|
|
|
required: true,
|
2019-10-28 22:45:37 +01:00
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
|
|
|
watch: {
|
2021-09-08 11:59:38 +02:00
|
|
|
task: {
|
|
|
|
handler() {
|
|
|
|
this.taskEditTask = this.task
|
|
|
|
this.initTaskFields()
|
|
|
|
},
|
|
|
|
immediate: true,
|
2019-10-28 22:45:37 +01:00
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
initTaskFields() {
|
2021-01-17 18:57:57 +01:00
|
|
|
this.taskEditTask.dueDate =
|
|
|
|
+new Date(this.task.dueDate) === 0 ? null : this.task.dueDate
|
|
|
|
this.taskEditTask.startDate =
|
|
|
|
+new Date(this.task.startDate) === 0
|
|
|
|
? null
|
|
|
|
: this.task.startDate
|
|
|
|
this.taskEditTask.endDate =
|
|
|
|
+new Date(this.task.endDate) === 0 ? null : this.task.endDate
|
2020-09-05 22:35:52 +02:00
|
|
|
// This makes the editor trigger its mounted function again which makes it forget every input
|
|
|
|
// it currently has in its textarea. This is a counter-hack to a hack inside of vue-easymde
|
|
|
|
// which made it impossible to detect change from the outside. Therefore the component would
|
|
|
|
// not update if new content from the outside was made available.
|
|
|
|
// See https://github.com/NikulinIlya/vue-easymde/issues/3
|
|
|
|
this.editorActive = false
|
2021-01-17 18:57:57 +01:00
|
|
|
this.$nextTick(() => (this.editorActive = true))
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
2021-10-11 19:37:20 +02:00
|
|
|
async editTaskSubmit() {
|
|
|
|
this.taskEditTask = await this.taskService.update(this.taskEditTask)
|
|
|
|
this.initTaskFields()
|
|
|
|
this.$message.success({message: this.$t('task.detail.updateSuccess')})
|
2019-10-28 22:45:37 +01:00
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
|
|
|
}
|
2019-04-29 23:41:39 +02:00
|
|
|
</script>
|
2021-10-18 14:22:47 +02:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.priority-select {
|
|
|
|
.select,
|
|
|
|
select {
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ul.assingees {
|
|
|
|
list-style: none;
|
|
|
|
margin: 0;
|
|
|
|
|
|
|
|
li {
|
|
|
|
padding: 0.5rem 0.5rem 0;
|
|
|
|
|
|
|
|
a {
|
|
|
|
float: right;
|
|
|
|
color: $red;
|
|
|
|
transition: all $transition;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.tag {
|
|
|
|
margin-right: 0.5rem;
|
|
|
|
margin-bottom: 0.5rem;
|
|
|
|
|
|
|
|
&:last-child {
|
|
|
|
margin-right: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|