diff --git a/lib/components/GGanttBar.vue b/lib/components/GGanttBar.vue index b6a1fed..433bac5 100644 --- a/lib/components/GGanttBar.vue +++ b/lib/components/GGanttBar.vue @@ -12,7 +12,7 @@ @contextmenu="onContextmenu($event)" >
- + {{ barConfig.label || '' }}
@@ -36,7 +36,7 @@ }" />
-
{{ bar.tooltip }}
+
{{ localBar.tooltip }}
{{ barStartText }} - {{ barEndText }}
@@ -79,7 +79,8 @@ export default { cursorOffsetX: 0, mousemoveCallback: null, // gets initialized when starting to drag, possible values: drag, dragByHandleLeft, dragByHandleRight, barStartBeforeDrag: null, - barEndBeforeDrag: null + barEndBeforeDrag: null, + localBar: this.bar } }, @@ -128,19 +129,19 @@ export default { barStartMoment: { get() { - return moment(this.bar[this.barStartKey], this.timeFormat) + return moment(this.localBar[this.barStartKey], this.timeFormat) }, set(value) { - this.bar[this.barStartKey] = value.format(this.timeFormat) + this.localBar[this.barStartKey] = value.format(this.timeFormat) } }, barEndMoment: { get() { - return moment(this.bar[this.barEndKey]) + return moment(this.localBar[this.barEndKey]) }, set(value) { - this.bar[this.barEndKey] = value.format(this.timeFormat) + this.localBar[this.barEndKey] = value.format(this.timeFormat) } }, @@ -158,16 +159,16 @@ export default { }, barConfig() { - if (this.bar[this.barConfigKey]) { + if (this.localBar[this.barConfigKey]) { return { - ...this.bar[this.barConfigKey], - background: this.bar[this.barConfigKey].isShadow + ...this.localBar[this.barConfigKey], + background: this.localBar[this.barConfigKey].isShadow ? 'grey' - : this.bar[this.barConfigKey].background || - this.bar[this.barConfigKey].backgroundColor, - opacity: this.bar[this.barConfigKey].isShadow + : this.localBar[this.barConfigKey].background || + this.localBar[this.barConfigKey].backgroundColor, + opacity: this.localBar[this.barConfigKey].isShadow ? '0.3' - : this.bar[this.barConfigKey].opacity + : this.localBar[this.barConfigKey].opacity } } return {} @@ -203,6 +204,12 @@ export default { } }, + watch: { + bar(value) { + this.localBar = value + } + }, + methods: { onMouseenter(e) { if (this.tooltipTimeout) { @@ -277,8 +284,8 @@ export default { initDrag(e) { // "e" must be the mousedown event this.isDragging = true - this.barStartBeforeDrag = this.bar[this.barStartKey] - this.barEndBeforeDrag = this.bar[this.barEndKey] + this.barStartBeforeDrag = this.localBar[this.barStartKey] + this.barEndBeforeDrag = this.localBar[this.barEndKey] let barX = this.$refs['g-gantt-bar'].getBoundingClientRect().left this.cursorOffsetX = e.clientX - barX @@ -377,22 +384,26 @@ export default { } // if ( - // moment(this.bar[this.barStartKey]).isAfter(this.barStartBeforeDrag) && - // moment(this.bar[this.barStartKey]) + // moment(this.localBar[this.barStartKey]).isAfter(this.barStartBeforeDrag) && + // moment(this.localBar[this.barStartKey]) // .add(1, this.timeUnit) - // .isAfter(this.bar[this.barEndBeforeDrag]) + // .isAfter(this.localBar[this.barEndBeforeDrag]) // ) { // return true // } const isSqueezeToLeft = newXStart && - moment(this.bar[this.barStartKey]).isBefore(this.barStartBeforeDrag) + moment(this.localBar[this.barStartKey]).isBefore( + this.barStartBeforeDrag + ) const isSqueezeToRight = newXEnd && - moment(this.bar[this.barEndKey]).isAfter(this.barEndBeforeDrag) + moment(this.localBar[this.barEndKey]).isAfter(this.barEndBeforeDrag) - const currentIndex = this.allBarsInRow.findIndex(bar => bar == this.bar) + const currentIndex = this.allBarsInRow.findIndex( + bar => bar == this.localBar + ) let otherBars = [] if (isSqueezeToRight) { @@ -460,7 +471,7 @@ export default { ) { return } - let currentBar = this.bar + let currentBar = this.localBar let { overlapBar, overlapType } = this.getOverlapBarAndType(currentBar) while (overlapBar) { let minuteDiff diff --git a/lib/components/GGanttRow.vue b/lib/components/GGanttRow.vue index 9560659..19f392f 100644 --- a/lib/components/GGanttRow.vue +++ b/lib/components/GGanttRow.vue @@ -21,12 +21,12 @@ @mouseleave="onMouseleave()" >