camunda-bpmn-js 2.0.2 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base-modeler.development.js +14001 -10194
- package/dist/base-modeler.production.min.js +41 -38
- package/dist/base-navigated-viewer.development.js +161 -121
- package/dist/base-navigated-viewer.production.min.js +1 -1
- package/dist/base-viewer.development.js +155 -119
- package/dist/base-viewer.production.min.js +1 -1
- package/dist/camunda-cloud-modeler.development.js +45602 -38158
- package/dist/camunda-cloud-modeler.production.min.js +35 -32
- package/dist/camunda-cloud-navigated-viewer.development.js +191 -141
- package/dist/camunda-cloud-navigated-viewer.production.min.js +1 -1
- package/dist/camunda-cloud-viewer.development.js +185 -139
- package/dist/camunda-cloud-viewer.production.min.js +1 -1
- package/dist/camunda-platform-modeler.development.js +52130 -46628
- package/dist/camunda-platform-modeler.production.min.js +35 -32
- package/dist/camunda-platform-navigated-viewer.development.js +161 -121
- package/dist/camunda-platform-navigated-viewer.production.min.js +1 -1
- package/dist/camunda-platform-viewer.development.js +155 -119
- package/dist/camunda-platform-viewer.production.min.js +1 -1
- package/lib/base/Modeler.js +13 -8
- package/lib/camunda-cloud/Modeler.js +9 -7
- package/lib/camunda-platform/Modeler.js +8 -3
- package/package.json +17 -15
- package/lib/camunda-cloud/features/create-append-anything/ElementTemplatesAppendProvider.js +0 -162
- package/lib/camunda-cloud/features/create-append-anything/ElementTemplatesCreateProvider.js +0 -114
- package/lib/camunda-cloud/features/create-append-anything/index.js +0 -11
- package/lib/camunda-cloud/features/replace/ElementTemplatesReplaceProvider.js +0 -118
- package/lib/camunda-cloud/features/replace/index.js +0 -6
- package/lib/shared/features/replace/UnlinkTemplateReplaceProvider.js +0 -178
- package/lib/shared/features/replace/index.js +0 -8
- package/lib/shared/features/replace/util/ReplaceOptionsUtil.js +0 -7
package/lib/base/Modeler.js
CHANGED
|
@@ -4,6 +4,7 @@ import BpmnModeler from 'bpmn-js/lib/Modeler';
|
|
|
4
4
|
|
|
5
5
|
import minimapModule from 'diagram-js-minimap';
|
|
6
6
|
|
|
7
|
+
import gridModule from 'diagram-js-grid';
|
|
7
8
|
import diagramOriginModule from 'diagram-js-origin';
|
|
8
9
|
import alignToOriginModule from '@bpmn-io/align-to-origin';
|
|
9
10
|
|
|
@@ -19,19 +20,23 @@ import {
|
|
|
19
20
|
* @param {Object} options
|
|
20
21
|
*/
|
|
21
22
|
export default function Modeler(options = {}) {
|
|
22
|
-
|
|
23
|
-
this._injectOriginModule(options);
|
|
24
|
-
|
|
25
23
|
BpmnModeler.call(this, options);
|
|
26
24
|
}
|
|
27
25
|
|
|
28
26
|
inherits(Modeler, BpmnModeler);
|
|
29
27
|
|
|
30
|
-
Modeler.prototype.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
Modeler.prototype.getModules = function(options) {
|
|
29
|
+
const modules = BpmnModeler.prototype.getModules.call(this, options);
|
|
30
|
+
|
|
31
|
+
return [
|
|
32
|
+
...modules,
|
|
33
|
+
options.disableAdjustOrigin
|
|
34
|
+
? diagramOriginModule
|
|
35
|
+
: alignToOriginModule,
|
|
36
|
+
options.disableGrid
|
|
37
|
+
? {}
|
|
38
|
+
: gridModule
|
|
39
|
+
];
|
|
35
40
|
};
|
|
36
41
|
|
|
37
42
|
Modeler.prototype._extensionModules = [
|
|
@@ -16,14 +16,16 @@ import {
|
|
|
16
16
|
ZeebeVariableResolverModule as variableResolverModule
|
|
17
17
|
} from '@bpmn-io/variable-resolver';
|
|
18
18
|
|
|
19
|
-
import
|
|
20
|
-
|
|
19
|
+
import exampleDataPropertiesProviderModule from '@camunda/example-data-properties-provider';
|
|
20
|
+
|
|
21
21
|
import colorPickerModule from 'bpmn-js-color-picker';
|
|
22
|
-
import createAppendElementTemplatesModule from './features/create-append-anything';
|
|
23
22
|
import elementTemplateChooserModule from '@bpmn-io/element-template-chooser';
|
|
24
|
-
|
|
25
23
|
import { commonModdleExtensions, commonModules } from './util/commonModules';
|
|
26
24
|
|
|
25
|
+
import {
|
|
26
|
+
CreateAppendAnythingModule as createAppendAnythingModule,
|
|
27
|
+
CreateAppendElementTemplatesModule as createAppendElementTemplatesModule
|
|
28
|
+
} from 'bpmn-js-create-append-anything';
|
|
27
29
|
|
|
28
30
|
/**
|
|
29
31
|
*
|
|
@@ -64,11 +66,11 @@ Modeler.prototype._camundaCloudModules = [
|
|
|
64
66
|
rulesModule,
|
|
65
67
|
zeebePropertiesProviderModule,
|
|
66
68
|
cloudElementTemplatesPropertiesProvider,
|
|
69
|
+
createAppendAnythingModule,
|
|
67
70
|
createAppendElementTemplatesModule,
|
|
68
|
-
replaceModule,
|
|
69
|
-
sharedReplaceModule,
|
|
70
71
|
colorPickerModule,
|
|
71
|
-
variableResolverModule
|
|
72
|
+
variableResolverModule,
|
|
73
|
+
exampleDataPropertiesProviderModule
|
|
72
74
|
];
|
|
73
75
|
|
|
74
76
|
Modeler.prototype._modules = [].concat(
|
|
@@ -15,9 +15,13 @@ import {
|
|
|
15
15
|
|
|
16
16
|
import { commonModdleExtensions } from './util/commonModules';
|
|
17
17
|
|
|
18
|
-
import sharedReplaceModule from '../shared/features/replace';
|
|
19
18
|
import colorPickerModule from 'bpmn-js-color-picker';
|
|
20
19
|
|
|
20
|
+
import {
|
|
21
|
+
CreateAppendAnythingModule as createAppendAnythingModule,
|
|
22
|
+
UnlinkTemplatesModule as unlinkTemplatesModule
|
|
23
|
+
} from 'bpmn-js-create-append-anything';
|
|
24
|
+
|
|
21
25
|
|
|
22
26
|
/**
|
|
23
27
|
*
|
|
@@ -42,9 +46,10 @@ Modeler.prototype._camundaPlatformModules = [
|
|
|
42
46
|
behaviorsModule,
|
|
43
47
|
CamundaPlatformPropertiesProviderModule,
|
|
44
48
|
ElementTemplatesPropertiesProviderModule,
|
|
45
|
-
sharedReplaceModule,
|
|
46
49
|
colorPickerModule,
|
|
47
|
-
|
|
50
|
+
createAppendAnythingModule,
|
|
51
|
+
variableResolverModule,
|
|
52
|
+
unlinkTemplatesModule
|
|
48
53
|
];
|
|
49
54
|
|
|
50
55
|
Modeler.prototype._modules = [].concat(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "camunda-bpmn-js",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "Embeddable Camunda modeling distributions based on bpmn-js",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"dev": "npm test -- --auto-watch --no-single-run",
|
|
10
10
|
"test": "karma start karma.config.js",
|
|
11
11
|
"clean": "del-cli dist",
|
|
12
|
-
"distro": "rollup -c --failAfterWarnings",
|
|
12
|
+
"distro": "rollup -c --failAfterWarnings --bundleConfigAsCjs",
|
|
13
13
|
"format": "run-s format:markdown 'lint -- --fix'",
|
|
14
14
|
"format:markdown": "remark . -qo",
|
|
15
15
|
"test:distro": "node tasks/test-distro.js",
|
|
@@ -48,16 +48,18 @@
|
|
|
48
48
|
"license": "MIT",
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@bpmn-io/align-to-origin": "^0.7.0",
|
|
51
|
-
"@bpmn-io/element-templates-icons-renderer": "^0.3.0",
|
|
52
51
|
"@bpmn-io/element-template-chooser": "^1.0.0",
|
|
52
|
+
"@bpmn-io/element-templates-icons-renderer": "^0.3.0",
|
|
53
53
|
"@bpmn-io/variable-resolver": "^0.1.0",
|
|
54
|
-
"@camunda/
|
|
55
|
-
"bpmn-js": "^
|
|
54
|
+
"@camunda/example-data-properties-provider": "^1.0.1",
|
|
55
|
+
"bpmn-js": "^12.0.0",
|
|
56
56
|
"bpmn-js-color-picker": "^0.5.0",
|
|
57
|
+
"bpmn-js-create-append-anything": "^0.1.0",
|
|
57
58
|
"bpmn-js-executable-fix": "^0.2.0",
|
|
58
|
-
"camunda-bpmn-js-behaviors": "^0.
|
|
59
|
+
"camunda-bpmn-js-behaviors": "^0.5.0",
|
|
59
60
|
"camunda-bpmn-moddle": "^7.0.1",
|
|
60
|
-
"diagram-js": "^11.
|
|
61
|
+
"diagram-js": "^11.12.0",
|
|
62
|
+
"diagram-js-grid": "^0.2.0",
|
|
61
63
|
"diagram-js-minimap": "^4.0.1",
|
|
62
64
|
"diagram-js-origin": "^1.4.0",
|
|
63
65
|
"inherits-browser": "^0.1.0",
|
|
@@ -66,14 +68,15 @@
|
|
|
66
68
|
},
|
|
67
69
|
"devDependencies": {
|
|
68
70
|
"@babel/core": "^7.18.13",
|
|
69
|
-
"@bpmn-io/properties-panel": "^1.
|
|
70
|
-
"@rollup/plugin-commonjs": "^
|
|
71
|
-
"@rollup/plugin-json": "^
|
|
72
|
-
"@rollup/plugin-node-resolve": "^
|
|
71
|
+
"@bpmn-io/properties-panel": "^1.6.2",
|
|
72
|
+
"@rollup/plugin-commonjs": "^24.0.1",
|
|
73
|
+
"@rollup/plugin-json": "^6.0.0",
|
|
74
|
+
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
75
|
+
"@rollup/plugin-terser": "^0.4.0",
|
|
73
76
|
"babel-loader": "^9.0.0",
|
|
74
77
|
"babel-plugin-istanbul": "^6.1.1",
|
|
75
78
|
"bpmn-js-connectors-extension": "^0.4.6",
|
|
76
|
-
"bpmn-js-properties-panel": "^1.
|
|
79
|
+
"bpmn-js-properties-panel": "^1.20.3",
|
|
77
80
|
"chai": "^4.3.7",
|
|
78
81
|
"cross-env": "^7.0.3",
|
|
79
82
|
"del-cli": "^5.0.0",
|
|
@@ -101,9 +104,8 @@
|
|
|
101
104
|
"raw-loader": "^4.0.2",
|
|
102
105
|
"remark-cli": "^11.0.0",
|
|
103
106
|
"remark-preset-bpmn-io": "^0.2.1",
|
|
104
|
-
"rollup": "^
|
|
105
|
-
"rollup-plugin-copy": "^3.
|
|
106
|
-
"rollup-plugin-terser": "^7.0.2",
|
|
107
|
+
"rollup": "^3.0.1",
|
|
108
|
+
"rollup-plugin-copy": "^3.4.0",
|
|
107
109
|
"sinon": "^15.0.0",
|
|
108
110
|
"sinon-chai": "^3.7.0",
|
|
109
111
|
"webpack": "^5.74.0"
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import { assign } from 'min-dash';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* A popup menu provider that allows to append elements with
|
|
6
|
-
* element templates.
|
|
7
|
-
*/
|
|
8
|
-
export default function ElementTemplatesAppendProvider(
|
|
9
|
-
popupMenu, translate, elementTemplates,
|
|
10
|
-
autoPlace, create, mouse, rules) {
|
|
11
|
-
|
|
12
|
-
this._popupMenu = popupMenu;
|
|
13
|
-
this._translate = translate;
|
|
14
|
-
this._elementTemplates = elementTemplates;
|
|
15
|
-
this._autoPlace = autoPlace;
|
|
16
|
-
this._create = create;
|
|
17
|
-
this._mouse = mouse;
|
|
18
|
-
this._rules = rules;
|
|
19
|
-
|
|
20
|
-
this.register();
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
ElementTemplatesAppendProvider.$inject = [
|
|
24
|
-
'popupMenu',
|
|
25
|
-
'translate',
|
|
26
|
-
'elementTemplates',
|
|
27
|
-
'autoPlace',
|
|
28
|
-
'create',
|
|
29
|
-
'move',
|
|
30
|
-
'rules'
|
|
31
|
-
];
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Register append menu provider in the popup menu
|
|
35
|
-
*/
|
|
36
|
-
ElementTemplatesAppendProvider.prototype.register = function() {
|
|
37
|
-
this._popupMenu.registerProvider('bpmn-append', this);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Adds the element templates to the append menu.
|
|
42
|
-
* @param {djs.model.Base} element
|
|
43
|
-
*
|
|
44
|
-
* @returns {Object}
|
|
45
|
-
*/
|
|
46
|
-
ElementTemplatesAppendProvider.prototype.getPopupMenuEntries = function(element) {
|
|
47
|
-
return (entries) => {
|
|
48
|
-
|
|
49
|
-
if (!this._rules.allowed('shape.append', { element: element })) {
|
|
50
|
-
return [];
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const filteredTemplates = this._filterTemplates(this._elementTemplates.getLatest());
|
|
54
|
-
|
|
55
|
-
// add template entries
|
|
56
|
-
assign(entries, this.getTemplateEntries(element, filteredTemplates));
|
|
57
|
-
|
|
58
|
-
return entries;
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Get all element templates.
|
|
64
|
-
*
|
|
65
|
-
* @param {djs.model.Base} element
|
|
66
|
-
*
|
|
67
|
-
* @return {Object} element templates as menu entries
|
|
68
|
-
*/
|
|
69
|
-
ElementTemplatesAppendProvider.prototype.getTemplateEntries = function(element, templates) {
|
|
70
|
-
|
|
71
|
-
const templateEntries = {};
|
|
72
|
-
|
|
73
|
-
templates.map(template => {
|
|
74
|
-
|
|
75
|
-
const {
|
|
76
|
-
icon = {},
|
|
77
|
-
category,
|
|
78
|
-
} = template;
|
|
79
|
-
|
|
80
|
-
const entryId = `append.template-${template.id}`;
|
|
81
|
-
|
|
82
|
-
const defaultGroup = {
|
|
83
|
-
id: 'templates',
|
|
84
|
-
name: this._translate('Templates')
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
templateEntries[entryId] = {
|
|
88
|
-
label: template.name,
|
|
89
|
-
description: template.description,
|
|
90
|
-
documentationRef: template.documentationRef,
|
|
91
|
-
imageUrl: icon.contents,
|
|
92
|
-
group: category || defaultGroup,
|
|
93
|
-
action: this._getEntryAction(element, template)
|
|
94
|
-
};
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
return templateEntries;
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Filter out templates from the options.
|
|
102
|
-
*
|
|
103
|
-
* @param {Array<Object>} templates
|
|
104
|
-
*
|
|
105
|
-
* @returns {Array<Object>}
|
|
106
|
-
*/
|
|
107
|
-
ElementTemplatesAppendProvider.prototype._filterTemplates = function(templates) {
|
|
108
|
-
return templates.filter(template => {
|
|
109
|
-
const {
|
|
110
|
-
appliesTo,
|
|
111
|
-
elementType
|
|
112
|
-
} = template;
|
|
113
|
-
|
|
114
|
-
const type = (elementType && elementType.value) || appliesTo[0];
|
|
115
|
-
|
|
116
|
-
// elements that can not be appended
|
|
117
|
-
if ([
|
|
118
|
-
'bpmn:StartEvent',
|
|
119
|
-
'bpmn:Participant'
|
|
120
|
-
].includes(type)) {
|
|
121
|
-
return false;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// sequence flow templates are supported
|
|
125
|
-
// but connections are not appendable
|
|
126
|
-
if ('bpmn:SequenceFlow' === type) {
|
|
127
|
-
return false;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return true;
|
|
131
|
-
});
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Create an action for a given template.
|
|
136
|
-
*
|
|
137
|
-
* @param {djs.model.Base} element
|
|
138
|
-
* @param {Object} template
|
|
139
|
-
*
|
|
140
|
-
* @returns {Object}
|
|
141
|
-
*/
|
|
142
|
-
ElementTemplatesAppendProvider.prototype._getEntryAction = function(element, template) {
|
|
143
|
-
return {
|
|
144
|
-
|
|
145
|
-
click: () => {
|
|
146
|
-
const newElement = this._elementTemplates.createElement(template);
|
|
147
|
-
this._autoPlace.append(element, newElement);
|
|
148
|
-
},
|
|
149
|
-
|
|
150
|
-
dragstart: (event) => {
|
|
151
|
-
const newElement = this._elementTemplates.createElement(template);
|
|
152
|
-
|
|
153
|
-
if (event instanceof KeyboardEvent) {
|
|
154
|
-
event = this._mouse.getLastMoveEvent();
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
this._create.start(event, newElement, {
|
|
158
|
-
source: element
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
};
|
|
162
|
-
};
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { assign } from 'min-dash';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* A popup menu provider that allows to create elements with
|
|
5
|
-
* element templates.
|
|
6
|
-
*/
|
|
7
|
-
export default function ElementTemplatesCreateProvider(
|
|
8
|
-
popupMenu, translate, elementTemplates,
|
|
9
|
-
mouse, create) {
|
|
10
|
-
|
|
11
|
-
this._popupMenu = popupMenu;
|
|
12
|
-
this._translate = translate;
|
|
13
|
-
this._elementTemplates = elementTemplates;
|
|
14
|
-
this._mouse = mouse;
|
|
15
|
-
this._create = create;
|
|
16
|
-
|
|
17
|
-
this.register();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
ElementTemplatesCreateProvider.$inject = [
|
|
21
|
-
'popupMenu',
|
|
22
|
-
'translate',
|
|
23
|
-
'elementTemplates',
|
|
24
|
-
'mouse',
|
|
25
|
-
'create'
|
|
26
|
-
];
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Register create menu provider in the popup menu
|
|
30
|
-
*/
|
|
31
|
-
ElementTemplatesCreateProvider.prototype.register = function() {
|
|
32
|
-
this._popupMenu.registerProvider('bpmn-create', this);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Adds the element templates to the create menu.
|
|
37
|
-
* @param {djs.model.Base} element
|
|
38
|
-
*
|
|
39
|
-
* @returns {Object}
|
|
40
|
-
*/
|
|
41
|
-
ElementTemplatesCreateProvider.prototype.getPopupMenuEntries = function(element) {
|
|
42
|
-
return (entries) => {
|
|
43
|
-
|
|
44
|
-
// add template entries
|
|
45
|
-
assign(entries, this.getTemplateEntries(element));
|
|
46
|
-
|
|
47
|
-
return entries;
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Get all element templates.
|
|
53
|
-
*
|
|
54
|
-
* @param {djs.model.Base} element
|
|
55
|
-
*
|
|
56
|
-
* @return {Array<Object>} a list of element templates as menu entries
|
|
57
|
-
*/
|
|
58
|
-
ElementTemplatesCreateProvider.prototype.getTemplateEntries = function() {
|
|
59
|
-
|
|
60
|
-
const templates = this._elementTemplates.getLatest();
|
|
61
|
-
const templateEntries = {};
|
|
62
|
-
|
|
63
|
-
templates.map(template => {
|
|
64
|
-
|
|
65
|
-
const {
|
|
66
|
-
icon = {},
|
|
67
|
-
category,
|
|
68
|
-
} = template;
|
|
69
|
-
|
|
70
|
-
const entryId = `create.template-${template.id}`;
|
|
71
|
-
|
|
72
|
-
const defaultGroup = {
|
|
73
|
-
id: 'templates',
|
|
74
|
-
name: this._translate('Templates')
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
templateEntries[entryId] = {
|
|
78
|
-
label: template.name,
|
|
79
|
-
description: template.description,
|
|
80
|
-
documentationRef: template.documentationRef,
|
|
81
|
-
imageUrl: icon.contents,
|
|
82
|
-
group: category || defaultGroup,
|
|
83
|
-
action: {
|
|
84
|
-
click: this._getEntryAction(template),
|
|
85
|
-
dragstart: this._getEntryAction(template)
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
return templateEntries;
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
ElementTemplatesCreateProvider.prototype._getEntryAction = function(template) {
|
|
95
|
-
const create = this._create;
|
|
96
|
-
const popupMenu = this._popupMenu;
|
|
97
|
-
const elementTemplates = this._elementTemplates;
|
|
98
|
-
const mouse = this._mouse;
|
|
99
|
-
|
|
100
|
-
return (event) => {
|
|
101
|
-
|
|
102
|
-
popupMenu.close();
|
|
103
|
-
|
|
104
|
-
// create the new element
|
|
105
|
-
let newElement = elementTemplates.createElement(template);
|
|
106
|
-
|
|
107
|
-
// use last mouse event if triggered via keyboard
|
|
108
|
-
if (event instanceof KeyboardEvent) {
|
|
109
|
-
event = mouse.getLastMoveEvent();
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return create.start(event, newElement);
|
|
113
|
-
};
|
|
114
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import ElementTemplatesAppendProvider from './ElementTemplatesAppendProvider';
|
|
2
|
-
import ElementTemplatesCreateProvider from './ElementTemplatesCreateProvider';
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
__init__: [
|
|
6
|
-
'elementTemplatesAppendProvider',
|
|
7
|
-
'elementTemplatesCreateProvider'
|
|
8
|
-
],
|
|
9
|
-
elementTemplatesAppendProvider: [ 'type', ElementTemplatesAppendProvider ],
|
|
10
|
-
elementTemplatesCreateProvider: [ 'type', ElementTemplatesCreateProvider ]
|
|
11
|
-
};
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getBusinessObject,
|
|
3
|
-
isAny
|
|
4
|
-
} from 'bpmn-js/lib/util/ModelUtil';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* A replace menu provider that allows to replace elements with
|
|
9
|
-
* element templates.
|
|
10
|
-
*/
|
|
11
|
-
export default function ElementTemplatesReplaceProvider(popupMenu, translate, elementTemplates) {
|
|
12
|
-
|
|
13
|
-
this._popupMenu = popupMenu;
|
|
14
|
-
this._translate = translate;
|
|
15
|
-
this._elementTemplates = elementTemplates;
|
|
16
|
-
|
|
17
|
-
this.register();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
ElementTemplatesReplaceProvider.$inject = [
|
|
21
|
-
'popupMenu',
|
|
22
|
-
'translate',
|
|
23
|
-
'elementTemplates'
|
|
24
|
-
];
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Register replace menu provider in the popup menu
|
|
28
|
-
*/
|
|
29
|
-
ElementTemplatesReplaceProvider.prototype.register = function() {
|
|
30
|
-
this._popupMenu.registerProvider('bpmn-replace', this);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Adds the element templates to the replace menu.
|
|
35
|
-
* @param {djs.model.Base} element
|
|
36
|
-
*
|
|
37
|
-
* @returns {Object}
|
|
38
|
-
*/
|
|
39
|
-
ElementTemplatesReplaceProvider.prototype.getPopupMenuEntries = function(element) {
|
|
40
|
-
|
|
41
|
-
return (entries) => {
|
|
42
|
-
|
|
43
|
-
// convert our entries into something sortable
|
|
44
|
-
let entrySet = Object.entries(entries);
|
|
45
|
-
|
|
46
|
-
// add template entries
|
|
47
|
-
entrySet = [ ...entrySet, ...this.getTemplateEntries(element) ];
|
|
48
|
-
|
|
49
|
-
// convert back to object
|
|
50
|
-
return entrySet.reduce((entries, [ key, value ]) => {
|
|
51
|
-
entries[key] = value;
|
|
52
|
-
|
|
53
|
-
return entries;
|
|
54
|
-
}, {});
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Get all element templates that can be used to replace the given element.
|
|
60
|
-
*
|
|
61
|
-
* @param {djs.model.Base} element
|
|
62
|
-
*
|
|
63
|
-
* @return {Array<Object>} a list of element templates as menu entries
|
|
64
|
-
*/
|
|
65
|
-
ElementTemplatesReplaceProvider.prototype.getTemplateEntries = function(element) {
|
|
66
|
-
|
|
67
|
-
const templates = this._getMatchingTemplates(element);
|
|
68
|
-
return templates.map(template => {
|
|
69
|
-
|
|
70
|
-
const {
|
|
71
|
-
icon = {},
|
|
72
|
-
category,
|
|
73
|
-
} = template;
|
|
74
|
-
|
|
75
|
-
const entryId = `replace.template-${template.id}`;
|
|
76
|
-
|
|
77
|
-
const defaultGroup = {
|
|
78
|
-
id: 'templates',
|
|
79
|
-
name: this._translate('Templates')
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
return [ entryId, {
|
|
83
|
-
label: template.name,
|
|
84
|
-
description: template.description,
|
|
85
|
-
documentationRef: template.documentationRef,
|
|
86
|
-
imageUrl: icon.contents,
|
|
87
|
-
group: category || defaultGroup,
|
|
88
|
-
action: () => {
|
|
89
|
-
this._elementTemplates.applyTemplate(element, template);
|
|
90
|
-
}
|
|
91
|
-
} ];
|
|
92
|
-
});
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Returns the templates that can the element can be replaced with.
|
|
97
|
-
*
|
|
98
|
-
* @param {djs.model.Base} element
|
|
99
|
-
*
|
|
100
|
-
* @return {Array<ElementTemplate>}
|
|
101
|
-
*/
|
|
102
|
-
ElementTemplatesReplaceProvider.prototype._getMatchingTemplates = function(element) {
|
|
103
|
-
return this._elementTemplates.getLatest().filter(template => {
|
|
104
|
-
return isAny(element, template.appliesTo) && !isTemplateApplied(element, template);
|
|
105
|
-
});
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
// helpers ////////////
|
|
110
|
-
export function isTemplateApplied(element, template) {
|
|
111
|
-
const businessObject = getBusinessObject(element);
|
|
112
|
-
|
|
113
|
-
if (businessObject) {
|
|
114
|
-
return businessObject.get('zeebe:modelerTemplate') === template.id;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return false;
|
|
118
|
-
}
|