2019-04-29 23:41:39 +02:00
|
|
|
<template>
|
2019-11-03 13:44:40 +01:00
|
|
|
<form @submit.prevent="editTaskSubmit()">
|
|
|
|
<div class="field">
|
2021-04-18 19:16:40 +02:00
|
|
|
<label class="label" for="tasktext">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 }"
|
2020-09-05 22:35:52 +02:00
|
|
|
:disabled="taskService.loading"
|
|
|
|
@change="editTaskSubmit()"
|
|
|
|
class="input"
|
|
|
|
id="tasktext"
|
|
|
|
placeholder="The task text is here..."
|
|
|
|
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">
|
|
|
|
<label class="label" for="taskdescription">Description</label>
|
|
|
|
<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"
|
|
|
|
placeholder="The tasks description goes here..."
|
|
|
|
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-04-18 19:16:40 +02:00
|
|
|
<strong>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-04-18 19:16:40 +02:00
|
|
|
<label class="label">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">
|
|
|
|
<label class="label">Color</label>
|
|
|
|
<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()"
|
|
|
|
>
|
2019-11-03 13:44:40 +01:00
|
|
|
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}}"
|
|
|
|
>
|
|
|
|
Open task detail view
|
|
|
|
</router-link>
|
2019-11-03 13:44:40 +01:00
|
|
|
</form>
|
2019-04-29 23:41:39 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-09-05 22:35:52 +02:00
|
|
|
import ListService from '../../services/list'
|
|
|
|
import TaskService from '../../services/task'
|
|
|
|
import TaskModel from '../../models/task'
|
|
|
|
import priorities from '../../models/priorities'
|
|
|
|
import EditLabels from './partials/editLabels'
|
|
|
|
import Reminders from './partials/reminders'
|
|
|
|
import ColorPicker from '../input/colorPicker'
|
|
|
|
import LoadingComponent from '../misc/loading'
|
|
|
|
import ErrorComponent from '../misc/error'
|
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,
|
|
|
|
listService: ListService,
|
|
|
|
taskService: TaskService,
|
2019-04-29 23:41:39 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
priorities: priorities,
|
|
|
|
list: {},
|
|
|
|
editorActive: false,
|
|
|
|
newTask: TaskModel,
|
|
|
|
isTaskEdit: false,
|
|
|
|
taskEditTask: TaskModel,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
components: {
|
|
|
|
ColorPicker,
|
|
|
|
Reminders,
|
|
|
|
EditLabels,
|
|
|
|
editor: () => ({
|
2021-04-18 19:16:40 +02:00
|
|
|
component: import(/* webpackChunkName: "editor" */ '../../components/input/editor'),
|
2020-09-05 22:35:52 +02:00
|
|
|
loading: LoadingComponent,
|
|
|
|
error: ErrorComponent,
|
|
|
|
timeout: 60000,
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
task: {
|
|
|
|
type: TaskModel,
|
|
|
|
required: true,
|
2019-10-28 22:45:37 +01:00
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
task() {
|
2019-10-28 22:45:37 +01:00
|
|
|
this.taskEditTask = this.task
|
2020-02-09 17:33:04 +01:00
|
|
|
this.initTaskFields()
|
2019-10-28 22:45:37 +01:00
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.listService = new ListService()
|
|
|
|
this.taskService = new TaskService()
|
|
|
|
this.newTask = new TaskModel()
|
|
|
|
this.taskEditTask = this.task
|
|
|
|
this.initTaskFields()
|
|
|
|
},
|
|
|
|
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
|
|
|
},
|
|
|
|
editTaskSubmit() {
|
2021-01-17 18:57:57 +01:00
|
|
|
this.taskService
|
|
|
|
.update(this.taskEditTask)
|
|
|
|
.then((r) => {
|
2020-09-05 22:35:52 +02:00
|
|
|
this.$set(this, 'taskEditTask', r)
|
|
|
|
this.initTaskFields()
|
2021-06-22 22:07:57 +02:00
|
|
|
this.success({message: 'The task has been saved successfully.'})
|
2020-09-05 22:35:52 +02:00
|
|
|
})
|
2021-01-17 18:57:57 +01:00
|
|
|
.catch((e) => {
|
2021-06-22 22:07:57 +02:00
|
|
|
this.error(e)
|
2020-09-05 22:35:52 +02:00
|
|
|
})
|
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>
|