2019-11-24 14:16:24 +01:00
|
|
|
<template>
|
2020-09-05 22:35:52 +02:00
|
|
|
<div :class="{ 'is-loading': taskService.loading}" class="loader-container task-view-container">
|
2019-11-24 14:16:24 +01:00
|
|
|
<div class="task-view">
|
2020-11-28 15:30:34 +01:00
|
|
|
<heading v-model="task" :can-write="canWrite"/>
|
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-06-17 22:02:10 +02:00
|
|
|
<router-link :to="{ name: listViewName, 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 -->
|
2020-09-05 22:35:52 +02:00
|
|
|
<div :class="{'is-two-thirds': canWrite}" class="column">
|
2019-11-24 14:16:24 +01:00
|
|
|
<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-09-05 22:35:52 +02:00
|
|
|
:disabled="!canWrite"
|
|
|
|
:list-id="task.listId"
|
|
|
|
:task-id="task.id"
|
|
|
|
ref="assignees"
|
2020-10-02 18:40:04 +02:00
|
|
|
v-model="task.assignees"
|
2019-11-24 14:16:24 +01:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div class="column" v-if="activeFields.priority">
|
|
|
|
<!-- Priority -->
|
|
|
|
<div class="detail-title">
|
|
|
|
<icon :icon="['far', 'star']"/>
|
|
|
|
Priority
|
|
|
|
</div>
|
2020-08-11 20:18:59 +02:00
|
|
|
<priority-select
|
2020-09-05 22:35:52 +02:00
|
|
|
:disabled="!canWrite"
|
|
|
|
@change="saveTask"
|
|
|
|
ref="priority"
|
|
|
|
v-model="task.priority"/>
|
2019-11-24 14:16:24 +01:00
|
|
|
</div>
|
|
|
|
<div class="column" v-if="activeFields.dueDate">
|
|
|
|
<!-- Due Date -->
|
|
|
|
<div class="detail-title">
|
|
|
|
<icon icon="calendar"/>
|
|
|
|
Due Date
|
|
|
|
</div>
|
|
|
|
<div class="date-input">
|
2020-11-28 14:59:27 +01:00
|
|
|
<datepicker
|
|
|
|
v-model="task.dueDate"
|
|
|
|
@close-on-change="() => saveTask()"
|
|
|
|
choose-date-label="Click here to set a due date"
|
2020-09-05 22:35:52 +02:00
|
|
|
:disabled="taskService.loading || !canWrite"
|
|
|
|
ref="dueDate"
|
2020-11-28 14:59:27 +01:00
|
|
|
/>
|
|
|
|
<a @click="() => {task.dueDate = null;saveTask()}" v-if="task.dueDate && canWrite" class="remove">
|
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>
|
2020-08-11 20:18:59 +02:00
|
|
|
<percent-done-select
|
2020-09-05 22:35:52 +02:00
|
|
|
:disabled="!canWrite"
|
|
|
|
@change="saveTask"
|
|
|
|
ref="percentDone"
|
|
|
|
v-model="task.percentDone"/>
|
2019-11-24 14:16:24 +01:00
|
|
|
</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">
|
2020-11-28 14:59:27 +01:00
|
|
|
<datepicker
|
|
|
|
v-model="task.startDate"
|
|
|
|
@close-on-change="() => saveTask()"
|
|
|
|
choose-date-label="Click here to set a start date"
|
2020-09-05 22:35:52 +02:00
|
|
|
:disabled="taskService.loading || !canWrite"
|
|
|
|
ref="startDate"
|
2020-11-28 14:59:27 +01:00
|
|
|
/>
|
|
|
|
<a @click="() => {task.startDate = null;saveTask()}" v-if="task.startDate && canWrite" class="remove">
|
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.endDate">
|
|
|
|
<!-- End Date -->
|
|
|
|
<div class="detail-title">
|
|
|
|
<icon icon="calendar-week"/>
|
|
|
|
End Date
|
|
|
|
</div>
|
|
|
|
<div class="date-input">
|
2020-11-28 14:59:27 +01:00
|
|
|
<datepicker
|
|
|
|
v-model="task.endDate"
|
|
|
|
@close-on-change="() => saveTask()"
|
|
|
|
choose-date-label="Click here to set an end date"
|
2020-09-05 22:35:52 +02:00
|
|
|
:disabled="taskService.loading || !canWrite"
|
|
|
|
ref="endDate"
|
2020-11-28 14:59:27 +01:00
|
|
|
/>
|
|
|
|
<a @click="() => {task.endDate = null;saveTask()}" v-if="task.endDate && canWrite" class="remove">
|
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.reminders">
|
|
|
|
<!-- Reminders -->
|
|
|
|
<div class="detail-title">
|
|
|
|
<icon icon="history"/>
|
|
|
|
Reminders
|
|
|
|
</div>
|
2020-08-11 20:18:59 +02:00
|
|
|
<reminders
|
2020-09-05 22:35:52 +02:00
|
|
|
:disabled="!canWrite"
|
|
|
|
@change="saveTask"
|
|
|
|
ref="reminders"
|
|
|
|
v-model="task.reminderDates"/>
|
2019-11-24 14:16:24 +01:00
|
|
|
</div>
|
|
|
|
<div class="column" v-if="activeFields.repeatAfter">
|
|
|
|
<!-- Repeat after -->
|
|
|
|
<div class="detail-title">
|
|
|
|
<icon :icon="['far', 'clock']"/>
|
|
|
|
Repeat
|
|
|
|
</div>
|
2020-06-14 14:43:01 +02:00
|
|
|
<repeat-after
|
2020-09-05 22:35:52 +02:00
|
|
|
:disabled="!canWrite"
|
|
|
|
@change="saveTask"
|
|
|
|
ref="repeatAfter"
|
|
|
|
v-model="task"/>
|
2019-11-24 14:16:24 +01:00
|
|
|
</div>
|
2020-06-21 20:27:39 +02:00
|
|
|
<div class="column" v-if="activeFields.color">
|
|
|
|
<!-- Color -->
|
|
|
|
<div class="detail-title">
|
|
|
|
<icon icon="fill-drip"/>
|
|
|
|
Color
|
|
|
|
</div>
|
|
|
|
<color-picker
|
2020-09-05 22:35:52 +02:00
|
|
|
@change="saveTask"
|
|
|
|
menu-position="bottom"
|
|
|
|
ref="color"
|
|
|
|
v-model="taskColor"/>
|
2020-06-21 20:27:39 +02:00
|
|
|
</div>
|
2019-11-24 14:16:24 +01:00
|
|
|
</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-09-05 22:35:52 +02:00
|
|
|
<edit-labels :disabled="!canWrite" :task-id="taskId" ref="labels" v-model="task.labels"/>
|
2019-11-24 14:16:24 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- Description -->
|
2020-09-05 22:35:52 +02:00
|
|
|
<div :class="{ 'has-top-border': activeFields.labels }" class="details content description">
|
2020-11-22 17:32:35 +01:00
|
|
|
<description
|
|
|
|
v-model="task"
|
|
|
|
:can-write="canWrite"
|
|
|
|
:attachment-upload="attachmentUpload"
|
|
|
|
/>
|
2019-11-24 14:16:24 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- Attachments -->
|
|
|
|
<div class="content attachments has-top-border" v-if="activeFields.attachments">
|
|
|
|
<attachments
|
2020-09-05 22:35:52 +02:00
|
|
|
:edit-enabled="canWrite"
|
|
|
|
:task-id="taskId"
|
|
|
|
ref="attachments"
|
2019-11-24 14:16:24 +01:00
|
|
|
/>
|
|
|
|
</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-09-05 22:35:52 +02:00
|
|
|
:edit-enabled="canWrite"
|
|
|
|
:initial-related-tasks="task.relatedTasks"
|
|
|
|
:list-id="task.listId"
|
|
|
|
:show-no-relations-notice="true"
|
|
|
|
:task-id="taskId"
|
|
|
|
ref="relatedTasks"
|
2019-11-24 14:16:24 +01:00
|
|
|
/>
|
|
|
|
</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">
|
2020-06-27 23:12:33 +02:00
|
|
|
<list-search @selected="changeList" ref="moveList"/>
|
2020-04-18 14:39:56 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2020-02-25 21:11:36 +01:00
|
|
|
<!-- Comments -->
|
2020-09-05 22:35:52 +02:00
|
|
|
<comments :can-write="canWrite" :task-id="taskId"/>
|
2019-11-24 14:16:24 +01:00
|
|
|
</div>
|
2020-08-11 20:18:59 +02:00
|
|
|
<div class="column is-one-third action-buttons" v-if="canWrite">
|
2020-05-09 23:28:54 +02:00
|
|
|
<a
|
2020-09-05 22:35:52 +02:00
|
|
|
:class="{'is-success': !task.done}"
|
|
|
|
@click="toggleTaskDone()"
|
|
|
|
class="button is-outlined noshadow has-no-border">
|
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>
|
2020-08-11 20:18:59 +02:00
|
|
|
<a
|
2020-09-05 22:35:52 +02:00
|
|
|
@click="setFieldActive('assignees')"
|
|
|
|
@shortkey="setFieldActive('assignees')"
|
|
|
|
class="button"
|
2020-11-11 21:31:11 +01:00
|
|
|
v-shortkey="['a']">
|
2019-11-24 14:16:24 +01:00
|
|
|
<span class="icon is-small"><icon icon="users"/></span>
|
|
|
|
Assign this task to a user
|
|
|
|
</a>
|
2020-08-11 20:18:59 +02:00
|
|
|
<a
|
2020-09-05 22:35:52 +02:00
|
|
|
@click="setFieldActive('labels')"
|
|
|
|
@shortkey="setFieldActive('labels')"
|
|
|
|
class="button"
|
2020-11-11 21:31:11 +01:00
|
|
|
v-shortkey="['l']">
|
2019-11-24 14:16:24 +01:00
|
|
|
<span class="icon is-small"><icon icon="tags"/></span>
|
|
|
|
Add labels
|
|
|
|
</a>
|
2020-09-05 22:35:52 +02:00
|
|
|
<a @click="setFieldActive('reminders')" class="button">
|
2020-02-09 12:50:57 +01:00
|
|
|
<span class="icon is-small"><icon icon="history"/></span>
|
|
|
|
Set Reminders
|
|
|
|
</a>
|
2020-08-11 20:18:59 +02:00
|
|
|
<a
|
2020-09-05 22:35:52 +02:00
|
|
|
@click="setFieldActive('dueDate')"
|
|
|
|
@shortkey="setFieldActive('dueDate')"
|
|
|
|
class="button"
|
2020-11-11 21:31:11 +01:00
|
|
|
v-shortkey="['d']">
|
2019-11-24 14:16:24 +01:00
|
|
|
<span class="icon is-small"><icon icon="calendar"/></span>
|
|
|
|
Set Due Date
|
|
|
|
</a>
|
2020-09-05 22:35:52 +02:00
|
|
|
<a @click="setFieldActive('startDate')" class="button">
|
2019-11-24 14:16:24 +01:00
|
|
|
<span class="icon is-small"><icon icon="calendar-week"/></span>
|
|
|
|
Set a Start Date
|
|
|
|
</a>
|
2020-09-05 22:35:52 +02:00
|
|
|
<a @click="setFieldActive('endDate')" class="button">
|
2019-11-24 14:16:24 +01:00
|
|
|
<span class="icon is-small"><icon icon="calendar-week"/></span>
|
|
|
|
Set an End Date
|
|
|
|
</a>
|
2020-09-05 22:35:52 +02:00
|
|
|
<a @click="setFieldActive('repeatAfter')" class="button">
|
2019-11-24 14:16:24 +01:00
|
|
|
<span class="icon is-small"><icon :icon="['far', 'clock']"/></span>
|
|
|
|
Set a repeating interval
|
|
|
|
</a>
|
2020-09-05 22:35:52 +02:00
|
|
|
<a @click="setFieldActive('priority')" class="button">
|
2020-02-09 14:54:09 +01:00
|
|
|
<span class="icon is-small"><icon :icon="['far', 'star']"/></span>
|
|
|
|
Set Priority
|
|
|
|
</a>
|
2020-09-05 22:35:52 +02:00
|
|
|
<a @click="setFieldActive('percentDone')" class="button">
|
2020-02-09 14:54:09 +01:00
|
|
|
<span class="icon is-small"><icon icon="percent"/></span>
|
|
|
|
Set Percent Done
|
|
|
|
</a>
|
2020-08-11 20:18:59 +02:00
|
|
|
<a
|
2020-09-05 22:35:52 +02:00
|
|
|
@click="setFieldActive('attachments')"
|
|
|
|
@shortkey="setFieldActive('attachments')"
|
|
|
|
class="button"
|
2020-11-11 21:31:11 +01:00
|
|
|
v-shortkey="['f']">
|
2020-02-09 14:54:09 +01:00
|
|
|
<span class="icon is-small"><icon icon="paperclip"/></span>
|
|
|
|
Add attachments
|
|
|
|
</a>
|
2020-08-11 20:18:59 +02:00
|
|
|
<a
|
2020-09-05 22:35:52 +02:00
|
|
|
@click="setFieldActive('relatedTasks')"
|
|
|
|
@shortkey="setFieldActive('relatedTasks')"
|
|
|
|
class="button"
|
2020-11-11 21:31:11 +01:00
|
|
|
v-shortkey="['r']">
|
2020-02-09 14:54:09 +01:00
|
|
|
<span class="icon is-small"><icon icon="tasks"/></span>
|
|
|
|
Add task relations
|
|
|
|
</a>
|
2020-09-05 22:35:52 +02:00
|
|
|
<a @click="setFieldActive('moveList')" class="button">
|
2020-04-18 14:39:56 +02:00
|
|
|
<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-09-05 22:35:52 +02:00
|
|
|
<a @click="setFieldActive('color')" class="button">
|
2020-06-21 20:27:39 +02:00
|
|
|
<span class="icon is-small"><icon icon="fill-drip"/></span>
|
|
|
|
Set task color
|
|
|
|
</a>
|
2020-09-05 22:35:52 +02:00
|
|
|
<a @click="showDeleteModal = true" class="button is-danger is-outlined noshadow has-no-border">
|
2020-01-22 21:18:39 +01:00
|
|
|
<span class="icon is-small"><icon icon="trash-alt"/></span>
|
|
|
|
Delete task
|
|
|
|
</a>
|
2020-10-25 12:25:08 +01:00
|
|
|
|
|
|
|
<!-- Created / Updated [by] -->
|
|
|
|
<p class="created">
|
2020-11-22 17:32:35 +01:00
|
|
|
Created <span v-tooltip="formatDate(task.created)">{{ formatDateSince(task.created) }}</span>
|
|
|
|
by {{ task.createdBy.getDisplayName() }}
|
2020-10-25 12:25:08 +01:00
|
|
|
<template v-if="+new Date(task.created) !== +new Date(task.updated)">
|
|
|
|
<br/>
|
|
|
|
<!-- Computed properties to show the actual date every time it gets updated -->
|
|
|
|
Updated <span v-tooltip="updatedFormatted">{{ updatedSince }}</span>
|
|
|
|
</template>
|
|
|
|
</p>
|
2019-11-24 14:16:24 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-01-22 21:18:39 +01:00
|
|
|
|
|
|
|
<modal
|
2020-09-05 22:35:52 +02:00
|
|
|
@close="showDeleteModal = false"
|
|
|
|
@submit="deleteTask()"
|
|
|
|
v-if="showDeleteModal">
|
2020-01-22 21:18:39 +01:00
|
|
|
<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>
|
2020-09-05 22:35:52 +02:00
|
|
|
import TaskService from '../../services/task'
|
|
|
|
import TaskModel from '../../models/task'
|
|
|
|
import relationKinds from '../../models/relationKinds.json'
|
2019-11-24 14:16:24 +01:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
import priorites from '../../models/priorities.json'
|
|
|
|
import rights from '../../models/rights.json'
|
2019-11-24 14:16:24 +01:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
import PrioritySelect from '../../components/tasks/partials/prioritySelect'
|
|
|
|
import PercentDoneSelect from '../../components/tasks/partials/percentDoneSelect'
|
|
|
|
import EditLabels from '../../components/tasks/partials/editLabels'
|
|
|
|
import EditAssignees from '../../components/tasks/partials/editAssignees'
|
|
|
|
import Attachments from '../../components/tasks/partials/attachments'
|
|
|
|
import RelatedTasks from '../../components/tasks/partials/relatedTasks'
|
|
|
|
import RepeatAfter from '../../components/tasks/partials/repeatAfter'
|
|
|
|
import Reminders from '../../components/tasks/partials/reminders'
|
|
|
|
import Comments from '../../components/tasks/partials/comments'
|
|
|
|
import router from '../../router'
|
|
|
|
import ListSearch from '../../components/tasks/partials/listSearch'
|
2020-11-22 17:32:35 +01:00
|
|
|
import description from '@/components/tasks/partials/description'
|
2020-09-05 22:35:52 +02:00
|
|
|
import ColorPicker from '../../components/input/colorPicker'
|
|
|
|
import attachmentUpload from '../../components/tasks/mixins/attachmentUpload'
|
2020-11-22 17:32:35 +01:00
|
|
|
import heading from '@/components/tasks/partials/heading'
|
2020-11-28 14:59:27 +01:00
|
|
|
import Datepicker from '@/components/input/datepicker'
|
2019-11-24 14:16:24 +01:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
export default {
|
|
|
|
name: 'TaskDetailView',
|
|
|
|
components: {
|
2020-11-28 14:59:27 +01:00
|
|
|
Datepicker,
|
2020-09-05 22:35:52 +02:00
|
|
|
ColorPicker,
|
|
|
|
ListSearch,
|
|
|
|
Reminders,
|
|
|
|
RepeatAfter,
|
|
|
|
RelatedTasks,
|
|
|
|
Attachments,
|
|
|
|
EditAssignees,
|
|
|
|
EditLabels,
|
|
|
|
PercentDoneSelect,
|
|
|
|
PrioritySelect,
|
|
|
|
Comments,
|
2020-11-22 17:32:35 +01:00
|
|
|
description,
|
|
|
|
heading,
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
|
|
|
mixins: [
|
|
|
|
attachmentUpload,
|
|
|
|
],
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
taskId: Number(this.$route.params.id),
|
|
|
|
taskService: TaskService,
|
|
|
|
task: TaskModel,
|
|
|
|
relationKinds: relationKinds,
|
|
|
|
// We doubled the task color property here because verte does not have a real change property, leading
|
|
|
|
// to the color property change being triggered when the # is removed from it, leading to an update,
|
|
|
|
// which leads in turn to a change... This creates an infinite loop in which the task is updated, changed,
|
|
|
|
// updated, changed, updated and so on.
|
|
|
|
// To prevent this, we put the task color property in a seperate value which is set to the task color
|
|
|
|
// when it is saved and loaded.
|
|
|
|
taskColor: '',
|
2019-11-24 14:16:24 +01:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
showDeleteModal: false,
|
|
|
|
descriptionChanged: false,
|
|
|
|
listViewName: 'list.list',
|
2019-11-24 14:16:24 +01:00
|
|
|
|
2020-11-22 17:32:35 +01:00
|
|
|
descriptionSaving: false,
|
|
|
|
descriptionRecentlySaved: false,
|
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
priorities: priorites,
|
|
|
|
activeFields: {
|
|
|
|
assignees: false,
|
|
|
|
priority: false,
|
|
|
|
dueDate: false,
|
|
|
|
percentDone: false,
|
|
|
|
startDate: false,
|
|
|
|
endDate: false,
|
|
|
|
reminders: false,
|
|
|
|
repeatAfter: false,
|
|
|
|
labels: false,
|
|
|
|
attachments: false,
|
|
|
|
relatedTasks: false,
|
|
|
|
moveList: false,
|
|
|
|
color: false,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
'$route': 'loadTask',
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.taskService = new TaskService()
|
|
|
|
this.task = new TaskModel()
|
|
|
|
},
|
|
|
|
mounted() {
|
2020-06-17 22:02:10 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
// Build the list path from the task detail name to send the user to the view they came from.
|
|
|
|
const parts = this.$route.name.split('.')
|
|
|
|
if (parts.length > 2 && parts[2] === 'detail') {
|
|
|
|
this.listViewName = `list.${parts[1]}`
|
|
|
|
}
|
2020-06-17 22:02:10 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
this.loadTask()
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
parent() {
|
|
|
|
if (!this.task.listId) {
|
|
|
|
return {
|
|
|
|
namespace: null,
|
|
|
|
list: null,
|
2020-05-09 23:28:54 +02:00
|
|
|
}
|
2020-09-05 22:35:52 +02:00
|
|
|
}
|
2020-05-09 23:28:54 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
if (!this.$store.getters['namespaces/getListAndNamespaceById']) {
|
|
|
|
return null
|
|
|
|
}
|
2020-05-09 23:28:54 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
return this.$store.getters['namespaces/getListAndNamespaceById'](this.task.listId)
|
2020-05-09 23:28:54 +02:00
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
canWrite() {
|
|
|
|
return this.task && this.task.maxRight && this.task.maxRight > rights.READ
|
|
|
|
},
|
2020-10-25 12:25:08 +01:00
|
|
|
updatedSince() {
|
|
|
|
return this.formatDateSince(this.task.updated)
|
|
|
|
},
|
|
|
|
updatedFormatted() {
|
|
|
|
return this.formatDate(this.task.updated)
|
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
loadTask() {
|
|
|
|
this.taskId = Number(this.$route.params.id)
|
|
|
|
this.taskService.get({id: this.taskId})
|
|
|
|
.then(r => {
|
|
|
|
this.$set(this, 'task', r)
|
|
|
|
this.$store.commit('attachments/set', r.attachments)
|
|
|
|
this.taskColor = this.task.hexColor
|
|
|
|
this.setActiveFields()
|
|
|
|
this.setTitle(this.task.title)
|
|
|
|
})
|
|
|
|
.catch(e => {
|
|
|
|
this.error(e, this)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
setActiveFields() {
|
2020-02-08 18:37:23 +01:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
this.task.startDate = this.task.startDate ? this.task.startDate : null
|
|
|
|
this.task.endDate = this.task.endDate ? this.task.endDate : null
|
2020-02-08 18:37:23 +01:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
// 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-10-24 18:12:14 +02:00
|
|
|
this.activeFields.reminders = this.task.reminderDates.length > 0
|
2020-09-05 22:35:52 +02: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
|
|
|
|
this.activeFields.relatedTasks = Object.keys(this.task.relatedTasks).length > 0
|
|
|
|
},
|
2020-11-22 17:32:35 +01:00
|
|
|
saveTask(showNotification = true, undoCallback = null) {
|
2020-02-09 14:52:45 +01:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
if (!this.canWrite) {
|
|
|
|
return
|
|
|
|
}
|
2020-08-11 20:18:59 +02:00
|
|
|
|
2020-10-03 14:30:26 +02:00
|
|
|
// We're doing the whole update in a nextTick because sometimes race conditions can occur when
|
|
|
|
// setting the due date on mobile which leads to no due date change being saved.
|
|
|
|
this.$nextTick(() => {
|
|
|
|
this.task.hexColor = this.taskColor
|
2020-05-09 19:00:54 +02:00
|
|
|
|
2020-10-03 14:30:26 +02: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-02-09 14:52:45 +01:00
|
|
|
|
2020-10-03 14:30:26 +02:00
|
|
|
this.$store.dispatch('tasks/update', this.task)
|
|
|
|
.then(r => {
|
|
|
|
this.$set(this, 'task', r)
|
2020-11-22 17:32:35 +01:00
|
|
|
this.setActiveFields()
|
|
|
|
|
|
|
|
if (!showNotification) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-10-03 14:30:26 +02:00
|
|
|
let actions = []
|
|
|
|
if (undoCallback !== null) {
|
|
|
|
actions = [{
|
|
|
|
title: 'Undo',
|
|
|
|
callback: undoCallback,
|
|
|
|
}]
|
|
|
|
}
|
2020-11-22 17:32:35 +01:00
|
|
|
this.success({message: 'The task was saved successfully.'}, this, actions)
|
2020-10-03 14:30:26 +02:00
|
|
|
})
|
|
|
|
.catch(e => {
|
|
|
|
this.error(e, this)
|
|
|
|
})
|
|
|
|
})
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
|
|
|
setFieldActive(fieldName) {
|
|
|
|
this.activeFields[fieldName] = true
|
|
|
|
this.$nextTick(() => {
|
|
|
|
if (this.$refs[fieldName]) {
|
|
|
|
this.$refs[fieldName].$el.focus()
|
2020-03-01 16:50:05 +01:00
|
|
|
}
|
2020-09-05 22:35:52 +02:00
|
|
|
})
|
|
|
|
},
|
|
|
|
deleteTask() {
|
|
|
|
this.$store.dispatch('tasks/delete', this.task)
|
|
|
|
.then(() => {
|
2020-11-22 17:32:35 +01:00
|
|
|
this.success({message: 'The task has been deleted successfully.'}, this)
|
2020-09-05 22:35:52 +02:00
|
|
|
router.back()
|
|
|
|
})
|
|
|
|
.catch(e => {
|
|
|
|
this.error(e, this)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
toggleTaskDone() {
|
|
|
|
this.task.done = !this.task.done
|
2020-11-22 17:32:35 +01:00
|
|
|
this.saveTask(true, () => this.toggleTaskDone())
|
2020-09-05 22:35:52 +02: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.
|
|
|
|
if (this.descriptionChanged) {
|
|
|
|
this.descriptionChanged = false
|
2020-04-18 14:39:56 +02:00
|
|
|
this.saveTask()
|
2020-09-05 22:35:52 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
changeList(list) {
|
|
|
|
this.task.listId = list.id
|
|
|
|
this.saveTask()
|
2019-11-24 14:16:24 +01:00
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
|
|
|
}
|
2019-11-24 14:16:24 +01:00
|
|
|
</script>
|