diff --git a/src/components/tasks/GanttChart.vue b/src/components/tasks/GanttChart.vue
index 296dc1cc8..a49eaf788 100644
--- a/src/components/tasks/GanttChart.vue
+++ b/src/components/tasks/GanttChart.vue
@@ -5,9 +5,8 @@
/>
import {computed, ref, watch, toRefs, onActivated} from 'vue'
import {useRouter} from 'vue-router'
-
import {getHexColor} from '@/models/task'
-
import {colorIsDark} from '@/helpers/color/colorIsDark'
-import {isoToKebabDate, isoToKebabTime} from '@/helpers/time/isoToKebabDate'
-import {parseKebabDate, parseKebabDateTime} from '@/helpers/time/parseKebabDate'
-
import type {ITask, ITaskPartialWithId} from '@/modelTypes/ITask'
-import type {DateISO} from '@/types/DateISO'
import type {GanttFilters} from '@/views/project/helpers/useGanttFilters'
import {
@@ -66,12 +59,10 @@ export interface GanttChartProps {
isLoading: boolean,
filters: GanttFilters,
tasks: Map,
- defaultTaskStartDate: DateISO
- defaultTaskEndDate: DateISO
+ defaultTaskStartDate: Date
+ defaultTaskEndDate: Date
}
-const DAYJS_ISO_DATE_FORMAT = 'YYYY-MM-DD HH:mm'
-
const props = defineProps()
const emit = defineEmits<{
@@ -135,8 +126,8 @@ function transformTaskToGanttBar(t: ITask) {
const black = 'var(--grey-800)'
return [{
- startDate: isoToKebabTime(t.startDate ? t.startDate.toISOString() : props.defaultTaskStartDate),
- endDate: isoToKebabTime(t.endDate ? t.endDate.toISOString() : props.defaultTaskEndDate),
+ startDate: t.startDate ?? props.defaultTaskStartDate,
+ endDate: t.endDate ?? props.defaultTaskEndDate,
ganttBarConfig: {
id: String(t.id),
label: t.title,
@@ -156,10 +147,32 @@ async function updateGanttTask(e: {
e: MouseEvent;
datetime?: string | undefined;
}) {
+
+ const taskId = Number(e.bar.ganttBarConfig.id)
+ const task = tasks.value.get(taskId)
+
+ const startDate: Date = new Date(e.bar.startDate)
+ const endDate: Date = new Date(e.bar.endDate)
+
+ if(task && ganttChartPrecision.value == 'day') {
+
+ if(task.startDate) {
+ startDate.setHours(task.startDate.getHours(), task.startDate.getMinutes(), task.startDate.getSeconds())
+ } else {
+ startDate.setHours(0,0,0)
+ }
+
+ if(task.endDate) {
+ endDate.setHours(task.endDate.getHours(), task.endDate.getMinutes(), task.endDate.getSeconds())
+ } else {
+ endDate.setHours(23,59,59)
+ }
+ }
+
emit('update:task', {
- id: Number(e.bar.ganttBarConfig.id),
- startDate: new Date(parseKebabDateTime(e.bar.startDate)),
- endDate: new Date(parseKebabDateTime(e.bar.endDate)),
+ id: Number(taskId),
+ startDate: startDate,
+ endDate: endDate,
})
}
diff --git a/src/views/project/ProjectGantt.vue b/src/views/project/ProjectGantt.vue
index ef270a6ed..026510419 100644
--- a/src/views/project/ProjectGantt.vue
+++ b/src/views/project/ProjectGantt.vue
@@ -65,7 +65,6 @@ import {createAsyncComponent} from '@/helpers/createAsyncComponent'
import {useGanttFilters} from './helpers/useGanttFilters'
import {RIGHTS} from '@/constants/rights'
-import type {DateISO} from '@/types/DateISO'
import type {ITask} from '@/modelTypes/ITask'
type Options = Flatpickr.Options.Options
@@ -91,12 +90,12 @@ const {
const DEFAULT_DATE_RANGE_DAYS = 7
const today = new Date()
-const defaultTaskStartDate: DateISO = new Date(today.setHours(0, 0, 0, 0)).toISOString()
-const defaultTaskEndDate: DateISO = new Date(new Date(
+const defaultTaskStartDate: Date = new Date(today.setHours(0, 0, 0, 0))
+const defaultTaskEndDate: Date = new Date(new Date(
today.getFullYear(),
today.getMonth(),
today.getDate() + DEFAULT_DATE_RANGE_DAYS,
-).setHours(23, 59, 0, 0)).toISOString()
+).setHours(23, 59, 0, 0))
async function addGanttTask(title: ITask['title']) {
return await addTask({