Make it look more like the old gantt chart

This commit is contained in:
kolaente 2021-05-20 14:14:10 +02:00
parent a1ee90df33
commit 7e6d5956ba
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B
2 changed files with 72 additions and 16 deletions

View file

@ -23,27 +23,22 @@
:chart-end="dateTo.toString()" :chart-end="dateTo.toString()"
:push-on-overlap="true" :push-on-overlap="true"
row-label-width="0" row-label-width="0"
:row-height="37"
:grid="true" :grid="true"
@dragend-bar="dragged($event)" @dragend-bar="dragged($event)"
> >
<g-gantt-row <g-gantt-row
v-for="(t, k) in theTasks" v-for="(t, k) in ganttBars"
:key="t ? t.id : 'k'+k" :key="t ? t.id : 'k'+k"
label="" label=""
bar-start="start" bar-start="start"
bar-end="end" bar-end="end"
:bars="[{ :bars="t.bars"
start: t.startDate.toString(),
end: t.endDate.toString(),
label: t.title,
ganttBarConfig: {
color: colorIsDark(t.getHexColor()) ? 'black' : 'white',
backgroundColor: t.getHexColor(),
handles: true,
}
}]"
:highlight-on-hover="true" :highlight-on-hover="true"
> >
<template v-slot:bar-label>
{{ t.title }}
</template>
<!-- <template #bar-label="{bar}">--> <!-- <template #bar-label="{bar}">-->
<!-- <span>{{ bar.label }}</span>--> <!-- <span>{{ bar.label }}</span>-->
<!-- </template>--> <!-- </template>-->
@ -228,15 +223,16 @@
import VueDragResize from 'vue-drag-resize' import VueDragResize from 'vue-drag-resize'
import {GGanttChart, GGanttRow} from 'vue-ganttastic' import {GGanttChart, GGanttRow} from 'vue-ganttastic'
import EditTask from './edit-task' import EditTask from './edit-task'
import {mapState} from 'vuex'
import TaskService from '../../services/task' import TaskService from '../../services/task'
import TaskModel from '../../models/task' import TaskModel from '../../models/task'
import priorities from '../../models/priorities' import priorities from '../../models/priorities'
import PriorityLabel from './partials/priorityLabel' import PriorityLabel from './partials/priorityLabel'
import TaskCollectionService from '../../services/taskCollection' import TaskCollectionService from '../../services/taskCollection'
import {mapState} from 'vuex'
import Rights from '../../models/rights.json' import Rights from '../../models/rights.json'
import FilterPopup from '@/components/list/partials/filter-popup' import FilterPopup from '@/components/list/partials/filter-popup'
import {colorIsDark} from '@/helpers/color/colorIsDark'
export default { export default {
name: 'GanttChart', name: 'GanttChart',
@ -289,6 +285,8 @@ export default {
taskCollectionService: TaskCollectionService, taskCollectionService: TaskCollectionService,
showTaskFilter: false, showTaskFilter: false,
ganttBars: [],
params: { params: {
sort_by: ['done', 'id'], sort_by: ['done', 'id'],
order_by: ['asc', 'desc'], order_by: ['asc', 'desc'],
@ -398,6 +396,25 @@ export default {
if (a.startDate > b.startDate) return 1 if (a.startDate > b.startDate) return 1
return 0 return 0
}) })
this.ganttBars = this.theTasks.map(t => {
return {
id: t.id,
title: t.title,
bars: [{
id: t.id,
start: t.startDate.toString(),
end: t.endDate.toString(),
label: t.title,
ganttBarConfig: {
color: colorIsDark(t.getHexColor()) ? 'black' : 'white',
backgroundColor: t.getHexColor(),
handles: true,
},
}],
}
})
}) })
.catch((e) => { .catch((e) => {
this.error(e, this) this.error(e, this)
@ -526,7 +543,13 @@ export default {
}) })
}, },
dragged(e) { dragged(e) {
console.log(e) const bar = e.movedBars.entries().next().value[0]
const index = this.theTasks.findIndex(t => t.id === bar.id)
const task = this.theTasks[index]
console.log(bar, task)
task.startDate = new Date(bar.start)
task.endDate = new Date(bar.end)
this.$set(this.theTasks, index, task)
}, },
}, },
} }

View file

@ -235,3 +235,36 @@ $gantt-vertical-border-color: $grey-100;
.vdr.active::before { .vdr.active::before {
display: none; display: none;
} }
#g-gantt-chart {
* {
font-family: $family-sans-serif !important;
}
// .85rem
.g-gantt-bar {
border-radius: 6px !important;
overflow: visible !important;
.g-gantt-bar-label {
font-size: .85rem;
justify-content: start;
padding: 0 .5rem !important;
overflow: hidden;
}
.g-gantt-bar-handle-left, .g-gantt-bar-handle-right {
width: 8px !important;
height: 8px !important;
opacity: 1 !important;
border-radius: 0 !important;
margin-left: -2px !important;
border: 1px solid $grey-700 !important;
}
.g-gantt-bar-handle-right {
margin-right: -2px !important;
}
}
}