@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,247 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var CommandInterceptor = require('diagram-js/lib/command/CommandInterceptor').default;
|
|
4
|
+
|
|
5
|
+
var cssEscape = require('css.escape');
|
|
6
|
+
|
|
7
|
+
var inherits = require('inherits');
|
|
8
|
+
|
|
9
|
+
var assign = require('min-dash').assign,
|
|
10
|
+
forEach = require('min-dash').forEach;
|
|
11
|
+
|
|
12
|
+
var getVisual = require('diagram-js/lib/util/GraphicsUtil').getVisual;
|
|
13
|
+
|
|
14
|
+
var isItemCapable = require('../modeling/util/PlanItemDefinitionUtil').isItemCapable;
|
|
15
|
+
|
|
16
|
+
var ModelUtil = require('../../util/ModelUtil'),
|
|
17
|
+
getBusinessObject = ModelUtil.getBusinessObject,
|
|
18
|
+
getDefinition = ModelUtil.getDefinition;
|
|
19
|
+
|
|
20
|
+
var domQuery = require('min-dom').query;
|
|
21
|
+
|
|
22
|
+
var svgAppend = require('tiny-svg').append,
|
|
23
|
+
svgClasses = require('tiny-svg').classes,
|
|
24
|
+
svgCreate = require('tiny-svg').create,
|
|
25
|
+
svgRemove = require('tiny-svg').remove;
|
|
26
|
+
|
|
27
|
+
var LOW_PRIORITY = 250;
|
|
28
|
+
|
|
29
|
+
function CmmnReplacePreview(
|
|
30
|
+
cmmnReplace,
|
|
31
|
+
cmmnRules,
|
|
32
|
+
elementFactory,
|
|
33
|
+
elementRegistry,
|
|
34
|
+
eventBus,
|
|
35
|
+
graphicsFactory
|
|
36
|
+
) {
|
|
37
|
+
|
|
38
|
+
CommandInterceptor.call(this, eventBus);
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
function createShape(element, replacement) {
|
|
42
|
+
|
|
43
|
+
var newElement = {
|
|
44
|
+
type: replacement.newElementType,
|
|
45
|
+
x: element.x,
|
|
46
|
+
y: element.y,
|
|
47
|
+
width: element.width,
|
|
48
|
+
height: element.height
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
if (isItemCapable(element)) {
|
|
52
|
+
|
|
53
|
+
var bo = getBusinessObject(element),
|
|
54
|
+
definition = getDefinition(element),
|
|
55
|
+
newElementType = replacement.newElementType,
|
|
56
|
+
newDefinitionType = replacement.newDefinitionType,
|
|
57
|
+
replaceCandidate;
|
|
58
|
+
|
|
59
|
+
if (newDefinitionType) {
|
|
60
|
+
definition = cmmnReplace.replacePlanItemDefinition(definition, newDefinitionType);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
replaceCandidate = cmmnReplace.replaceItemCapable(bo, newElementType, definition);
|
|
64
|
+
|
|
65
|
+
assign(newElement, {
|
|
66
|
+
businessObject: replaceCandidate
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return elementFactory.createShape(newElement);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
function initVisualReplacements(context) {
|
|
75
|
+
if (!context.visualReplacements) {
|
|
76
|
+
context.visualReplacements = {};
|
|
77
|
+
}
|
|
78
|
+
return context.visualReplacements;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
function canReplace(event) {
|
|
83
|
+
var context = event.context,
|
|
84
|
+
canExecute = context.canExecute || context.allowed;
|
|
85
|
+
|
|
86
|
+
if (canExecute === 'attach') {
|
|
87
|
+
var position = context.position || { x: event.x, y: event.y },
|
|
88
|
+
shapes = context.shapes || [ context.shape ],
|
|
89
|
+
target = context.target;
|
|
90
|
+
|
|
91
|
+
canExecute = cmmnRules.canReplace(shapes, target, position, context.source);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
return canExecute;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Replace the visuals to the given shape
|
|
101
|
+
*/
|
|
102
|
+
function replaceVisualGraphics(gfx, shape) {
|
|
103
|
+
|
|
104
|
+
var visual = gfx && getVisual(gfx);
|
|
105
|
+
|
|
106
|
+
if (visual) {
|
|
107
|
+
svgRemove(visual);
|
|
108
|
+
|
|
109
|
+
visual = svgCreate('g');
|
|
110
|
+
svgClasses(visual).add('djs-visual');
|
|
111
|
+
|
|
112
|
+
svgAppend(gfx, visual);
|
|
113
|
+
|
|
114
|
+
graphicsFactory.drawShape(visual, shape);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
function replaceVisual(context, replacements, gfxSelector) {
|
|
121
|
+
|
|
122
|
+
forEach(replacements, function(replacement) {
|
|
123
|
+
|
|
124
|
+
var id = replacement.oldElementId,
|
|
125
|
+
shape = elementRegistry.get(id) || context.shape;
|
|
126
|
+
|
|
127
|
+
// if the visual of the element is already replaced
|
|
128
|
+
if (context.visualReplacements[id]) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// create a temporary shape
|
|
133
|
+
var tempShape = createShape(shape, replacement);
|
|
134
|
+
|
|
135
|
+
// select the original SVG element related to the element and hide it
|
|
136
|
+
var gfx = gfxSelector(shape);
|
|
137
|
+
|
|
138
|
+
replaceVisualGraphics(gfx, tempShape);
|
|
139
|
+
context.visualReplacements[id] = shape;
|
|
140
|
+
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function restoreVisual(context, gfxSelector) {
|
|
146
|
+
|
|
147
|
+
var visualReplacements = context.visualReplacements;
|
|
148
|
+
|
|
149
|
+
forEach(visualReplacements, function(shape, id) {
|
|
150
|
+
|
|
151
|
+
var gfx = gfxSelector(shape);
|
|
152
|
+
replaceVisualGraphics(gfx, shape);
|
|
153
|
+
|
|
154
|
+
delete visualReplacements[id];
|
|
155
|
+
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
eventBus.on([ 'shape.move.move', 'create.move' ], LOW_PRIORITY, function(event) {
|
|
161
|
+
|
|
162
|
+
var context = event.context,
|
|
163
|
+
dragGroup = context.dragGroup,
|
|
164
|
+
visual = context.visual,
|
|
165
|
+
canExecute = canReplace(event),
|
|
166
|
+
replacements = canExecute && canExecute.replacements;
|
|
167
|
+
|
|
168
|
+
initVisualReplacements(context);
|
|
169
|
+
|
|
170
|
+
var getGfx = function(shape) {
|
|
171
|
+
var selector,
|
|
172
|
+
gfx;
|
|
173
|
+
|
|
174
|
+
if (dragGroup) {
|
|
175
|
+
selector = '[data-element-id="' + cssEscape(shape.id) + '"]';
|
|
176
|
+
gfx = dragGroup;
|
|
177
|
+
}
|
|
178
|
+
else if (visual) {
|
|
179
|
+
selector = '.djs-dragger';
|
|
180
|
+
gfx = visual;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return gfx && domQuery(selector, gfx);
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
if (replacements && replacements.length) {
|
|
187
|
+
replaceVisual(context, replacements, getGfx);
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
restoreVisual(context, getGfx);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
eventBus.on([
|
|
197
|
+
'bendpoint.move.move',
|
|
198
|
+
'connect.move'
|
|
199
|
+
], LOW_PRIORITY, function(event) {
|
|
200
|
+
|
|
201
|
+
var context = event.context,
|
|
202
|
+
canExecute = canReplace(event),
|
|
203
|
+
replacements = canExecute && canExecute.replacements;
|
|
204
|
+
|
|
205
|
+
initVisualReplacements(context);
|
|
206
|
+
|
|
207
|
+
if (replacements && replacements.length) {
|
|
208
|
+
replaceVisual(context, replacements, function(shape) {
|
|
209
|
+
return elementRegistry.getGraphics(shape);
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
eventBus.on([
|
|
217
|
+
'bendpoint.move.cancel',
|
|
218
|
+
'bendpoint.move.cleanup',
|
|
219
|
+
'bendpoint.move.end',
|
|
220
|
+
'bendpoint.move.out',
|
|
221
|
+
'connect.cleanup',
|
|
222
|
+
'connect.end',
|
|
223
|
+
'connect.out'
|
|
224
|
+
], LOW_PRIORITY, function(event) {
|
|
225
|
+
|
|
226
|
+
var context = event.context;
|
|
227
|
+
|
|
228
|
+
restoreVisual(context, function(shape) {
|
|
229
|
+
return elementRegistry.getGraphics(shape);
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
CmmnReplacePreview.$inject = [
|
|
237
|
+
'cmmnReplace',
|
|
238
|
+
'cmmnRules',
|
|
239
|
+
'elementFactory',
|
|
240
|
+
'elementRegistry',
|
|
241
|
+
'eventBus',
|
|
242
|
+
'graphicsFactory'
|
|
243
|
+
];
|
|
244
|
+
|
|
245
|
+
inherits(CmmnReplacePreview, CommandInterceptor);
|
|
246
|
+
|
|
247
|
+
module.exports = CmmnReplacePreview;
|