-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/134 duration for activities (#147)
* * Adds a Dropdown that contains Name,Duration,Role and Number of People * * Fixes a small Problem with the DatObjectLabelHandler * Working on a CustomRenderer * Working on a CustomRenderer pt.2 * * Implements the Custom Acticity Renderer * * Enables Import/Export * Fixes a small bug where direct editing of the labels was enabled * Changing the durations location * Renaming CustomRenderer to TaskRenderer * * Deletes fragmentLabelHandler --------- Co-authored-by: Noel <[email protected]> Co-authored-by: lottchen <[email protected]>
- Loading branch information
1 parent
3dddae0
commit 166ac24
Showing
3 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import BaseRenderer from "diagram-js/lib/draw/BaseRenderer"; | ||
import {is} from "../../util/Util"; | ||
import {assign} from 'min-dash'; | ||
import {getLabelColor, getSemantic} from 'bpmn-js/lib/draw/BpmnRenderUtil'; | ||
import { | ||
append as svgAppend, | ||
classes as svgClasses | ||
} from 'tiny-svg'; | ||
|
||
const HIGH_PRIORITY = 1500; | ||
|
||
export default class TaskRenderer extends BaseRenderer { | ||
constructor(eventBus, bpmnRenderer, textRenderer) { | ||
super(eventBus, HIGH_PRIORITY); | ||
|
||
this.bpmnRenderer = bpmnRenderer; | ||
this.textRenderer = textRenderer; | ||
} | ||
|
||
canRender(element) { | ||
return is(element, 'bpmn:Task'); | ||
} | ||
|
||
drawShape(parentNode, element) { | ||
const shape = this.bpmnRenderer.drawShape(parentNode, element); | ||
this.renderEmbeddedDurationLabel(parentNode, element, 'right-top'); | ||
return shape; | ||
} | ||
|
||
renderEmbeddedDurationLabel(parentGfx, element, align) { | ||
let semantic = getSemantic(element); | ||
|
||
if (semantic.duration) { | ||
var duration = "🕒:" + semantic.duration; | ||
} else { | ||
duration = ""; | ||
} | ||
|
||
return this.renderLabel(parentGfx, duration, { | ||
box: element, | ||
align: align, | ||
padding: 2, | ||
style: { | ||
fill: getLabelColor(element) | ||
} | ||
}); | ||
} | ||
|
||
renderLabel(parentGfx, label, options) { | ||
|
||
options = assign({ | ||
size: { | ||
width: 100 | ||
} | ||
}, options); | ||
|
||
var text = this.textRenderer.createText(label || '', options); | ||
|
||
svgClasses(text).add('djs-label'); | ||
|
||
svgAppend(parentGfx, text); | ||
|
||
return text; | ||
} | ||
} | ||
|
||
TaskRenderer.$inject = ['eventBus', 'bpmnRenderer', 'textRenderer']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import TaskRenderer from './TaskRenderer'; | ||
|
||
export default { | ||
__init__: [ 'taskRenderer' ], | ||
taskRenderer: [ 'type', TaskRenderer ] | ||
}; |