Add background stripes and such
This commit is contained in:
parent
affaa95e3f
commit
1817a1f958
2 changed files with 49 additions and 6 deletions
|
@ -24,8 +24,10 @@
|
|||
:push-on-overlap="true"
|
||||
row-label-width="0"
|
||||
:row-height="37"
|
||||
:grid="true"
|
||||
:grid="false"
|
||||
@dragend-bar="dragged($event)"
|
||||
:style="{'--day-width': dayWidthPercent + 'px'}"
|
||||
ref="g-gantt-chart-container"
|
||||
>
|
||||
<g-gantt-row
|
||||
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 {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 {
|
||||
name: 'GanttChart',
|
||||
components: {
|
||||
|
@ -313,9 +327,21 @@ export default {
|
|||
mounted() {
|
||||
this.buildTheGanttChart()
|
||||
},
|
||||
computed: mapState({
|
||||
canWrite: (state) => state.currentList.maxRight > Rights.READ,
|
||||
}),
|
||||
computed: {
|
||||
...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: {
|
||||
buildTheGanttChart() {
|
||||
this.setDates()
|
||||
|
|
|
@ -236,18 +236,35 @@ $gantt-vertical-border-color: $grey-100;
|
|||
display: none;
|
||||
}
|
||||
|
||||
:root {
|
||||
--day-width: 50px;
|
||||
}
|
||||
|
||||
#g-gantt-chart {
|
||||
* {
|
||||
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 {
|
||||
border-radius: 6px !important;
|
||||
overflow: visible !important;
|
||||
cursor: grab;
|
||||
|
||||
|
||||
&:active {
|
||||
cursor: grabbing;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue