2019-04-29 23:41:39 +02:00
|
|
|
<template>
|
2021-01-24 14:00:21 +01:00
|
|
|
<div class="gantt-chart">
|
2020-11-15 16:32:46 +01:00
|
|
|
<div class="filter-container">
|
|
|
|
<div class="items">
|
2021-01-17 18:57:57 +01:00
|
|
|
<x-button
|
|
|
|
@click.prevent.stop="showTaskFilter = !showTaskFilter"
|
|
|
|
type="secondary"
|
|
|
|
icon="filter"
|
|
|
|
>
|
2020-11-15 16:32:46 +01:00
|
|
|
Filters
|
2021-01-17 18:57:57 +01:00
|
|
|
</x-button>
|
2020-11-15 16:32:46 +01:00
|
|
|
</div>
|
2021-01-17 11:36:57 +01:00
|
|
|
<filter-popup
|
|
|
|
@change="loadTasks"
|
|
|
|
:visible="showTaskFilter"
|
|
|
|
v-model="params"
|
|
|
|
/>
|
2020-11-15 16:32:46 +01:00
|
|
|
</div>
|
2019-04-29 23:41:39 +02:00
|
|
|
<div class="dates">
|
|
|
|
<template v-for="(y, yk) in days">
|
2020-09-05 22:35:52 +02:00
|
|
|
<div :key="yk + 'year'" class="months">
|
2021-01-17 18:57:57 +01:00
|
|
|
<div
|
|
|
|
:key="mk + 'month'"
|
|
|
|
class="month"
|
|
|
|
v-for="(m, mk) in days[yk]"
|
|
|
|
>
|
|
|
|
{{
|
|
|
|
new Date(
|
|
|
|
new Date(yk).setMonth(mk)
|
|
|
|
).toLocaleString('en-us', {month: 'long'})
|
|
|
|
}},
|
|
|
|
{{ new Date(yk).getFullYear() }}
|
2019-04-29 23:41:39 +02:00
|
|
|
<div class="days">
|
|
|
|
<div
|
2021-01-17 18:57:57 +01:00
|
|
|
:class="{
|
|
|
|
today:
|
|
|
|
d.toDateString() === now.toDateString(),
|
|
|
|
}"
|
2020-09-05 22:35:52 +02:00
|
|
|
:key="dk + 'day'"
|
2021-01-17 18:57:57 +01:00
|
|
|
:style="{ width: dayWidth + 'px' }"
|
2020-09-05 22:35:52 +02:00
|
|
|
class="day"
|
2021-01-17 18:57:57 +01:00
|
|
|
v-for="(d, dk) in days[yk][mk]"
|
|
|
|
>
|
2019-04-29 23:41:39 +02:00
|
|
|
<span class="theday" v-if="dayWidth > 25">
|
2020-09-05 22:35:52 +02:00
|
|
|
{{ d.getDate() }}
|
2019-04-29 23:41:39 +02:00
|
|
|
</span>
|
|
|
|
<span class="weekday" v-if="dayWidth > 25">
|
2021-01-17 18:57:57 +01:00
|
|
|
{{
|
|
|
|
d.toLocaleString('en-us', {
|
|
|
|
weekday: 'short',
|
|
|
|
})
|
|
|
|
}}
|
2019-04-29 23:41:39 +02:00
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</div>
|
2021-01-17 18:57:57 +01:00
|
|
|
<div :style="{ width: fullWidth + 'px' }" class="tasks">
|
2020-09-05 22:35:52 +02:00
|
|
|
<div
|
2021-04-25 18:01:17 +02:00
|
|
|
v-for="(t, k) in theTasks"
|
|
|
|
:key="t ? t.id : 0"
|
2021-01-17 18:57:57 +01:00
|
|
|
:style="{
|
|
|
|
background:
|
|
|
|
'repeating-linear-gradient(90deg, #ededed, #ededed 1px, ' +
|
|
|
|
(k % 2 === 0
|
|
|
|
? '#fafafa 1px, #fafafa '
|
|
|
|
: '#fff 1px, #fff ') +
|
|
|
|
dayWidth +
|
|
|
|
'px)',
|
|
|
|
}"
|
2020-09-05 22:35:52 +02:00
|
|
|
class="row"
|
2021-01-17 18:57:57 +01:00
|
|
|
>
|
2019-04-29 23:41:39 +02:00
|
|
|
<VueDragResize
|
2020-09-05 22:35:52 +02:00
|
|
|
:class="{
|
2021-04-25 18:01:17 +02:00
|
|
|
done: t ? t.done : false,
|
|
|
|
'is-current-edit': taskToEdit !== null && taskToEdit.id === t.id,
|
2021-04-18 19:16:53 +02:00
|
|
|
'has-light-text': !colorIsDark(t.getHexColor()),
|
|
|
|
'has-dark-text': colorIsDark(t.getHexColor()),
|
2021-01-17 18:57:57 +01:00
|
|
|
}"
|
2020-09-05 22:35:52 +02:00
|
|
|
:gridX="dayWidth"
|
|
|
|
:h="31"
|
|
|
|
:isActive="canWrite"
|
|
|
|
:minw="dayWidth"
|
|
|
|
:parentLimitation="true"
|
|
|
|
:parentW="fullWidth"
|
|
|
|
:snapToGrid="true"
|
|
|
|
:sticks="['mr', 'ml']"
|
2021-01-17 18:57:57 +01:00
|
|
|
:style="{
|
2021-04-18 19:16:53 +02:00
|
|
|
'border-color': t.getHexColor(),
|
|
|
|
'background-color': t.getHexColor(),
|
2021-01-17 18:57:57 +01:00
|
|
|
}"
|
2020-09-05 22:35:52 +02:00
|
|
|
:w="t.durationDays * dayWidth"
|
|
|
|
:x="t.offsetDays * dayWidth - 6"
|
|
|
|
:y="0"
|
|
|
|
@clicked="setTaskDragged(t)"
|
|
|
|
@dragstop="resizeTask"
|
|
|
|
@resizestop="resizeTask"
|
|
|
|
axis="x"
|
|
|
|
class="task"
|
2019-04-29 23:41:39 +02:00
|
|
|
>
|
2021-01-17 18:57:57 +01:00
|
|
|
<span
|
|
|
|
:class="{
|
|
|
|
'has-high-priority': t.priority >= priorities.HIGH,
|
|
|
|
'has-not-so-high-priority':
|
|
|
|
t.priority === priorities.HIGH,
|
|
|
|
'has-super-high-priority':
|
|
|
|
t.priority === priorities.DO_NOW,
|
|
|
|
}"
|
|
|
|
>{{ t.title }}</span
|
|
|
|
>
|
2019-11-24 14:16:24 +01:00
|
|
|
<priority-label :priority="t.priority"/>
|
2019-04-29 23:41:39 +02:00
|
|
|
<!-- using the key here forces vue to use the updated version model and not the response returned by the api -->
|
2019-11-03 13:44:40 +01:00
|
|
|
<a @click="editTask(theTasks[k])" class="edit-toggle">
|
|
|
|
<icon icon="pen"/>
|
|
|
|
</a>
|
|
|
|
</VueDragResize>
|
2019-04-29 23:41:39 +02:00
|
|
|
</div>
|
|
|
|
<template v-if="showTaskswithoutDates">
|
2020-09-05 22:35:52 +02:00
|
|
|
<div
|
|
|
|
:key="t.id"
|
2021-01-17 18:57:57 +01:00
|
|
|
:style="{
|
|
|
|
background:
|
|
|
|
'repeating-linear-gradient(90deg, #ededed, #ededed 1px, ' +
|
|
|
|
(k % 2 === 0
|
|
|
|
? '#fafafa 1px, #fafafa '
|
|
|
|
: '#fff 1px, #fff ') +
|
|
|
|
dayWidth +
|
|
|
|
'px)',
|
|
|
|
}"
|
2020-09-05 22:35:52 +02:00
|
|
|
class="row"
|
2021-01-17 18:57:57 +01:00
|
|
|
v-for="(t, k) in tasksWithoutDates"
|
|
|
|
>
|
2019-04-29 23:41:39 +02:00
|
|
|
<VueDragResize
|
2020-09-05 22:35:52 +02:00
|
|
|
:gridX="dayWidth"
|
|
|
|
:h="31"
|
|
|
|
:isActive="canWrite"
|
|
|
|
:minw="dayWidth"
|
|
|
|
:parentLimitation="true"
|
|
|
|
:parentW="fullWidth"
|
|
|
|
:snapToGrid="true"
|
|
|
|
:sticks="['mr', 'ml']"
|
|
|
|
:x="dayOffsetUntilToday * dayWidth - 6"
|
|
|
|
:y="0"
|
|
|
|
@clicked="setTaskDragged(t)"
|
|
|
|
@dragstop="resizeTask"
|
|
|
|
@resizestop="resizeTask"
|
|
|
|
axis="x"
|
|
|
|
class="task nodate"
|
|
|
|
v-tooltip="'This task has no dates set.'"
|
2019-04-29 23:41:39 +02:00
|
|
|
>
|
2020-09-05 22:35:52 +02:00
|
|
|
<span>{{ t.title }}</span>
|
2019-04-29 23:41:39 +02:00
|
|
|
</VueDragResize>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</div>
|
2021-01-17 18:57:57 +01:00
|
|
|
<form
|
|
|
|
@submit.prevent="addNewTask()"
|
|
|
|
class="add-new-task"
|
|
|
|
v-if="canWrite"
|
|
|
|
>
|
2019-04-29 23:41:39 +02:00
|
|
|
<transition name="width">
|
|
|
|
<input
|
2020-09-05 22:35:52 +02:00
|
|
|
@blur="hideCrateNewTask"
|
|
|
|
@keyup.esc="newTaskFieldActive = false"
|
2019-04-29 23:41:39 +02:00
|
|
|
class="input"
|
|
|
|
ref="newTaskTitleField"
|
2020-09-05 22:35:52 +02:00
|
|
|
type="text"
|
|
|
|
v-if="newTaskFieldActive"
|
|
|
|
v-model="newTaskTitle"
|
2019-04-29 23:41:39 +02:00
|
|
|
/>
|
|
|
|
</transition>
|
2021-01-17 18:57:57 +01:00
|
|
|
<x-button @click="showCreateNewTask" :shadow="false" icon="plus">
|
2019-04-29 23:41:39 +02:00
|
|
|
Add a new task
|
2021-01-17 18:57:57 +01:00
|
|
|
</x-button>
|
2019-04-29 23:41:39 +02:00
|
|
|
</form>
|
|
|
|
<transition name="fade">
|
2021-01-17 18:57:57 +01:00
|
|
|
<card
|
|
|
|
v-if="isTaskEdit"
|
|
|
|
class="taskedit"
|
|
|
|
title="Edit Task"
|
|
|
|
@close="() => {isTaskEdit = false;taskToEdit = null}"
|
|
|
|
:has-close="true"
|
|
|
|
>
|
|
|
|
<edit-task :task="taskToEdit"/>
|
|
|
|
</card>
|
2019-04-29 23:41:39 +02:00
|
|
|
</transition>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-09-05 22:35:52 +02:00
|
|
|
import VueDragResize from 'vue-drag-resize'
|
|
|
|
import EditTask from './edit-task'
|
2019-04-29 23:41:39 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
import TaskService from '../../services/task'
|
|
|
|
import TaskModel from '../../models/task'
|
|
|
|
import priorities from '../../models/priorities'
|
|
|
|
import PriorityLabel from './partials/priorityLabel'
|
|
|
|
import TaskCollectionService from '../../services/taskCollection'
|
|
|
|
import {mapState} from 'vuex'
|
|
|
|
import Rights from '../../models/rights.json'
|
2021-01-17 11:36:57 +01:00
|
|
|
import FilterPopup from '@/components/list/partials/filter-popup'
|
2019-04-29 23:41:39 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
export default {
|
|
|
|
name: 'GanttChart',
|
|
|
|
components: {
|
2021-01-17 11:36:57 +01:00
|
|
|
FilterPopup,
|
2020-09-05 22:35:52 +02:00
|
|
|
PriorityLabel,
|
|
|
|
EditTask,
|
|
|
|
VueDragResize,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
listId: {
|
|
|
|
type: Number,
|
|
|
|
required: true,
|
2019-04-29 23:41:39 +02:00
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
showTaskswithoutDates: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
2019-04-29 23:41:39 +02:00
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
dateFrom: {
|
2021-01-17 18:57:57 +01:00
|
|
|
default: new Date(new Date().setDate(new Date().getDate() - 15)),
|
2019-04-29 23:41:39 +02:00
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
dateTo: {
|
2021-01-17 18:57:57 +01:00
|
|
|
default: new Date(new Date().setDate(new Date().getDate() + 30)),
|
2019-04-29 23:41:39 +02:00
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
// The width of a day in pixels, used to calculate all sorts of things.
|
|
|
|
dayWidth: {
|
|
|
|
type: Number,
|
|
|
|
default: 35,
|
2020-04-04 18:26:35 +02:00
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
days: [],
|
|
|
|
startDate: null,
|
|
|
|
endDate: null,
|
|
|
|
theTasks: [], // Pretty much a copy of the prop, since we cant mutate the prop directly
|
|
|
|
tasksWithoutDates: [],
|
|
|
|
taskService: TaskService,
|
|
|
|
taskDragged: null, // Saves to currently dragged task to be able to update it
|
|
|
|
fullWidth: 0,
|
|
|
|
now: null,
|
|
|
|
dayOffsetUntilToday: 0,
|
|
|
|
isTaskEdit: false,
|
|
|
|
taskToEdit: null,
|
|
|
|
newTaskTitle: '',
|
|
|
|
newTaskFieldActive: false,
|
|
|
|
priorities: {},
|
|
|
|
taskCollectionService: TaskCollectionService,
|
2020-11-15 16:32:46 +01:00
|
|
|
showTaskFilter: false,
|
|
|
|
|
|
|
|
params: {
|
|
|
|
sort_by: ['done', 'id'],
|
|
|
|
order_by: ['asc', 'desc'],
|
|
|
|
filter_by: ['done'],
|
|
|
|
filter_value: ['false'],
|
|
|
|
filter_comparator: ['equals'],
|
|
|
|
filter_concat: 'and',
|
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
2021-01-17 18:57:57 +01:00
|
|
|
dateFrom: 'buildTheGanttChart',
|
|
|
|
dateTo: 'buildTheGanttChart',
|
|
|
|
listId: 'parseTasks',
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.now = new Date()
|
|
|
|
this.taskCollectionService = new TaskCollectionService()
|
|
|
|
this.taskService = new TaskService()
|
|
|
|
this.priorities = priorities
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.buildTheGanttChart()
|
|
|
|
},
|
|
|
|
computed: mapState({
|
2021-01-17 18:57:57 +01:00
|
|
|
canWrite: (state) => state.currentList.maxRight > Rights.READ,
|
2020-09-05 22:35:52 +02:00
|
|
|
}),
|
|
|
|
methods: {
|
|
|
|
buildTheGanttChart() {
|
|
|
|
this.setDates()
|
|
|
|
this.prepareGanttDays()
|
|
|
|
this.parseTasks()
|
2019-04-29 23:41:39 +02:00
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
setDates() {
|
|
|
|
this.startDate = new Date(this.dateFrom)
|
|
|
|
this.endDate = new Date(this.dateTo)
|
2019-04-29 23:41:39 +02:00
|
|
|
|
2021-01-17 18:57:57 +01:00
|
|
|
this.dayOffsetUntilToday =
|
|
|
|
Math.floor((this.now - this.startDate) / 1000 / 60 / 60 / 24) +
|
|
|
|
1
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
|
|
|
prepareGanttDays() {
|
|
|
|
// Layout: years => [months => [days]]
|
|
|
|
let years = {}
|
2021-01-17 18:57:57 +01:00
|
|
|
for (
|
|
|
|
let d = this.startDate;
|
|
|
|
d <= this.endDate;
|
|
|
|
d.setDate(d.getDate() + 1)
|
|
|
|
) {
|
2020-09-05 22:35:52 +02:00
|
|
|
let date = new Date(d)
|
|
|
|
if (years[date.getFullYear() + ''] === undefined) {
|
|
|
|
years[date.getFullYear() + ''] = {}
|
2019-04-29 23:41:39 +02:00
|
|
|
}
|
2021-01-17 18:57:57 +01:00
|
|
|
if (
|
|
|
|
years[date.getFullYear() + ''][date.getMonth() + ''] ===
|
|
|
|
undefined
|
|
|
|
) {
|
2020-09-05 22:35:52 +02:00
|
|
|
years[date.getFullYear() + ''][date.getMonth() + ''] = []
|
2020-04-04 18:26:35 +02:00
|
|
|
}
|
2020-09-05 22:35:52 +02:00
|
|
|
years[date.getFullYear() + ''][date.getMonth() + ''].push(date)
|
|
|
|
this.fullWidth += this.dayWidth
|
|
|
|
}
|
|
|
|
this.$set(this, 'days', years)
|
|
|
|
},
|
|
|
|
parseTasks() {
|
|
|
|
this.setDates()
|
2020-11-15 16:32:46 +01:00
|
|
|
this.loadTasks()
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
2020-11-15 16:32:46 +01:00
|
|
|
loadTasks() {
|
|
|
|
this.$set(this, 'theTasks', [])
|
|
|
|
this.$set(this, 'tasksWithoutDates', [])
|
2020-04-04 18:26:35 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
const getAllTasks = (page = 1) => {
|
2021-01-17 18:57:57 +01:00
|
|
|
return this.taskCollectionService
|
|
|
|
.getAll({listId: this.listId}, this.params, page)
|
|
|
|
.then((tasks) => {
|
2020-09-05 22:35:52 +02:00
|
|
|
if (page < this.taskCollectionService.totalPages) {
|
2021-01-17 18:57:57 +01:00
|
|
|
return getAllTasks(page + 1).then((nextTasks) => {
|
|
|
|
return tasks.concat(nextTasks)
|
|
|
|
})
|
2020-09-05 22:35:52 +02:00
|
|
|
} else {
|
|
|
|
return tasks
|
|
|
|
}
|
2019-04-29 23:41:39 +02:00
|
|
|
})
|
2021-01-17 18:57:57 +01:00
|
|
|
.catch((e) => {
|
2020-09-05 22:35:52 +02:00
|
|
|
return Promise.reject(e)
|
2019-04-29 23:41:39 +02:00
|
|
|
})
|
2020-09-05 22:35:52 +02:00
|
|
|
}
|
2019-04-29 23:41:39 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
getAllTasks()
|
2021-01-17 18:57:57 +01:00
|
|
|
.then((tasks) => {
|
2020-09-05 22:35:52 +02:00
|
|
|
this.theTasks = tasks
|
2021-01-17 18:57:57 +01:00
|
|
|
.filter((t) => {
|
2020-09-05 22:35:52 +02:00
|
|
|
if (t.startDate === null && !t.done) {
|
|
|
|
this.tasksWithoutDates.push(t)
|
|
|
|
}
|
2021-01-17 18:57:57 +01:00
|
|
|
return (
|
|
|
|
t.startDate >= this.startDate &&
|
|
|
|
t.endDate <= this.endDate
|
|
|
|
)
|
2020-09-05 22:35:52 +02:00
|
|
|
})
|
2021-01-17 18:57:57 +01:00
|
|
|
.map((t) => {
|
2020-09-05 22:35:52 +02:00
|
|
|
return this.addGantAttributes(t)
|
|
|
|
})
|
|
|
|
.sort(function (a, b) {
|
2021-01-17 18:57:57 +01:00
|
|
|
if (a.startDate < b.startDate) return -1
|
|
|
|
if (a.startDate > b.startDate) return 1
|
2020-09-05 22:35:52 +02:00
|
|
|
return 0
|
|
|
|
})
|
|
|
|
})
|
2021-01-17 18:57:57 +01:00
|
|
|
.catch((e) => {
|
2020-09-05 22:35:52 +02:00
|
|
|
this.error(e, this)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
addGantAttributes(t) {
|
2021-04-25 18:01:17 +02:00
|
|
|
if (typeof t.durationDays !== 'undefined' && typeof t.offsetDays !== 'undefined') {
|
|
|
|
return t
|
|
|
|
}
|
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
t.endDate === null ? this.endDate : t.endDate
|
2021-04-25 18:01:17 +02:00
|
|
|
t.durationDays = Math.floor((t.endDate - t.startDate) / 1000 / 60 / 60 / 24)
|
|
|
|
t.offsetDays = Math.floor((t.startDate - this.startDate) / 1000 / 60 / 60 / 24)
|
2020-09-05 22:35:52 +02:00
|
|
|
return t
|
|
|
|
},
|
|
|
|
setTaskDragged(t) {
|
|
|
|
this.taskDragged = t
|
|
|
|
},
|
|
|
|
resizeTask(newRect) {
|
2021-04-25 18:01:17 +02:00
|
|
|
if (this.isTaskEdit) {
|
|
|
|
return
|
|
|
|
}
|
2019-04-29 23:41:39 +02:00
|
|
|
|
2021-04-25 18:01:17 +02:00
|
|
|
const didntHaveDates = this.taskDragged.startDate === null ? true : false
|
2019-04-29 23:41:39 +02:00
|
|
|
|
2021-04-25 18:01:17 +02:00
|
|
|
let startDate = new Date(this.startDate)
|
|
|
|
startDate.setDate(
|
|
|
|
startDate.getDate() + newRect.left / this.dayWidth
|
|
|
|
)
|
|
|
|
startDate.setUTCHours(0)
|
|
|
|
startDate.setUTCMinutes(0)
|
|
|
|
startDate.setUTCSeconds(0)
|
|
|
|
startDate.setUTCMilliseconds(0)
|
|
|
|
this.taskDragged.startDate = startDate
|
|
|
|
let endDate = new Date(startDate)
|
|
|
|
endDate.setDate(
|
|
|
|
startDate.getDate() + newRect.width / this.dayWidth
|
|
|
|
)
|
|
|
|
this.taskDragged.startDate = startDate
|
|
|
|
this.taskDragged.endDate = endDate
|
2020-09-05 22:35:52 +02:00
|
|
|
|
2021-04-25 18:01:17 +02:00
|
|
|
// We take the task from the overall tasks array because the one in it has bad data after it was updated once.
|
|
|
|
// FIXME: This is a workaround. We should use a better mechanism to get the task or, even better,
|
|
|
|
// prevent it from containing outdated Data in the first place.
|
|
|
|
for (const tt in this.theTasks) {
|
|
|
|
if (this.theTasks[tt].id === this.taskDragged.id) {
|
|
|
|
this.$set(this, 'taskDragged', this.theTasks[tt])
|
|
|
|
break
|
2020-09-05 22:35:52 +02:00
|
|
|
}
|
2021-04-25 18:01:17 +02:00
|
|
|
}
|
2020-04-04 18:26:35 +02:00
|
|
|
|
2021-04-25 18:01:17 +02:00
|
|
|
const ganttData = {
|
|
|
|
endDate: this.taskDragged.endDate,
|
|
|
|
durationDays: this.taskDragged.durationDays,
|
|
|
|
offsetDays: this.taskDragged.offsetDays,
|
|
|
|
}
|
|
|
|
|
|
|
|
this.taskService
|
|
|
|
.update(this.taskDragged)
|
|
|
|
.then(r => {
|
|
|
|
r.endDate = ganttData.endDate
|
|
|
|
r.durationDays = ganttData.durationDays
|
|
|
|
r.offsetDays = ganttData.offsetDays
|
|
|
|
|
|
|
|
// If the task didn't have dates before, we'll update the list
|
|
|
|
if (didntHaveDates) {
|
|
|
|
for (const t in this.tasksWithoutDates) {
|
|
|
|
if (this.tasksWithoutDates[t].id === r.id) {
|
|
|
|
this.tasksWithoutDates.splice(t, 1)
|
|
|
|
break
|
2020-09-05 22:35:52 +02:00
|
|
|
}
|
2021-04-25 18:01:17 +02:00
|
|
|
}
|
|
|
|
this.theTasks.push(this.addGantAttributes(r))
|
|
|
|
} else {
|
|
|
|
for (const tt in this.theTasks) {
|
|
|
|
if (this.theTasks[tt].id === r.id) {
|
|
|
|
this.$set(
|
|
|
|
this.theTasks,
|
|
|
|
tt,
|
|
|
|
this.addGantAttributes(r)
|
|
|
|
)
|
|
|
|
break
|
2019-04-29 23:41:39 +02:00
|
|
|
}
|
2020-09-05 22:35:52 +02:00
|
|
|
}
|
2021-04-25 18:01:17 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch((e) => {
|
|
|
|
this.error(e, this)
|
|
|
|
})
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
|
|
|
editTask(task) {
|
|
|
|
this.taskToEdit = task
|
|
|
|
this.isTaskEdit = true
|
|
|
|
},
|
|
|
|
showCreateNewTask() {
|
|
|
|
if (!this.newTaskFieldActive) {
|
|
|
|
// Timeout to not send the form if the field isn't even shown
|
|
|
|
setTimeout(() => {
|
|
|
|
this.newTaskFieldActive = true
|
|
|
|
this.$nextTick(() => this.$refs.newTaskTitleField.focus())
|
|
|
|
}, 100)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
hideCrateNewTask() {
|
|
|
|
if (this.newTaskTitle === '') {
|
2021-01-17 18:57:57 +01:00
|
|
|
this.$nextTick(() => (this.newTaskFieldActive = false))
|
2020-09-05 22:35:52 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
addNewTask() {
|
|
|
|
if (!this.newTaskFieldActive) {
|
|
|
|
return
|
|
|
|
}
|
2021-01-17 18:57:57 +01:00
|
|
|
let task = new TaskModel({
|
|
|
|
title: this.newTaskTitle,
|
|
|
|
listId: this.listId,
|
|
|
|
})
|
|
|
|
this.taskService
|
|
|
|
.create(task)
|
|
|
|
.then((r) => {
|
2020-09-05 22:35:52 +02:00
|
|
|
this.tasksWithoutDates.push(this.addGantAttributes(r))
|
|
|
|
this.newTaskTitle = ''
|
|
|
|
this.hideCrateNewTask()
|
|
|
|
})
|
2021-01-17 18:57:57 +01:00
|
|
|
.catch((e) => {
|
2020-09-05 22:35:52 +02:00
|
|
|
this.error(e, this)
|
|
|
|
})
|
2019-04-29 23:41:39 +02:00
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
|
|
|
}
|
2019-04-29 23:41:39 +02:00
|
|
|
</script>
|