@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,335 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Map containing SVG paths needed by CmmnRenderer.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
function PathMap() {
|
|
8
|
+
|
|
9
|
+
var PATH_USER_TYPE_1 = 'm {mx},{my} c 0.909,-0.845 1.594,-2.049 1.594,-3.385 0,-2.554 -1.805,-4.62199999 ' +
|
|
10
|
+
'-4.357,-4.62199999 -2.55199998,0 -4.28799998,2.06799999 -4.28799998,4.62199999 0,1.348 ' +
|
|
11
|
+
'0.974,2.562 1.89599998,3.405 -0.52899998,0.187 -5.669,2.097 -5.794,4.7560005 v 6.718 ' +
|
|
12
|
+
'h 17 v -6.718 c 0,-2.2980005 -5.5279996,-4.5950005 -6.0509996,-4.7760005 z' +
|
|
13
|
+
'm -8,6 l 0,5.5 m 11,0 l 0,-5';
|
|
14
|
+
|
|
15
|
+
var PATH_USER_TYPE_2 = 'm {mx},{my} m 2.162,1.009 c 0,2.4470005 -2.158,4.4310005 -4.821,4.4310005 ' +
|
|
16
|
+
'-2.66499998,0 -4.822,-1.981 -4.822,-4.4310005';
|
|
17
|
+
|
|
18
|
+
var PATH_USER_TYPE_3 = 'm {mx},{my} m -6.9,-3.80 c 0,0 2.25099998,-2.358 4.27399998,-1.177 2.024,1.181 4.221,1.537 ' +
|
|
19
|
+
'4.124,0.965 -0.098,-0.57 -0.117,-3.79099999 -4.191,-4.13599999 -3.57499998,0.001 ' +
|
|
20
|
+
'-4.20799998,3.36699999 -4.20699998,4.34799999 z';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Contains a map of path elements
|
|
24
|
+
*
|
|
25
|
+
* <h1>Path definition</h1>
|
|
26
|
+
* A parameterized path is defined like this:
|
|
27
|
+
* <pre>
|
|
28
|
+
* 'EVENT_TIMER_WH': {
|
|
29
|
+
* d: 'M {mx},{my} l {e.x0},-{e.y0} m -{e.x0},{e.y0} l {e.x1},{e.y1} ',
|
|
30
|
+
* height: 17.5,
|
|
31
|
+
* width: 17.5,
|
|
32
|
+
* heightElements: [2.5, 7.5],
|
|
33
|
+
* widthElements: [2.5, 7.5]
|
|
34
|
+
* }
|
|
35
|
+
* </pre>
|
|
36
|
+
* <p>It's important to specify a correct <b>height and width</b> for the path as the scaling
|
|
37
|
+
* is based on the ratio between the specified height and width in this object and the
|
|
38
|
+
* height and width that is set as scale target (Note x,y coordinates will be scaled with
|
|
39
|
+
* individual ratios).</p>
|
|
40
|
+
* <p>The '<b>heightElements</b>' and '<b>widthElements</b>' array must contain the values that will be scaled.
|
|
41
|
+
* The scaling is based on the computed ratios.
|
|
42
|
+
* Coordinates on the y axis should be in the <b>heightElement</b>'s array, they will be scaled using
|
|
43
|
+
* the computed ratio coefficient.
|
|
44
|
+
* In the parameterized path the scaled values can be accessed through the 'e' object in {} brackets.
|
|
45
|
+
* <ul>
|
|
46
|
+
* <li>The values for the y axis can be accessed in the path string using {e.y0}, {e.y1}, ....</li>
|
|
47
|
+
* <li>The values for the x axis can be accessed in the path string using {e.x0}, {e.x1}, ....</li>
|
|
48
|
+
* </ul>
|
|
49
|
+
* The numbers x0, x1 respectively y0, y1, ... map to the corresponding array index.
|
|
50
|
+
* </p>
|
|
51
|
+
*/
|
|
52
|
+
this.pathMap = {
|
|
53
|
+
|
|
54
|
+
// TASK DECORATOR
|
|
55
|
+
|
|
56
|
+
'TASK_TYPE_FOLDER': {
|
|
57
|
+
d: 'm {mx},{my} l18,0 l0,12 l-18,0 l0,-12 m 2,0 l3,-4 l5,0 l3,4'
|
|
58
|
+
},
|
|
59
|
+
'TASK_TYPE_CHEVRON': {
|
|
60
|
+
d: 'm {mx},{my} l15,0 l6,6 l-6,6 l-15,0 l6,-6 l-6,-6'
|
|
61
|
+
},
|
|
62
|
+
'TASK_TYPE_USER_1': {
|
|
63
|
+
d: PATH_USER_TYPE_1
|
|
64
|
+
},
|
|
65
|
+
'TASK_TYPE_USER_2': {
|
|
66
|
+
d: PATH_USER_TYPE_2
|
|
67
|
+
},
|
|
68
|
+
'TASK_TYPE_USER_3': {
|
|
69
|
+
d: PATH_USER_TYPE_3
|
|
70
|
+
},
|
|
71
|
+
'TASK_TYPE_MANUAL': {
|
|
72
|
+
d: 'm {mx},{my} c 0.234,-0.01 5.604,0.008 8.029,0.004 0.808,0 1.271,-0.172 1.417,-0.752 0.227,-0.898 ' +
|
|
73
|
+
'-0.334,-1.314 -1.338,-1.316 -2.467,-0.01 -7.886,-0.004 -8.108,-0.004 -0.014,-0.079 0.016,-0.533 0,-0.61 ' +
|
|
74
|
+
'0.195,-0.042 8.507,0.006 9.616,0.002 0.877,-0.007 1.35,-0.438 1.353,-1.208 0.003,-0.768 -0.479,-1.09 ' +
|
|
75
|
+
'-1.35,-1.091 -2.968,-0.002 -9.619,-0.013 -9.619,-0.013 v -0.591 c 0,0 5.052,-0.016 7.225,-0.016 ' +
|
|
76
|
+
'0.888,-0.002 1.354,-0.416 1.351,-1.193 -0.006,-0.761 -0.492,-1.196 -1.361,-1.196 -3.473,-0.005 ' +
|
|
77
|
+
'-10.86,-0.003 -11.0829995,-0.003 -0.022,-0.047 -0.045,-0.094 -0.069,-0.139 0.3939995,-0.319 ' +
|
|
78
|
+
'2.0409995,-1.626 2.4149995,-2.017 0.469,-0.4870005 0.519,-1.1650005 0.162,-1.6040005 -0.414,-0.511 ' +
|
|
79
|
+
'-0.973,-0.5 -1.48,-0.236 -1.4609995,0.764 -6.5999995,3.6430005 -7.7329995,4.2710005 -0.9,0.499 ' +
|
|
80
|
+
'-1.516,1.253 -1.882,2.19 -0.37000002,0.95 -0.17,2.01 -0.166,2.979 0.004,0.718 -0.27300002,1.345 ' +
|
|
81
|
+
'-0.055,2.063 0.629,2.087 2.425,3.312 4.859,3.318 4.6179995,0.014 9.2379995,-0.139 13.8569995,-0.158 ' +
|
|
82
|
+
'0.755,-0.004 1.171,-0.301 1.182,-1.033 0.012,-0.754 -0.423,-0.969 -1.183,-0.973 -1.778,-0.01 ' +
|
|
83
|
+
'-5.824,-0.004 -6.04,-0.004 10e-4,-0.084 0.003,-0.586 10e-4,-0.67 z'
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
'TASK_TYPE_BUSINESS_RULE_HEADER': {
|
|
87
|
+
d: 'm {mx},{my} 0,4 20,0 0,-4 z'
|
|
88
|
+
},
|
|
89
|
+
'TASK_TYPE_BUSINESS_RULE_MAIN': {
|
|
90
|
+
d: 'm {mx},{my} 0,12 20,0 0,-12 z' +
|
|
91
|
+
'm 0,8 l 20,0 ' +
|
|
92
|
+
'm -13,-4 l 0,8'
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
// EVENT LISTENER DECORATOR
|
|
96
|
+
|
|
97
|
+
'EVENT_TIMER_WH': {
|
|
98
|
+
d: 'M {mx},{my} l {e.x0},-{e.y0} m -{e.x0},{e.y0} l {e.x1},{e.y1} ',
|
|
99
|
+
height: 36,
|
|
100
|
+
width: 36,
|
|
101
|
+
heightElements: [10, 2],
|
|
102
|
+
widthElements: [3, 7]
|
|
103
|
+
},
|
|
104
|
+
'EVENT_TIMER_LINE': {
|
|
105
|
+
d: 'M {mx},{my} ' +
|
|
106
|
+
'm {e.x0},{e.y0} l -{e.x1},{e.y1} ',
|
|
107
|
+
height: 36,
|
|
108
|
+
width: 36,
|
|
109
|
+
heightElements: [10, 3],
|
|
110
|
+
widthElements: [0, 0]
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
'EVENT_USER_1': {
|
|
114
|
+
d: PATH_USER_TYPE_1,
|
|
115
|
+
height: 36,
|
|
116
|
+
width: 36,
|
|
117
|
+
heightElements: [],
|
|
118
|
+
widthElements: []
|
|
119
|
+
|
|
120
|
+
},
|
|
121
|
+
'EVENT_USER_2': {
|
|
122
|
+
d: PATH_USER_TYPE_2,
|
|
123
|
+
height: 36,
|
|
124
|
+
width: 36,
|
|
125
|
+
heightElements: [],
|
|
126
|
+
widthElements: []
|
|
127
|
+
},
|
|
128
|
+
'EVENT_USER_3': {
|
|
129
|
+
d: PATH_USER_TYPE_3,
|
|
130
|
+
height: 36,
|
|
131
|
+
width: 36,
|
|
132
|
+
heightElements: [],
|
|
133
|
+
widthElements: []
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
// MARKERS
|
|
137
|
+
|
|
138
|
+
'MARKER_STAGE_EXPANDED': {
|
|
139
|
+
d: 'm{mx},{my} m 2,7 l 10,0',
|
|
140
|
+
height: 10,
|
|
141
|
+
width: 10,
|
|
142
|
+
heightElements: [],
|
|
143
|
+
widthElements: []
|
|
144
|
+
},
|
|
145
|
+
'MARKER_STAGE_COLLAPSED': {
|
|
146
|
+
d: 'm{mx},{my} m 2,7 l 10,0 m -5,-5 l 0,10',
|
|
147
|
+
height: 10,
|
|
148
|
+
width: 10,
|
|
149
|
+
heightElements: [],
|
|
150
|
+
widthElements: []
|
|
151
|
+
},
|
|
152
|
+
'MARKER_REQUIRED': {
|
|
153
|
+
d: 'm{mx},{my} l 0,9 m 0,2 l0,3',
|
|
154
|
+
height: 14,
|
|
155
|
+
width: 3,
|
|
156
|
+
heightElements: [],
|
|
157
|
+
widthElements: []
|
|
158
|
+
},
|
|
159
|
+
|
|
160
|
+
'MARKER_MANUAL_ACTIVATION': {
|
|
161
|
+
d: 'm{mx}, {my} l 14,7 l -14,7 l 0,-14 z',
|
|
162
|
+
height: 14,
|
|
163
|
+
width: 14,
|
|
164
|
+
heightElements: [],
|
|
165
|
+
widthElements: []
|
|
166
|
+
},
|
|
167
|
+
|
|
168
|
+
'MARKER_REPEATABLE': {
|
|
169
|
+
d: 'm{mx},{my} m 3,0 l 0,14 m 6,-14 l 0,14 m -10,-10 l 14,0 m -14,6 l 14,0',
|
|
170
|
+
height: 14,
|
|
171
|
+
width: 14,
|
|
172
|
+
heightElements: [],
|
|
173
|
+
widthElements: []
|
|
174
|
+
},
|
|
175
|
+
|
|
176
|
+
'MARKER_PLANNING_TABLE_EXPANDED': {
|
|
177
|
+
d: 'm{mx},{my} m 0,12 l 30,0 m -20,-12 l 0, 24 m 10, -24 l 0, 24 m -10, -6 l 10,0',
|
|
178
|
+
height: 24,
|
|
179
|
+
width: 30,
|
|
180
|
+
heightElements: [],
|
|
181
|
+
widthElements: []
|
|
182
|
+
},
|
|
183
|
+
'MARKER_PLANNING_TABLE_COLLAPSED': {
|
|
184
|
+
d: 'm{mx},{my} m 0,12 l 30,0 m -20,-12 l 0, 24 m 10, -24 l 0, 24 m -10, -6 l 10,0 m -5, -6 l 0,12',
|
|
185
|
+
height: 10,
|
|
186
|
+
width: 10,
|
|
187
|
+
heightElements: [],
|
|
188
|
+
widthElements: []
|
|
189
|
+
},
|
|
190
|
+
|
|
191
|
+
'DATA_OBJECT_PATH': {
|
|
192
|
+
d:'m 0,0 {e.x1},0 {e.x0},{e.y0} 0,{e.y1} -{e.x2},0 0,-{e.y2} {e.x1},0 0,{e.y0} {e.x0},0',
|
|
193
|
+
height: 61,
|
|
194
|
+
width: 51,
|
|
195
|
+
heightElements: [10, 50, 60],
|
|
196
|
+
widthElements: [10, 40, 50, 60]
|
|
197
|
+
},
|
|
198
|
+
|
|
199
|
+
'TEXT_ANNOTATION': {
|
|
200
|
+
d: 'm {mx}, {my} m 10,0 l -10,0 l 0,{e.y0} l 10,0',
|
|
201
|
+
height: 30,
|
|
202
|
+
width: 10,
|
|
203
|
+
heightElements: [30],
|
|
204
|
+
widthElements: [10]
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
this.getRawPath = function getRawPath(pathId) {
|
|
209
|
+
return this.pathMap[pathId].d;
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Scales the path to the given height and width.
|
|
214
|
+
* <h1>Use case</h1>
|
|
215
|
+
* <p>Use case is to scale the content of elements (event) based
|
|
216
|
+
* on the element bounding box's size.
|
|
217
|
+
* </p>
|
|
218
|
+
* <h1>Why not transform</h1>
|
|
219
|
+
* <p>Scaling a path with transform() will also scale the stroke and IE does not support
|
|
220
|
+
* the option 'non-scaling-stroke' to prevent this.
|
|
221
|
+
* Also there are use cases where only some parts of a path should be
|
|
222
|
+
* scaled.</p>
|
|
223
|
+
*
|
|
224
|
+
* @param {String} pathId The ID of the path.
|
|
225
|
+
* @param {Object} param <p>
|
|
226
|
+
* Example param object scales the path to 60% size of the container (data.width, data.height).
|
|
227
|
+
* <pre>
|
|
228
|
+
* {
|
|
229
|
+
* xScaleFactor: 0.6,
|
|
230
|
+
* yScaleFactor:0.6,
|
|
231
|
+
* containerWidth: data.width,
|
|
232
|
+
* containerHeight: data.height,
|
|
233
|
+
* position: {
|
|
234
|
+
* mx: 0.46,
|
|
235
|
+
* my: 0.2,
|
|
236
|
+
* }
|
|
237
|
+
* }
|
|
238
|
+
* </pre>
|
|
239
|
+
* <ul>
|
|
240
|
+
* <li>targetpathwidth = xScaleFactor * containerWidth</li>
|
|
241
|
+
* <li>targetpathheight = yScaleFactor * containerHeight</li>
|
|
242
|
+
* <li>Position is used to set the starting coordinate of the path. M is computed:
|
|
243
|
+
* <ul>
|
|
244
|
+
* <li>position.x * containerWidth</li>
|
|
245
|
+
* <li>position.y * containerHeight</li>
|
|
246
|
+
* </ul>
|
|
247
|
+
* Center of the container <pre> position: {
|
|
248
|
+
* mx: 0.5,
|
|
249
|
+
* my: 0.5,
|
|
250
|
+
* }</pre>
|
|
251
|
+
* Upper left corner of the container
|
|
252
|
+
* <pre> position: {
|
|
253
|
+
* mx: 0.0,
|
|
254
|
+
* my: 0.0,
|
|
255
|
+
* }</pre>
|
|
256
|
+
* </li>
|
|
257
|
+
* </ul>
|
|
258
|
+
* </p>
|
|
259
|
+
*
|
|
260
|
+
*/
|
|
261
|
+
this.getScaledPath = function getScaledPath(pathId, param) {
|
|
262
|
+
var rawPath = this.pathMap[pathId];
|
|
263
|
+
|
|
264
|
+
// positioning
|
|
265
|
+
// compute the start point of the path
|
|
266
|
+
var mx, my;
|
|
267
|
+
|
|
268
|
+
if (param.abspos) {
|
|
269
|
+
mx = param.abspos.x;
|
|
270
|
+
my = param.abspos.y;
|
|
271
|
+
} else {
|
|
272
|
+
mx = param.containerWidth * param.position.mx;
|
|
273
|
+
my = param.containerHeight * param.position.my;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
var coordinates = {}; // map for the scaled coordinates
|
|
277
|
+
if (param.position) {
|
|
278
|
+
|
|
279
|
+
// path
|
|
280
|
+
var heightRatio = (param.containerHeight / rawPath.height) * param.yScaleFactor;
|
|
281
|
+
var widthRatio = (param.containerWidth / rawPath.width) * param.xScaleFactor;
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
// Apply height ratio
|
|
285
|
+
for (var heightIndex = 0; heightIndex < rawPath.heightElements.length; heightIndex++) {
|
|
286
|
+
coordinates['y' + heightIndex] = rawPath.heightElements[heightIndex] * heightRatio;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// Apply width ratio
|
|
290
|
+
for (var widthIndex = 0; widthIndex < rawPath.widthElements.length; widthIndex++) {
|
|
291
|
+
coordinates['x' + widthIndex] = rawPath.widthElements[widthIndex] * widthRatio;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// Apply value to raw path
|
|
296
|
+
var path = format(
|
|
297
|
+
rawPath.d, {
|
|
298
|
+
mx: mx,
|
|
299
|
+
my: my,
|
|
300
|
+
e: coordinates
|
|
301
|
+
}
|
|
302
|
+
);
|
|
303
|
+
return path;
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
module.exports = PathMap;
|
|
308
|
+
|
|
309
|
+
// helpers /////////////////
|
|
310
|
+
|
|
311
|
+
// copied from https://github.com/adobe-webplatform/Snap.svg/blob/master/src/svg.js
|
|
312
|
+
var tokenRegex = /\{([^}]+)\}/g,
|
|
313
|
+
objNotationRegex = /(?:(?:^|\.)(.+?)(?=\[|\.|$|\()|\[('|")(.+?)\2\])(\(\))?/g; // matches .xxxxx or ["xxxxx"] to run over object properties
|
|
314
|
+
|
|
315
|
+
function replacer(all, key, obj) {
|
|
316
|
+
var res = obj;
|
|
317
|
+
key.replace(objNotationRegex, function(all, name, quote, quotedName, isFunc) {
|
|
318
|
+
name = name || quotedName;
|
|
319
|
+
if (res) {
|
|
320
|
+
if (name in res) {
|
|
321
|
+
res = res[name];
|
|
322
|
+
}
|
|
323
|
+
typeof res == 'function' && isFunc && (res = res());
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
res = (res == null || res == obj ? all : res) + '';
|
|
327
|
+
|
|
328
|
+
return res;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
function format(str, obj) {
|
|
332
|
+
return String(str).replace(tokenRegex, function(all, key) {
|
|
333
|
+
return replacer(all, key, obj);
|
|
334
|
+
});
|
|
335
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var is = require('../../util/ModelUtil').is,
|
|
4
|
+
getDefinition = require('../../util/ModelUtil').getDefinition;
|
|
5
|
+
|
|
6
|
+
var inherits = require('inherits');
|
|
7
|
+
|
|
8
|
+
var forEach = require('min-dash').forEach;
|
|
9
|
+
|
|
10
|
+
var AutoResizeProvider = require('diagram-js/lib/features/auto-resize/AutoResizeProvider').default;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* This module provides a CMMN specific check if an element
|
|
14
|
+
* can be resized.
|
|
15
|
+
*/
|
|
16
|
+
function CmmnAutoResizeProvider(eventBus) {
|
|
17
|
+
AutoResizeProvider.call(this, eventBus);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
inherits(CmmnAutoResizeProvider, AutoResizeProvider);
|
|
21
|
+
|
|
22
|
+
CmmnAutoResizeProvider.$inject = [ 'eventBus' ];
|
|
23
|
+
|
|
24
|
+
module.exports = CmmnAutoResizeProvider;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Check if the given shape can be expanded
|
|
28
|
+
*
|
|
29
|
+
* @param {Array<djs.model.Shape>} elements
|
|
30
|
+
* @param {djs.model.Shape} target
|
|
31
|
+
*
|
|
32
|
+
* @return {boolean}
|
|
33
|
+
*/
|
|
34
|
+
CmmnAutoResizeProvider.prototype.canResize = function(elements, target) {
|
|
35
|
+
|
|
36
|
+
if (!is(target, 'cmmn:CMMNElement')) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
var criterionsOnly = true;
|
|
41
|
+
|
|
42
|
+
forEach(elements, function(element) {
|
|
43
|
+
if (!is(element, 'cmmn:Criterion')) {
|
|
44
|
+
criterionsOnly = false;
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// prevent auto expand if the selected elements are exclusively criterions
|
|
50
|
+
if (criterionsOnly) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
var definition = getDefinition(target);
|
|
55
|
+
|
|
56
|
+
return is(definition, 'cmmn:PlanFragment');
|
|
57
|
+
};
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var assign = require('min-dash').assign,
|
|
4
|
+
isArray = require('min-dash').isArray;
|
|
5
|
+
|
|
6
|
+
var isAny = require('../modeling/util/ModelingUtil').isAny;
|
|
7
|
+
|
|
8
|
+
var ModelUtil = require('../../util/ModelUtil'),
|
|
9
|
+
is = ModelUtil.is,
|
|
10
|
+
getDefinition = ModelUtil.getDefinition;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A provider for CMMN 1.1 elements context pad
|
|
14
|
+
*/
|
|
15
|
+
function ContextPadProvider(
|
|
16
|
+
contextPad,
|
|
17
|
+
connect,
|
|
18
|
+
create,
|
|
19
|
+
elementFactory,
|
|
20
|
+
modeling,
|
|
21
|
+
rules,
|
|
22
|
+
popupMenu,
|
|
23
|
+
canvas
|
|
24
|
+
) {
|
|
25
|
+
|
|
26
|
+
contextPad.registerProvider(this);
|
|
27
|
+
|
|
28
|
+
this._contextPad = contextPad;
|
|
29
|
+
this._connect = connect;
|
|
30
|
+
this._create = create;
|
|
31
|
+
this._elementFactory = elementFactory;
|
|
32
|
+
this._modeling = modeling;
|
|
33
|
+
this._rules = rules;
|
|
34
|
+
this._popupMenu = popupMenu;
|
|
35
|
+
this._canvas = canvas;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
ContextPadProvider.$inject = [
|
|
39
|
+
'contextPad',
|
|
40
|
+
'connect',
|
|
41
|
+
'create',
|
|
42
|
+
'elementFactory',
|
|
43
|
+
'modeling',
|
|
44
|
+
'rules',
|
|
45
|
+
'popupMenu',
|
|
46
|
+
'canvas'
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
module.exports = ContextPadProvider;
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
ContextPadProvider.prototype.getContextPadEntries = function(element) {
|
|
53
|
+
|
|
54
|
+
var contextPad = this._contextPad,
|
|
55
|
+
connect = this._connect,
|
|
56
|
+
create = this._create,
|
|
57
|
+
elementFactory = this._elementFactory,
|
|
58
|
+
modeling = this._modeling,
|
|
59
|
+
canvas = this._canvas,
|
|
60
|
+
rules = this._rules,
|
|
61
|
+
popupMenu = this._popupMenu;
|
|
62
|
+
|
|
63
|
+
var actions = {};
|
|
64
|
+
|
|
65
|
+
if (element.type === 'label') {
|
|
66
|
+
return actions;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
function removeElement(e) {
|
|
71
|
+
modeling.removeElements([ element ]);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function getReplaceMenuPosition(element) {
|
|
75
|
+
|
|
76
|
+
var Y_OFFSET = 5;
|
|
77
|
+
|
|
78
|
+
var diagramContainer = canvas.getContainer(),
|
|
79
|
+
pad = contextPad.getPad(element).html;
|
|
80
|
+
|
|
81
|
+
var diagramRect = diagramContainer.getBoundingClientRect(),
|
|
82
|
+
padRect = pad.getBoundingClientRect();
|
|
83
|
+
|
|
84
|
+
var top = padRect.top - diagramRect.top;
|
|
85
|
+
var left = padRect.left - diagramRect.left;
|
|
86
|
+
|
|
87
|
+
var pos = {
|
|
88
|
+
x: left,
|
|
89
|
+
y: top + padRect.height + Y_OFFSET
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
return pos;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function startConnect(event, element, autoActivate) {
|
|
96
|
+
connect.start(event, element, autoActivate);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
function appendCriterionAction(className, title, options) {
|
|
101
|
+
|
|
102
|
+
function appendListener(event, element) {
|
|
103
|
+
var shape = elementFactory.createCriterionShape('cmmn:EntryCriterion');
|
|
104
|
+
create.start(event, shape, element);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return appendAction('cmmn:EntryCriterion', className, title, options, appendListener);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function appendDiscretionaryItemAction(className, title, options) {
|
|
111
|
+
|
|
112
|
+
function appendListener(event, element) {
|
|
113
|
+
var shape = elementFactory.createDiscretionaryItemShape('cmmn:Task');
|
|
114
|
+
create.start(event, shape, element);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return appendAction('cmmn:DiscretionaryItem', className, title, options, appendListener);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function appendAction(type, className, title, options, listener) {
|
|
121
|
+
|
|
122
|
+
if (typeof title !== 'string') {
|
|
123
|
+
options = title;
|
|
124
|
+
title = 'Append ' + type.replace(/^cmmn:/, '');
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function appendListener(event, element) {
|
|
128
|
+
var shape = elementFactory.createShape(assign({ type: type }, options));
|
|
129
|
+
create.start(event, shape, element);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return {
|
|
133
|
+
group: 'model',
|
|
134
|
+
className: className,
|
|
135
|
+
title: title,
|
|
136
|
+
action: {
|
|
137
|
+
dragstart: listener || appendListener,
|
|
138
|
+
click: listener || appendListener
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
if (isAny(element, [ 'cmmn:PlanItem', 'cmmn:CaseFileItem' ])) {
|
|
145
|
+
assign(actions, {
|
|
146
|
+
'append.entryCriterion': appendCriterionAction('cmmn-icon-entry-criterion', 'Append Criterion')
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (isBlockingHumanTask(element)) {
|
|
151
|
+
assign(actions, {
|
|
152
|
+
'append.discretionaryItem': appendDiscretionaryItemAction(
|
|
153
|
+
'cmmn-icon-task-discretionary',
|
|
154
|
+
'Append DiscretionaryItem'
|
|
155
|
+
)
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
if (!popupMenu.isEmpty(element, 'cmmn-replace')) {
|
|
161
|
+
|
|
162
|
+
// Replace menu entry
|
|
163
|
+
assign(actions, {
|
|
164
|
+
'replace': {
|
|
165
|
+
group: 'edit',
|
|
166
|
+
className: 'cmmn-icon-screw-wrench',
|
|
167
|
+
title: 'Change type',
|
|
168
|
+
action: {
|
|
169
|
+
click: function(event, element) {
|
|
170
|
+
|
|
171
|
+
var position = assign(getReplaceMenuPosition(element), {
|
|
172
|
+
cursor: { x: event.x, y: event.y }
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
popupMenu.open(element, 'cmmn-replace', position);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
if (!isAny(element, [ 'cmmndi:CMMNEdge', 'cmmn:TextAnnotation' ])) {
|
|
184
|
+
assign(actions, {
|
|
185
|
+
'append.text-annotation': appendAction('cmmn:TextAnnotation', 'cmmn-icon-text-annotation')
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
if (isAny(element, [
|
|
191
|
+
'cmmn:PlanItem',
|
|
192
|
+
'cmmn:DiscretionaryItem',
|
|
193
|
+
'cmmn:CaseFileItem',
|
|
194
|
+
'cmmn:Criterion'
|
|
195
|
+
])) {
|
|
196
|
+
|
|
197
|
+
assign(actions, {
|
|
198
|
+
|
|
199
|
+
'connect': {
|
|
200
|
+
group: 'connect',
|
|
201
|
+
className: 'cmmn-icon-connection',
|
|
202
|
+
title: 'Connect using Discretionary/OnPart or Association',
|
|
203
|
+
action: {
|
|
204
|
+
click: startConnect,
|
|
205
|
+
dragstart: startConnect
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
// delete element entry, only show if allowed by rules
|
|
213
|
+
var deleteAllowed = rules.allowed('elements.delete', { elements: [ element ] });
|
|
214
|
+
|
|
215
|
+
if (isArray(deleteAllowed)) {
|
|
216
|
+
// was the element returned as a deletion candidate?
|
|
217
|
+
deleteAllowed = deleteAllowed[0] === element;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (deleteAllowed) {
|
|
221
|
+
assign(actions, {
|
|
222
|
+
'delete': {
|
|
223
|
+
group: 'edit',
|
|
224
|
+
className: 'cmmn-icon-trash',
|
|
225
|
+
title: 'Remove',
|
|
226
|
+
action: {
|
|
227
|
+
click: removeElement
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
return actions;
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
function isBlockingHumanTask(element) {
|
|
238
|
+
var definition = getDefinition(element);
|
|
239
|
+
return is(definition, 'cmmn:HumanTask') && definition.isBlocking;
|
|
240
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
__depends__: [
|
|
3
|
+
require('diagram-js/lib/features/connect').default,
|
|
4
|
+
require('diagram-js/lib/features/context-pad').default,
|
|
5
|
+
require('diagram-js/lib/features/create').default,
|
|
6
|
+
require('diagram-js/lib/features/selection').default,
|
|
7
|
+
require('../popup-menu')
|
|
8
|
+
],
|
|
9
|
+
__init__: [ 'contextPadProvider' ],
|
|
10
|
+
contextPadProvider: [ 'type', require('./ContextPadProvider') ]
|
|
11
|
+
};
|