mirror of
https://github.com/tenrok/vue-ganttastic.git
synced 2026-06-18 19:50:32 +03:00
feat: add bar when double click on row
This commit is contained in:
+4
-2
@@ -61,7 +61,8 @@ export default {
|
||||
minGapBetweenBars: {
|
||||
type: Number,
|
||||
default: 0
|
||||
}
|
||||
},
|
||||
defaultBarLength: { type: Number, default: 1 }
|
||||
},
|
||||
|
||||
data(){
|
||||
@@ -295,7 +296,8 @@ export default {
|
||||
onDragendBar: (e, ganttBar) => this.onDragendBar(e, ganttBar),
|
||||
shouldSnapBackOnOverlap: () => this.snapBackOnOverlap,
|
||||
snapBackBundle: (ganttBar) => this.snapBackBundle(ganttBar),
|
||||
getMinGapBetweenBars: () => this.minGapBetweenBars
|
||||
getMinGapBetweenBars: () => this.minGapBetweenBars,
|
||||
getDefaultBarLength: () => this.defaultBarLength
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+15
-1
@@ -20,6 +20,7 @@
|
||||
@dragover="onDragover($event)"
|
||||
@dragleave="onDragleave($event)"
|
||||
@drop="onDrop($event)"
|
||||
@dblclick="onDoubleClick($event)"
|
||||
@mouseover="onMouseover()"
|
||||
@mouseleave="onMouseleave()"
|
||||
>
|
||||
@@ -69,7 +70,8 @@ export default {
|
||||
"getThemeColors",
|
||||
"getHourCount",
|
||||
"getChartStart",
|
||||
"getChartEnd"
|
||||
"getChartEnd",
|
||||
"getDefaultBarLength"
|
||||
],
|
||||
|
||||
data(){
|
||||
@@ -125,6 +127,18 @@ export default {
|
||||
this.$emit("drop", {event: e, bar, time: time.format("YYYY-MM-DD HH:mm:ss")})
|
||||
},
|
||||
|
||||
onDoubleClick(e){
|
||||
let barContainer = this.$refs.barContainer.getBoundingClientRect()
|
||||
let xPos = e.clientX - barContainer.left
|
||||
let hourDiffFromStart = (xPos/barContainer.width) * this.getHourCount()
|
||||
let time = moment(this.getChartStart()).add(hourDiffFromStart, "hours")
|
||||
let bar = {};
|
||||
bar[this.barStart] = time.format("YYYY-MM-DD HH:mm:ss")
|
||||
bar[this.barEnd] = time.add(this.getDefaultBarLength(), "hours").format("YYYY-MM-DD HH:mm:ss")
|
||||
bar.ganttBarConfig = {handles: true}
|
||||
this.bars.push(bar)
|
||||
},
|
||||
|
||||
onMouseover(){
|
||||
if(this.highlightOnHover){
|
||||
this.$refs["g-gantt-row"].style.backgroundColor = this.getThemeColors().hoverHighlight
|
||||
|
||||
Reference in New Issue
Block a user