2019-04-29 23:41:39 +02:00
|
|
|
<template>
|
2019-11-03 13:44:40 +01:00
|
|
|
<form @submit.prevent="editTaskSubmit()">
|
|
|
|
<div class="field">
|
|
|
|
<label class="label" for="tasktext">Task Text</label>
|
|
|
|
<div class="control">
|
2020-07-14 21:26:05 +02:00
|
|
|
<input
|
|
|
|
v-focus
|
|
|
|
:class="{ 'disabled': taskService.loading}"
|
|
|
|
:disabled="taskService.loading"
|
|
|
|
class="input"
|
|
|
|
type="text"
|
|
|
|
id="tasktext"
|
|
|
|
placeholder="The task text is here..."
|
|
|
|
v-model="taskEditTask.title"
|
|
|
|
@change="editTaskSubmit()"/>
|
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
|
|
|
|
placeholder="The tasks description goes here..."
|
|
|
|
id="taskdescription"
|
|
|
|
v-model="taskEditTask.description"
|
|
|
|
:preview-is-default="false"
|
|
|
|
v-if="editorActive"
|
|
|
|
/>
|
2019-11-03 13:44:40 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2019-04-29 23:41:39 +02:00
|
|
|
|
2019-11-03 13:44:40 +01:00
|
|
|
<b>Reminder Dates</b>
|
2020-02-09 17:30:42 +01:00
|
|
|
<reminders v-model="taskEditTask.reminderDates" @change="editTaskSubmit()"/>
|
2019-04-29 23:41:39 +02:00
|
|
|
|
2019-11-03 13:44:40 +01:00
|
|
|
<div class="field">
|
|
|
|
<label class="label" for="taskduedate">Due Date</label>
|
|
|
|
<div class="control">
|
|
|
|
<flat-pickr
|
|
|
|
:class="{ 'disabled': taskService.loading}"
|
|
|
|
class="input"
|
|
|
|
:disabled="taskService.loading"
|
|
|
|
v-model="taskEditTask.dueDate"
|
|
|
|
:config="flatPickerConfig"
|
2020-02-09 17:30:42 +01:00
|
|
|
@on-close="editTaskSubmit()"
|
2019-11-03 13:44:40 +01:00
|
|
|
id="taskduedate"
|
|
|
|
placeholder="The tasks due date is here...">
|
|
|
|
</flat-pickr>
|
|
|
|
</div>
|
|
|
|
</div>
|
2019-04-29 23:41:39 +02:00
|
|
|
|
2019-11-03 13:44:40 +01:00
|
|
|
<div class="field">
|
|
|
|
<label class="label" for="">Duration</label>
|
|
|
|
<div class="control columns">
|
|
|
|
<div class="column">
|
|
|
|
<flat-pickr
|
|
|
|
:class="{ 'disabled': taskService.loading}"
|
|
|
|
class="input"
|
|
|
|
:disabled="taskService.loading"
|
|
|
|
v-model="taskEditTask.startDate"
|
|
|
|
:config="flatPickerConfig"
|
2020-02-09 17:30:42 +01:00
|
|
|
@on-close="editTaskSubmit()"
|
2019-11-03 13:44:40 +01:00
|
|
|
id="taskduedate"
|
|
|
|
placeholder="Start date">
|
|
|
|
</flat-pickr>
|
|
|
|
</div>
|
|
|
|
<div class="column">
|
|
|
|
<flat-pickr
|
|
|
|
:class="{ 'disabled': taskService.loading}"
|
|
|
|
class="input"
|
|
|
|
:disabled="taskService.loading"
|
|
|
|
v-model="taskEditTask.endDate"
|
|
|
|
:config="flatPickerConfig"
|
2020-02-09 17:30:42 +01:00
|
|
|
@on-close="editTaskSubmit()"
|
2019-11-03 13:44:40 +01:00
|
|
|
id="taskduedate"
|
|
|
|
placeholder="End date">
|
|
|
|
</flat-pickr>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2019-04-29 23:41:39 +02:00
|
|
|
|
2019-11-03 13:44:40 +01:00
|
|
|
<div class="field">
|
|
|
|
<label class="label" for="">Repeat after</label>
|
2020-02-09 17:30:42 +01:00
|
|
|
<repeat-after v-model="taskEditTask.repeatAfter" @change="editTaskSubmit()"/>
|
2019-11-03 13:44:40 +01:00
|
|
|
</div>
|
2019-04-29 23:41:39 +02:00
|
|
|
|
2019-11-03 13:44:40 +01:00
|
|
|
<div class="field">
|
|
|
|
<label class="label" for="">Priority</label>
|
|
|
|
<div class="control priority-select">
|
2020-02-09 17:30:42 +01:00
|
|
|
<priority-select v-model="taskEditTask.priority" @change="editTaskSubmit()"/>
|
2019-11-03 13:44:40 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2019-04-29 23:41:39 +02:00
|
|
|
|
2019-11-03 13:44:40 +01:00
|
|
|
<div class="field">
|
|
|
|
<label class="label">Percent Done</label>
|
|
|
|
<div class="control">
|
2020-02-09 17:30:42 +01:00
|
|
|
<percent-done-select v-model="taskEditTask.percentDone" @change="editTaskSubmit()"/>
|
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">
|
2020-06-15 11:46:52 +02: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
|
|
|
|
2019-11-03 13:44:40 +01:00
|
|
|
<div class="field">
|
|
|
|
<label class="label" for="">Assignees</label>
|
|
|
|
<ul class="assingees">
|
|
|
|
<li v-for="(a, index) in taskEditTask.assignees" :key="a.id">
|
|
|
|
{{a.username}}
|
|
|
|
<a @click="deleteAssigneeByIndex(index)">
|
|
|
|
<icon icon="times"/>
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
2019-04-29 23:41:39 +02:00
|
|
|
|
2019-11-03 13:44:40 +01:00
|
|
|
<div class="field has-addons">
|
|
|
|
<div class="control is-expanded">
|
2020-07-14 21:26:05 +02:00
|
|
|
<edit-assignees
|
|
|
|
:task-id="taskEditTask.id"
|
|
|
|
:list-id="taskEditTask.listId"
|
|
|
|
:initial-assignees="taskEditTask.assignees"/>
|
2019-11-03 13:44:40 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2019-04-29 23:41:39 +02:00
|
|
|
|
2019-11-03 13:44:40 +01:00
|
|
|
<div class="field">
|
|
|
|
<label class="label">Labels</label>
|
|
|
|
<div class="control">
|
2020-04-17 12:19:53 +02:00
|
|
|
<edit-labels :task-id="taskEditTask.id" v-model="taskEditTask.labels"/>
|
2019-11-03 13:44:40 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2019-04-29 23:41:39 +02:00
|
|
|
|
2019-11-24 14:16:24 +01:00
|
|
|
<related-tasks
|
2020-07-14 21:26:05 +02:00
|
|
|
class="is-narrow"
|
|
|
|
:task-id="task.id"
|
|
|
|
:list-id="task.listId"
|
|
|
|
:initial-related-tasks="task.relatedTasks"
|
2019-11-24 14:16:24 +01:00
|
|
|
/>
|
2019-04-29 23:41:39 +02:00
|
|
|
|
2019-11-03 13:44:40 +01:00
|
|
|
<button type="submit" class="button is-success is-fullwidth" :class="{ 'is-loading': taskService.loading}">
|
|
|
|
Save
|
|
|
|
</button>
|
2019-04-29 23:41:39 +02:00
|
|
|
|
2019-11-03 13:44:40 +01:00
|
|
|
</form>
|
2019-04-29 23:41:39 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2019-10-28 22:45:37 +01:00
|
|
|
import flatPickr from 'vue-flatpickr-component'
|
|
|
|
import 'flatpickr/dist/flatpickr.css'
|
2019-04-29 23:41:39 +02:00
|
|
|
|
2019-10-28 22:45:37 +01:00
|
|
|
import ListService from '../../services/list'
|
|
|
|
import TaskService from '../../services/task'
|
|
|
|
import TaskModel from '../../models/task'
|
|
|
|
import priorities from '../../models/priorities'
|
2020-06-17 22:15:59 +02:00
|
|
|
import PrioritySelect from './partials/prioritySelect'
|
|
|
|
import PercentDoneSelect from './partials/percentDoneSelect'
|
|
|
|
import EditLabels from './partials/editLabels'
|
|
|
|
import EditAssignees from './partials/editAssignees'
|
|
|
|
import RelatedTasks from './partials/relatedTasks'
|
|
|
|
import RepeatAfter from './partials/repeatAfter'
|
|
|
|
import Reminders from './partials/reminders'
|
|
|
|
import ColorPicker from '../input/colorPicker'
|
2019-04-29 23:41:39 +02:00
|
|
|
|
2019-10-28 22:45:37 +01:00
|
|
|
export default {
|
|
|
|
name: 'edit-task',
|
|
|
|
data() {
|
|
|
|
return {
|
2020-04-17 12:19:53 +02:00
|
|
|
listId: this.$route.params.id,
|
2019-10-28 22:45:37 +01:00
|
|
|
listService: ListService,
|
|
|
|
taskService: TaskService,
|
2019-04-29 23:41:39 +02:00
|
|
|
|
2019-10-28 22:45:37 +01:00
|
|
|
priorities: priorities,
|
|
|
|
list: {},
|
2020-07-14 21:26:05 +02:00
|
|
|
editorActive: false,
|
2019-10-28 22:45:37 +01:00
|
|
|
newTask: TaskModel,
|
|
|
|
isTaskEdit: false,
|
|
|
|
taskEditTask: TaskModel,
|
|
|
|
flatPickerConfig: {
|
|
|
|
altFormat: 'j M Y H:i',
|
|
|
|
altInput: true,
|
|
|
|
dateFormat: 'Y-m-d H:i',
|
|
|
|
enableTime: true,
|
|
|
|
onOpen: this.updateLastReminderDate,
|
|
|
|
onClose: this.addReminderDate,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
components: {
|
2020-06-15 11:46:52 +02:00
|
|
|
ColorPicker,
|
2019-11-24 14:16:24 +01:00
|
|
|
Reminders,
|
|
|
|
RepeatAfter,
|
|
|
|
RelatedTasks,
|
|
|
|
EditAssignees,
|
|
|
|
EditLabels,
|
|
|
|
PercentDoneSelect,
|
|
|
|
PrioritySelect,
|
2019-10-28 22:45:37 +01:00
|
|
|
flatPickr,
|
2020-07-14 21:26:05 +02:00
|
|
|
editor: () => import(/* webpackPrefetch: true */ '../../components/input/editor'),
|
2019-10-28 22:45:37 +01:00
|
|
|
},
|
|
|
|
props: {
|
|
|
|
task: {
|
|
|
|
type: TaskModel,
|
|
|
|
required: true,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
task() {
|
|
|
|
this.taskEditTask = this.task
|
2020-02-09 17:33:04 +01:00
|
|
|
this.initTaskFields()
|
2019-10-28 22:45:37 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.listService = new ListService()
|
|
|
|
this.taskService = new TaskService()
|
|
|
|
this.newTask = new TaskModel()
|
|
|
|
this.taskEditTask = this.task
|
2020-02-09 17:33:04 +01:00
|
|
|
this.initTaskFields()
|
2019-10-28 22:45:37 +01:00
|
|
|
},
|
|
|
|
methods: {
|
2020-02-09 17:33:04 +01:00
|
|
|
initTaskFields() {
|
|
|
|
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-07-14 21:26:05 +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
|
|
|
|
this.$nextTick(() => this.editorActive = true)
|
2020-02-09 17:33:04 +01:00
|
|
|
},
|
2019-10-28 22:45:37 +01:00
|
|
|
editTaskSubmit() {
|
|
|
|
this.taskService.update(this.taskEditTask)
|
|
|
|
.then(r => {
|
|
|
|
this.$set(this, 'taskEditTask', r)
|
2020-02-09 17:33:04 +01:00
|
|
|
this.initTaskFields()
|
2019-10-28 22:45:37 +01:00
|
|
|
})
|
|
|
|
.catch(e => {
|
2020-01-30 22:47:08 +01:00
|
|
|
this.error(e, this)
|
2019-10-28 22:45:37 +01:00
|
|
|
})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
2019-04-29 23:41:39 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
2019-11-03 13:44:40 +01:00
|
|
|
form {
|
|
|
|
margin-bottom: 1em;
|
|
|
|
}
|
2019-04-29 23:41:39 +02:00
|
|
|
</style>
|