Add background stripes and such

This commit is contained in:
kolaente 2021-05-20 17:44:25 +02:00
parent affaa95e3f
commit 1817a1f958
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B
2 changed files with 49 additions and 6 deletions

View file

@ -24,8 +24,10 @@
:push-on-overlap="true" :push-on-overlap="true"
row-label-width="0" row-label-width="0"
:row-height="37" :row-height="37"
:grid="true" :grid="false"
@dragend-bar="dragged($event)" @dragend-bar="dragged($event)"
:style="{'--day-width': dayWidthPercent + 'px'}"
ref="g-gantt-chart-container"
> >
<g-gantt-row <g-gantt-row
v-for="(t, k) in ganttBars" v-for="(t, k) in ganttBars"
@ -236,6 +238,18 @@ 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' import {colorIsDark} from '@/helpers/color/colorIsDark'
// Source: https://stackoverflow.com/a/11252167/10924593
const treatAsUTC = date => {
const result = new Date(date)
result.setMinutes(result.getMinutes() - result.getTimezoneOffset())
return result
}
const daysBetween = (startDate, endDate) => {
const millisecondsPerDay = 24 * 60 * 60 * 1000;
return (treatAsUTC(endDate) - treatAsUTC(startDate)) / millisecondsPerDay;
}
export default { export default {
name: 'GanttChart', name: 'GanttChart',
components: { components: {
@ -313,9 +327,21 @@ export default {
mounted() { mounted() {
this.buildTheGanttChart() this.buildTheGanttChart()
}, },
computed: mapState({ computed: {
canWrite: (state) => state.currentList.maxRight > Rights.READ, ...mapState({
}), canWrite: (state) => state.currentList.maxRight > Rights.READ,
}),
dayWidthPercent() {
const days = daysBetween(this.startDate, this.endDate)
let containerWidth = 1
if(this.$refs['g-gantt-chart-container']) {
containerWidth = this.$refs['g-gantt-chart-container'].$el.clientWidth
}
return Math.round(containerWidth / days)
},
},
methods: { methods: {
buildTheGanttChart() { buildTheGanttChart() {
this.setDates() this.setDates()

View file

@ -236,18 +236,35 @@ $gantt-vertical-border-color: $grey-100;
display: none; display: none;
} }
:root {
--day-width: 50px;
}
#g-gantt-chart { #g-gantt-chart {
* { * {
font-family: $family-sans-serif !important; font-family: $family-sans-serif !important;
} }
// .85rem
.g-gantt-row {
&:nth-child(even) {
background: rgba(0, 0, 0, 0) repeating-linear-gradient(90deg, #ededed, #ededed 1px, #fff 1px, #fff var(--day-width)) repeat scroll 0% 0%;
}
&:nth-child(odd) {
background: rgba(0, 0, 0, 0) repeating-linear-gradient(90deg, #ededed, #ededed 1px, #fafafa 1px, #fafafa var(--day-width)) repeat scroll 0% 0%;
}
> .g-gantt-row-bars-container {
border: 0;
}
}
.g-gantt-bar { .g-gantt-bar {
border-radius: 6px !important; border-radius: 6px !important;
overflow: visible !important; overflow: visible !important;
cursor: grab; cursor: grab;
&:active { &:active {
cursor: grabbing; cursor: grabbing;
} }