bpmn-js 9.0.0-subprocesses.3 → 9.0.2
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 +50 -0
- package/dist/assets/bpmn-js.css +44 -7
- package/dist/assets/diagram-js.css +1 -1
- package/dist/bpmn-modeler.development.js +2424 -1130
- package/dist/bpmn-modeler.production.min.js +8 -8
- package/dist/bpmn-navigated-viewer.development.js +990 -317
- package/dist/bpmn-navigated-viewer.production.min.js +6 -6
- package/dist/bpmn-viewer.development.js +989 -316
- package/dist/bpmn-viewer.production.min.js +6 -6
- package/lib/BaseViewer.js +1 -1
- package/lib/draw/BpmnRenderer.js +8 -7
- package/lib/features/auto-resize/BpmnAutoResizeProvider.js +6 -0
- package/lib/features/copy-paste/BpmnCopyPaste.js +1 -0
- package/lib/features/di-ordering/BpmnDiOrdering.js +15 -11
- package/lib/features/drilldown/DrilldownBreadcrumbs.js +122 -0
- package/lib/features/drilldown/DrilldownCentering.js +87 -10
- package/lib/features/drilldown/DrilldownOverlayBehavior.js +181 -0
- package/lib/features/drilldown/SubprocessCompatibility.js +15 -7
- package/lib/features/drilldown/index.js +7 -4
- 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 +5 -1
- package/lib/features/modeling/BpmnUpdater.js +43 -1
- package/lib/features/modeling/ElementFactory.js +4 -0
- package/lib/features/modeling/behavior/CreateParticipantBehavior.js +59 -84
- package/lib/features/modeling/behavior/DropOnFlowBehavior.js +2 -2
- package/lib/features/modeling/behavior/GroupBehavior.js +6 -18
- package/lib/features/modeling/behavior/RemoveEmbeddedLabelBoundsBehavior.js +34 -0
- 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/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/import/BpmnImporter.js +15 -9
- package/lib/import/Importer.js +130 -10
- package/lib/util/DrilldownUtil.js +66 -0
- package/lib/util/ModelUtil.js +19 -0
- package/package.json +2 -2
- package/lib/features/drilldown/DrilldownOverlays.js +0 -110
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* bpmn-js - bpmn-viewer v9.0.
|
|
2
|
+
* bpmn-js - bpmn-viewer v9.0.2
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) 2014-present, camunda Services GmbH
|
|
5
5
|
*
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* Source Code: https://github.com/bpmn-io/bpmn-js
|
|
10
10
|
*
|
|
11
|
-
* Date:
|
|
11
|
+
* Date: 2022-02-23
|
|
12
12
|
*/
|
|
13
13
|
(function (global, factory) {
|
|
14
14
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
@@ -207,6 +207,23 @@
|
|
|
207
207
|
function some(collection, matcher) {
|
|
208
208
|
return !!find(collection, matcher);
|
|
209
209
|
}
|
|
210
|
+
/**
|
|
211
|
+
* Transform a collection into another collection
|
|
212
|
+
* by piping each member through the given fn.
|
|
213
|
+
*
|
|
214
|
+
* @param {Object|Array} collection
|
|
215
|
+
* @param {Function} fn
|
|
216
|
+
*
|
|
217
|
+
* @return {Array} transformed collection
|
|
218
|
+
*/
|
|
219
|
+
|
|
220
|
+
function map$1(collection, fn) {
|
|
221
|
+
var result = [];
|
|
222
|
+
forEach(collection, function (val, key) {
|
|
223
|
+
result.push(fn(val, key));
|
|
224
|
+
});
|
|
225
|
+
return result;
|
|
226
|
+
}
|
|
210
227
|
/**
|
|
211
228
|
* Create an object pattern matcher.
|
|
212
229
|
*
|
|
@@ -214,7 +231,7 @@
|
|
|
214
231
|
*
|
|
215
232
|
* const matcher = matchPattern({ id: 1 });
|
|
216
233
|
*
|
|
217
|
-
*
|
|
234
|
+
* let element = find(elements, matcher);
|
|
218
235
|
*
|
|
219
236
|
* @param {Object} pattern
|
|
220
237
|
*
|
|
@@ -244,8 +261,11 @@
|
|
|
244
261
|
}
|
|
245
262
|
|
|
246
263
|
/**
|
|
247
|
-
* Debounce fn, calling it only once if
|
|
248
|
-
*
|
|
264
|
+
* Debounce fn, calling it only once if the given time
|
|
265
|
+
* elapsed between calls.
|
|
266
|
+
*
|
|
267
|
+
* Lodash-style the function exposes methods to `#clear`
|
|
268
|
+
* and `#flush` to control internal behavior.
|
|
249
269
|
*
|
|
250
270
|
* @param {Function} fn
|
|
251
271
|
* @param {Number} timeout
|
|
@@ -258,23 +278,39 @@
|
|
|
258
278
|
var lastThis;
|
|
259
279
|
var lastNow;
|
|
260
280
|
|
|
261
|
-
function fire() {
|
|
281
|
+
function fire(force) {
|
|
262
282
|
var now = Date.now();
|
|
263
|
-
var scheduledDiff = lastNow + timeout - now;
|
|
283
|
+
var scheduledDiff = force ? 0 : lastNow + timeout - now;
|
|
264
284
|
|
|
265
285
|
if (scheduledDiff > 0) {
|
|
266
286
|
return schedule(scheduledDiff);
|
|
267
287
|
}
|
|
268
288
|
|
|
269
289
|
fn.apply(lastThis, lastArgs);
|
|
270
|
-
|
|
290
|
+
clear();
|
|
271
291
|
}
|
|
272
292
|
|
|
273
293
|
function schedule(timeout) {
|
|
274
294
|
timer = setTimeout(fire, timeout);
|
|
275
295
|
}
|
|
276
296
|
|
|
277
|
-
|
|
297
|
+
function clear() {
|
|
298
|
+
if (timer) {
|
|
299
|
+
clearTimeout(timer);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
timer = lastNow = lastArgs = lastThis = undefined;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
function flush() {
|
|
306
|
+
if (timer) {
|
|
307
|
+
fire(true);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
clear();
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function callback() {
|
|
278
314
|
lastNow = Date.now();
|
|
279
315
|
|
|
280
316
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
@@ -287,7 +323,11 @@
|
|
|
287
323
|
if (!timer) {
|
|
288
324
|
schedule(timeout);
|
|
289
325
|
}
|
|
290
|
-
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
callback.flush = flush;
|
|
329
|
+
callback.cancel = clear;
|
|
330
|
+
return callback;
|
|
291
331
|
}
|
|
292
332
|
/**
|
|
293
333
|
* Bind function against target <this>.
|
|
@@ -476,7 +516,6 @@
|
|
|
476
516
|
return bo && (typeof bo.$instanceOf === 'function') && bo.$instanceOf(type);
|
|
477
517
|
}
|
|
478
518
|
|
|
479
|
-
|
|
480
519
|
/**
|
|
481
520
|
* Return the business object for a given element.
|
|
482
521
|
*
|
|
@@ -2530,16 +2569,16 @@
|
|
|
2530
2569
|
return drawPath(parentGfx, path, assign({ 'data-marker': type }, attrs));
|
|
2531
2570
|
}
|
|
2532
2571
|
|
|
2572
|
+
function renderer(type) {
|
|
2573
|
+
return handlers[type];
|
|
2574
|
+
}
|
|
2575
|
+
|
|
2533
2576
|
function as(type) {
|
|
2534
2577
|
return function(parentGfx, element) {
|
|
2535
|
-
return
|
|
2578
|
+
return renderer(type)(parentGfx, element);
|
|
2536
2579
|
};
|
|
2537
2580
|
}
|
|
2538
2581
|
|
|
2539
|
-
function renderer(type) {
|
|
2540
|
-
return handlers[type];
|
|
2541
|
-
}
|
|
2542
|
-
|
|
2543
2582
|
function renderEventContent(element, parentGfx) {
|
|
2544
2583
|
|
|
2545
2584
|
var event = getSemantic(element);
|
|
@@ -4020,6 +4059,7 @@
|
|
|
4020
4059
|
// extension API, use at your own risk
|
|
4021
4060
|
this._drawPath = drawPath;
|
|
4022
4061
|
|
|
4062
|
+
this._renderer = renderer;
|
|
4023
4063
|
}
|
|
4024
4064
|
|
|
4025
4065
|
|
|
@@ -4041,7 +4081,7 @@
|
|
|
4041
4081
|
|
|
4042
4082
|
BpmnRenderer.prototype.drawShape = function(parentGfx, element) {
|
|
4043
4083
|
var type = element.type;
|
|
4044
|
-
var h = this.
|
|
4084
|
+
var h = this._renderer(type);
|
|
4045
4085
|
|
|
4046
4086
|
/* jshint -W040 */
|
|
4047
4087
|
return h(parentGfx, element);
|
|
@@ -4049,7 +4089,7 @@
|
|
|
4049
4089
|
|
|
4050
4090
|
BpmnRenderer.prototype.drawConnection = function(parentGfx, element) {
|
|
4051
4091
|
var type = element.type;
|
|
4052
|
-
var h = this.
|
|
4092
|
+
var h = this._renderer(type);
|
|
4053
4093
|
|
|
4054
4094
|
/* jshint -W040 */
|
|
4055
4095
|
return h(parentGfx, element);
|
|
@@ -5259,6 +5299,13 @@
|
|
|
5259
5299
|
return '<' + e.$type + (e.id ? ' id="' + e.id : '') + '" />';
|
|
5260
5300
|
}
|
|
5261
5301
|
|
|
5302
|
+
/**
|
|
5303
|
+
* @param {ModdleElement} semantic
|
|
5304
|
+
* @param {ModdleElement} di
|
|
5305
|
+
* @param {Object} [attrs=null]
|
|
5306
|
+
*
|
|
5307
|
+
* @return {Object}
|
|
5308
|
+
*/
|
|
5262
5309
|
function elementData(semantic, di, attrs) {
|
|
5263
5310
|
return assign({
|
|
5264
5311
|
id: semantic.id,
|
|
@@ -5338,15 +5385,14 @@
|
|
|
5338
5385
|
// invisible root element (process, subprocess or collaboration)
|
|
5339
5386
|
if (is$1(di, 'bpmndi:BPMNPlane')) {
|
|
5340
5387
|
|
|
5341
|
-
|
|
5342
|
-
|
|
5388
|
+
var attrs = is$1(semantic, 'bpmn:SubProcess')
|
|
5389
|
+
? { id: semantic.id + '_plane' }
|
|
5390
|
+
: {};
|
|
5343
5391
|
|
|
5344
|
-
//
|
|
5345
|
-
|
|
5346
|
-
element.id = element.id + '_plane';
|
|
5347
|
-
}
|
|
5392
|
+
// add a virtual element (not being drawn)
|
|
5393
|
+
element = this._elementFactory.createRoot(elementData(semantic, di, attrs));
|
|
5348
5394
|
|
|
5349
|
-
this._canvas.
|
|
5395
|
+
this._canvas.addRootElement(element);
|
|
5350
5396
|
}
|
|
5351
5397
|
|
|
5352
5398
|
// SHAPE
|
|
@@ -5382,7 +5428,7 @@
|
|
|
5382
5428
|
|
|
5383
5429
|
// check whether data store is inside our outside of its semantic parent
|
|
5384
5430
|
if (!isPointInsideBBox(parentElement, getMid(bounds))) {
|
|
5385
|
-
parentElement = this._canvas.
|
|
5431
|
+
parentElement = this._canvas.findRoot(parentElement);
|
|
5386
5432
|
}
|
|
5387
5433
|
}
|
|
5388
5434
|
|
|
@@ -5410,7 +5456,7 @@
|
|
|
5410
5456
|
// are rendered correctly across different "hacks" people
|
|
5411
5457
|
// love to model such as cross participant / sub process
|
|
5412
5458
|
// associations
|
|
5413
|
-
parentElement = this._canvas.
|
|
5459
|
+
parentElement = this._canvas.findRoot(parentElement);
|
|
5414
5460
|
}
|
|
5415
5461
|
|
|
5416
5462
|
// insert sequence flows behind other flow nodes (cf. #727)
|
|
@@ -5644,7 +5690,7 @@
|
|
|
5644
5690
|
return isPrimaryButton(event) || isAuxiliaryButton(event);
|
|
5645
5691
|
}
|
|
5646
5692
|
|
|
5647
|
-
var LOW_PRIORITY$
|
|
5693
|
+
var LOW_PRIORITY$3 = 500;
|
|
5648
5694
|
|
|
5649
5695
|
|
|
5650
5696
|
/**
|
|
@@ -5839,7 +5885,7 @@
|
|
|
5839
5885
|
eventBus.on([
|
|
5840
5886
|
'shape.changed',
|
|
5841
5887
|
'connection.changed'
|
|
5842
|
-
], LOW_PRIORITY$
|
|
5888
|
+
], LOW_PRIORITY$3, function(event) {
|
|
5843
5889
|
|
|
5844
5890
|
var element = event.element,
|
|
5845
5891
|
gfx = event.gfx;
|
|
@@ -5847,7 +5893,7 @@
|
|
|
5847
5893
|
eventBus.fire('interactionEvents.updateHit', { element: element, gfx: gfx });
|
|
5848
5894
|
});
|
|
5849
5895
|
|
|
5850
|
-
eventBus.on('interactionEvents.createHit', LOW_PRIORITY$
|
|
5896
|
+
eventBus.on('interactionEvents.createHit', LOW_PRIORITY$3, function(event) {
|
|
5851
5897
|
var element = event.element,
|
|
5852
5898
|
gfx = event.gfx;
|
|
5853
5899
|
|
|
@@ -6195,7 +6241,7 @@
|
|
|
6195
6241
|
return !!(element && element.isFrame);
|
|
6196
6242
|
}
|
|
6197
6243
|
|
|
6198
|
-
var LOW_PRIORITY$
|
|
6244
|
+
var LOW_PRIORITY$2 = 500;
|
|
6199
6245
|
|
|
6200
6246
|
|
|
6201
6247
|
/**
|
|
@@ -6233,7 +6279,7 @@
|
|
|
6233
6279
|
|
|
6234
6280
|
// A low priortity is necessary, because outlines of labels have to be updated
|
|
6235
6281
|
// after the label bounds have been updated in the renderer.
|
|
6236
|
-
eventBus.on([ 'shape.added', 'shape.changed' ], LOW_PRIORITY$
|
|
6282
|
+
eventBus.on([ 'shape.added', 'shape.changed' ], LOW_PRIORITY$2, function(event) {
|
|
6237
6283
|
var element = event.element,
|
|
6238
6284
|
gfx = event.gfx;
|
|
6239
6285
|
|
|
@@ -6330,7 +6376,7 @@
|
|
|
6330
6376
|
self.deselect(element);
|
|
6331
6377
|
});
|
|
6332
6378
|
|
|
6333
|
-
eventBus.on([ 'diagram.clear', '
|
|
6379
|
+
eventBus.on([ 'diagram.clear', 'root.set' ], function(e) {
|
|
6334
6380
|
self.select(null);
|
|
6335
6381
|
});
|
|
6336
6382
|
}
|
|
@@ -6383,10 +6429,12 @@
|
|
|
6383
6429
|
|
|
6384
6430
|
var canvas = this._canvas;
|
|
6385
6431
|
|
|
6432
|
+
var rootElement = canvas.getRootElement();
|
|
6433
|
+
|
|
6386
6434
|
elements = elements.filter(function(element) {
|
|
6387
|
-
var
|
|
6435
|
+
var elementRoot = canvas.findRoot(element);
|
|
6388
6436
|
|
|
6389
|
-
return
|
|
6437
|
+
return rootElement === elementRoot;
|
|
6390
6438
|
});
|
|
6391
6439
|
|
|
6392
6440
|
// selection may be cleared by passing an empty array or null
|
|
@@ -6627,7 +6675,7 @@
|
|
|
6627
6675
|
// document wide unique overlay ids
|
|
6628
6676
|
var ids = new IdGenerator('ov');
|
|
6629
6677
|
|
|
6630
|
-
var LOW_PRIORITY = 500;
|
|
6678
|
+
var LOW_PRIORITY$1 = 500;
|
|
6631
6679
|
|
|
6632
6680
|
|
|
6633
6681
|
/**
|
|
@@ -6857,8 +6905,7 @@
|
|
|
6857
6905
|
*
|
|
6858
6906
|
* @see Overlays#get for filter options.
|
|
6859
6907
|
*
|
|
6860
|
-
* @param {string} [
|
|
6861
|
-
* @param {Object} [filter]
|
|
6908
|
+
* @param {string|object} [filter]
|
|
6862
6909
|
*/
|
|
6863
6910
|
Overlays.prototype.remove = function(filter) {
|
|
6864
6911
|
|
|
@@ -6974,6 +7021,7 @@
|
|
|
6974
7021
|
}
|
|
6975
7022
|
|
|
6976
7023
|
setPosition(htmlContainer, left || 0, top || 0);
|
|
7024
|
+
this._updateOverlayVisibilty(overlay, this._canvas.viewbox());
|
|
6977
7025
|
};
|
|
6978
7026
|
|
|
6979
7027
|
|
|
@@ -7057,12 +7105,10 @@
|
|
|
7057
7105
|
classes(htmlContainer).add('djs-overlay-' + overlay.type);
|
|
7058
7106
|
}
|
|
7059
7107
|
|
|
7060
|
-
var
|
|
7061
|
-
var
|
|
7062
|
-
|
|
7063
|
-
|
|
7064
|
-
setVisible(htmlContainer, false);
|
|
7065
|
-
}
|
|
7108
|
+
var elementRoot = this._canvas.findRoot(element);
|
|
7109
|
+
var activeRoot = this._canvas.getRootElement();
|
|
7110
|
+
|
|
7111
|
+
setVisible(htmlContainer, elementRoot === activeRoot);
|
|
7066
7112
|
|
|
7067
7113
|
overlay.htmlContainer = htmlContainer;
|
|
7068
7114
|
|
|
@@ -7078,14 +7124,14 @@
|
|
|
7078
7124
|
|
|
7079
7125
|
Overlays.prototype._updateOverlayVisibilty = function(overlay, viewbox) {
|
|
7080
7126
|
var show = overlay.show,
|
|
7081
|
-
|
|
7127
|
+
rootElement = this._canvas.findRoot(overlay.element),
|
|
7082
7128
|
minZoom = show && show.minZoom,
|
|
7083
7129
|
maxZoom = show && show.maxZoom,
|
|
7084
7130
|
htmlContainer = overlay.htmlContainer,
|
|
7085
|
-
|
|
7131
|
+
activeRootElement = this._canvas.getRootElement(),
|
|
7086
7132
|
visible = true;
|
|
7087
7133
|
|
|
7088
|
-
if (
|
|
7134
|
+
if (rootElement !== activeRootElement) {
|
|
7089
7135
|
visible = false;
|
|
7090
7136
|
} else if (show) {
|
|
7091
7137
|
if (
|
|
@@ -7196,7 +7242,7 @@
|
|
|
7196
7242
|
|
|
7197
7243
|
// move integration
|
|
7198
7244
|
|
|
7199
|
-
eventBus.on('element.changed', LOW_PRIORITY, function(e) {
|
|
7245
|
+
eventBus.on('element.changed', LOW_PRIORITY$1, function(e) {
|
|
7200
7246
|
var element = e.element;
|
|
7201
7247
|
|
|
7202
7248
|
var container = self._getOverlayContainer(element, true);
|
|
@@ -7221,10 +7267,8 @@
|
|
|
7221
7267
|
});
|
|
7222
7268
|
|
|
7223
7269
|
|
|
7224
|
-
eventBus.on('
|
|
7225
|
-
|
|
7226
|
-
setVisible(el.htmlContainer, el.plane === e.plane);
|
|
7227
|
-
});
|
|
7270
|
+
eventBus.on('root.set', function() {
|
|
7271
|
+
self._updateOverlaysVisibilty(self._canvas.viewbox());
|
|
7228
7272
|
});
|
|
7229
7273
|
|
|
7230
7274
|
// clear overlays with diagram
|
|
@@ -7337,6 +7381,181 @@
|
|
|
7337
7381
|
changeSupport: [ 'type', ChangeSupport ]
|
|
7338
7382
|
};
|
|
7339
7383
|
|
|
7384
|
+
var DEFAULT_PRIORITY$1 = 1000;
|
|
7385
|
+
|
|
7386
|
+
/**
|
|
7387
|
+
* A utility that can be used to plug-in into the command execution for
|
|
7388
|
+
* extension and/or validation.
|
|
7389
|
+
*
|
|
7390
|
+
* @param {EventBus} eventBus
|
|
7391
|
+
*
|
|
7392
|
+
* @example
|
|
7393
|
+
*
|
|
7394
|
+
* import inherits from 'inherits';
|
|
7395
|
+
*
|
|
7396
|
+
* import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
|
|
7397
|
+
*
|
|
7398
|
+
* function CommandLogger(eventBus) {
|
|
7399
|
+
* CommandInterceptor.call(this, eventBus);
|
|
7400
|
+
*
|
|
7401
|
+
* this.preExecute(function(event) {
|
|
7402
|
+
* console.log('command pre-execute', event);
|
|
7403
|
+
* });
|
|
7404
|
+
* }
|
|
7405
|
+
*
|
|
7406
|
+
* inherits(CommandLogger, CommandInterceptor);
|
|
7407
|
+
*
|
|
7408
|
+
*/
|
|
7409
|
+
function CommandInterceptor(eventBus) {
|
|
7410
|
+
this._eventBus = eventBus;
|
|
7411
|
+
}
|
|
7412
|
+
|
|
7413
|
+
CommandInterceptor.$inject = [ 'eventBus' ];
|
|
7414
|
+
|
|
7415
|
+
function unwrapEvent(fn, that) {
|
|
7416
|
+
return function(event) {
|
|
7417
|
+
return fn.call(that || null, event.context, event.command, event);
|
|
7418
|
+
};
|
|
7419
|
+
}
|
|
7420
|
+
|
|
7421
|
+
/**
|
|
7422
|
+
* Register an interceptor for a command execution
|
|
7423
|
+
*
|
|
7424
|
+
* @param {string|Array<string>} [events] list of commands to register on
|
|
7425
|
+
* @param {string} [hook] command hook, i.e. preExecute, executed to listen on
|
|
7426
|
+
* @param {number} [priority] the priority on which to hook into the execution
|
|
7427
|
+
* @param {Function} handlerFn interceptor to be invoked with (event)
|
|
7428
|
+
* @param {boolean} unwrap if true, unwrap the event and pass (context, command, event) to the
|
|
7429
|
+
* listener instead
|
|
7430
|
+
* @param {Object} [that] Pass context (`this`) to the handler function
|
|
7431
|
+
*/
|
|
7432
|
+
CommandInterceptor.prototype.on = function(events, hook, priority, handlerFn, unwrap, that) {
|
|
7433
|
+
|
|
7434
|
+
if (isFunction(hook) || isNumber(hook)) {
|
|
7435
|
+
that = unwrap;
|
|
7436
|
+
unwrap = handlerFn;
|
|
7437
|
+
handlerFn = priority;
|
|
7438
|
+
priority = hook;
|
|
7439
|
+
hook = null;
|
|
7440
|
+
}
|
|
7441
|
+
|
|
7442
|
+
if (isFunction(priority)) {
|
|
7443
|
+
that = unwrap;
|
|
7444
|
+
unwrap = handlerFn;
|
|
7445
|
+
handlerFn = priority;
|
|
7446
|
+
priority = DEFAULT_PRIORITY$1;
|
|
7447
|
+
}
|
|
7448
|
+
|
|
7449
|
+
if (isObject(unwrap)) {
|
|
7450
|
+
that = unwrap;
|
|
7451
|
+
unwrap = false;
|
|
7452
|
+
}
|
|
7453
|
+
|
|
7454
|
+
if (!isFunction(handlerFn)) {
|
|
7455
|
+
throw new Error('handlerFn must be a function');
|
|
7456
|
+
}
|
|
7457
|
+
|
|
7458
|
+
if (!isArray$1(events)) {
|
|
7459
|
+
events = [ events ];
|
|
7460
|
+
}
|
|
7461
|
+
|
|
7462
|
+
var eventBus = this._eventBus;
|
|
7463
|
+
|
|
7464
|
+
forEach(events, function(event) {
|
|
7465
|
+
|
|
7466
|
+
// concat commandStack(.event)?(.hook)?
|
|
7467
|
+
var fullEvent = [ 'commandStack', event, hook ].filter(function(e) { return e; }).join('.');
|
|
7468
|
+
|
|
7469
|
+
eventBus.on(fullEvent, priority, unwrap ? unwrapEvent(handlerFn, that) : handlerFn, that);
|
|
7470
|
+
});
|
|
7471
|
+
};
|
|
7472
|
+
|
|
7473
|
+
|
|
7474
|
+
var hooks = [
|
|
7475
|
+
'canExecute',
|
|
7476
|
+
'preExecute',
|
|
7477
|
+
'preExecuted',
|
|
7478
|
+
'execute',
|
|
7479
|
+
'executed',
|
|
7480
|
+
'postExecute',
|
|
7481
|
+
'postExecuted',
|
|
7482
|
+
'revert',
|
|
7483
|
+
'reverted'
|
|
7484
|
+
];
|
|
7485
|
+
|
|
7486
|
+
/*
|
|
7487
|
+
* Install hook shortcuts
|
|
7488
|
+
*
|
|
7489
|
+
* This will generate the CommandInterceptor#(preExecute|...|reverted) methods
|
|
7490
|
+
* which will in term forward to CommandInterceptor#on.
|
|
7491
|
+
*/
|
|
7492
|
+
forEach(hooks, function(hook) {
|
|
7493
|
+
|
|
7494
|
+
/**
|
|
7495
|
+
* {canExecute|preExecute|preExecuted|execute|executed|postExecute|postExecuted|revert|reverted}
|
|
7496
|
+
*
|
|
7497
|
+
* A named hook for plugging into the command execution
|
|
7498
|
+
*
|
|
7499
|
+
* @param {string|Array<string>} [events] list of commands to register on
|
|
7500
|
+
* @param {number} [priority] the priority on which to hook into the execution
|
|
7501
|
+
* @param {Function} handlerFn interceptor to be invoked with (event)
|
|
7502
|
+
* @param {boolean} [unwrap=false] if true, unwrap the event and pass (context, command, event) to the
|
|
7503
|
+
* listener instead
|
|
7504
|
+
* @param {Object} [that] Pass context (`this`) to the handler function
|
|
7505
|
+
*/
|
|
7506
|
+
CommandInterceptor.prototype[hook] = function(events, priority, handlerFn, unwrap, that) {
|
|
7507
|
+
|
|
7508
|
+
if (isFunction(events) || isNumber(events)) {
|
|
7509
|
+
that = unwrap;
|
|
7510
|
+
unwrap = handlerFn;
|
|
7511
|
+
handlerFn = priority;
|
|
7512
|
+
priority = events;
|
|
7513
|
+
events = null;
|
|
7514
|
+
}
|
|
7515
|
+
|
|
7516
|
+
this.on(events, hook, priority, handlerFn, unwrap, that);
|
|
7517
|
+
};
|
|
7518
|
+
});
|
|
7519
|
+
|
|
7520
|
+
/**
|
|
7521
|
+
* A modeling behavior that ensures we set the correct root element
|
|
7522
|
+
* as we undo and redo commands.
|
|
7523
|
+
*
|
|
7524
|
+
* @param {Canvas} canvas
|
|
7525
|
+
* @param {didi.Injector} injector
|
|
7526
|
+
*/
|
|
7527
|
+
function RootElementsBehavior(canvas, injector) {
|
|
7528
|
+
|
|
7529
|
+
injector.invoke(CommandInterceptor, this);
|
|
7530
|
+
|
|
7531
|
+
this.executed(function(event) {
|
|
7532
|
+
var context = event.context;
|
|
7533
|
+
|
|
7534
|
+
if (context.rootElement) {
|
|
7535
|
+
canvas.setRootElement(context.rootElement);
|
|
7536
|
+
} else {
|
|
7537
|
+
context.rootElement = canvas.getRootElement();
|
|
7538
|
+
}
|
|
7539
|
+
});
|
|
7540
|
+
|
|
7541
|
+
this.revert(function(event) {
|
|
7542
|
+
var context = event.context;
|
|
7543
|
+
|
|
7544
|
+
if (context.rootElement) {
|
|
7545
|
+
canvas.setRootElement(context.rootElement);
|
|
7546
|
+
}
|
|
7547
|
+
});
|
|
7548
|
+
}
|
|
7549
|
+
|
|
7550
|
+
inherits$1(RootElementsBehavior, CommandInterceptor);
|
|
7551
|
+
|
|
7552
|
+
RootElementsBehavior.$inject = [ 'canvas', 'injector'];
|
|
7553
|
+
|
|
7554
|
+
var RootElementsModule = {
|
|
7555
|
+
__init__: [ 'rootElementsBehavior' ],
|
|
7556
|
+
rootElementsBehavior: [ 'type', RootElementsBehavior ]
|
|
7557
|
+
};
|
|
7558
|
+
|
|
7340
7559
|
var css_escape = {exports: {}};
|
|
7341
7560
|
|
|
7342
7561
|
/*! https://mths.be/cssescape v1.5.1 by @mathias | MIT license */
|
|
@@ -7459,39 +7678,94 @@
|
|
|
7459
7678
|
});
|
|
7460
7679
|
}
|
|
7461
7680
|
|
|
7462
|
-
var
|
|
7681
|
+
var planeSuffix = '_plane';
|
|
7682
|
+
|
|
7683
|
+
/**
|
|
7684
|
+
* Get plane ID for a primary shape.
|
|
7685
|
+
*
|
|
7686
|
+
* @param {djs.model.Base|ModdleElement} element
|
|
7687
|
+
*
|
|
7688
|
+
* @returns {String}
|
|
7689
|
+
*/
|
|
7690
|
+
function getPlaneIdFromShape(element) {
|
|
7691
|
+
var id = element.id;
|
|
7692
|
+
|
|
7693
|
+
if (is$1(element, 'bpmn:SubProcess')) {
|
|
7694
|
+
return addPlaneSuffix(id);
|
|
7695
|
+
}
|
|
7696
|
+
|
|
7697
|
+
return id;
|
|
7698
|
+
}
|
|
7699
|
+
|
|
7700
|
+
function addPlaneSuffix(id) {
|
|
7701
|
+
return id + planeSuffix;
|
|
7702
|
+
}
|
|
7463
7703
|
|
|
7464
7704
|
var OPEN_CLASS = 'bjs-breadcrumbs-shown';
|
|
7465
7705
|
|
|
7706
|
+
|
|
7466
7707
|
/**
|
|
7467
|
-
* Adds
|
|
7708
|
+
* Adds overlays that allow switching planes on collapsed subprocesses.
|
|
7468
7709
|
*
|
|
7469
7710
|
* @param {eventBus} eventBus
|
|
7470
7711
|
* @param {elementRegistry} elementRegistry
|
|
7471
7712
|
* @param {overlays} overlays
|
|
7472
7713
|
* @param {canvas} canvas
|
|
7473
7714
|
*/
|
|
7474
|
-
function
|
|
7715
|
+
function DrilldownBreadcrumbs(eventBus, elementRegistry, overlays, canvas) {
|
|
7475
7716
|
var breadcrumbs = domify('<ul class="bjs-breadcrumbs"></ul>');
|
|
7476
7717
|
var container = canvas.getContainer();
|
|
7477
7718
|
var containerClasses = classes(container);
|
|
7478
7719
|
container.appendChild(breadcrumbs);
|
|
7479
7720
|
|
|
7480
|
-
|
|
7481
|
-
|
|
7482
|
-
|
|
7721
|
+
var boParents = [];
|
|
7722
|
+
|
|
7723
|
+
// update breadcrumbs if name or ID of the primary shape changes
|
|
7724
|
+
eventBus.on('element.changed', function(e) {
|
|
7725
|
+
var shape = e.element,
|
|
7726
|
+
bo = getBusinessObject(shape);
|
|
7727
|
+
|
|
7728
|
+
var isPresent = find(boParents, function(el) {
|
|
7729
|
+
return el === bo;
|
|
7730
|
+
});
|
|
7483
7731
|
|
|
7484
|
-
|
|
7485
|
-
|
|
7732
|
+
if (!isPresent) {
|
|
7733
|
+
return;
|
|
7734
|
+
}
|
|
7735
|
+
|
|
7736
|
+
updateBreadcrumbs();
|
|
7737
|
+
});
|
|
7738
|
+
|
|
7739
|
+
/**
|
|
7740
|
+
* Updates the displayed breadcrumbs. If no element is provided, only the
|
|
7741
|
+
* labels are updated.
|
|
7742
|
+
*
|
|
7743
|
+
* @param {djs.model.Base} [element]
|
|
7744
|
+
*/
|
|
7745
|
+
function updateBreadcrumbs(element) {
|
|
7746
|
+
if (element) {
|
|
7747
|
+
boParents = getBoParentChain(element);
|
|
7748
|
+
}
|
|
7749
|
+
|
|
7750
|
+
var path = boParents.map(function(parent) {
|
|
7751
|
+
var title = escapeHTML(parent.name || parent.id);
|
|
7486
7752
|
var link = domify('<li><span class="bjs-crumb"><a title="' + title + '">' + title + '</a></span></li>');
|
|
7487
7753
|
|
|
7754
|
+
var parentPlane = canvas.findRoot(getPlaneIdFromShape(parent)) || canvas.findRoot(parent.id);
|
|
7755
|
+
|
|
7756
|
+
// when the root is a collaboration, the process does not have a corresponding
|
|
7757
|
+
// element in the elementRegisty. Instead, we search for the corresponding participant
|
|
7758
|
+
if (!parentPlane && is$1(parent, 'bpmn:Process')) {
|
|
7759
|
+
var participant = elementRegistry.find(function(element) {
|
|
7760
|
+
var bo = getBusinessObject(element);
|
|
7761
|
+
return bo && bo.processRef && bo.processRef === parent;
|
|
7762
|
+
});
|
|
7763
|
+
|
|
7764
|
+
parentPlane = canvas.findRoot(participant.id);
|
|
7765
|
+
}
|
|
7766
|
+
|
|
7488
7767
|
link.addEventListener('click', function() {
|
|
7489
|
-
|
|
7490
|
-
canvas.setActivePlane(el.id);
|
|
7491
|
-
} else {
|
|
7492
|
-
var plane = canvas.findPlane(el.id);
|
|
7493
|
-
canvas.setActivePlane(plane);
|
|
7494
|
-
}
|
|
7768
|
+
canvas.setRootElement(parentPlane);
|
|
7495
7769
|
});
|
|
7496
7770
|
|
|
7497
7771
|
return link;
|
|
@@ -7508,50 +7782,26 @@
|
|
|
7508
7782
|
});
|
|
7509
7783
|
}
|
|
7510
7784
|
|
|
7511
|
-
eventBus.on('
|
|
7512
|
-
|
|
7513
|
-
|
|
7514
|
-
updateBreadcrumbs(plane);
|
|
7785
|
+
eventBus.on('root.set', function(event) {
|
|
7786
|
+
updateBreadcrumbs(event.element);
|
|
7515
7787
|
});
|
|
7516
7788
|
|
|
7517
|
-
var createOverlay = function(element) {
|
|
7518
|
-
var html = domify('<button class="bjs-drilldown">' + ARROW_DOWN_SVG + '</button>');
|
|
7519
|
-
|
|
7520
|
-
html.addEventListener('click', function() {
|
|
7521
|
-
canvas.setActivePlane(element.id);
|
|
7522
|
-
});
|
|
7523
|
-
|
|
7524
|
-
overlays.add(element, {
|
|
7525
|
-
position: {
|
|
7526
|
-
bottom: -7,
|
|
7527
|
-
right: -8
|
|
7528
|
-
},
|
|
7529
|
-
html: html
|
|
7530
|
-
});
|
|
7531
|
-
};
|
|
7532
|
-
|
|
7533
|
-
var addOverlays = function(elements) {
|
|
7534
|
-
elements.forEach(function(element) {
|
|
7535
|
-
if (is$1(element, 'bpmn:SubProcess')
|
|
7536
|
-
&& element.collapsed
|
|
7537
|
-
&& canvas.getPlane(element.id)) {
|
|
7538
|
-
createOverlay(element);
|
|
7539
|
-
}
|
|
7540
|
-
});
|
|
7541
|
-
};
|
|
7542
|
-
|
|
7543
|
-
eventBus.on('import.done', function() {
|
|
7544
|
-
addOverlays(elementRegistry.filter(function(el) {
|
|
7545
|
-
return is$1(el, 'bpmn:SubProcess');
|
|
7546
|
-
}));
|
|
7547
|
-
});
|
|
7548
7789
|
}
|
|
7549
7790
|
|
|
7550
|
-
|
|
7791
|
+
DrilldownBreadcrumbs.$inject = [ 'eventBus', 'elementRegistry', 'overlays', 'canvas' ];
|
|
7551
7792
|
|
|
7552
7793
|
|
|
7553
|
-
// helpers
|
|
7554
|
-
|
|
7794
|
+
// helpers //////////
|
|
7795
|
+
|
|
7796
|
+
/**
|
|
7797
|
+
* Returns the parents for the element using the business object chain,
|
|
7798
|
+
* starting with the root element.
|
|
7799
|
+
*
|
|
7800
|
+
* @param {djs.model.Shape} child
|
|
7801
|
+
*
|
|
7802
|
+
* @returns {Array<djs.model.Shape>} parents
|
|
7803
|
+
*/
|
|
7804
|
+
function getBoParentChain(child) {
|
|
7555
7805
|
var bo = getBusinessObject(child);
|
|
7556
7806
|
|
|
7557
7807
|
var parents = [];
|
|
@@ -7563,29 +7813,40 @@
|
|
|
7563
7813
|
}
|
|
7564
7814
|
|
|
7565
7815
|
return parents.reverse();
|
|
7566
|
-
}
|
|
7816
|
+
}
|
|
7567
7817
|
|
|
7568
7818
|
/**
|
|
7569
|
-
* Move collapsed subprocesses into view when drilling down.
|
|
7570
|
-
*
|
|
7819
|
+
* Move collapsed subprocesses into view when drilling down.
|
|
7820
|
+
*
|
|
7821
|
+
* Zoom and scroll are saved in a session.
|
|
7571
7822
|
*
|
|
7572
7823
|
* @param {eventBus} eventBus
|
|
7573
7824
|
* @param {canvas} canvas
|
|
7574
7825
|
*/
|
|
7575
7826
|
function DrilldownCentering(eventBus, canvas) {
|
|
7576
|
-
var currentPlane = 'base';
|
|
7577
|
-
var positionMap = {};
|
|
7578
7827
|
|
|
7579
|
-
|
|
7828
|
+
var currentRoot = null;
|
|
7829
|
+
var positionMap = new Map();
|
|
7830
|
+
|
|
7831
|
+
eventBus.on('root.set', function(event) {
|
|
7832
|
+
var newRoot = event.element;
|
|
7580
7833
|
var currentViewbox = canvas.viewbox();
|
|
7581
|
-
|
|
7834
|
+
var storedViewbox = positionMap.get(newRoot);
|
|
7835
|
+
|
|
7836
|
+
positionMap.set(currentRoot, {
|
|
7582
7837
|
x: currentViewbox.x,
|
|
7583
7838
|
y: currentViewbox.y,
|
|
7584
7839
|
zoom: currentViewbox.scale
|
|
7585
|
-
};
|
|
7840
|
+
});
|
|
7586
7841
|
|
|
7587
|
-
|
|
7588
|
-
|
|
7842
|
+
currentRoot = newRoot;
|
|
7843
|
+
|
|
7844
|
+
// current root was replaced with a collaboration, we don't update the viewbox
|
|
7845
|
+
if (is$1(newRoot, 'bpmn:Collaboration') && !storedViewbox) {
|
|
7846
|
+
return;
|
|
7847
|
+
}
|
|
7848
|
+
|
|
7849
|
+
storedViewbox = storedViewbox || { x: 0, y: 0, zoom: 1 };
|
|
7589
7850
|
|
|
7590
7851
|
var dx = (currentViewbox.x - storedViewbox.x) * currentViewbox.scale,
|
|
7591
7852
|
dy = (currentViewbox.y - storedViewbox.y) * currentViewbox.scale;
|
|
@@ -7600,13 +7861,77 @@
|
|
|
7600
7861
|
if (storedViewbox.zoom !== currentViewbox.scale) {
|
|
7601
7862
|
canvas.zoom(storedViewbox.zoom, { x: 0, y: 0 });
|
|
7602
7863
|
}
|
|
7864
|
+
});
|
|
7603
7865
|
|
|
7604
|
-
|
|
7866
|
+
eventBus.on('diagram.clear', function() {
|
|
7867
|
+
positionMap.clear();
|
|
7868
|
+
currentRoot = null;
|
|
7605
7869
|
});
|
|
7870
|
+
|
|
7606
7871
|
}
|
|
7607
7872
|
|
|
7608
7873
|
DrilldownCentering.$inject = [ 'eventBus', 'canvas' ];
|
|
7609
7874
|
|
|
7875
|
+
|
|
7876
|
+
/**
|
|
7877
|
+
* ES5 Map implementation. Works.
|
|
7878
|
+
*/
|
|
7879
|
+
function Map() {
|
|
7880
|
+
|
|
7881
|
+
this._entries = [];
|
|
7882
|
+
|
|
7883
|
+
this.set = function(key, value) {
|
|
7884
|
+
|
|
7885
|
+
var found = false;
|
|
7886
|
+
|
|
7887
|
+
for (var k in this._entries) {
|
|
7888
|
+
if (this._entries[k][0] === key) {
|
|
7889
|
+
this._entries[k][1] = value;
|
|
7890
|
+
|
|
7891
|
+
found = true;
|
|
7892
|
+
|
|
7893
|
+
break;
|
|
7894
|
+
}
|
|
7895
|
+
}
|
|
7896
|
+
|
|
7897
|
+
if (!found) {
|
|
7898
|
+
this._entries.push([ key, value ]);
|
|
7899
|
+
}
|
|
7900
|
+
};
|
|
7901
|
+
|
|
7902
|
+
this.get = function(key) {
|
|
7903
|
+
|
|
7904
|
+
for (var k in this._entries) {
|
|
7905
|
+
if (this._entries[k][0] === key) {
|
|
7906
|
+
return this._entries[k][1];
|
|
7907
|
+
}
|
|
7908
|
+
}
|
|
7909
|
+
|
|
7910
|
+
return null;
|
|
7911
|
+
};
|
|
7912
|
+
|
|
7913
|
+
this.clear = function() {
|
|
7914
|
+
this._entries.length = 0;
|
|
7915
|
+
};
|
|
7916
|
+
|
|
7917
|
+
this.remove = function(key) {
|
|
7918
|
+
|
|
7919
|
+
var idx = -1;
|
|
7920
|
+
|
|
7921
|
+
for (var k in this._entries) {
|
|
7922
|
+
if (this._entries[k][0] === key) {
|
|
7923
|
+
idx = k;
|
|
7924
|
+
|
|
7925
|
+
break;
|
|
7926
|
+
}
|
|
7927
|
+
}
|
|
7928
|
+
|
|
7929
|
+
if (idx !== -1) {
|
|
7930
|
+
this._entries.splice(idx, 1);
|
|
7931
|
+
}
|
|
7932
|
+
};
|
|
7933
|
+
}
|
|
7934
|
+
|
|
7610
7935
|
var DEFAULT_POSITION = {
|
|
7611
7936
|
x: 180,
|
|
7612
7937
|
y: 160
|
|
@@ -7673,6 +7998,11 @@
|
|
|
7673
7998
|
|
|
7674
7999
|
plane.get('planeElement').forEach(function(diElement) {
|
|
7675
8000
|
var bo = diElement.bpmnElement;
|
|
8001
|
+
|
|
8002
|
+
if (!bo) {
|
|
8003
|
+
return;
|
|
8004
|
+
}
|
|
8005
|
+
|
|
7676
8006
|
var parent = bo.$parent;
|
|
7677
8007
|
|
|
7678
8008
|
if (is$1(bo, 'bpmn:SubProcess') && !diElement.isExpanded) {
|
|
@@ -7688,12 +8018,21 @@
|
|
|
7688
8018
|
|
|
7689
8019
|
var newDiagrams = [];
|
|
7690
8020
|
|
|
8021
|
+
// create new planes for all collapsed subprocesses, even when they are empty
|
|
8022
|
+
collapsedElements.forEach(function(element) {
|
|
8023
|
+
if (!self._processToDiagramMap[element.id]) {
|
|
8024
|
+
var diagram = self.createDiagram(element);
|
|
8025
|
+
self._processToDiagramMap[element.id] = diagram;
|
|
8026
|
+
newDiagrams.push(diagram);
|
|
8027
|
+
}
|
|
8028
|
+
});
|
|
8029
|
+
|
|
7691
8030
|
elementsToMove.forEach(function(element) {
|
|
7692
8031
|
var diElement = element.diElement;
|
|
7693
8032
|
var parent = element.parent;
|
|
7694
8033
|
|
|
7695
8034
|
// parent is expanded, get nearest collapsed parent
|
|
7696
|
-
while (parent &&
|
|
8035
|
+
while (parent && collapsedElements.indexOf(parent) === -1) {
|
|
7697
8036
|
parent = parent.$parent;
|
|
7698
8037
|
}
|
|
7699
8038
|
|
|
@@ -7703,12 +8042,6 @@
|
|
|
7703
8042
|
}
|
|
7704
8043
|
|
|
7705
8044
|
var diagram = self._processToDiagramMap[parent.id];
|
|
7706
|
-
if (!diagram) {
|
|
7707
|
-
diagram = self.createDiagram(parent);
|
|
7708
|
-
self._processToDiagramMap[parent.id] = diagram;
|
|
7709
|
-
newDiagrams.push(diagram);
|
|
7710
|
-
}
|
|
7711
|
-
|
|
7712
8045
|
self.moveToDiPlane(diElement, diagram.plane);
|
|
7713
8046
|
});
|
|
7714
8047
|
|
|
@@ -7775,33 +8108,209 @@
|
|
|
7775
8108
|
}
|
|
7776
8109
|
}
|
|
7777
8110
|
|
|
7778
|
-
function getPlaneBounds(plane) {
|
|
7779
|
-
var planeTrbl = {
|
|
7780
|
-
top: Infinity,
|
|
7781
|
-
right: -Infinity,
|
|
7782
|
-
bottom: -Infinity,
|
|
7783
|
-
left: Infinity
|
|
7784
|
-
};
|
|
8111
|
+
function getPlaneBounds(plane) {
|
|
8112
|
+
var planeTrbl = {
|
|
8113
|
+
top: Infinity,
|
|
8114
|
+
right: -Infinity,
|
|
8115
|
+
bottom: -Infinity,
|
|
8116
|
+
left: Infinity
|
|
8117
|
+
};
|
|
8118
|
+
|
|
8119
|
+
plane.planeElement.forEach(function(element) {
|
|
8120
|
+
if (!element.bounds) {
|
|
8121
|
+
return;
|
|
8122
|
+
}
|
|
8123
|
+
|
|
8124
|
+
var trbl = asTRBL(element.bounds);
|
|
8125
|
+
|
|
8126
|
+
planeTrbl.top = Math.min(trbl.top, planeTrbl.top);
|
|
8127
|
+
planeTrbl.left = Math.min(trbl.left, planeTrbl.left);
|
|
8128
|
+
});
|
|
8129
|
+
|
|
8130
|
+
return asBounds(planeTrbl);
|
|
8131
|
+
}
|
|
8132
|
+
|
|
8133
|
+
var LOW_PRIORITY = 250;
|
|
8134
|
+
var ARROW_DOWN_SVG = '<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M4.81801948,3.50735931 L10.4996894,9.1896894 L10.5,4 L12,4 L12,12 L4,12 L4,10.5 L9.6896894,10.4996894 L3.75735931,4.56801948 C3.46446609,4.27512627 3.46446609,3.80025253 3.75735931,3.50735931 C4.05025253,3.21446609 4.52512627,3.21446609 4.81801948,3.50735931 Z"/></svg>';
|
|
8135
|
+
|
|
8136
|
+
var EMPTY_MARKER = 'bjs-drilldown-empty';
|
|
8137
|
+
|
|
8138
|
+
function DrilldownOverlayBehavior(
|
|
8139
|
+
canvas, eventBus, elementRegistry, overlays
|
|
8140
|
+
) {
|
|
8141
|
+
CommandInterceptor.call(this, eventBus);
|
|
8142
|
+
|
|
8143
|
+
this._canvas = canvas;
|
|
8144
|
+
this._eventBus = eventBus;
|
|
8145
|
+
this._elementRegistry = elementRegistry;
|
|
8146
|
+
this._overlays = overlays;
|
|
8147
|
+
|
|
8148
|
+
var self = this;
|
|
8149
|
+
|
|
8150
|
+
this.executed('shape.toggleCollapse', LOW_PRIORITY, function(context) {
|
|
8151
|
+
var shape = context.shape;
|
|
8152
|
+
|
|
8153
|
+
// Add overlay to the collapsed shape
|
|
8154
|
+
if (self.canDrillDown(shape)) {
|
|
8155
|
+
self.addOverlay(shape);
|
|
8156
|
+
} else {
|
|
8157
|
+
self.removeOverlay(shape);
|
|
8158
|
+
}
|
|
8159
|
+
}, true);
|
|
8160
|
+
|
|
8161
|
+
|
|
8162
|
+
this.reverted('shape.toggleCollapse', LOW_PRIORITY, function(context) {
|
|
8163
|
+
var shape = context.shape;
|
|
8164
|
+
|
|
8165
|
+
// Add overlay to the collapsed shape
|
|
8166
|
+
if (self.canDrillDown(shape)) {
|
|
8167
|
+
self.addOverlay(shape);
|
|
8168
|
+
} else {
|
|
8169
|
+
self.removeOverlay(shape);
|
|
8170
|
+
}
|
|
8171
|
+
}, true);
|
|
8172
|
+
|
|
8173
|
+
|
|
8174
|
+
this.executed(['shape.create', 'shape.move', 'shape.delete'], LOW_PRIORITY,
|
|
8175
|
+
function(context) {
|
|
8176
|
+
var oldParent = context.oldParent,
|
|
8177
|
+
newParent = context.newParent || context.parent,
|
|
8178
|
+
shape = context.shape;
|
|
8179
|
+
|
|
8180
|
+
// Add overlay to the collapsed shape
|
|
8181
|
+
if (self.canDrillDown(shape)) {
|
|
8182
|
+
self.addOverlay(shape);
|
|
8183
|
+
}
|
|
8184
|
+
|
|
8185
|
+
self.updateDrilldownOverlay(oldParent);
|
|
8186
|
+
self.updateDrilldownOverlay(newParent);
|
|
8187
|
+
self.updateDrilldownOverlay(shape);
|
|
8188
|
+
}, true);
|
|
8189
|
+
|
|
8190
|
+
|
|
8191
|
+
this.reverted(['shape.create', 'shape.move', 'shape.delete'], LOW_PRIORITY,
|
|
8192
|
+
function(context) {
|
|
8193
|
+
var oldParent = context.oldParent,
|
|
8194
|
+
newParent = context.newParent || context.parent,
|
|
8195
|
+
shape = context.shape;
|
|
8196
|
+
|
|
8197
|
+
// Add overlay to the collapsed shape
|
|
8198
|
+
if (self.canDrillDown(shape)) {
|
|
8199
|
+
self.addOverlay(shape);
|
|
8200
|
+
}
|
|
8201
|
+
|
|
8202
|
+
self.updateDrilldownOverlay(oldParent);
|
|
8203
|
+
self.updateDrilldownOverlay(newParent);
|
|
8204
|
+
self.updateDrilldownOverlay(shape);
|
|
8205
|
+
}, true);
|
|
8206
|
+
|
|
8207
|
+
|
|
8208
|
+
eventBus.on('import.done', function() {
|
|
8209
|
+
elementRegistry.filter(function(e) {
|
|
8210
|
+
return self.canDrillDown(e);
|
|
8211
|
+
}).map(function(el) {
|
|
8212
|
+
self.addOverlay(el);
|
|
8213
|
+
});
|
|
8214
|
+
});
|
|
8215
|
+
|
|
8216
|
+
}
|
|
8217
|
+
|
|
8218
|
+
inherits$1(DrilldownOverlayBehavior, CommandInterceptor);
|
|
8219
|
+
|
|
8220
|
+
DrilldownOverlayBehavior.prototype.updateDrilldownOverlay = function(shape) {
|
|
8221
|
+
var canvas = this._canvas;
|
|
8222
|
+
|
|
8223
|
+
if (!shape) {
|
|
8224
|
+
return;
|
|
8225
|
+
}
|
|
8226
|
+
|
|
8227
|
+
var root = canvas.findRoot(shape);
|
|
8228
|
+
if (root) {
|
|
8229
|
+
this.updateOverlayVisibility(root);
|
|
8230
|
+
}
|
|
8231
|
+
};
|
|
8232
|
+
|
|
8233
|
+
|
|
8234
|
+
DrilldownOverlayBehavior.prototype.canDrillDown = function(element) {
|
|
8235
|
+
var canvas = this._canvas;
|
|
8236
|
+
return is$1(element, 'bpmn:SubProcess') && canvas.findRoot(getPlaneIdFromShape(element));
|
|
8237
|
+
};
|
|
8238
|
+
|
|
8239
|
+
/**
|
|
8240
|
+
* Updates visibility of the drilldown overlay. If the plane has no elements,
|
|
8241
|
+
* the drilldown will be only shown when the element is selected.
|
|
8242
|
+
*
|
|
8243
|
+
* @param {djs.model.Shape|djs.model.Root} element collapsed shape or root element
|
|
8244
|
+
*/
|
|
8245
|
+
DrilldownOverlayBehavior.prototype.updateOverlayVisibility = function(element) {
|
|
8246
|
+
var overlays = this._overlays;
|
|
8247
|
+
|
|
8248
|
+
var bo = element.businessObject;
|
|
8249
|
+
|
|
8250
|
+
var overlay = overlays.get({ element: bo.id, type: 'drilldown' })[0];
|
|
8251
|
+
|
|
8252
|
+
if (!overlay) {
|
|
8253
|
+
return;
|
|
8254
|
+
}
|
|
8255
|
+
|
|
8256
|
+
var hasContent = bo && bo.flowElements && bo.flowElements.length;
|
|
8257
|
+
classes(overlay.html).toggle(EMPTY_MARKER, !hasContent);
|
|
8258
|
+
};
|
|
8259
|
+
|
|
8260
|
+
/**
|
|
8261
|
+
* Attaches a drilldown button to the given element. We assume that the plane has
|
|
8262
|
+
* the same id as the element.
|
|
8263
|
+
*
|
|
8264
|
+
* @param {djs.model.Shape} element collapsed shape
|
|
8265
|
+
*/
|
|
8266
|
+
DrilldownOverlayBehavior.prototype.addOverlay = function(element) {
|
|
8267
|
+
var canvas = this._canvas;
|
|
8268
|
+
var overlays = this._overlays;
|
|
8269
|
+
|
|
8270
|
+
var existingOverlays = overlays.get({ element: element, type: 'drilldown' });
|
|
8271
|
+
if (existingOverlays.length) {
|
|
8272
|
+
this.removeOverlay(element);
|
|
8273
|
+
}
|
|
8274
|
+
|
|
8275
|
+
var button = domify('<button class="bjs-drilldown">' + ARROW_DOWN_SVG + '</button>');
|
|
7785
8276
|
|
|
7786
|
-
|
|
7787
|
-
|
|
7788
|
-
|
|
7789
|
-
}
|
|
8277
|
+
button.addEventListener('click', function() {
|
|
8278
|
+
canvas.setRootElement(canvas.findRoot(getPlaneIdFromShape(element)));
|
|
8279
|
+
});
|
|
7790
8280
|
|
|
7791
|
-
|
|
8281
|
+
overlays.add(element, 'drilldown', {
|
|
8282
|
+
position: {
|
|
8283
|
+
bottom: -7,
|
|
8284
|
+
right: -8
|
|
8285
|
+
},
|
|
8286
|
+
html: button
|
|
8287
|
+
});
|
|
7792
8288
|
|
|
7793
|
-
|
|
7794
|
-
|
|
8289
|
+
this.updateOverlayVisibility(element);
|
|
8290
|
+
};
|
|
8291
|
+
|
|
8292
|
+
DrilldownOverlayBehavior.prototype.removeOverlay = function(element) {
|
|
8293
|
+
var overlays = this._overlays;
|
|
8294
|
+
|
|
8295
|
+
overlays.remove({
|
|
8296
|
+
element: element,
|
|
8297
|
+
type: 'drilldown'
|
|
7795
8298
|
});
|
|
8299
|
+
};
|
|
7796
8300
|
|
|
7797
|
-
|
|
7798
|
-
|
|
8301
|
+
DrilldownOverlayBehavior.$inject = [
|
|
8302
|
+
'canvas',
|
|
8303
|
+
'eventBus',
|
|
8304
|
+
'elementRegistry',
|
|
8305
|
+
'overlays'
|
|
8306
|
+
];
|
|
7799
8307
|
|
|
7800
8308
|
var DrilldownModdule = {
|
|
7801
|
-
__depends__: [ OverlaysModule, ChangeSupportModule ],
|
|
7802
|
-
__init__: [ '
|
|
7803
|
-
|
|
8309
|
+
__depends__: [ OverlaysModule, ChangeSupportModule, RootElementsModule ],
|
|
8310
|
+
__init__: [ 'drilldownBreadcrumbs', 'drilldownOverlayBehavior', 'drilldownCentering', 'subprocessCompatibility'],
|
|
8311
|
+
drilldownBreadcrumbs: [ 'type', DrilldownBreadcrumbs ],
|
|
7804
8312
|
drilldownCentering: [ 'type', DrilldownCentering ],
|
|
8313
|
+
drilldownOverlayBehavior: [ 'type', DrilldownOverlayBehavior ],
|
|
7805
8314
|
subprocessCompatibility: [ 'type', SubprocessCompatibility ]
|
|
7806
8315
|
};
|
|
7807
8316
|
|
|
@@ -8442,7 +8951,6 @@
|
|
|
8442
8951
|
}
|
|
8443
8952
|
|
|
8444
8953
|
var BASE_LAYER = 'base';
|
|
8445
|
-
var HIDDEN_MARKER = 'djs-element-hidden';
|
|
8446
8954
|
|
|
8447
8955
|
// render plane contents behind utility layers
|
|
8448
8956
|
var PLANE_LAYER_INDEX = 0;
|
|
@@ -8473,6 +8981,12 @@
|
|
|
8473
8981
|
this._elementRegistry = elementRegistry;
|
|
8474
8982
|
this._graphicsFactory = graphicsFactory;
|
|
8475
8983
|
|
|
8984
|
+
this._rootsIdx = 0;
|
|
8985
|
+
|
|
8986
|
+
this._layers = {};
|
|
8987
|
+
this._planes = [];
|
|
8988
|
+
this._rootElement = null;
|
|
8989
|
+
|
|
8476
8990
|
this._init(config || {});
|
|
8477
8991
|
}
|
|
8478
8992
|
|
|
@@ -8510,9 +9024,6 @@
|
|
|
8510
9024
|
|
|
8511
9025
|
var viewport = this._viewport = createGroup(svg, 'viewport');
|
|
8512
9026
|
|
|
8513
|
-
this._layers = {};
|
|
8514
|
-
this._planes = {};
|
|
8515
|
-
|
|
8516
9027
|
// debounce canvas.viewbox.changed events
|
|
8517
9028
|
// for smoother diagram interaction
|
|
8518
9029
|
if (config.deferUpdate !== false) {
|
|
@@ -8547,7 +9058,7 @@
|
|
|
8547
9058
|
'shape.removed',
|
|
8548
9059
|
'connection.removed',
|
|
8549
9060
|
'elements.changed',
|
|
8550
|
-
'
|
|
9061
|
+
'root.set'
|
|
8551
9062
|
], function() {
|
|
8552
9063
|
delete this._cachedViewbox;
|
|
8553
9064
|
}, this);
|
|
@@ -8572,7 +9083,7 @@
|
|
|
8572
9083
|
delete this._container;
|
|
8573
9084
|
delete this._layers;
|
|
8574
9085
|
delete this._planes;
|
|
8575
|
-
delete this.
|
|
9086
|
+
delete this._rootElement;
|
|
8576
9087
|
delete this._viewport;
|
|
8577
9088
|
};
|
|
8578
9089
|
|
|
@@ -8587,15 +9098,15 @@
|
|
|
8587
9098
|
var type = getType(element);
|
|
8588
9099
|
|
|
8589
9100
|
if (type === 'root') {
|
|
8590
|
-
self.
|
|
9101
|
+
self.removeRootElement(element);
|
|
8591
9102
|
} else {
|
|
8592
9103
|
self._removeElement(element, type);
|
|
8593
9104
|
}
|
|
8594
9105
|
});
|
|
8595
9106
|
|
|
8596
9107
|
// remove all planes
|
|
8597
|
-
this.
|
|
8598
|
-
this.
|
|
9108
|
+
this._planes = [];
|
|
9109
|
+
this._rootElement = null;
|
|
8599
9110
|
|
|
8600
9111
|
// force recomputation of view box
|
|
8601
9112
|
delete this._cachedViewbox;
|
|
@@ -8676,140 +9187,75 @@
|
|
|
8676
9187
|
|
|
8677
9188
|
};
|
|
8678
9189
|
|
|
8679
|
-
/**
|
|
8680
|
-
* Returns a plane that is used to draw elements on it.
|
|
8681
|
-
*
|
|
8682
|
-
* @param {string} name
|
|
8683
|
-
*
|
|
8684
|
-
* @return {Object} plane descriptor with { layer, rootElement, name }
|
|
8685
|
-
*/
|
|
8686
|
-
Canvas.prototype.getPlane = function(name) {
|
|
8687
|
-
if (!name) {
|
|
8688
|
-
throw new Error('must specify a name');
|
|
8689
|
-
}
|
|
8690
|
-
|
|
8691
|
-
return this._planes[name];
|
|
8692
|
-
};
|
|
8693
|
-
|
|
8694
|
-
/**
|
|
8695
|
-
* Creates a plane that is used to draw elements on it. If no
|
|
8696
|
-
* root element is provided, an implicit root will be used.
|
|
8697
|
-
*
|
|
8698
|
-
* @param {string} name
|
|
8699
|
-
* @param {Object|djs.model.Root} [rootElement] optional root element
|
|
8700
|
-
*
|
|
8701
|
-
* @return {Object} plane descriptor with { layer, rootElement, name }
|
|
8702
|
-
*/
|
|
8703
|
-
Canvas.prototype.createPlane = function(name, rootElement) {
|
|
8704
|
-
if (!name) {
|
|
8705
|
-
throw new Error('must specify a name');
|
|
8706
|
-
}
|
|
8707
|
-
|
|
8708
|
-
if (this._planes[name]) {
|
|
8709
|
-
throw new Error('plane ' + name + ' already exists');
|
|
8710
|
-
}
|
|
8711
|
-
|
|
8712
|
-
if (!rootElement) {
|
|
8713
|
-
rootElement = {
|
|
8714
|
-
id: '__implicitroot' + name,
|
|
8715
|
-
children: [],
|
|
8716
|
-
isImplicit: true
|
|
8717
|
-
};
|
|
8718
|
-
}
|
|
8719
|
-
|
|
8720
|
-
var svgLayer = this.getLayer(name, PLANE_LAYER_INDEX);
|
|
8721
|
-
classes$1(svgLayer).add(HIDDEN_MARKER);
|
|
8722
|
-
|
|
8723
|
-
var plane = this._planes[name] = {
|
|
8724
|
-
layer: svgLayer,
|
|
8725
|
-
name: name,
|
|
8726
|
-
rootElement: null
|
|
8727
|
-
};
|
|
8728
|
-
|
|
8729
|
-
this.setRootElementForPlane(rootElement, plane);
|
|
8730
|
-
|
|
8731
|
-
return plane;
|
|
8732
|
-
};
|
|
8733
|
-
|
|
8734
|
-
/**
|
|
8735
|
-
* Sets the active plane and hides the previously active plane.
|
|
8736
|
-
*
|
|
8737
|
-
* @param {string|Object} plane
|
|
8738
|
-
*
|
|
8739
|
-
* @return {Object} plane descriptor with { layer, rootElement, name }
|
|
8740
|
-
*/
|
|
8741
|
-
Canvas.prototype.setActivePlane = function(plane) {
|
|
8742
|
-
if (!plane) {
|
|
8743
|
-
throw new Error('must specify a plane');
|
|
8744
|
-
}
|
|
8745
|
-
|
|
8746
|
-
if (typeof plane === 'string') {
|
|
8747
|
-
plane = this.getPlane(plane);
|
|
8748
|
-
}
|
|
8749
9190
|
|
|
8750
|
-
|
|
8751
|
-
if (this._activePlane) {
|
|
8752
|
-
classes$1(this._activePlane.layer).add(HIDDEN_MARKER);
|
|
8753
|
-
}
|
|
9191
|
+
Canvas.prototype._removeLayer = function(name) {
|
|
8754
9192
|
|
|
8755
|
-
|
|
9193
|
+
var layer = this._layers[name];
|
|
8756
9194
|
|
|
8757
|
-
|
|
8758
|
-
|
|
9195
|
+
if (layer) {
|
|
9196
|
+
delete this._layers[name];
|
|
8759
9197
|
|
|
8760
|
-
|
|
8761
|
-
this._elementRegistry.updateGraphics(plane.rootElement, this._svg, true);
|
|
9198
|
+
remove$2(layer.group);
|
|
8762
9199
|
}
|
|
8763
|
-
|
|
8764
|
-
this._eventBus.fire('plane.set', { plane: plane });
|
|
8765
|
-
|
|
8766
|
-
return plane;
|
|
8767
9200
|
};
|
|
8768
9201
|
|
|
8769
9202
|
/**
|
|
8770
|
-
* Returns the currently active layer
|
|
9203
|
+
* Returns the currently active layer. Can be null.
|
|
8771
9204
|
*
|
|
8772
|
-
* @returns {SVGElement}
|
|
9205
|
+
* @returns {SVGElement|null}
|
|
8773
9206
|
*/
|
|
8774
|
-
|
|
8775
9207
|
Canvas.prototype.getActiveLayer = function() {
|
|
8776
|
-
|
|
8777
|
-
};
|
|
9208
|
+
var plane = this._findPlaneForRoot(this.getRootElement());
|
|
8778
9209
|
|
|
8779
|
-
/**
|
|
8780
|
-
* Returns the currently active plane.
|
|
8781
|
-
*
|
|
8782
|
-
* @return {Object} plane descriptor with { layer, rootElement, name }
|
|
8783
|
-
*/
|
|
8784
|
-
Canvas.prototype.getActivePlane = function() {
|
|
8785
|
-
var plane = this._activePlane;
|
|
8786
9210
|
if (!plane) {
|
|
8787
|
-
|
|
8788
|
-
this.setActivePlane(BASE_LAYER);
|
|
9211
|
+
return null;
|
|
8789
9212
|
}
|
|
8790
9213
|
|
|
8791
|
-
return plane;
|
|
9214
|
+
return plane.layer;
|
|
8792
9215
|
};
|
|
8793
9216
|
|
|
9217
|
+
|
|
8794
9218
|
/**
|
|
8795
9219
|
* Returns the plane which contains the given element.
|
|
8796
9220
|
*
|
|
8797
9221
|
* @param {string|djs.model.Base} element
|
|
8798
9222
|
*
|
|
8799
|
-
* @return {
|
|
9223
|
+
* @return {djs.model.Base} root for element
|
|
8800
9224
|
*/
|
|
8801
|
-
Canvas.prototype.
|
|
9225
|
+
Canvas.prototype.findRoot = function(element) {
|
|
8802
9226
|
if (typeof element === 'string') {
|
|
8803
9227
|
element = this._elementRegistry.get(element);
|
|
8804
9228
|
}
|
|
8805
9229
|
|
|
8806
|
-
|
|
9230
|
+
if (!element) {
|
|
9231
|
+
return;
|
|
9232
|
+
}
|
|
9233
|
+
|
|
9234
|
+
var plane = this._findPlaneForRoot(
|
|
9235
|
+
findRoot(element)
|
|
9236
|
+
) || {};
|
|
9237
|
+
|
|
9238
|
+
return plane.rootElement;
|
|
9239
|
+
};
|
|
9240
|
+
|
|
9241
|
+
/**
|
|
9242
|
+
* Return a list of all root elements on the diagram.
|
|
9243
|
+
*
|
|
9244
|
+
* @return {djs.model.Root[]}
|
|
9245
|
+
*/
|
|
9246
|
+
Canvas.prototype.getRootElements = function() {
|
|
9247
|
+
return this._planes.map(function(plane) {
|
|
9248
|
+
return plane.rootElement;
|
|
9249
|
+
});
|
|
9250
|
+
};
|
|
8807
9251
|
|
|
9252
|
+
Canvas.prototype._findPlaneForRoot = function(rootElement) {
|
|
8808
9253
|
return find(this._planes, function(plane) {
|
|
8809
|
-
return plane.rootElement ===
|
|
9254
|
+
return plane.rootElement === rootElement;
|
|
8810
9255
|
});
|
|
8811
9256
|
};
|
|
8812
9257
|
|
|
9258
|
+
|
|
8813
9259
|
/**
|
|
8814
9260
|
* Returns the html element that encloses the
|
|
8815
9261
|
* drawing canvas.
|
|
@@ -8930,95 +9376,205 @@
|
|
|
8930
9376
|
}
|
|
8931
9377
|
};
|
|
8932
9378
|
|
|
9379
|
+
/**
|
|
9380
|
+
* Returns the current root element.
|
|
9381
|
+
*
|
|
9382
|
+
* Supports two different modes for handling root elements:
|
|
9383
|
+
*
|
|
9384
|
+
* 1. if no root element has been added before, an implicit root will be added
|
|
9385
|
+
* and returned. This is used in applications that don't require explicit
|
|
9386
|
+
* root elements.
|
|
9387
|
+
*
|
|
9388
|
+
* 2. when root elements have been added before calling `getRootElement`,
|
|
9389
|
+
* root elements can be null. This is used for applications that want to manage
|
|
9390
|
+
* root elements themselves.
|
|
9391
|
+
*
|
|
9392
|
+
* @returns {Object|djs.model.Root|null} rootElement.
|
|
9393
|
+
*/
|
|
8933
9394
|
Canvas.prototype.getRootElement = function() {
|
|
8934
|
-
var
|
|
9395
|
+
var rootElement = this._rootElement;
|
|
8935
9396
|
|
|
8936
|
-
return
|
|
9397
|
+
// can return null if root elements are present but none was set yet
|
|
9398
|
+
if (rootElement || this._planes.length) {
|
|
9399
|
+
return rootElement;
|
|
9400
|
+
}
|
|
9401
|
+
|
|
9402
|
+
return this.setRootElement(this.addRootElement(null));
|
|
8937
9403
|
};
|
|
8938
9404
|
|
|
9405
|
+
/**
|
|
9406
|
+
* Adds a given root element and returns it.
|
|
9407
|
+
*
|
|
9408
|
+
* @param {Object|djs.model.Root} rootElement
|
|
9409
|
+
*
|
|
9410
|
+
* @return {Object|djs.model.Root} rootElement
|
|
9411
|
+
*/
|
|
8939
9412
|
|
|
9413
|
+
Canvas.prototype.addRootElement = function(rootElement) {
|
|
9414
|
+
var idx = this._rootsIdx++;
|
|
8940
9415
|
|
|
8941
|
-
|
|
9416
|
+
if (!rootElement) {
|
|
9417
|
+
rootElement = {
|
|
9418
|
+
id: '__implicitroot_' + idx,
|
|
9419
|
+
children: [],
|
|
9420
|
+
isImplicit: true
|
|
9421
|
+
};
|
|
9422
|
+
}
|
|
9423
|
+
|
|
9424
|
+
var layerName = rootElement.layer = 'root-' + idx;
|
|
9425
|
+
|
|
9426
|
+
this._ensureValid('root', rootElement);
|
|
9427
|
+
|
|
9428
|
+
var layer = this.getLayer(layerName, PLANE_LAYER_INDEX);
|
|
9429
|
+
|
|
9430
|
+
attr$1(layer, 'display', 'none');
|
|
9431
|
+
|
|
9432
|
+
this._addRoot(rootElement, layer);
|
|
9433
|
+
|
|
9434
|
+
this._planes.push({
|
|
9435
|
+
rootElement: rootElement,
|
|
9436
|
+
layer: layer
|
|
9437
|
+
});
|
|
9438
|
+
|
|
9439
|
+
return rootElement;
|
|
9440
|
+
};
|
|
8942
9441
|
|
|
8943
9442
|
/**
|
|
8944
|
-
*
|
|
8945
|
-
* and returns the new root element.
|
|
9443
|
+
* Removes a given rootElement and returns it.
|
|
8946
9444
|
*
|
|
8947
|
-
* @param {
|
|
8948
|
-
* @param {boolean} [override] whether to override the current root element, if any
|
|
9445
|
+
* @param {djs.model.Root|String} rootElement
|
|
8949
9446
|
*
|
|
8950
|
-
* @return {Object|djs.model.Root}
|
|
9447
|
+
* @return {Object|djs.model.Root} rootElement
|
|
8951
9448
|
*/
|
|
8952
|
-
Canvas.prototype.
|
|
8953
|
-
var activePlane = this._activePlane;
|
|
9449
|
+
Canvas.prototype.removeRootElement = function(rootElement) {
|
|
8954
9450
|
|
|
8955
|
-
if (
|
|
8956
|
-
|
|
8957
|
-
}
|
|
8958
|
-
|
|
9451
|
+
if (typeof rootElement === 'string') {
|
|
9452
|
+
rootElement = this._elementRegistry.get(rootElement);
|
|
9453
|
+
}
|
|
9454
|
+
|
|
9455
|
+
var plane = this._findPlaneForRoot(rootElement);
|
|
9456
|
+
|
|
9457
|
+
if (!plane) {
|
|
9458
|
+
return;
|
|
9459
|
+
}
|
|
9460
|
+
|
|
9461
|
+
// hook up life-cycle events
|
|
9462
|
+
this._removeRoot(rootElement);
|
|
9463
|
+
|
|
9464
|
+
// clean up layer
|
|
9465
|
+
this._removeLayer(rootElement.layer);
|
|
8959
9466
|
|
|
8960
|
-
|
|
9467
|
+
// clean up plane
|
|
9468
|
+
this._planes = this._planes.filter(function(plane) {
|
|
9469
|
+
return plane.rootElement !== rootElement;
|
|
9470
|
+
});
|
|
8961
9471
|
|
|
8962
|
-
|
|
9472
|
+
// clean up active root
|
|
9473
|
+
if (this._rootElement === rootElement) {
|
|
9474
|
+
this._rootElement = null;
|
|
8963
9475
|
}
|
|
9476
|
+
|
|
9477
|
+
return rootElement;
|
|
8964
9478
|
};
|
|
8965
9479
|
|
|
8966
9480
|
|
|
9481
|
+
// root element handling //////////////////////
|
|
9482
|
+
|
|
8967
9483
|
/**
|
|
8968
9484
|
* Sets a given element as the new root element for the canvas
|
|
8969
9485
|
* and returns the new root element.
|
|
8970
9486
|
*
|
|
8971
|
-
* @param {Object|djs.model.Root}
|
|
8972
|
-
* @param {Object|djs.model.Root} plane
|
|
8973
|
-
* @param {boolean} [override] whether to override the current root element, if any
|
|
9487
|
+
* @param {Object|djs.model.Root} rootElement
|
|
8974
9488
|
*
|
|
8975
9489
|
* @return {Object|djs.model.Root} new root element
|
|
8976
9490
|
*/
|
|
8977
|
-
Canvas.prototype.
|
|
9491
|
+
Canvas.prototype.setRootElement = function(rootElement, override) {
|
|
8978
9492
|
|
|
8979
|
-
if (
|
|
8980
|
-
|
|
9493
|
+
if (isDefined(override)) {
|
|
9494
|
+
throw new Error('override not supported');
|
|
8981
9495
|
}
|
|
8982
9496
|
|
|
8983
|
-
if (
|
|
8984
|
-
|
|
9497
|
+
if (rootElement === this._rootElement) {
|
|
9498
|
+
return;
|
|
8985
9499
|
}
|
|
8986
9500
|
|
|
8987
|
-
var
|
|
8988
|
-
elementRegistry = this._elementRegistry,
|
|
8989
|
-
eventBus = this._eventBus;
|
|
9501
|
+
var plane;
|
|
8990
9502
|
|
|
8991
|
-
if (
|
|
8992
|
-
|
|
8993
|
-
|
|
8994
|
-
}
|
|
9503
|
+
if (!rootElement) {
|
|
9504
|
+
throw new Error('rootElement required');
|
|
9505
|
+
}
|
|
8995
9506
|
|
|
8996
|
-
|
|
8997
|
-
eventBus.fire('root.remove', { element: currentRoot });
|
|
8998
|
-
eventBus.fire('root.removed', { element: currentRoot });
|
|
9507
|
+
plane = this._findPlaneForRoot(rootElement);
|
|
8999
9508
|
|
|
9000
|
-
|
|
9509
|
+
// give set add semantics for backwards compatibility
|
|
9510
|
+
if (!plane) {
|
|
9511
|
+
rootElement = this.addRootElement(rootElement);
|
|
9001
9512
|
}
|
|
9002
9513
|
|
|
9003
|
-
|
|
9004
|
-
|
|
9514
|
+
this._setRoot(rootElement);
|
|
9515
|
+
|
|
9516
|
+
return rootElement;
|
|
9517
|
+
};
|
|
9005
9518
|
|
|
9006
|
-
// resemble element add event sequence
|
|
9007
|
-
eventBus.fire('root.add', { element: element });
|
|
9008
9519
|
|
|
9009
|
-
|
|
9520
|
+
Canvas.prototype._removeRoot = function(element) {
|
|
9521
|
+
var elementRegistry = this._elementRegistry,
|
|
9522
|
+
eventBus = this._eventBus;
|
|
9523
|
+
|
|
9524
|
+
// simulate element remove event sequence
|
|
9525
|
+
eventBus.fire('root.remove', { element: element });
|
|
9526
|
+
eventBus.fire('root.removed', { element: element });
|
|
9527
|
+
|
|
9528
|
+
elementRegistry.remove(element);
|
|
9529
|
+
};
|
|
9530
|
+
|
|
9531
|
+
|
|
9532
|
+
Canvas.prototype._addRoot = function(element, gfx) {
|
|
9533
|
+
var elementRegistry = this._elementRegistry,
|
|
9534
|
+
eventBus = this._eventBus;
|
|
9535
|
+
|
|
9536
|
+
// resemble element add event sequence
|
|
9537
|
+
eventBus.fire('root.add', { element: element });
|
|
9538
|
+
|
|
9539
|
+
elementRegistry.add(element, gfx);
|
|
9540
|
+
|
|
9541
|
+
eventBus.fire('root.added', { element: element, gfx: gfx });
|
|
9542
|
+
};
|
|
9543
|
+
|
|
9544
|
+
|
|
9545
|
+
Canvas.prototype._setRoot = function(rootElement, layer) {
|
|
9010
9546
|
|
|
9011
|
-
|
|
9547
|
+
var currentRoot = this._rootElement;
|
|
9012
9548
|
|
|
9013
|
-
|
|
9014
|
-
|
|
9015
|
-
|
|
9549
|
+
var currentLayer;
|
|
9550
|
+
|
|
9551
|
+
if (currentRoot) {
|
|
9552
|
+
|
|
9553
|
+
// un-associate previous root element <svg>
|
|
9554
|
+
this._elementRegistry.updateGraphics(currentRoot, null, true);
|
|
9555
|
+
|
|
9556
|
+
// hide previous layer
|
|
9557
|
+
currentLayer = this._findPlaneForRoot(currentRoot).layer;
|
|
9558
|
+
|
|
9559
|
+
attr$1(currentLayer, 'display', 'none');
|
|
9560
|
+
}
|
|
9561
|
+
|
|
9562
|
+
if (rootElement) {
|
|
9563
|
+
|
|
9564
|
+
if (!layer) {
|
|
9565
|
+
layer = this._findPlaneForRoot(rootElement).layer;
|
|
9016
9566
|
}
|
|
9567
|
+
|
|
9568
|
+
// associate element with <svg>
|
|
9569
|
+
this._elementRegistry.updateGraphics(rootElement, this._svg, true);
|
|
9570
|
+
|
|
9571
|
+
// show root layer
|
|
9572
|
+
attr$1(layer, 'display', null);
|
|
9017
9573
|
}
|
|
9018
9574
|
|
|
9019
|
-
|
|
9575
|
+
this._rootElement = rootElement;
|
|
9020
9576
|
|
|
9021
|
-
|
|
9577
|
+
this._eventBus.fire('root.set', { element: rootElement });
|
|
9022
9578
|
};
|
|
9023
9579
|
|
|
9024
9580
|
// add functionality //////////////////////
|
|
@@ -9029,7 +9585,7 @@
|
|
|
9029
9585
|
}
|
|
9030
9586
|
|
|
9031
9587
|
if (this._elementRegistry.get(element.id)) {
|
|
9032
|
-
throw new Error('element
|
|
9588
|
+
throw new Error('element <' + element.id + '> already exists');
|
|
9033
9589
|
}
|
|
9034
9590
|
|
|
9035
9591
|
var requiredAttrs = REQUIRED_MODEL_ATTRS[type];
|
|
@@ -9319,6 +9875,7 @@
|
|
|
9319
9875
|
innerBox,
|
|
9320
9876
|
outerBox = this.getSize(),
|
|
9321
9877
|
matrix,
|
|
9878
|
+
activeLayer,
|
|
9322
9879
|
transform,
|
|
9323
9880
|
scale,
|
|
9324
9881
|
x, y;
|
|
@@ -9326,10 +9883,11 @@
|
|
|
9326
9883
|
if (!box) {
|
|
9327
9884
|
|
|
9328
9885
|
// compute the inner box based on the
|
|
9329
|
-
// diagrams active
|
|
9886
|
+
// diagrams active layer. This allows us to exclude
|
|
9330
9887
|
// external components, such as overlays
|
|
9331
9888
|
|
|
9332
|
-
|
|
9889
|
+
activeLayer = this._rootElement ? this.getActiveLayer() : null;
|
|
9890
|
+
innerBox = activeLayer && activeLayer.getBBox() || {};
|
|
9333
9891
|
|
|
9334
9892
|
transform = transform$1(viewport);
|
|
9335
9893
|
matrix = transform ? transform.matrix : createMatrix();
|
|
@@ -9412,10 +9970,11 @@
|
|
|
9412
9970
|
element = this._elementRegistry.get(element);
|
|
9413
9971
|
}
|
|
9414
9972
|
|
|
9415
|
-
//
|
|
9416
|
-
var
|
|
9417
|
-
|
|
9418
|
-
|
|
9973
|
+
// set to correct rootElement
|
|
9974
|
+
var rootElement = this.findRoot(element);
|
|
9975
|
+
|
|
9976
|
+
if (rootElement !== this.getRootElement()) {
|
|
9977
|
+
this.setRootElement(rootElement);
|
|
9419
9978
|
}
|
|
9420
9979
|
|
|
9421
9980
|
if (!padding) {
|
|
@@ -9778,7 +10337,9 @@
|
|
|
9778
10337
|
container.gfx = gfx;
|
|
9779
10338
|
}
|
|
9780
10339
|
|
|
9781
|
-
|
|
10340
|
+
if (gfx) {
|
|
10341
|
+
attr$1(gfx, ELEMENT_ID, id);
|
|
10342
|
+
}
|
|
9782
10343
|
|
|
9783
10344
|
return gfx;
|
|
9784
10345
|
};
|
|
@@ -19555,18 +20116,29 @@
|
|
|
19555
20116
|
|
|
19556
20117
|
var walker = new BpmnTreeWalker(visitor, translate);
|
|
19557
20118
|
|
|
20119
|
+
|
|
20120
|
+
bpmnDiagram = bpmnDiagram || (definitions.diagrams && definitions.diagrams[0]);
|
|
20121
|
+
|
|
20122
|
+
var diagramsToImport = getDiagramsToImport(definitions, bpmnDiagram);
|
|
20123
|
+
|
|
20124
|
+
if (!diagramsToImport) {
|
|
20125
|
+
throw new Error(translate('no diagram to display'));
|
|
20126
|
+
}
|
|
20127
|
+
|
|
19558
20128
|
// traverse BPMN 2.0 document model,
|
|
19559
20129
|
// starting at definitions
|
|
19560
|
-
|
|
19561
|
-
|
|
19562
|
-
|
|
19563
|
-
}
|
|
19564
|
-
} else {
|
|
19565
|
-
walker.handleDefinitions(definitions, bpmnDiagram);
|
|
19566
|
-
}
|
|
20130
|
+
forEach(diagramsToImport, function(diagram) {
|
|
20131
|
+
walker.handleDefinitions(definitions, diagram);
|
|
20132
|
+
});
|
|
19567
20133
|
|
|
19568
|
-
var
|
|
19569
|
-
|
|
20134
|
+
var rootId = bpmnDiagram.plane.bpmnElement.id;
|
|
20135
|
+
|
|
20136
|
+
// we do need to account for different ways we create root elements
|
|
20137
|
+
// each nested imported <root> do have the `_plane` suffix, while
|
|
20138
|
+
// the root <root> is found under the business object ID
|
|
20139
|
+
canvas.setRootElement(
|
|
20140
|
+
canvas.findRoot(rootId + '_plane') || canvas.findRoot(rootId)
|
|
20141
|
+
);
|
|
19570
20142
|
}
|
|
19571
20143
|
|
|
19572
20144
|
return new Promise(function(resolve, reject) {
|
|
@@ -19594,6 +20166,107 @@
|
|
|
19594
20166
|
});
|
|
19595
20167
|
}
|
|
19596
20168
|
|
|
20169
|
+
/**
|
|
20170
|
+
* Returns all diagrams in the same hirarchy as the requested diagram.
|
|
20171
|
+
* Includes all parent and sub process diagrams.
|
|
20172
|
+
*
|
|
20173
|
+
* @param {Array} definitions
|
|
20174
|
+
* @param {Object} bpmnDiagram
|
|
20175
|
+
*
|
|
20176
|
+
* @returns {Array<Object>}
|
|
20177
|
+
*/
|
|
20178
|
+
function getDiagramsToImport(definitions, bpmnDiagram) {
|
|
20179
|
+
if (!bpmnDiagram) {
|
|
20180
|
+
return;
|
|
20181
|
+
}
|
|
20182
|
+
|
|
20183
|
+
var bpmnElement = bpmnDiagram.plane.bpmnElement,
|
|
20184
|
+
rootElement = bpmnElement;
|
|
20185
|
+
|
|
20186
|
+
if (!is$1(bpmnElement, 'bpmn:Process') && !is$1(bpmnElement, 'bpmn:Collaboration')) {
|
|
20187
|
+
rootElement = findRootProcess(bpmnElement);
|
|
20188
|
+
}
|
|
20189
|
+
|
|
20190
|
+
// in case the process is part of a collaboration, the plane references the
|
|
20191
|
+
// collaboration, not the process
|
|
20192
|
+
var collaboration;
|
|
20193
|
+
|
|
20194
|
+
if (is$1(rootElement, 'bpmn:Collaboration')) {
|
|
20195
|
+
collaboration = rootElement;
|
|
20196
|
+
} else {
|
|
20197
|
+
collaboration = find(definitions.rootElements, function(element) {
|
|
20198
|
+
if (!is$1(element, 'bpmn:Collaboration')) {
|
|
20199
|
+
return;
|
|
20200
|
+
}
|
|
20201
|
+
|
|
20202
|
+
return find(element.participants, function(participant) {
|
|
20203
|
+
return participant.processRef === rootElement;
|
|
20204
|
+
});
|
|
20205
|
+
});
|
|
20206
|
+
}
|
|
20207
|
+
|
|
20208
|
+
var rootElements = [ rootElement ];
|
|
20209
|
+
|
|
20210
|
+
// all collaboration processes can contain sub-diagrams
|
|
20211
|
+
if (collaboration) {
|
|
20212
|
+
rootElements = map$1(collaboration.participants, function(participant) {
|
|
20213
|
+
return participant.processRef;
|
|
20214
|
+
});
|
|
20215
|
+
|
|
20216
|
+
rootElements.push(collaboration);
|
|
20217
|
+
}
|
|
20218
|
+
|
|
20219
|
+
var allChildren = selfAndAllFlowElements(rootElements);
|
|
20220
|
+
|
|
20221
|
+
// if we have multiple diagrams referencing the same element, we
|
|
20222
|
+
// use the first in the file
|
|
20223
|
+
var diagramsToImport = [ bpmnDiagram ];
|
|
20224
|
+
var handledElements = [ bpmnElement ];
|
|
20225
|
+
|
|
20226
|
+
forEach(definitions.diagrams, function(diagram) {
|
|
20227
|
+
var businessObject = diagram.plane.bpmnElement;
|
|
20228
|
+
|
|
20229
|
+
if (
|
|
20230
|
+
allChildren.indexOf(businessObject) !== -1 &&
|
|
20231
|
+
handledElements.indexOf(businessObject) === -1
|
|
20232
|
+
) {
|
|
20233
|
+
diagramsToImport.push(diagram);
|
|
20234
|
+
handledElements.push(businessObject);
|
|
20235
|
+
}
|
|
20236
|
+
});
|
|
20237
|
+
|
|
20238
|
+
|
|
20239
|
+
return diagramsToImport;
|
|
20240
|
+
}
|
|
20241
|
+
|
|
20242
|
+
function selfAndAllFlowElements(elements) {
|
|
20243
|
+
var result = [];
|
|
20244
|
+
|
|
20245
|
+
forEach(elements, function(element) {
|
|
20246
|
+
if (!element) {
|
|
20247
|
+
return;
|
|
20248
|
+
}
|
|
20249
|
+
|
|
20250
|
+
result.push(element);
|
|
20251
|
+
|
|
20252
|
+
result = result.concat(selfAndAllFlowElements(element.flowElements));
|
|
20253
|
+
});
|
|
20254
|
+
|
|
20255
|
+
return result;
|
|
20256
|
+
}
|
|
20257
|
+
|
|
20258
|
+
function findRootProcess(element) {
|
|
20259
|
+
var parent = element;
|
|
20260
|
+
|
|
20261
|
+
while (parent) {
|
|
20262
|
+
if (is$1(parent, 'bpmn:Process')) {
|
|
20263
|
+
return parent;
|
|
20264
|
+
}
|
|
20265
|
+
|
|
20266
|
+
parent = parent.$parent;
|
|
20267
|
+
}
|
|
20268
|
+
}
|
|
20269
|
+
|
|
19597
20270
|
/**
|
|
19598
20271
|
* This file must not be changed or exchanged.
|
|
19599
20272
|
*
|
|
@@ -20084,7 +20757,7 @@
|
|
|
20084
20757
|
try {
|
|
20085
20758
|
var canvas = self.get('canvas');
|
|
20086
20759
|
|
|
20087
|
-
var contentNode = canvas.
|
|
20760
|
+
var contentNode = canvas.getActiveLayer(),
|
|
20088
20761
|
defsNode = query('defs', canvas._svg);
|
|
20089
20762
|
|
|
20090
20763
|
var contents = innerSVG(contentNode),
|