bpmn-js 9.0.0-subprocesses.0 → 9.0.0
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/CHANGELOG.md +73 -1
- package/dist/assets/bpmn-js.css +113 -0
- package/dist/assets/diagram-js.css +82 -78
- package/dist/bpmn-modeler.development.js +3402 -2196
- package/dist/bpmn-modeler.production.min.js +9 -8
- package/dist/bpmn-navigated-viewer.development.js +21207 -20345
- package/dist/bpmn-navigated-viewer.production.min.js +22 -20
- package/dist/bpmn-viewer.development.js +20401 -19562
- package/dist/bpmn-viewer.production.min.js +22 -20
- package/lib/BaseViewer.js +1 -1
- package/lib/Modeler.js +1 -4
- package/lib/Viewer.js +2 -2
- package/lib/draw/BpmnRenderer.js +8 -7
- package/lib/draw/PathMap.js +2 -2
- package/lib/features/auto-resize/BpmnAutoResizeProvider.js +9 -6
- package/lib/features/copy-paste/BpmnCopyPaste.js +1 -0
- package/lib/features/copy-paste/ModdleCopy.js +19 -2
- package/lib/features/di-ordering/BpmnDiOrdering.js +15 -11
- package/lib/features/drilldown/DrilldownBreadcrumbs.js +122 -0
- package/lib/features/drilldown/DrilldownCentering.js +118 -0
- package/lib/features/drilldown/DrilldownOverlayBehavior.js +181 -0
- package/lib/features/drilldown/SubprocessCompatibility.js +196 -0
- package/lib/features/drilldown/index.js +17 -0
- package/lib/features/label-editing/LabelEditingProvider.js +1 -1
- package/lib/features/label-editing/cmd/UpdateLabelHandler.js +29 -2
- package/lib/features/modeling/BpmnFactory.js +12 -8
- package/lib/features/modeling/BpmnUpdater.js +43 -6
- package/lib/features/modeling/ElementFactory.js +31 -13
- package/lib/features/modeling/behavior/CreateParticipantBehavior.js +59 -84
- package/lib/features/modeling/behavior/DropOnFlowBehavior.js +2 -2
- package/lib/features/modeling/behavior/RemoveEmbeddedLabelBoundsBehavior.js +34 -0
- package/lib/features/modeling/behavior/ResizeBehavior.js +129 -3
- package/lib/features/modeling/behavior/SubProcessPlaneBehavior.js +557 -0
- package/lib/features/modeling/behavior/ToggleCollapseConnectionBehaviour.js +74 -0
- package/lib/features/modeling/behavior/UnclaimIdBehavior.js +3 -1
- package/lib/features/modeling/behavior/index.js +27 -18
- package/lib/features/modeling/behavior/util/ResizeUtil.js +1 -132
- package/lib/features/modeling/cmd/SetColorHandler.js +23 -6
- package/lib/features/modeling/cmd/UpdateCanvasRootHandler.js +4 -2
- package/lib/features/modeling/util/ModelingUtil.js +2 -20
- package/lib/features/ordering/BpmnOrderingProvider.js +3 -3
- package/lib/features/palette/PaletteProvider.js +1 -1
- package/lib/features/popup-menu/ReplaceMenuProvider.js +1 -1
- package/lib/features/replace/BpmnReplace.js +38 -16
- package/lib/import/BpmnImporter.js +19 -13
- package/lib/import/BpmnTreeWalker.js +2 -2
- package/lib/import/Importer.js +134 -14
- package/lib/util/DiUtil.js +1 -0
- package/lib/util/DrilldownUtil.js +66 -0
- package/lib/util/ModelUtil.js +19 -0
- package/package.json +2 -2
- package/test/util/MockEvents.js +10 -2
- package/lib/features/collapsed-subprocesses/DeleteBehaviour.js +0 -65
- package/lib/features/collapsed-subprocesses/ToggleCollapseBehaviour.js +0 -133
- package/lib/features/collapsed-subprocesses/diagramFactory.js +0 -56
- package/lib/features/collapsed-subprocesses/index.js +0 -12
- package/lib/features/collapsed-subprocesses-navigation/CollapsedSubprocessNavigation.js +0 -198
- package/lib/features/collapsed-subprocesses-navigation/index.js +0 -7
package/lib/import/Importer.js
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
find,
|
|
3
|
+
forEach,
|
|
4
|
+
map
|
|
5
|
+
} from 'min-dash';
|
|
6
|
+
|
|
1
7
|
import BpmnTreeWalker from './BpmnTreeWalker';
|
|
2
8
|
|
|
9
|
+
import { is } from '../util/ModelUtil';
|
|
10
|
+
|
|
3
11
|
|
|
4
12
|
/**
|
|
5
13
|
* The importBpmnDiagram result.
|
|
@@ -50,12 +58,12 @@ export function importBpmnDiagram(diagram, definitions, bpmnDiagram) {
|
|
|
50
58
|
|
|
51
59
|
var visitor = {
|
|
52
60
|
|
|
53
|
-
root: function(element) {
|
|
54
|
-
return importer.add(element);
|
|
61
|
+
root: function(element, di) {
|
|
62
|
+
return importer.add(element, di);
|
|
55
63
|
},
|
|
56
64
|
|
|
57
|
-
element: function(element, parentShape) {
|
|
58
|
-
return importer.add(element, parentShape);
|
|
65
|
+
element: function(element, di, parentShape) {
|
|
66
|
+
return importer.add(element, di, parentShape);
|
|
59
67
|
},
|
|
60
68
|
|
|
61
69
|
error: function(message, context) {
|
|
@@ -65,18 +73,29 @@ export function importBpmnDiagram(diagram, definitions, bpmnDiagram) {
|
|
|
65
73
|
|
|
66
74
|
var walker = new BpmnTreeWalker(visitor, translate);
|
|
67
75
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
walker.handleDefinitions(definitions, bpmnDiagram);
|
|
76
|
+
|
|
77
|
+
bpmnDiagram = bpmnDiagram || (definitions.diagrams && definitions.diagrams[0]);
|
|
78
|
+
|
|
79
|
+
var diagramsToImport = getDiagramsToImport(definitions, bpmnDiagram);
|
|
80
|
+
|
|
81
|
+
if (!diagramsToImport) {
|
|
82
|
+
throw new Error(translate('no diagram to display'));
|
|
76
83
|
}
|
|
77
84
|
|
|
78
|
-
|
|
79
|
-
|
|
85
|
+
// traverse BPMN 2.0 document model,
|
|
86
|
+
// starting at definitions
|
|
87
|
+
forEach(diagramsToImport, function(diagram) {
|
|
88
|
+
walker.handleDefinitions(definitions, diagram);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
var rootId = bpmnDiagram.plane.bpmnElement.id;
|
|
92
|
+
|
|
93
|
+
// we do need to account for different ways we create root elements
|
|
94
|
+
// each nested imported <root> do have the `_plane` suffix, while
|
|
95
|
+
// the root <root> is found under the business object ID
|
|
96
|
+
canvas.setRootElement(
|
|
97
|
+
canvas.findRoot(rootId + '_plane') || canvas.findRoot(rootId)
|
|
98
|
+
);
|
|
80
99
|
}
|
|
81
100
|
|
|
82
101
|
return new Promise(function(resolve, reject) {
|
|
@@ -103,3 +122,104 @@ export function importBpmnDiagram(diagram, definitions, bpmnDiagram) {
|
|
|
103
122
|
}
|
|
104
123
|
});
|
|
105
124
|
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Returns all diagrams in the same hirarchy as the requested diagram.
|
|
128
|
+
* Includes all parent and sub process diagrams.
|
|
129
|
+
*
|
|
130
|
+
* @param {Array} definitions
|
|
131
|
+
* @param {Object} bpmnDiagram
|
|
132
|
+
*
|
|
133
|
+
* @returns {Array<Object>}
|
|
134
|
+
*/
|
|
135
|
+
function getDiagramsToImport(definitions, bpmnDiagram) {
|
|
136
|
+
if (!bpmnDiagram) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
var bpmnElement = bpmnDiagram.plane.bpmnElement,
|
|
141
|
+
rootElement = bpmnElement;
|
|
142
|
+
|
|
143
|
+
if (!is(bpmnElement, 'bpmn:Process') && !is(bpmnElement, 'bpmn:Collaboration')) {
|
|
144
|
+
rootElement = findRootProcess(bpmnElement);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// in case the process is part of a collaboration, the plane references the
|
|
148
|
+
// collaboration, not the process
|
|
149
|
+
var collaboration;
|
|
150
|
+
|
|
151
|
+
if (is(rootElement, 'bpmn:Collaboration')) {
|
|
152
|
+
collaboration = rootElement;
|
|
153
|
+
} else {
|
|
154
|
+
collaboration = find(definitions.rootElements, function(element) {
|
|
155
|
+
if (!is(element, 'bpmn:Collaboration')) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return find(element.participants, function(participant) {
|
|
160
|
+
return participant.processRef === rootElement;
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
var rootElements = [ rootElement ];
|
|
166
|
+
|
|
167
|
+
// all collaboration processes can contain sub-diagrams
|
|
168
|
+
if (collaboration) {
|
|
169
|
+
rootElements = map(collaboration.participants, function(participant) {
|
|
170
|
+
return participant.processRef;
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
rootElements.push(collaboration);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
var allChildren = selfAndAllFlowElements(rootElements);
|
|
177
|
+
|
|
178
|
+
// if we have multiple diagrams referencing the same element, we
|
|
179
|
+
// use the first in the file
|
|
180
|
+
var diagramsToImport = [ bpmnDiagram ];
|
|
181
|
+
var handledElements = [ bpmnElement ];
|
|
182
|
+
|
|
183
|
+
forEach(definitions.diagrams, function(diagram) {
|
|
184
|
+
var businessObject = diagram.plane.bpmnElement;
|
|
185
|
+
|
|
186
|
+
if (
|
|
187
|
+
allChildren.indexOf(businessObject) !== -1 &&
|
|
188
|
+
handledElements.indexOf(businessObject) === -1
|
|
189
|
+
) {
|
|
190
|
+
diagramsToImport.push(diagram);
|
|
191
|
+
handledElements.push(businessObject);
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
return diagramsToImport;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function selfAndAllFlowElements(elements) {
|
|
200
|
+
var result = [];
|
|
201
|
+
|
|
202
|
+
forEach(elements, function(element) {
|
|
203
|
+
if (!element) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
result.push(element);
|
|
208
|
+
|
|
209
|
+
result = result.concat(selfAndAllFlowElements(element.flowElements));
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
return result;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function findRootProcess(element) {
|
|
216
|
+
var parent = element;
|
|
217
|
+
|
|
218
|
+
while (parent) {
|
|
219
|
+
if (is(parent, 'bpmn:Process')) {
|
|
220
|
+
return parent;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
parent = parent.$parent;
|
|
224
|
+
}
|
|
225
|
+
}
|
package/lib/util/DiUtil.js
CHANGED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { getDi, is } from './ModelUtil';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export var planeSuffix = '_plane';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Get primary shape ID for a plane.
|
|
8
|
+
*
|
|
9
|
+
* @param {djs.model.Base|ModdleElement} element
|
|
10
|
+
*
|
|
11
|
+
* @returns {String}
|
|
12
|
+
*/
|
|
13
|
+
export function getShapeIdFromPlane(element) {
|
|
14
|
+
var id = element.id;
|
|
15
|
+
|
|
16
|
+
return removePlaneSuffix(id);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Get plane ID for a primary shape.
|
|
21
|
+
*
|
|
22
|
+
* @param {djs.model.Base|ModdleElement} element
|
|
23
|
+
*
|
|
24
|
+
* @returns {String}
|
|
25
|
+
*/
|
|
26
|
+
export function getPlaneIdFromShape(element) {
|
|
27
|
+
var id = element.id;
|
|
28
|
+
|
|
29
|
+
if (is(element, 'bpmn:SubProcess')) {
|
|
30
|
+
return addPlaneSuffix(id);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return id;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Get plane ID for primary shape ID.
|
|
38
|
+
*
|
|
39
|
+
* @param {String} id
|
|
40
|
+
*
|
|
41
|
+
* @returns {String}
|
|
42
|
+
*/
|
|
43
|
+
export function toPlaneId(id) {
|
|
44
|
+
return addPlaneSuffix(id);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Check wether element is plane.
|
|
49
|
+
*
|
|
50
|
+
* @param {djs.model.Base|ModdleElement} element
|
|
51
|
+
*
|
|
52
|
+
* @returns {Boolean}
|
|
53
|
+
*/
|
|
54
|
+
export function isPlane(element) {
|
|
55
|
+
var di = getDi(element);
|
|
56
|
+
|
|
57
|
+
return is(di, 'bpmndi:BPMNPlane');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function addPlaneSuffix(id) {
|
|
61
|
+
return id + planeSuffix;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function removePlaneSuffix(id) {
|
|
65
|
+
return id.replace(new RegExp(planeSuffix + '$'), '');
|
|
66
|
+
}
|
package/lib/util/ModelUtil.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import {
|
|
2
|
+
some
|
|
3
|
+
} from 'min-dash';
|
|
4
|
+
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* Is an element of the given BPMN type?
|
|
3
8
|
*
|
|
@@ -13,6 +18,20 @@ export function is(element, type) {
|
|
|
13
18
|
}
|
|
14
19
|
|
|
15
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Return true if element has any of the given types.
|
|
23
|
+
*
|
|
24
|
+
* @param {djs.model.Base} element
|
|
25
|
+
* @param {Array<string>} types
|
|
26
|
+
*
|
|
27
|
+
* @return {boolean}
|
|
28
|
+
*/
|
|
29
|
+
export function isAny(element, types) {
|
|
30
|
+
return some(types, function(t) {
|
|
31
|
+
return is(element, t);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
16
35
|
/**
|
|
17
36
|
* Return the business object for a given element.
|
|
18
37
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bpmn-js",
|
|
3
|
-
"version": "9.0.0
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"description": "A bpmn 2.0 toolkit and web modeler",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"dependencies": {
|
|
101
101
|
"bpmn-moddle": "^7.1.2",
|
|
102
102
|
"css.escape": "^1.5.1",
|
|
103
|
-
"diagram-js": "
|
|
103
|
+
"diagram-js": "^8.1.1",
|
|
104
104
|
"diagram-js-direct-editing": "^1.6.3",
|
|
105
105
|
"ids": "^1.0.0",
|
|
106
106
|
"inherits": "^2.0.4",
|
package/test/util/MockEvents.js
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
* specified canvas local coordinates.
|
|
14
14
|
*
|
|
15
15
|
* @param {Point} point of the event local the canvas (closure)
|
|
16
|
-
* @param {Object} data
|
|
16
|
+
* @param {Object} [data]
|
|
17
17
|
*
|
|
18
18
|
* @return {Event} event, scoped to the given canvas
|
|
19
19
|
*/
|
|
@@ -34,7 +34,15 @@ export function createCanvasEvent(position, data) {
|
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Create an Event
|
|
39
|
+
*
|
|
40
|
+
* @param {Element} target
|
|
41
|
+
* @param { { x: number, y: number } } position
|
|
42
|
+
* @param {any} [data]
|
|
43
|
+
*
|
|
44
|
+
* @return {Event}
|
|
45
|
+
*/
|
|
38
46
|
export function createEvent(target, position, data) {
|
|
39
47
|
|
|
40
48
|
return getBpmnJS().invoke(function(eventBus) {
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import inherits from 'inherits';
|
|
2
|
-
|
|
3
|
-
import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
|
|
4
|
-
|
|
5
|
-
import { is } from '../../util/ModelUtil';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export default function RemoveDiagramBehavior(canvas, bpmnjs, injector, elementRegistry, commandStack) {
|
|
9
|
-
|
|
10
|
-
var removeNestedProcesses = function(process) {
|
|
11
|
-
var removedProcesses = [];
|
|
12
|
-
|
|
13
|
-
process.flowElements && process.flowElements.forEach(element => {
|
|
14
|
-
if (is(element, 'bpmn:SubProcess')) {
|
|
15
|
-
removedProcesses = removedProcesses.concat(removeNestedProcesses(element));
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
var removedDi = removeProcess(process.id);
|
|
20
|
-
|
|
21
|
-
if (removedDi) {
|
|
22
|
-
removedProcesses.push(removedDi);
|
|
23
|
-
}
|
|
24
|
-
return removedProcesses;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
injector.invoke(CommandInterceptor, this);
|
|
28
|
-
|
|
29
|
-
this.executed('shape.delete', function(event) {
|
|
30
|
-
var context = event.context;
|
|
31
|
-
|
|
32
|
-
if (is(context.shape, 'bpmn:SubProcess')) {
|
|
33
|
-
var removedDi = removeNestedProcesses(context.shape.businessObject);
|
|
34
|
-
context.removedDiDiagrams = removedDi;
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
this.reverted('shape.delete', function(event) {
|
|
39
|
-
var context = event.context;
|
|
40
|
-
|
|
41
|
-
if (is(context.shape, 'bpmn:SubProcess') && context.removedDiDiagrams) {
|
|
42
|
-
var diagrams = bpmnjs.getDefinitions().diagrams;
|
|
43
|
-
Array.prototype.push.apply(diagrams, context.removedDiDiagrams);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
// Util
|
|
48
|
-
var removeProcess = function(id) {
|
|
49
|
-
var diagrams = bpmnjs.getDefinitions().diagrams,
|
|
50
|
-
removedDiagram;
|
|
51
|
-
var diagramIndex = diagrams.findIndex(element => {
|
|
52
|
-
return element.plane.bpmnElement.id === id;
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
if (diagramIndex > -1) {
|
|
56
|
-
removedDiagram = diagrams[diagramIndex];
|
|
57
|
-
diagrams.splice(diagramIndex, 1);
|
|
58
|
-
}
|
|
59
|
-
return removedDiagram;
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
inherits(RemoveDiagramBehavior, CommandInterceptor);
|
|
64
|
-
|
|
65
|
-
RemoveDiagramBehavior.$inject = [ 'canvas', 'bpmnjs', 'injector', 'elementRegistry', 'commandStack' ];
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import inherits from 'inherits';
|
|
2
|
-
|
|
3
|
-
import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
find
|
|
7
|
-
} from 'min-dash';
|
|
8
|
-
|
|
9
|
-
import { getBusinessObject, getDi, is } from '../../util/ModelUtil';
|
|
10
|
-
import { selfAndAllChildren } from '../../../../diagram-js/lib/util/Elements';
|
|
11
|
-
|
|
12
|
-
var HIGH_PRIORITY = 5000;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export default function ExpandBehaviour(commandStack, injector, canvas, bpmnImporter, bpmnUpdater, bpmnjs, elementRegistry, eventBus, modeling, bpmnFactory) {
|
|
16
|
-
|
|
17
|
-
injector.invoke(CommandInterceptor, this);
|
|
18
|
-
|
|
19
|
-
var handler = function(event) {
|
|
20
|
-
const shape = event.context.shape;
|
|
21
|
-
const diagrams = bpmnjs.getDefinitions().diagrams;
|
|
22
|
-
|
|
23
|
-
if (!is(shape, 'bpmn:SubProcess')) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (!shape.collapsed) {
|
|
28
|
-
|
|
29
|
-
// expand
|
|
30
|
-
var oldDiagram = findDiagram(shape.id);
|
|
31
|
-
var newDiagram = findRootDiagram(getDi(shape));
|
|
32
|
-
|
|
33
|
-
// Add elements to parent diagram
|
|
34
|
-
oldDiagram.plane.planeElement.forEach(di => {
|
|
35
|
-
var childElement = elementRegistry.get(di.bpmnElement.id);
|
|
36
|
-
var bo = childElement.businessObject;
|
|
37
|
-
var parent = elementRegistry.get(bo.$parent.id);
|
|
38
|
-
|
|
39
|
-
if (parent === shape) {
|
|
40
|
-
childElement.parent = shape;
|
|
41
|
-
eventBus.fire('elements.changed', { elements: [childElement] });
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// reorder di
|
|
45
|
-
newDiagram.plane.planeElement.push(di);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
diagrams.splice(diagrams.indexOf(oldDiagram), 1);
|
|
49
|
-
|
|
50
|
-
// debugger;
|
|
51
|
-
canvas.setRootElementForPlane(null, shape.id, true);
|
|
52
|
-
elementRegistry.remove(shape.id + '_layer');
|
|
53
|
-
} else {
|
|
54
|
-
|
|
55
|
-
// Collapse
|
|
56
|
-
var bo = getBusinessObject(shape);
|
|
57
|
-
newDiagram = createDiagram(shape);
|
|
58
|
-
diagrams.push(newDiagram);
|
|
59
|
-
console.log(shape, bo, newDiagram.plane);
|
|
60
|
-
var newShape = bpmnImporter.add({ element: bo, di: newDiagram.plane });
|
|
61
|
-
var planeElements = newDiagram.plane.get('planeElement');
|
|
62
|
-
|
|
63
|
-
oldDiagram = findRootDiagram(getDi(shape));
|
|
64
|
-
|
|
65
|
-
selfAndAllChildren(shape).forEach(function(childShape) {
|
|
66
|
-
if (childShape === shape) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (childShape.parent === shape) {
|
|
71
|
-
childShape.parent = newShape;
|
|
72
|
-
}
|
|
73
|
-
childShape.hidden = false;
|
|
74
|
-
|
|
75
|
-
var di = getDi(childShape);
|
|
76
|
-
|
|
77
|
-
// Remove DI from old Plane and add it to the new one
|
|
78
|
-
var parentPlaneElements = oldDiagram.plane.get('planeElement');
|
|
79
|
-
parentPlaneElements.splice(parentPlaneElements.indexOf(di), 1);
|
|
80
|
-
planeElements.push(di);
|
|
81
|
-
|
|
82
|
-
eventBus.fire('elements.changed', { elements: [childShape] });
|
|
83
|
-
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
bo.flowElements.forEach(el => {
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
this.executed([ 'shape.toggleCollapse' ], HIGH_PRIORITY, handler);
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
this.reverted([ 'shape.toggleCollapse' ], HIGH_PRIORITY, handler);
|
|
95
|
-
|
|
96
|
-
// Util
|
|
97
|
-
|
|
98
|
-
var findRootDiagram = function(element) {
|
|
99
|
-
if (is(element, 'bpmndi:BPMNDiagram')) {
|
|
100
|
-
return element;
|
|
101
|
-
} else {
|
|
102
|
-
return findRootDiagram(element.$parent);
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
var findDiagram = function(id) {
|
|
107
|
-
return find(bpmnjs.getDefinitions().diagrams, function(diagram) {
|
|
108
|
-
const plane = diagram.plane,
|
|
109
|
-
bpmnElement = plane.bpmnElement;
|
|
110
|
-
|
|
111
|
-
console.log(diagram, bpmnElement, id);
|
|
112
|
-
return bpmnElement.id === id;
|
|
113
|
-
});
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
var createDiagram = function(shape) {
|
|
117
|
-
var bo = getBusinessObject(shape);
|
|
118
|
-
var plane = bpmnFactory.createDiPlane(bo);
|
|
119
|
-
var diagram = bpmnFactory.create('bpmndi:BPMNDiagram', {
|
|
120
|
-
plane: plane
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
// shape.di = plane;
|
|
124
|
-
plane.$parent = diagram;
|
|
125
|
-
plane.bpmnElement = bo;
|
|
126
|
-
diagram.$parent = bpmnjs.getDefinitions();
|
|
127
|
-
return diagram;
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
inherits(ExpandBehaviour, CommandInterceptor);
|
|
132
|
-
|
|
133
|
-
ExpandBehaviour.$inject = [ 'commandStack', 'injector', 'canvas', 'bpmnImporter', 'bpmnUpdater', 'bpmnjs', 'elementRegistry', 'eventBus', 'modeling', 'bpmnFactory' ];
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
find
|
|
3
|
-
} from 'min-dash';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export default function DiagramRegistry(bpmnjs, bpmnFactory) {
|
|
7
|
-
this._bpmnjs = bpmnjs;
|
|
8
|
-
this._bpmnFactory = bpmnFactory;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
DiagramRegistry.prototype.getDefinitions = function() {
|
|
12
|
-
return this._bpmnjs._definitions || [];
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
DiagramRegistry.prototype.getDiagrams = function() {
|
|
16
|
-
return this.getDefinitions().diagrams || [];
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
DiagramRegistry.prototype.findDiagram = function(id) {
|
|
20
|
-
return find(this._bpmnjs.getDefinitions().diagrams, function(diagram) {
|
|
21
|
-
const plane = diagram.plane,
|
|
22
|
-
bpmnElement = plane.bpmnElement;
|
|
23
|
-
|
|
24
|
-
return bpmnElement.id === id;
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
DiagramRegistry.prototype.createProcess = function() {
|
|
29
|
-
var process = this._bpmnFactory.create('bpmn:Process', {});
|
|
30
|
-
process.$parent = this.getDefinitions();
|
|
31
|
-
return process;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
DiagramRegistry.prototype.createDiagram = function(rootElement) {
|
|
35
|
-
var plane = this._bpmnFactory.createDiPlane(rootElement);
|
|
36
|
-
var diagram = this._bpmnFactory.create('bpmndi:BPMNDiagram', {
|
|
37
|
-
plane: plane
|
|
38
|
-
});
|
|
39
|
-
rootElement.di = plane;
|
|
40
|
-
plane.$parent = diagram;
|
|
41
|
-
plane.bpmnElement = rootElement;
|
|
42
|
-
diagram.$parent = this.getDefinitions();
|
|
43
|
-
return diagram;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
DiagramRegistry.prototype.removeProcess = function(id) {
|
|
47
|
-
let diagramIndex = this.getDiagrams().findIndex(element => {
|
|
48
|
-
return element.plane.bpmnElement.id === id;
|
|
49
|
-
});
|
|
50
|
-
if (diagramIndex > -1) {
|
|
51
|
-
this.getDiagrams().splice(diagramIndex, 1);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
DiagramRegistry.$inject = ['bpmnjs', 'bpmnFactory'];
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import ExpandBehaviour from './ToggleCollapseBehaviour';
|
|
2
|
-
import RemoveDiagramBehavior from './DeleteBehaviour';
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
__depends__: [ ],
|
|
6
|
-
__init__: [
|
|
7
|
-
'removeDiagramBehavior',
|
|
8
|
-
'expandBehaviour'
|
|
9
|
-
],
|
|
10
|
-
removeDiagramBehavior: ['type', RemoveDiagramBehavior],
|
|
11
|
-
expandBehaviour: ['type', ExpandBehaviour]
|
|
12
|
-
};
|