@jylups/cmmn-js 0.0.0-stage → 0.21.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/.babelrc +3 -0
- package/CHANGELOG.md +119 -0
- package/LICENSE +23 -0
- package/README.md +107 -2
- package/dist/assets/cmmn-font/css/cmmn-codes.css +41 -0
- package/dist/assets/cmmn-font/css/cmmn-embedded.css +94 -0
- package/dist/assets/cmmn-font/css/cmmn.css +97 -0
- package/dist/assets/cmmn-font/font/cmmn.eot +0 -0
- package/dist/assets/cmmn-font/font/cmmn.svg +90 -0
- package/dist/assets/cmmn-font/font/cmmn.ttf +0 -0
- package/dist/assets/cmmn-font/font/cmmn.woff +0 -0
- package/dist/assets/cmmn-font/font/cmmn.woff2 +0 -0
- package/dist/assets/diagram-js.css +713 -0
- package/dist/cmmn-modeler.development.js +44817 -0
- package/dist/cmmn-modeler.production.min.js +2 -0
- package/dist/cmmn-navigated-viewer.development.js +18131 -0
- package/dist/cmmn-navigated-viewer.production.min.js +2 -0
- package/dist/cmmn-viewer.development.js +17599 -0
- package/dist/cmmn-viewer.production.min.js +2 -0
- package/index.js +1 -0
- package/lib/Modeler.js +222 -0
- package/lib/NavigatedViewer.js +28 -0
- package/lib/Viewer.js +489 -0
- package/lib/core/ItemRegistry.js +316 -0
- package/lib/core/index.js +7 -0
- package/lib/draw/CmmnRenderer.js +1235 -0
- package/lib/draw/PathMap.js +335 -0
- package/lib/draw/index.js +5 -0
- package/lib/features/auto-resize/CmmnAutoResizeProvider.js +57 -0
- package/lib/features/auto-resize/index.js +7 -0
- package/lib/features/context-pad/ContextPadProvider.js +240 -0
- package/lib/features/context-pad/index.js +11 -0
- package/lib/features/editor-actions/CmmnEditorActions.js +105 -0
- package/lib/features/editor-actions/index.js +10 -0
- package/lib/features/keyboard/CmmnKeyboardBindings.js +159 -0
- package/lib/features/keyboard/index.js +7 -0
- package/lib/features/label-editing/LabelEditingProvider.js +221 -0
- package/lib/features/label-editing/LabelUtil.js +95 -0
- package/lib/features/label-editing/cmd/UpdateLabelHandler.js +63 -0
- package/lib/features/label-editing/index.js +9 -0
- package/lib/features/modeling/CmmnFactory.js +166 -0
- package/lib/features/modeling/CmmnLayouter.js +49 -0
- package/lib/features/modeling/CmmnUpdater.js +511 -0
- package/lib/features/modeling/ElementFactory.js +215 -0
- package/lib/features/modeling/Modeling.js +185 -0
- package/lib/features/modeling/behavior/AttachCriterionBehavior.js +58 -0
- package/lib/features/modeling/behavior/CaseFileItemUpdater.js +324 -0
- package/lib/features/modeling/behavior/LabelBehavior.js +139 -0
- package/lib/features/modeling/behavior/PlanItemDefinitionUpdater.js +449 -0
- package/lib/features/modeling/behavior/PlanningTableUpdater.js +620 -0
- package/lib/features/modeling/behavior/ReplaceConnectionBehavior.js +320 -0
- package/lib/features/modeling/behavior/ReplaceElementBehavior.js +395 -0
- package/lib/features/modeling/behavior/ResizeCasePlanModelBehavior.js +108 -0
- package/lib/features/modeling/behavior/SentryUpdater.js +678 -0
- package/lib/features/modeling/behavior/UnclaimIdBehavior.js +28 -0
- package/lib/features/modeling/behavior/index.js +24 -0
- package/lib/features/modeling/cmd/AppendShapeHandler.js +52 -0
- package/lib/features/modeling/cmd/IdClaimHandler.js +38 -0
- package/lib/features/modeling/cmd/ReconnectConnectionHandler.js +57 -0
- package/lib/features/modeling/cmd/ReplaceShapeHandler.js +46 -0
- package/lib/features/modeling/cmd/UpdateControlsHandler.js +221 -0
- package/lib/features/modeling/cmd/UpdatePropertiesHandler.js +240 -0
- package/lib/features/modeling/cmd/UpdateSemanticParentHandler.js +94 -0
- package/lib/features/modeling/index.js +20 -0
- package/lib/features/modeling/util/ModelingUtil.js +138 -0
- package/lib/features/modeling/util/PlanItemDefinitionUtil.js +183 -0
- package/lib/features/ordering/CmmnOrderingProvider.js +146 -0
- package/lib/features/ordering/index.js +4 -0
- package/lib/features/outline/Outline.js +47 -0
- package/lib/features/outline/index.js +6 -0
- package/lib/features/palette/PaletteProvider.js +171 -0
- package/lib/features/palette/index.js +12 -0
- package/lib/features/popup-menu/ReplaceMenuProvider.js +448 -0
- package/lib/features/popup-menu/index.js +4 -0
- package/lib/features/replace/CmmnReplace.js +355 -0
- package/lib/features/replace/ReplaceOptions.js +241 -0
- package/lib/features/replace/index.js +8 -0
- package/lib/features/replace-preview/CmmnReplacePreview.js +247 -0
- package/lib/features/replace-preview/index.js +7 -0
- package/lib/features/rules/CmmnRules.js +1040 -0
- package/lib/features/rules/index.js +7 -0
- package/lib/features/search/CmmnSearchProvider.js +129 -0
- package/lib/features/search/index.js +7 -0
- package/lib/features/snapping/CmmnConnectSnapping.js +110 -0
- package/lib/features/snapping/CmmnCreateMoveSnapping.js +148 -0
- package/lib/features/snapping/CmmnResizeSnapping.js +42 -0
- package/lib/features/snapping/CmmnSnappingUtil.js +76 -0
- package/lib/features/snapping/index.js +17 -0
- package/lib/import/CmmnImporter.js +251 -0
- package/lib/import/CmmnTreeWalker.js +410 -0
- package/lib/import/Importer.js +73 -0
- package/lib/import/Util.js +9 -0
- package/lib/import/index.js +3 -0
- package/lib/util/DiUtil.js +39 -0
- package/lib/util/LabelUtil.js +124 -0
- package/lib/util/ModelUtil.js +257 -0
- package/lib/util/PoweredByUtil.js +91 -0
- package/package.json +88 -4
- package/test/helper/index.js +231 -0
- package/test/util/KeyEvents.js +23 -0
- package/test/util/MockEvents.js +55 -0
- package/test/util/custom-rules/CustomRules.js +19 -0
- package/test/util/custom-rules/index.js +4 -0
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var inherits = require('inherits');
|
|
4
|
+
|
|
5
|
+
var CommandInterceptor = require('diagram-js/lib/command/CommandInterceptor').default;
|
|
6
|
+
|
|
7
|
+
var forEach = require('min-dash').forEach;
|
|
8
|
+
var filter = require('min-dash').filter;
|
|
9
|
+
var reduce = require('min-dash').reduce;
|
|
10
|
+
|
|
11
|
+
var ModelUtil = require('../../../util/ModelUtil'),
|
|
12
|
+
getDefinition = ModelUtil.getDefinition,
|
|
13
|
+
getBusinessObject = ModelUtil.getBusinessObject,
|
|
14
|
+
is = ModelUtil.is;
|
|
15
|
+
|
|
16
|
+
var ModelingUtil = require('../util/ModelingUtil'),
|
|
17
|
+
getCase = ModelingUtil.getCase,
|
|
18
|
+
getParent = ModelingUtil.getParent,
|
|
19
|
+
isSameCase = ModelingUtil.isSameCase,
|
|
20
|
+
isLabel = ModelingUtil.isLabel;
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
function CaseFileItemUpdater(
|
|
24
|
+
eventBus,
|
|
25
|
+
itemRegistry,
|
|
26
|
+
cmmnFactory,
|
|
27
|
+
modeling
|
|
28
|
+
) {
|
|
29
|
+
|
|
30
|
+
this._cmmnFactory = cmmnFactory;
|
|
31
|
+
this._modeling = modeling;
|
|
32
|
+
|
|
33
|
+
CommandInterceptor.call(this, eventBus);
|
|
34
|
+
|
|
35
|
+
var containment = 'caseFileItems';
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
this.preExecuted('shape.create', function(context) {
|
|
39
|
+
|
|
40
|
+
var shape = context.shape,
|
|
41
|
+
parent = context.parent,
|
|
42
|
+
parentBusinessObject = getBusinessObject(parent),
|
|
43
|
+
definitions,
|
|
44
|
+
caseFileItemDefinition,
|
|
45
|
+
caseFileModel;
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
if (!isCaseFileItem(shape)) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
caseFileItemDefinition = getDefinition(shape);
|
|
53
|
+
|
|
54
|
+
if (caseFileItemDefinition) {
|
|
55
|
+
definitions = getDefinitions(parentBusinessObject);
|
|
56
|
+
modeling.updateSemanticParent(caseFileItemDefinition, definitions, 'caseFileItemDefinitions');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
caseFileModel = createCaseFileModel(parent);
|
|
60
|
+
|
|
61
|
+
modeling.updateSemanticParent(shape, caseFileModel, containment);
|
|
62
|
+
|
|
63
|
+
}, true);
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
this.preExecuted('elements.move', function(context) {
|
|
69
|
+
|
|
70
|
+
var newParent = context.newParent,
|
|
71
|
+
hints = context.hints,
|
|
72
|
+
oldParent = hints && hints.primaryShape && hints.primaryShape.parent,
|
|
73
|
+
closure = context.closure || {},
|
|
74
|
+
shapes = closure.allShapes,
|
|
75
|
+
caseFileModel;
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
if (!newParent || oldParent === newParent) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
shapes = filter(shapes, function(shape) {
|
|
84
|
+
return isCaseFileItem(shape) && !isLabel(shape) && !isSameCase(shape.parent, newParent);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
if (shapes && shapes.length) {
|
|
88
|
+
|
|
89
|
+
caseFileModel = createCaseFileModel(newParent);
|
|
90
|
+
|
|
91
|
+
shapes = toMap(shapes);
|
|
92
|
+
|
|
93
|
+
forEach(shapes, function(shape) {
|
|
94
|
+
|
|
95
|
+
var caseFileItem = getBusinessObject(shape),
|
|
96
|
+
oldCaseFileModel = getParentCaseFile(caseFileItem),
|
|
97
|
+
oldSemanticParent = getParent(caseFileItem);
|
|
98
|
+
|
|
99
|
+
if (isCaseFileModel(oldSemanticParent)) {
|
|
100
|
+
|
|
101
|
+
modeling.updateSemanticParent(shape, caseFileModel, containment);
|
|
102
|
+
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
|
|
106
|
+
var parentCaseFileItem = getParent(caseFileItem, 'cmmn:CaseFileItem');
|
|
107
|
+
if (!shapes[parentCaseFileItem.id]) {
|
|
108
|
+
modeling.updateSemanticParent(shape, caseFileModel, containment);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
var source = caseFileItem.sourceRef;
|
|
114
|
+
if (source && !shapes[source.id]) {
|
|
115
|
+
clearSourceRef(caseFileItem);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
clearTargetRefs(caseFileItem, function(target) {
|
|
119
|
+
return !shapes[target.id];
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
moveChildren(caseFileItem, oldCaseFileModel, function(child) {
|
|
124
|
+
return !shapes[child.id];
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
clearCaseFileItemContainer(oldSemanticParent);
|
|
128
|
+
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
}, true);
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
this.postExecuted('shape.delete', function(context) {
|
|
137
|
+
|
|
138
|
+
var shape = context.shape,
|
|
139
|
+
bo = getBusinessObject(shape),
|
|
140
|
+
caseFileItemDefinition;
|
|
141
|
+
|
|
142
|
+
if (!isCaseFileItem(shape) || isLabel(shape)) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
var oldSemanticParent = getParent(bo),
|
|
147
|
+
caseFileModel = getParentCaseFile(bo);
|
|
148
|
+
|
|
149
|
+
modeling.updateSemanticParent(shape, null, containment);
|
|
150
|
+
|
|
151
|
+
clearSourceRef(shape);
|
|
152
|
+
clearTargetRefs(shape);
|
|
153
|
+
moveChildren(bo, caseFileModel);
|
|
154
|
+
|
|
155
|
+
clearCaseFileItemContainer(oldSemanticParent);
|
|
156
|
+
|
|
157
|
+
if (isExlusiveRef(shape)) {
|
|
158
|
+
caseFileItemDefinition = getDefinition(shape);
|
|
159
|
+
modeling.updateSemanticParent(caseFileItemDefinition, null, 'caseFileItemDefinitions');
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
}, true);
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
function createCaseFileModel(element) {
|
|
167
|
+
var _case = getCase(element),
|
|
168
|
+
caseFileModel = _case.caseFileModel;
|
|
169
|
+
|
|
170
|
+
if (!caseFileModel) {
|
|
171
|
+
caseFileModel = cmmnFactory.createCaseFileModel(_case);
|
|
172
|
+
modeling.updateProperties(_case, { caseFileModel: caseFileModel });
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return caseFileModel;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
function clearCaseFileItemContainer(container) {
|
|
180
|
+
var items = container && container.get(containment);
|
|
181
|
+
|
|
182
|
+
if (items && !items.length) {
|
|
183
|
+
|
|
184
|
+
var prop = 'caseFileModel',
|
|
185
|
+
parent = container.$parent;
|
|
186
|
+
|
|
187
|
+
if (!isCaseFileModel(container)) {
|
|
188
|
+
prop = 'children';
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
var update = {};
|
|
192
|
+
update[prop] = undefined;
|
|
193
|
+
|
|
194
|
+
modeling.updateProperties(parent, update);
|
|
195
|
+
modeling.updateSemanticParent(container);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
function clearSourceRef(target) {
|
|
202
|
+
target = getBusinessObject(target);
|
|
203
|
+
|
|
204
|
+
var source = target.sourceRef;
|
|
205
|
+
|
|
206
|
+
if (source) {
|
|
207
|
+
clearTargetRefs(source, function(elem) {
|
|
208
|
+
return target === elem;
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
modeling.updateProperties(target, { sourceRef: undefined });
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
function clearTargetRefs(source, canRemoveFilter) {
|
|
218
|
+
source = getBusinessObject(source);
|
|
219
|
+
|
|
220
|
+
var targets = source && source.get('targetRefs'),
|
|
221
|
+
copy;
|
|
222
|
+
|
|
223
|
+
if (targets && targets.length) {
|
|
224
|
+
|
|
225
|
+
copy = targets.slice();
|
|
226
|
+
|
|
227
|
+
forEach(targets, function(target) {
|
|
228
|
+
|
|
229
|
+
var canRemove = !canRemoveFilter || canRemoveFilter(target);
|
|
230
|
+
|
|
231
|
+
if (canRemove) {
|
|
232
|
+
|
|
233
|
+
if (target.sourceRef === source) {
|
|
234
|
+
modeling.updateProperties(target, { sourceRef: undefined });
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
var idx = copy.indexOf(target);
|
|
238
|
+
if (idx !== -1) {
|
|
239
|
+
copy.splice(idx, 1);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
if (targets.length !== copy.length) {
|
|
247
|
+
modeling.updateProperties(source, { targetRefs: copy });
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
function moveChildren(caseFileItem, newParent, canMoveFilter) {
|
|
256
|
+
caseFileItem = getBusinessObject(caseFileItem);
|
|
257
|
+
|
|
258
|
+
var childrenElement = caseFileItem.children,
|
|
259
|
+
children = childrenElement && childrenElement.get(containment);
|
|
260
|
+
|
|
261
|
+
if (children && children.length) {
|
|
262
|
+
|
|
263
|
+
forEach(children, function(child) {
|
|
264
|
+
|
|
265
|
+
var canMove = !canMoveFilter || canMoveFilter(child);
|
|
266
|
+
|
|
267
|
+
if (canMove) {
|
|
268
|
+
modeling.updateSemanticParent(child, newParent, containment);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
clearCaseFileItemContainer(childrenElement);
|
|
274
|
+
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
function isExlusiveRef(element) {
|
|
281
|
+
var definition = getDefinition(element);
|
|
282
|
+
return definition && itemRegistry.getReferences(definition).length === 1;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
CaseFileItemUpdater.$inject = [
|
|
288
|
+
'eventBus',
|
|
289
|
+
'itemRegistry',
|
|
290
|
+
'cmmnFactory',
|
|
291
|
+
'modeling'
|
|
292
|
+
];
|
|
293
|
+
|
|
294
|
+
inherits(CaseFileItemUpdater, CommandInterceptor);
|
|
295
|
+
|
|
296
|
+
module.exports = CaseFileItemUpdater;
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
function getDefinitions(element) {
|
|
300
|
+
return getParent(element, 'cmmn:Definitions');
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
function isCaseFileItem(element) {
|
|
305
|
+
return is(element, 'cmmn:CaseFileItem');
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
function isCaseFileModel(element) {
|
|
310
|
+
return is(element, 'cmmn:CaseFile');
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
function toMap(elements) {
|
|
315
|
+
return reduce(elements, function(result, value) {
|
|
316
|
+
result[value.id] = value;
|
|
317
|
+
return result;
|
|
318
|
+
}, {});
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
function getParentCaseFile(element) {
|
|
323
|
+
return getParent(getBusinessObject(element), 'cmmn:CaseFile');
|
|
324
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var assign = require('min-dash').assign,
|
|
4
|
+
inherits = require('inherits');
|
|
5
|
+
|
|
6
|
+
var LabelUtil = require('../../../util/LabelUtil'),
|
|
7
|
+
ModelUtil = require('../../../util/ModelUtil'),
|
|
8
|
+
DiUtil = require('../../../util/DiUtil'),
|
|
9
|
+
ModelingUtil = require('../util/ModelingUtil');
|
|
10
|
+
|
|
11
|
+
var getBusinessObject = ModelUtil.getBusinessObject,
|
|
12
|
+
getName = ModelUtil.getName;
|
|
13
|
+
|
|
14
|
+
var hasExternalLabel = LabelUtil.hasExternalLabel,
|
|
15
|
+
getExternalLabelMid = LabelUtil.getExternalLabelMid;
|
|
16
|
+
|
|
17
|
+
var isStandardEventVisible = DiUtil.isStandardEventVisible;
|
|
18
|
+
|
|
19
|
+
var isAny = ModelingUtil.isAny;
|
|
20
|
+
|
|
21
|
+
var CommandInterceptor = require('diagram-js/lib/command/CommandInterceptor').default;
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* A component that makes sure that external labels are added
|
|
26
|
+
* together with respective elements and properly updated (DI wise)
|
|
27
|
+
* during move.
|
|
28
|
+
*
|
|
29
|
+
* @param {EventBus} eventBus
|
|
30
|
+
* @param {Modeling} modeling
|
|
31
|
+
* @param {cmmnFactory} cmmnFactory
|
|
32
|
+
*/
|
|
33
|
+
function LabelBehavior(eventBus, modeling, cmmnFactory) {
|
|
34
|
+
|
|
35
|
+
CommandInterceptor.call(this, eventBus);
|
|
36
|
+
|
|
37
|
+
// create external labels on shape creation
|
|
38
|
+
|
|
39
|
+
this.postExecuted([ 'shape.create', 'connection.create' ], 200, function(e) {
|
|
40
|
+
var context = e.context;
|
|
41
|
+
|
|
42
|
+
var element = context.shape || context.connection,
|
|
43
|
+
businessObject = element.businessObject;
|
|
44
|
+
|
|
45
|
+
var position;
|
|
46
|
+
|
|
47
|
+
if (hasExternalLabel(businessObject)) {
|
|
48
|
+
position = getExternalLabelMid(element);
|
|
49
|
+
|
|
50
|
+
modeling.createLabel(element, position, {
|
|
51
|
+
id: businessObject.id + '_label',
|
|
52
|
+
hidden: !getName(element) && !isStandardEventVisible(businessObject),
|
|
53
|
+
businessObject: businessObject
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
// update label position on waypoints change if still hidden
|
|
60
|
+
this.postExecute([ 'connection.updateWaypoints' ], function(e) {
|
|
61
|
+
var context = e.context,
|
|
62
|
+
connection = context.connection,
|
|
63
|
+
label = connection.label;
|
|
64
|
+
|
|
65
|
+
if (!label) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (label.hidden) {
|
|
70
|
+
var position = getExternalLabelMid(connection);
|
|
71
|
+
|
|
72
|
+
var delta = {
|
|
73
|
+
x: position.x - label.x - label.width / 2,
|
|
74
|
+
y: position.y - label.y - label.height / 2
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
modeling.moveShape(label, delta);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
this.postExecute([ 'shape.replace' ], function(e) {
|
|
83
|
+
var context = e.context,
|
|
84
|
+
newShape = context.newShape,
|
|
85
|
+
oldShape = context.oldShape;
|
|
86
|
+
|
|
87
|
+
var businessObject = getBusinessObject(newShape);
|
|
88
|
+
|
|
89
|
+
if (businessObject && hasExternalLabel(businessObject)) {
|
|
90
|
+
newShape.label.x = oldShape.label.x;
|
|
91
|
+
newShape.label.y = oldShape.label.y;
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
// update di information on label creation
|
|
97
|
+
this.executed([ 'label.create' ], function(e) {
|
|
98
|
+
|
|
99
|
+
var element = e.context.shape,
|
|
100
|
+
businessObject,
|
|
101
|
+
di;
|
|
102
|
+
|
|
103
|
+
// we want to trigger on real labels only
|
|
104
|
+
if (!element.labelTarget) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// we want to trigger on CMMN elements only
|
|
109
|
+
if (!isAny(element.labelTarget || element, [ 'cmmn:CMMNElement', 'cmmndi:CMMNDiagramElement' ])) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
businessObject = element.businessObject,
|
|
114
|
+
di = businessObject.di || businessObject;
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
if (!di.label) {
|
|
118
|
+
di.label = cmmnFactory.createDiLabel();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (!di.label.bounds) {
|
|
122
|
+
di.label.bounds = cmmnFactory.createDiBounds();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
assign(di.label.bounds, {
|
|
126
|
+
x: element.x,
|
|
127
|
+
y: element.y,
|
|
128
|
+
width: element.width,
|
|
129
|
+
height: element.height
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
inherits(LabelBehavior, CommandInterceptor);
|
|
136
|
+
|
|
137
|
+
LabelBehavior.$inject = [ 'eventBus', 'modeling', 'cmmnFactory' ];
|
|
138
|
+
|
|
139
|
+
module.exports = LabelBehavior;
|