2019-11-24 14:16:24 +01:00
|
|
|
<template>
|
2020-05-31 21:17:10 +02:00
|
|
|
<div class="loader-container task-view-container" :class="{ 'is-loading': taskService.loading}">
|
2019-11-24 14:16:24 +01:00
|
|
|
<div class="task-view">
|
|
|
|
<div class="heading">
|
2020-05-16 13:14:57 +02:00
|
|
|
<h1 class="title task-id" v-if="task.identifier === ''">
|
|
|
|
#{{ task.index }}
|
|
|
|
</h1>
|
|
|
|
<h1 class="title task-id" v-else>
|
|
|
|
{{ task.identifier }}
|
2019-11-24 14:16:24 +01:00
|
|
|
</h1>
|
|
|
|
<div class="is-done" v-if="task.done">Done</div>
|
2020-05-09 23:28:54 +02:00
|
|
|
<h1 class="title input" contenteditable="true" @focusout="saveTaskOnChange()" ref="taskTitle"
|
2020-05-16 12:31:16 +02:00
|
|
|
@keyup.ctrl.enter="saveTaskOnChange()">{{ task.title }}</h1>
|
2019-11-24 14:16:24 +01:00
|
|
|
</div>
|
2020-05-09 23:28:54 +02:00
|
|
|
<h6 class="subtitle" v-if="parent && parent.namespace && parent.list">
|
2020-05-16 12:31:16 +02:00
|
|
|
{{ parent.namespace.title }} >
|
2020-05-09 23:38:32 +02:00
|
|
|
<router-link :to="{ name: 'list.list', params: { listId: parent.list.id } }">
|
2020-05-09 23:28:54 +02:00
|
|
|
{{ parent.list.title }}
|
|
|
|
</router-link>
|
|
|
|
</h6>
|
2019-11-24 14:16:24 +01:00
|
|
|
|
|
|
|
<!-- Content and buttons -->
|
|
|
|
<div class="columns">
|
|
|
|
<!-- Content -->
|
|
|
|
<div class="column">
|
|
|
|
<div class="columns details">
|
|
|
|
<div class="column assignees" v-if="activeFields.assignees">
|
|
|
|
<!-- Assignees -->
|
|
|
|
<div class="detail-title">
|
|
|
|
<icon icon="users"/>
|
|
|
|
Assignees
|
|
|
|
</div>
|
|
|
|
<edit-assignees
|
2020-04-17 12:19:53 +02:00
|
|
|
:task-id="task.id"
|
|
|
|
:list-id="task.listId"
|
2019-11-24 14:16:24 +01:00
|
|
|
:initial-assignees="task.assignees"
|
|
|
|
ref="assignees"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div class="column" v-if="activeFields.priority">
|
|
|
|
<!-- Priority -->
|
|
|
|
<div class="detail-title">
|
|
|
|
<icon :icon="['far', 'star']"/>
|
|
|
|
Priority
|
|
|
|
</div>
|
|
|
|
<priority-select v-model="task.priority" @change="saveTask" ref="priority"/>
|
|
|
|
</div>
|
|
|
|
<div class="column" v-if="activeFields.dueDate">
|
|
|
|
<!-- Due Date -->
|
|
|
|
<div class="detail-title">
|
|
|
|
<icon icon="calendar"/>
|
|
|
|
Due Date
|
|
|
|
</div>
|
|
|
|
<div class="date-input">
|
|
|
|
<flat-pickr
|
2020-05-09 23:28:54 +02:00
|
|
|
:class="{ 'disabled': taskService.loading}"
|
|
|
|
class="input"
|
|
|
|
:disabled="taskService.loading"
|
|
|
|
v-model="dueDate"
|
|
|
|
:config="flatPickerConfig"
|
|
|
|
@on-close="saveTask"
|
|
|
|
placeholder="Click here to set a due date"
|
|
|
|
ref="dueDate"
|
2019-11-24 14:16:24 +01:00
|
|
|
>
|
|
|
|
</flat-pickr>
|
2020-05-09 19:00:54 +02:00
|
|
|
<a v-if="dueDate" @click="() => {dueDate = task.dueDate = null;saveTask()}">
|
2019-11-24 14:16:24 +01:00
|
|
|
<span class="icon is-small">
|
|
|
|
<icon icon="times"></icon>
|
|
|
|
</span>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="column" v-if="activeFields.percentDone">
|
|
|
|
<!-- Percent Done -->
|
|
|
|
<div class="detail-title">
|
|
|
|
<icon icon="percent"/>
|
|
|
|
Percent Done
|
|
|
|
</div>
|
|
|
|
<percent-done-select v-model="task.percentDone" @change="saveTask" ref="percentDone"/>
|
|
|
|
</div>
|
|
|
|
<div class="column" v-if="activeFields.startDate">
|
|
|
|
<!-- Start Date -->
|
|
|
|
<div class="detail-title">
|
|
|
|
<icon icon="calendar-week"/>
|
|
|
|
Start Date
|
|
|
|
</div>
|
|
|
|
<div class="date-input">
|
|
|
|
<flat-pickr
|
2020-05-09 23:28:54 +02:00
|
|
|
:class="{ 'disabled': taskService.loading}"
|
|
|
|
class="input"
|
|
|
|
:disabled="taskService.loading"
|
|
|
|
v-model="task.startDate"
|
|
|
|
:config="flatPickerConfig"
|
|
|
|
@on-close="saveTask"
|
|
|
|
placeholder="Click here to set a start date"
|
|
|
|
ref="startDate"
|
2019-11-24 14:16:24 +01:00
|
|
|
>
|
|
|
|
</flat-pickr>
|
|
|
|
<a v-if="task.startDate" @click="() => {task.startDate = null;saveTask()}">
|
|
|
|
<span class="icon is-small">
|
|
|
|
<icon icon="times"></icon>
|
|
|
|
</span>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="column" v-if="activeFields.endDate">
|
|
|
|
<!-- End Date -->
|
|
|
|
<div class="detail-title">
|
|
|
|
<icon icon="calendar-week"/>
|
|
|
|
End Date
|
|
|
|
</div>
|
|
|
|
<div class="date-input">
|
|
|
|
<flat-pickr
|
2020-05-09 23:28:54 +02:00
|
|
|
:class="{ 'disabled': taskService.loading}"
|
|
|
|
class="input"
|
|
|
|
:disabled="taskService.loading"
|
|
|
|
v-model="task.endDate"
|
|
|
|
:config="flatPickerConfig"
|
|
|
|
@on-close="saveTask"
|
|
|
|
placeholder="Click here to set an end date"
|
|
|
|
ref="endDate"
|
2019-11-24 14:16:24 +01:00
|
|
|
>
|
|
|
|
</flat-pickr>
|
|
|
|
<a v-if="task.endDate" @click="() => {task.endDate = null;saveTask()}">
|
|
|
|
<span class="icon is-small">
|
|
|
|
<icon icon="times"></icon>
|
|
|
|
</span>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="column" v-if="activeFields.reminders">
|
|
|
|
<!-- Reminders -->
|
|
|
|
<div class="detail-title">
|
|
|
|
<icon icon="history"/>
|
|
|
|
Reminders
|
|
|
|
</div>
|
|
|
|
<reminders v-model="task.reminderDates" @change="saveTask" ref="reminders"/>
|
|
|
|
</div>
|
|
|
|
<div class="column" v-if="activeFields.repeatAfter">
|
|
|
|
<!-- Repeat after -->
|
|
|
|
<div class="detail-title">
|
|
|
|
<icon :icon="['far', 'clock']"/>
|
|
|
|
Repeat
|
|
|
|
</div>
|
|
|
|
<repeat-after v-model="task.repeatAfter" @change="saveTask" ref="repeatAfter"/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- Labels -->
|
|
|
|
<div class="labels-list details" v-if="activeFields.labels">
|
|
|
|
<div class="detail-title">
|
|
|
|
<span class="icon is-grey">
|
|
|
|
<icon icon="tags"/>
|
|
|
|
</span>
|
|
|
|
Labels
|
|
|
|
</div>
|
2020-04-17 12:19:53 +02:00
|
|
|
<edit-labels :task-id="taskId" v-model="task.labels" ref="labels"/>
|
2019-11-24 14:16:24 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- Description -->
|
|
|
|
<div class="details content" :class="{ 'has-top-border': activeFields.labels }">
|
|
|
|
<h3>
|
|
|
|
<span class="icon is-grey">
|
|
|
|
<icon icon="align-left"/>
|
|
|
|
</span>
|
|
|
|
Description
|
|
|
|
</h3>
|
|
|
|
<!-- We're using a normal textarea until the problem with the icons is resolved in easymde -->
|
|
|
|
<!-- <easymde v-model="task.description" @change="saveTask"/>-->
|
2020-03-01 16:50:05 +01:00
|
|
|
<textarea
|
|
|
|
class="textarea"
|
|
|
|
v-model="task.description"
|
|
|
|
rows="6"
|
|
|
|
placeholder="Click here to enter a description..."
|
|
|
|
@keyup.ctrl.enter="saveTaskIfDescriptionChanged"
|
|
|
|
@keydown="setDescriptionChanged"
|
|
|
|
@change="saveTaskIfDescriptionChanged"
|
|
|
|
></textarea>
|
2019-11-24 14:16:24 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- Attachments -->
|
|
|
|
<div class="content attachments has-top-border" v-if="activeFields.attachments">
|
|
|
|
<attachments
|
2020-04-17 12:19:53 +02:00
|
|
|
:task-id="taskId"
|
2019-11-24 14:16:24 +01:00
|
|
|
:initial-attachments="task.attachments"
|
|
|
|
ref="attachments"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- Related Tasks -->
|
|
|
|
<div class="content details has-top-border" v-if="activeFields.relatedTasks">
|
|
|
|
<h3>
|
|
|
|
<span class="icon is-grey">
|
|
|
|
<icon icon="tasks"/>
|
|
|
|
</span>
|
|
|
|
Related Tasks
|
|
|
|
</h3>
|
|
|
|
<related-tasks
|
2020-04-17 12:19:53 +02:00
|
|
|
:task-id="taskId"
|
2020-04-12 23:54:46 +02:00
|
|
|
:list-id="task.listId"
|
|
|
|
:initial-related-tasks="task.relatedTasks"
|
2019-11-24 14:16:24 +01:00
|
|
|
:show-no-relations-notice="true"
|
|
|
|
ref="relatedTasks"
|
|
|
|
/>
|
|
|
|
</div>
|
2020-02-25 21:11:36 +01:00
|
|
|
|
2020-04-18 14:39:56 +02:00
|
|
|
<!-- Move Task -->
|
|
|
|
<div class="content details has-top-border" v-if="activeFields.moveList">
|
|
|
|
<h3>
|
|
|
|
<span class="icon is-grey">
|
|
|
|
<icon icon="list"/>
|
|
|
|
</span>
|
2020-05-04 21:33:01 +02:00
|
|
|
Move task to a different list
|
2020-04-18 14:39:56 +02:00
|
|
|
</h3>
|
|
|
|
<div class="field has-addons">
|
|
|
|
<div class="control is-expanded">
|
|
|
|
<list-search @selected="changeList"/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2020-02-25 21:11:36 +01:00
|
|
|
<!-- Comments -->
|
2020-04-17 12:19:53 +02:00
|
|
|
<comments :task-id="taskId"/>
|
2019-11-24 14:16:24 +01:00
|
|
|
</div>
|
2020-04-26 01:11:34 +02:00
|
|
|
<div class="column is-one-third action-buttons">
|
2020-05-09 23:28:54 +02:00
|
|
|
<a
|
|
|
|
class="button is-outlined noshadow has-no-border"
|
|
|
|
:class="{'is-success': !task.done}"
|
|
|
|
@click="toggleTaskDone()">
|
2020-02-09 14:46:01 +01:00
|
|
|
<span class="icon is-small"><icon icon="check-double"/></span>
|
|
|
|
<template v-if="task.done">
|
|
|
|
Mark as undone
|
|
|
|
</template>
|
|
|
|
<template v-else>
|
|
|
|
Done!
|
|
|
|
</template>
|
|
|
|
</a>
|
2019-11-24 14:16:24 +01:00
|
|
|
<a class="button" @click="setFieldActive('assignees')">
|
|
|
|
<span class="icon is-small"><icon icon="users"/></span>
|
|
|
|
Assign this task to a user
|
|
|
|
</a>
|
|
|
|
<a class="button" @click="setFieldActive('labels')">
|
|
|
|
<span class="icon is-small"><icon icon="tags"/></span>
|
|
|
|
Add labels
|
|
|
|
</a>
|
2020-02-09 12:50:57 +01:00
|
|
|
<a class="button" @click="setFieldActive('reminders')">
|
|
|
|
<span class="icon is-small"><icon icon="history"/></span>
|
|
|
|
Set Reminders
|
|
|
|
</a>
|
2019-11-24 14:16:24 +01:00
|
|
|
<a class="button" @click="setFieldActive('dueDate')">
|
|
|
|
<span class="icon is-small"><icon icon="calendar"/></span>
|
|
|
|
Set Due Date
|
|
|
|
</a>
|
|
|
|
<a class="button" @click="setFieldActive('startDate')">
|
|
|
|
<span class="icon is-small"><icon icon="calendar-week"/></span>
|
|
|
|
Set a Start Date
|
|
|
|
</a>
|
|
|
|
<a class="button" @click="setFieldActive('endDate')">
|
|
|
|
<span class="icon is-small"><icon icon="calendar-week"/></span>
|
|
|
|
Set an End Date
|
|
|
|
</a>
|
|
|
|
<a class="button" @click="setFieldActive('repeatAfter')">
|
|
|
|
<span class="icon is-small"><icon :icon="['far', 'clock']"/></span>
|
|
|
|
Set a repeating interval
|
|
|
|
</a>
|
2020-02-09 14:54:09 +01:00
|
|
|
<a class="button" @click="setFieldActive('priority')">
|
|
|
|
<span class="icon is-small"><icon :icon="['far', 'star']"/></span>
|
|
|
|
Set Priority
|
|
|
|
</a>
|
|
|
|
<a class="button" @click="setFieldActive('percentDone')">
|
|
|
|
<span class="icon is-small"><icon icon="percent"/></span>
|
|
|
|
Set Percent Done
|
|
|
|
</a>
|
|
|
|
<a class="button" @click="setFieldActive('attachments')">
|
|
|
|
<span class="icon is-small"><icon icon="paperclip"/></span>
|
|
|
|
Add attachments
|
|
|
|
</a>
|
|
|
|
<a class="button" @click="setFieldActive('relatedTasks')">
|
|
|
|
<span class="icon is-small"><icon icon="tasks"/></span>
|
|
|
|
Add task relations
|
|
|
|
</a>
|
2020-04-18 14:39:56 +02:00
|
|
|
<a class="button" @click="setFieldActive('moveList')">
|
|
|
|
<span class="icon is-small"><icon icon="list"/></span>
|
2020-05-04 21:33:01 +02:00
|
|
|
Move task
|
2020-04-18 14:39:56 +02:00
|
|
|
</a>
|
2020-01-22 21:18:39 +01:00
|
|
|
<a class="button is-danger is-outlined noshadow has-no-border" @click="showDeleteModal = true">
|
|
|
|
<span class="icon is-small"><icon icon="trash-alt"/></span>
|
|
|
|
Delete task
|
|
|
|
</a>
|
2019-11-24 14:16:24 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- Created / Updated [by] -->
|
|
|
|
</div>
|
2020-01-22 21:18:39 +01:00
|
|
|
|
|
|
|
<modal
|
|
|
|
v-if="showDeleteModal"
|
|
|
|
@close="showDeleteModal = false"
|
|
|
|
@submit="deleteTask()">
|
|
|
|
<span slot="header">Delete this task</span>
|
|
|
|
<p slot="text">
|
|
|
|
Are you sure you want to remove this task? <br/>
|
|
|
|
This will also remove all attachments, reminders and relations associated with this task and
|
|
|
|
<b>cannot be undone!</b>
|
|
|
|
</p>
|
|
|
|
</modal>
|
2019-11-24 14:16:24 +01:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import TaskService from '../../services/task'
|
|
|
|
import TaskModel from '../../models/task'
|
|
|
|
import relationKinds from '../../models/relationKinds'
|
|
|
|
|
|
|
|
import priorites from '../../models/priorities'
|
|
|
|
|
|
|
|
import flatPickr from 'vue-flatpickr-component'
|
|
|
|
import 'flatpickr/dist/flatpickr.css'
|
|
|
|
import PrioritySelect from './reusable/prioritySelect'
|
|
|
|
import PercentDoneSelect from './reusable/percentDoneSelect'
|
|
|
|
import EditLabels from './reusable/editLabels'
|
|
|
|
import EditAssignees from './reusable/editAssignees'
|
|
|
|
import Attachments from './reusable/attachments'
|
|
|
|
import RelatedTasks from './reusable/relatedTasks'
|
|
|
|
import RepeatAfter from './reusable/repeatAfter'
|
|
|
|
import Reminders from './reusable/reminders'
|
2020-02-25 21:11:36 +01:00
|
|
|
import Comments from './reusable/comments'
|
2020-01-22 21:18:39 +01:00
|
|
|
import router from '../../router'
|
2020-04-30 12:49:42 +02:00
|
|
|
import ListSearch from './reusable/listSearch'
|
2019-11-24 14:16:24 +01:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'TaskDetailView',
|
|
|
|
components: {
|
2020-04-18 14:39:56 +02:00
|
|
|
ListSearch,
|
2019-11-24 14:16:24 +01:00
|
|
|
Reminders,
|
|
|
|
RepeatAfter,
|
|
|
|
RelatedTasks,
|
|
|
|
Attachments,
|
|
|
|
EditAssignees,
|
|
|
|
EditLabels,
|
|
|
|
PercentDoneSelect,
|
|
|
|
PrioritySelect,
|
2020-02-25 21:11:36 +01:00
|
|
|
Comments,
|
2019-11-24 14:16:24 +01:00
|
|
|
flatPickr,
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2020-04-17 12:19:53 +02:00
|
|
|
taskId: Number(this.$route.params.id),
|
2019-11-24 14:16:24 +01:00
|
|
|
taskService: TaskService,
|
|
|
|
task: TaskModel,
|
|
|
|
relationKinds: relationKinds,
|
2020-05-09 19:00:54 +02:00
|
|
|
// The due date is a seperate property in the task to prevent flatpickr from modifying the task model
|
|
|
|
// in store right after updating it from the api resulting in the wrong due date format being saved in the task.
|
|
|
|
dueDate: null,
|
2019-11-24 14:16:24 +01:00
|
|
|
|
2020-01-22 21:18:39 +01:00
|
|
|
showDeleteModal: false,
|
2020-01-31 17:09:29 +01:00
|
|
|
taskTitle: '',
|
2020-03-01 16:50:05 +01:00
|
|
|
descriptionChanged: false,
|
2019-11-24 14:16:24 +01:00
|
|
|
|
|
|
|
priorities: priorites,
|
|
|
|
flatPickerConfig: {
|
|
|
|
altFormat: 'j M Y H:i',
|
|
|
|
altInput: true,
|
|
|
|
dateFormat: 'Y-m-d H:i',
|
|
|
|
enableTime: true,
|
|
|
|
time_24hr: true,
|
|
|
|
},
|
|
|
|
activeFields: {
|
|
|
|
assignees: false,
|
|
|
|
priority: false,
|
|
|
|
dueDate: false,
|
|
|
|
percentDone: false,
|
|
|
|
startDate: false,
|
|
|
|
endDate: false,
|
|
|
|
reminders: false,
|
|
|
|
repeatAfter: false,
|
|
|
|
labels: false,
|
|
|
|
attachments: false,
|
|
|
|
relatedTasks: false,
|
2020-04-18 14:39:56 +02:00
|
|
|
moveList: false,
|
2019-11-24 14:16:24 +01:00
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
'$route': 'loadTask'
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.taskService = new TaskService()
|
|
|
|
this.task = new TaskModel()
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.loadTask()
|
|
|
|
},
|
2020-05-09 23:28:54 +02:00
|
|
|
computed: {
|
|
|
|
parent() {
|
|
|
|
if(!this.task.listId) {
|
|
|
|
return {
|
|
|
|
namespace: null,
|
|
|
|
list: null,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!this.$store.getters["namespaces/getListAndNamespaceById"]) {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.$store.getters["namespaces/getListAndNamespaceById"](this.task.listId)
|
|
|
|
},
|
|
|
|
},
|
2019-11-24 14:16:24 +01:00
|
|
|
methods: {
|
|
|
|
loadTask() {
|
2020-04-17 12:19:53 +02:00
|
|
|
this.taskId = Number(this.$route.params.id)
|
|
|
|
this.taskService.get({id: this.taskId})
|
2019-11-24 14:16:24 +01:00
|
|
|
.then(r => {
|
|
|
|
this.$set(this, 'task', r)
|
2020-05-16 12:31:16 +02:00
|
|
|
this.taskTitle = this.task.title
|
2020-02-08 18:37:23 +01:00
|
|
|
this.setActiveFields()
|
2019-11-24 14:16:24 +01:00
|
|
|
})
|
|
|
|
.catch(e => {
|
2020-01-30 22:47:08 +01:00
|
|
|
this.error(e, this)
|
2019-11-24 14:16:24 +01:00
|
|
|
})
|
|
|
|
},
|
2020-02-08 18:37:23 +01:00
|
|
|
setActiveFields() {
|
|
|
|
|
2020-05-09 19:00:54 +02:00
|
|
|
this.dueDate = +new Date(this.task.dueDate) === 0 ? null : this.task.dueDate
|
2020-02-08 18:37:23 +01:00
|
|
|
this.task.startDate = +new Date(this.task.startDate) === 0 ? null : this.task.startDate
|
|
|
|
this.task.endDate = +new Date(this.task.endDate) === 0 ? null : this.task.endDate
|
|
|
|
|
|
|
|
// Set all active fields based on values in the model
|
|
|
|
this.activeFields.assignees = this.task.assignees.length > 0
|
|
|
|
this.activeFields.priority = this.task.priority !== priorites.UNSET
|
|
|
|
this.activeFields.dueDate = this.task.dueDate !== null
|
|
|
|
this.activeFields.percentDone = this.task.percentDone > 0
|
|
|
|
this.activeFields.startDate = this.task.startDate !== null
|
|
|
|
this.activeFields.endDate = this.task.endDate !== null
|
2020-03-01 17:20:25 +01:00
|
|
|
// On chrome, reminderDates.length holds the actual number of reminders that are not null.
|
|
|
|
// Unlike on desktop where it holds all reminders, including the ones which are null.
|
|
|
|
// This causes the reminders to dissapear entierly when only one is set and the user is on mobile.
|
|
|
|
this.activeFields.reminders = this.task.reminderDates.length > 1 || (window.innerWidth < 769 && this.task.reminderDates.length > 0)
|
2020-02-08 18:37:23 +01:00
|
|
|
this.activeFields.repeatAfter = this.task.repeatAfter.amount > 0
|
|
|
|
this.activeFields.labels = this.task.labels.length > 0
|
|
|
|
this.activeFields.attachments = this.task.attachments.length > 0
|
2020-04-12 23:54:46 +02:00
|
|
|
this.activeFields.relatedTasks = Object.keys(this.task.relatedTasks).length > 0
|
2020-02-08 18:37:23 +01:00
|
|
|
},
|
2020-01-31 17:09:29 +01:00
|
|
|
saveTaskOnChange() {
|
|
|
|
this.$refs.taskTitle.spellcheck = false
|
|
|
|
|
|
|
|
// Pull the task title from the contenteditable
|
|
|
|
let taskTitle = this.$refs.taskTitle.textContent
|
2020-05-16 12:31:16 +02:00
|
|
|
this.task.title = taskTitle
|
2020-01-31 17:09:29 +01:00
|
|
|
|
|
|
|
// We only want to save if the title was actually change.
|
|
|
|
// Because the contenteditable does not have a change event,
|
|
|
|
// we're building it ourselves and only calling saveTask()
|
|
|
|
// if the task title changed.
|
2020-05-16 12:31:16 +02:00
|
|
|
if (this.task.title !== this.taskTitle) {
|
2020-01-31 17:09:29 +01:00
|
|
|
this.saveTask()
|
|
|
|
this.taskTitle = taskTitle
|
|
|
|
}
|
|
|
|
},
|
2020-03-02 21:19:26 +01:00
|
|
|
saveTask(undoCallback = null) {
|
2020-02-09 14:52:45 +01:00
|
|
|
|
2020-05-09 19:00:54 +02:00
|
|
|
this.task.dueDate = this.dueDate
|
|
|
|
|
2020-02-09 14:52:45 +01:00
|
|
|
// If no end date is being set, but a start date and due date,
|
|
|
|
// use the due date as the end date
|
|
|
|
if (this.task.endDate === null && this.task.startDate !== null && this.task.dueDate !== null) {
|
|
|
|
this.task.endDate = this.task.dueDate
|
|
|
|
}
|
|
|
|
|
2020-05-09 19:00:54 +02:00
|
|
|
this.$store.dispatch('tasks/update', this.task)
|
2019-11-24 14:16:24 +01:00
|
|
|
.then(r => {
|
|
|
|
this.$set(this, 'task', r)
|
2020-03-02 21:19:26 +01:00
|
|
|
let actions = []
|
|
|
|
if (undoCallback !== null) {
|
|
|
|
actions = [{
|
|
|
|
title: 'Undo',
|
|
|
|
callback: undoCallback,
|
|
|
|
}]
|
2020-06-01 00:09:21 +02:00
|
|
|
this.success({message: 'The task was saved successfully.'}, this, actions)
|
2020-03-02 21:19:26 +01:00
|
|
|
}
|
2020-05-09 19:00:54 +02:00
|
|
|
this.dueDate = this.task.dueDate
|
2020-02-08 18:37:23 +01:00
|
|
|
this.setActiveFields()
|
2019-11-24 14:16:24 +01:00
|
|
|
})
|
|
|
|
.catch(e => {
|
2020-01-30 22:47:08 +01:00
|
|
|
this.error(e, this)
|
2019-11-24 14:16:24 +01:00
|
|
|
})
|
|
|
|
},
|
|
|
|
setFieldActive(fieldName) {
|
|
|
|
this.activeFields[fieldName] = true
|
|
|
|
this.$nextTick(() => this.$refs[fieldName].$el.focus())
|
|
|
|
},
|
2020-01-22 21:18:39 +01:00
|
|
|
deleteTask() {
|
2020-05-11 17:24:51 +02:00
|
|
|
this.$store.dispatch('tasks/delete', this.task)
|
2020-01-22 21:18:39 +01:00
|
|
|
.then(() => {
|
2020-01-30 22:47:08 +01:00
|
|
|
this.success({message: 'The task been deleted successfully.'}, this)
|
2020-04-30 12:49:42 +02:00
|
|
|
router.back()
|
2020-01-22 21:18:39 +01:00
|
|
|
})
|
|
|
|
.catch(e => {
|
2020-01-30 22:47:08 +01:00
|
|
|
this.error(e, this)
|
2020-01-22 21:18:39 +01:00
|
|
|
})
|
|
|
|
},
|
2020-02-09 14:46:01 +01:00
|
|
|
toggleTaskDone() {
|
|
|
|
this.task.done = !this.task.done
|
2020-03-02 21:19:26 +01:00
|
|
|
this.saveTask(() => this.toggleTaskDone())
|
2020-02-09 14:46:01 +01:00
|
|
|
},
|
2020-03-01 16:50:05 +01:00
|
|
|
setDescriptionChanged(e) {
|
|
|
|
if (e.key === 'Enter' || e.key === 'Control') {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
this.descriptionChanged = true
|
|
|
|
},
|
|
|
|
saveTaskIfDescriptionChanged() {
|
|
|
|
// We want to only save the description if it was changed.
|
|
|
|
// Since we can either trigger this with ctrl+enter or @change, it would be possible to save a task first
|
|
|
|
// with ctrl+enter and then with @change although nothing changed since the last save when @change gets fired.
|
|
|
|
// To only save one time we added this method.
|
2020-05-09 23:28:54 +02:00
|
|
|
if (this.descriptionChanged) {
|
2020-03-01 16:50:05 +01:00
|
|
|
this.descriptionChanged = false
|
|
|
|
this.saveTask()
|
|
|
|
}
|
|
|
|
},
|
2020-04-18 14:39:56 +02:00
|
|
|
changeList(list) {
|
|
|
|
this.task.listId = list.id
|
|
|
|
this.saveTask()
|
|
|
|
}
|
2019-11-24 14:16:24 +01:00
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|