-
Notifications
You must be signed in to change notification settings - Fork 0
/
CustomContextPad.js
59 lines (50 loc) · 1.33 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
export default class CustomContextPad {
constructor(config, contextPad, create, elementFactory, injector, translate) {
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,
create,
elementFactory,
translate
} = this;
function appendServiceTask(event, element) {
if (autoPlace) {
const shape = elementFactory.createShape({ type: 'bpmn:ServiceTask' });
autoPlace.append(element, shape);
} else {
appendServiceTaskStart(event, element);
}
}
function appendServiceTaskStart(event) {
const shape = elementFactory.createShape({ type: 'bpmn:ServiceTask' });
create.start(event, shape, element);
}
return {
'append.service-task': {
group: 'model',
className: 'bpmn-icon-service-task',
title: translate('Append ServiceTask'),
action: {
click: appendServiceTask,
dragstart: appendServiceTaskStart
}
}
};
}
}
CustomContextPad.$inject = [
'config',
'contextPad',
'create',
'elementFactory',
'injector',
'translate'
];