Skip to content

Commit

Permalink
Feature/134 duration for activities (#147)
Browse files Browse the repository at this point in the history
* * 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
3 people authored Apr 26, 2023
1 parent 3dddae0 commit 166ac24
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/lib/fragmentmodeler/FragmentModeler.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import bpmnExtension from './moddle/bpmnextension.json';
import { is } from 'bpmn-js/lib/util/ModelUtil';
import { without } from 'min-dash';
import taskLabelHandling from "./taskLabelHandling";
import taskRenderer from "./draw";


export default function FragmentModeler(options) {
const customModules = [
fragmentPaletteModule,
customModelingModule,
taskRenderer,
taskLabelHandling,
{
fragmentModeler: ['value', this]
Expand Down
67 changes: 67 additions & 0 deletions app/lib/fragmentmodeler/draw/TaskRenderer.js
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'];
6 changes: 6 additions & 0 deletions app/lib/fragmentmodeler/draw/index.js
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 ]
};

0 comments on commit 166ac24

Please sign in to comment.