gantt: better variable passing from task into markup
This commit is contained in:
+8
-5
@@ -149,6 +149,13 @@ class BZgantt extends Buildoz {
|
|||||||
for(const task of this.tasks){
|
for(const task of this.tasks){
|
||||||
const startIdx = this.getDayIndex(firstDate, new Date(task.start))
|
const startIdx = this.getDayIndex(firstDate, new Date(task.start))
|
||||||
const taskEndIdx = this.getDayIndex(firstDate, new Date(task.end))
|
const taskEndIdx = this.getDayIndex(firstDate, new Date(task.end))
|
||||||
|
const markup = {}
|
||||||
|
for(const [key, value] of Object.entries(task)){
|
||||||
|
if(value == null || typeof value === 'object') continue
|
||||||
|
markup[`task.${key}`] = value
|
||||||
|
}
|
||||||
|
if(!markup['task.color']) markup['task.color'] = '#CCC'
|
||||||
|
markup.width = (startIdx<taskEndIdx) ? (taskEndIdx-startIdx) * this.dayWidth : this.dayWidth
|
||||||
flow.nodes.push({
|
flow.nodes.push({
|
||||||
"nodeType": "bar",
|
"nodeType": "bar",
|
||||||
"id": task.id,
|
"id": task.id,
|
||||||
@@ -156,11 +163,7 @@ class BZgantt extends Buildoz {
|
|||||||
"x": startIdx * this.dayWidth,
|
"x": startIdx * this.dayWidth,
|
||||||
"y": curY,
|
"y": curY,
|
||||||
},
|
},
|
||||||
"markup": {
|
"markup": markup
|
||||||
"task": task.name,
|
|
||||||
"color": task.color || '#CCC',
|
|
||||||
"width": (startIdx<taskEndIdx) ? (taskEndIdx-startIdx) * this.dayWidth : this.dayWidth,
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
for(const dep of task.dependsOn ?? []){
|
for(const dep of task.dependsOn ?? []){
|
||||||
flow.links.push({ "from": [dep, "out1"], "to": [task.id, "inp1"] })
|
flow.links.push({ "from": [dep, "out1"], "to": [task.id, "inp1"] })
|
||||||
|
|||||||
Reference in New Issue
Block a user