mirror of
https://github.com/tenrok/vue-ganttastic.git
synced 2026-06-20 06:20:33 +03:00
Added prop 'min-gap-between-bars' (in minutes)
Fixed drag limit when a shadow is to the right Bumped version
This commit is contained in:
Generated
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vue-ganttastic",
|
||||
"version": "0.9.23",
|
||||
"version": "0.9.24",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vue-ganttastic",
|
||||
"version": "0.9.23",
|
||||
"version": "0.9.25",
|
||||
"description": "A simple and customizable Gantt chart component for Vue.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
+10
-7
@@ -65,7 +65,8 @@ export default {
|
||||
"moveBarsFromBundleOfPushedBar",
|
||||
"setDragLimitsOfGanttBar",
|
||||
"onBarEvent",
|
||||
"onDragendBar"
|
||||
"onDragendBar",
|
||||
"getMinGapBetweenBars",
|
||||
],
|
||||
|
||||
data(){
|
||||
@@ -260,10 +261,10 @@ export default {
|
||||
if(!this.ganttChartProps.pushOnOverlap) {
|
||||
return false
|
||||
}
|
||||
if(xStart && this.dragLimitLeft !== null && xStart < this.dragLimitLeft+2){
|
||||
if(xStart && this.dragLimitLeft !== null && xStart < this.dragLimitLeft + this.getMinGapBetweenBars()){
|
||||
return true
|
||||
}
|
||||
if(xEnd && this.dragLimitRight !== null && xEnd > this.dragLimitRight-2){
|
||||
if(xEnd && this.dragLimitRight !== null && xEnd > this.dragLimitRight - this.getMinGapBetweenBars()){
|
||||
return true
|
||||
}
|
||||
return false
|
||||
@@ -301,16 +302,17 @@ export default {
|
||||
let overlapEndMoment = moment(overlapBar[this.barEnd])
|
||||
switch(overlapType){
|
||||
case "left":
|
||||
minuteDiff = overlapEndMoment.diff(currentStartMoment, "minutes", true)
|
||||
overlapBar[this.barEnd] = currentBar[this.barStart]
|
||||
minuteDiff = overlapEndMoment.diff(currentStartMoment, "minutes", true) + this.getMinGapBetweenBars()
|
||||
overlapBar[this.barEnd] = moment(currentBar[this.barStart]).subtract(this.getMinGapBetweenBars(), "minutes", true)
|
||||
overlapBar[this.barStart] = overlapStartMoment.subtract(minuteDiff, "minutes", true)
|
||||
break
|
||||
case "right":
|
||||
minuteDiff = currentEndMoment.diff(overlapStartMoment, "minutes", true)
|
||||
overlapBar[this.barStart] = currentBar[this.barEnd]
|
||||
minuteDiff = currentEndMoment.diff(overlapStartMoment, "minutes", true) + this.getMinGapBetweenBars()
|
||||
overlapBar[this.barStart] = moment(currentBar[this.barEnd]).add(this.getMinGapBetweenBars(), "minutes", true)
|
||||
overlapBar[this.barEnd] = overlapEndMoment.add(minuteDiff, "minutes", true)
|
||||
break
|
||||
default:
|
||||
// eslint-disable-next-line
|
||||
console.warn("One bar is inside of the other one! This should never occur while push-on-overlap is active!")
|
||||
return
|
||||
}
|
||||
@@ -353,6 +355,7 @@ export default {
|
||||
this.barEndMoment = moment(this.barEndMoment).add(minuteCount, "minutes", true)
|
||||
break
|
||||
default:
|
||||
// eslint-disable-next-line
|
||||
console.warn("wrong direction in moveBarByMinutesAndPush")
|
||||
return
|
||||
}
|
||||
|
||||
+7
-2
@@ -58,6 +58,10 @@ export default {
|
||||
width: {type: String, default: "100%"}, // the total width of the entire ganttastic component in %
|
||||
pushOnOverlap: {type: Boolean},
|
||||
snapBackOnOverlap: {type: Boolean},
|
||||
minGapBetweenBars: {
|
||||
type: Number,
|
||||
default: 0
|
||||
}
|
||||
},
|
||||
|
||||
data(){
|
||||
@@ -224,7 +228,7 @@ export default {
|
||||
while(nextBar){
|
||||
let currentBarOffsetRight = currentBar.$refs['g-gantt-bar'].offsetLeft + currentBar.$refs['g-gantt-bar'].offsetWidth
|
||||
gapDistanceSoFar += nextBar.$refs['g-gantt-bar'].offsetLeft - currentBarOffsetRight
|
||||
if(nextBar.barConfig.immobile){
|
||||
if(nextBar.barConfig.immobile || (nextBar.barConfig.isShadow && !ignoreShadows)){
|
||||
return [gapDistanceSoFar, bundleBarsAndGapDist]
|
||||
} else if(nextBar.barConfig.bundle){
|
||||
bundleBarsAndGapDist.push({bar: nextBar, gapDistance: gapDistanceSoFar})
|
||||
@@ -290,7 +294,8 @@ export default {
|
||||
onBarEvent: (e, ganttBar) => this.onBarEvent(e, ganttBar),
|
||||
onDragendBar: (e, ganttBar) => this.onDragendBar(e, ganttBar),
|
||||
shouldSnapBackOnOverlap: () => this.snapBackOnOverlap,
|
||||
snapBackBundle: (ganttBar) => this.snapBackBundle(ganttBar)
|
||||
snapBackBundle: (ganttBar) => this.snapBackBundle(ganttBar),
|
||||
getMinGapBetweenBars: () => this.minGapBetweenBars
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user