-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathCustomContextPad.js
102 lines (88 loc) · 2.78 KB
/
CustomContextPad.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
const SUITABILITY_SCORE_HIGH = 100,
SUITABILITY_SCORE_AVERAGE = 50,
SUITABILITY_SCORE_LOW = 25;
export default class CustomContextPad {
constructor(bpmnFactory, config, contextPad, create, elementFactory, injector, translate) {
this.bpmnFactory = bpmnFactory;
this.create = create;
this.elementFactory = elementFactory;
this.translate = translate;
if (config.autoPlace !== false) {
this.autoPlace = injector.get('autoPlace', false);
}
contextPad.registerProvider(this);
}
getContextPadEntries(element) {
const {
autoPlace,
bpmnFactory,
create,
elementFactory,
translate
} = this;
function appendServiceTask(suitabilityScore) {
return function(event, element) {
if (autoPlace) {
const businessObject = bpmnFactory.create('bpmn:Task');
businessObject.suitable = suitabilityScore;
const shape = elementFactory.createShape({
type: 'bpmn:Task',
businessObject: businessObject
});
autoPlace.append(element, shape);
} else {
appendServiceTaskStart(event, element);
}
};
}
function appendServiceTaskStart(suitabilityScore) {
return function(event) {
const businessObject = bpmnFactory.create('bpmn:Task');
businessObject.suitable = suitabilityScore;
const shape = elementFactory.createShape({
type: 'bpmn:Task',
businessObject: businessObject
});
create.start(event, shape, element);
};
}
return {
'append.low-task': {
group: 'model',
className: 'bpmn-icon-task red',
title: translate('Append Task with low suitability score'),
action: {
click: appendServiceTask(SUITABILITY_SCORE_LOW),
dragstart: appendServiceTaskStart(SUITABILITY_SCORE_LOW)
}
},
'append.average-task': {
group: 'model',
className: 'bpmn-icon-task yellow',
title: translate('Append Task with average suitability score'),
action: {
click: appendServiceTask(SUITABILITY_SCORE_AVERAGE),
dragstart: appendServiceTaskStart(SUITABILITY_SCORE_AVERAGE)
}
},
'append.high-task': {
group: 'model',
className: 'bpmn-icon-task green',
title: translate('Append Task with high suitability score'),
action: {
click: appendServiceTask(SUITABILITY_SCORE_HIGH),
dragstart: appendServiceTaskStart(SUITABILITY_SCORE_HIGH)
}
}
};
}
}
CustomContextPad.$inject = [
'bpmnFactory',
'config',
'contextPad',
'create',
'elementFactory',
'injector',
'translate'
];