@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.
Files changed (103) hide show
  1. package/.babelrc +3 -0
  2. package/CHANGELOG.md +119 -0
  3. package/LICENSE +23 -0
  4. package/README.md +107 -2
  5. package/dist/assets/cmmn-font/css/cmmn-codes.css +41 -0
  6. package/dist/assets/cmmn-font/css/cmmn-embedded.css +94 -0
  7. package/dist/assets/cmmn-font/css/cmmn.css +97 -0
  8. package/dist/assets/cmmn-font/font/cmmn.eot +0 -0
  9. package/dist/assets/cmmn-font/font/cmmn.svg +90 -0
  10. package/dist/assets/cmmn-font/font/cmmn.ttf +0 -0
  11. package/dist/assets/cmmn-font/font/cmmn.woff +0 -0
  12. package/dist/assets/cmmn-font/font/cmmn.woff2 +0 -0
  13. package/dist/assets/diagram-js.css +713 -0
  14. package/dist/cmmn-modeler.development.js +44817 -0
  15. package/dist/cmmn-modeler.production.min.js +2 -0
  16. package/dist/cmmn-navigated-viewer.development.js +18131 -0
  17. package/dist/cmmn-navigated-viewer.production.min.js +2 -0
  18. package/dist/cmmn-viewer.development.js +17599 -0
  19. package/dist/cmmn-viewer.production.min.js +2 -0
  20. package/index.js +1 -0
  21. package/lib/Modeler.js +222 -0
  22. package/lib/NavigatedViewer.js +28 -0
  23. package/lib/Viewer.js +489 -0
  24. package/lib/core/ItemRegistry.js +316 -0
  25. package/lib/core/index.js +7 -0
  26. package/lib/draw/CmmnRenderer.js +1235 -0
  27. package/lib/draw/PathMap.js +335 -0
  28. package/lib/draw/index.js +5 -0
  29. package/lib/features/auto-resize/CmmnAutoResizeProvider.js +57 -0
  30. package/lib/features/auto-resize/index.js +7 -0
  31. package/lib/features/context-pad/ContextPadProvider.js +240 -0
  32. package/lib/features/context-pad/index.js +11 -0
  33. package/lib/features/editor-actions/CmmnEditorActions.js +105 -0
  34. package/lib/features/editor-actions/index.js +10 -0
  35. package/lib/features/keyboard/CmmnKeyboardBindings.js +159 -0
  36. package/lib/features/keyboard/index.js +7 -0
  37. package/lib/features/label-editing/LabelEditingProvider.js +221 -0
  38. package/lib/features/label-editing/LabelUtil.js +95 -0
  39. package/lib/features/label-editing/cmd/UpdateLabelHandler.js +63 -0
  40. package/lib/features/label-editing/index.js +9 -0
  41. package/lib/features/modeling/CmmnFactory.js +166 -0
  42. package/lib/features/modeling/CmmnLayouter.js +49 -0
  43. package/lib/features/modeling/CmmnUpdater.js +511 -0
  44. package/lib/features/modeling/ElementFactory.js +215 -0
  45. package/lib/features/modeling/Modeling.js +185 -0
  46. package/lib/features/modeling/behavior/AttachCriterionBehavior.js +58 -0
  47. package/lib/features/modeling/behavior/CaseFileItemUpdater.js +324 -0
  48. package/lib/features/modeling/behavior/LabelBehavior.js +139 -0
  49. package/lib/features/modeling/behavior/PlanItemDefinitionUpdater.js +449 -0
  50. package/lib/features/modeling/behavior/PlanningTableUpdater.js +620 -0
  51. package/lib/features/modeling/behavior/ReplaceConnectionBehavior.js +320 -0
  52. package/lib/features/modeling/behavior/ReplaceElementBehavior.js +395 -0
  53. package/lib/features/modeling/behavior/ResizeCasePlanModelBehavior.js +108 -0
  54. package/lib/features/modeling/behavior/SentryUpdater.js +678 -0
  55. package/lib/features/modeling/behavior/UnclaimIdBehavior.js +28 -0
  56. package/lib/features/modeling/behavior/index.js +24 -0
  57. package/lib/features/modeling/cmd/AppendShapeHandler.js +52 -0
  58. package/lib/features/modeling/cmd/IdClaimHandler.js +38 -0
  59. package/lib/features/modeling/cmd/ReconnectConnectionHandler.js +57 -0
  60. package/lib/features/modeling/cmd/ReplaceShapeHandler.js +46 -0
  61. package/lib/features/modeling/cmd/UpdateControlsHandler.js +221 -0
  62. package/lib/features/modeling/cmd/UpdatePropertiesHandler.js +240 -0
  63. package/lib/features/modeling/cmd/UpdateSemanticParentHandler.js +94 -0
  64. package/lib/features/modeling/index.js +20 -0
  65. package/lib/features/modeling/util/ModelingUtil.js +138 -0
  66. package/lib/features/modeling/util/PlanItemDefinitionUtil.js +183 -0
  67. package/lib/features/ordering/CmmnOrderingProvider.js +146 -0
  68. package/lib/features/ordering/index.js +4 -0
  69. package/lib/features/outline/Outline.js +47 -0
  70. package/lib/features/outline/index.js +6 -0
  71. package/lib/features/palette/PaletteProvider.js +171 -0
  72. package/lib/features/palette/index.js +12 -0
  73. package/lib/features/popup-menu/ReplaceMenuProvider.js +448 -0
  74. package/lib/features/popup-menu/index.js +4 -0
  75. package/lib/features/replace/CmmnReplace.js +355 -0
  76. package/lib/features/replace/ReplaceOptions.js +241 -0
  77. package/lib/features/replace/index.js +8 -0
  78. package/lib/features/replace-preview/CmmnReplacePreview.js +247 -0
  79. package/lib/features/replace-preview/index.js +7 -0
  80. package/lib/features/rules/CmmnRules.js +1040 -0
  81. package/lib/features/rules/index.js +7 -0
  82. package/lib/features/search/CmmnSearchProvider.js +129 -0
  83. package/lib/features/search/index.js +7 -0
  84. package/lib/features/snapping/CmmnConnectSnapping.js +110 -0
  85. package/lib/features/snapping/CmmnCreateMoveSnapping.js +148 -0
  86. package/lib/features/snapping/CmmnResizeSnapping.js +42 -0
  87. package/lib/features/snapping/CmmnSnappingUtil.js +76 -0
  88. package/lib/features/snapping/index.js +17 -0
  89. package/lib/import/CmmnImporter.js +251 -0
  90. package/lib/import/CmmnTreeWalker.js +410 -0
  91. package/lib/import/Importer.js +73 -0
  92. package/lib/import/Util.js +9 -0
  93. package/lib/import/index.js +3 -0
  94. package/lib/util/DiUtil.js +39 -0
  95. package/lib/util/LabelUtil.js +124 -0
  96. package/lib/util/ModelUtil.js +257 -0
  97. package/lib/util/PoweredByUtil.js +91 -0
  98. package/package.json +88 -4
  99. package/test/helper/index.js +231 -0
  100. package/test/util/KeyEvents.js +23 -0
  101. package/test/util/MockEvents.js +55 -0
  102. package/test/util/custom-rules/CustomRules.js +19 -0
  103. package/test/util/custom-rules/index.js +4 -0
@@ -0,0 +1,94 @@
1
+ 'use strict';
2
+
3
+ var flatten = require('min-dash').flatten;
4
+
5
+ var Collections = require('diagram-js/lib/util/Collections');
6
+
7
+
8
+ function UpdateSemanticParentHandler() {
9
+ }
10
+
11
+ module.exports = UpdateSemanticParentHandler;
12
+
13
+
14
+ // api /////////////////
15
+
16
+ UpdateSemanticParentHandler.prototype.preExecute = function(context) {
17
+ var element = context.element,
18
+ shape = context.shape;
19
+
20
+ if (!element) {
21
+ throw new Error('element required');
22
+ }
23
+
24
+ var bo = element.businessObject || element;
25
+
26
+ context.businessObject = bo;
27
+ context.oldParent = bo.$parent;
28
+
29
+ var changed = [];
30
+
31
+ if (element.businessObject) {
32
+ changed.push(element);
33
+ }
34
+
35
+ if (shape) {
36
+ changed.push(shape);
37
+ }
38
+
39
+ context.changed = flatten(changed);
40
+ };
41
+
42
+ UpdateSemanticParentHandler.prototype.execute = function(context) {
43
+
44
+ var businessObject = context.businessObject,
45
+ newParent = context.newParent,
46
+ containment = context.containment;
47
+
48
+ this.updateSemanticParent(businessObject, newParent, containment);
49
+
50
+ // indicate changed on objects affected by the update
51
+ return context.changed;
52
+ };
53
+
54
+
55
+ UpdateSemanticParentHandler.prototype.revert = function(context) {
56
+
57
+ var businessObject = context.businessObject,
58
+ newParent = context.oldParent,
59
+ containment = context.containment;
60
+
61
+ this.updateSemanticParent(businessObject, newParent, containment);
62
+
63
+ return context.changed;
64
+ };
65
+
66
+
67
+ UpdateSemanticParentHandler.prototype.updateSemanticParent = function(element, newParent, containment) {
68
+
69
+ if (element.$parent === newParent) {
70
+ return;
71
+ }
72
+
73
+ var children;
74
+
75
+ if (element.$parent && containment) {
76
+ // remove from old parent
77
+ children = element.$parent.get(containment);
78
+ Collections.remove(children, element);
79
+ }
80
+
81
+ element.$parent = null;
82
+
83
+ if (newParent) {
84
+
85
+ if (containment) {
86
+ // add to new parent
87
+ children = newParent.get(containment);
88
+ children.push(element);
89
+ }
90
+
91
+ element.$parent = newParent;
92
+ }
93
+
94
+ };
@@ -0,0 +1,20 @@
1
+ module.exports = {
2
+ __init__: [ 'modeling', 'cmmnUpdater' ],
3
+ __depends__: [
4
+ require('./behavior'),
5
+ require('../ordering'),
6
+ require('../replace'),
7
+ require('../rules'),
8
+ require('diagram-js/lib/command').default,
9
+ require('diagram-js/lib/features/selection').default,
10
+ require('diagram-js/lib/features/label-support').default,
11
+ require('diagram-js/lib/features/attach-support').default,
12
+ require('diagram-js/lib/features/change-support').default
13
+ ],
14
+ cmmnFactory: [ 'type', require('./CmmnFactory') ],
15
+ cmmnUpdater: [ 'type', require('./CmmnUpdater') ],
16
+ elementFactory: [ 'type', require('./ElementFactory') ],
17
+ modeling: [ 'type', require('./Modeling') ],
18
+ layouter: [ 'type', require('./CmmnLayouter') ],
19
+ connectionDocking: [ 'type', require('diagram-js/lib/layout/CroppingConnectionDocking').default ]
20
+ };
@@ -0,0 +1,138 @@
1
+ 'use strict';
2
+
3
+ var some = require('min-dash').some;
4
+
5
+ var ModelUtil = require('../../../util/ModelUtil'),
6
+ is = ModelUtil.is,
7
+ getBusinessObject = ModelUtil.getBusinessObject;
8
+
9
+ var Model = require('diagram-js/lib/model');
10
+
11
+ /**
12
+ * Return true if given elements are the same.
13
+ *
14
+ * @param {Object} a
15
+ * @param {Object} b
16
+ *
17
+ * @return {boolean}
18
+ */
19
+ function isSame(a, b) {
20
+ return a === b;
21
+ }
22
+
23
+ module.exports.isSame = isSame;
24
+
25
+
26
+ /**
27
+ * Return true if given cases are the same.
28
+ *
29
+ * @param {ModdleElement} a
30
+ * @param {ModdleElement} b
31
+ *
32
+ * @return {boolean}
33
+ */
34
+ function isSameCase(a, b) {
35
+ return isSame(getCase(a), getCase(b));
36
+ }
37
+
38
+ module.exports.isSameCase = isSameCase;
39
+
40
+ function getCase(element) {
41
+ return getParent(getBusinessObject(element), 'cmmn:Case');
42
+ }
43
+
44
+ module.exports.getCase = getCase;
45
+
46
+
47
+ /**
48
+ * Return the parents of the element with any of the given types.
49
+ *
50
+ * @param {ModdleElement} element
51
+ * @param {String|Array<String>} anyType
52
+ *
53
+ * @return {Array<ModdleElement>}
54
+ */
55
+ function getParents(element, anyType) {
56
+
57
+ var parents = [];
58
+
59
+ if (typeof anyType === 'string') {
60
+ anyType = [ anyType ];
61
+ }
62
+
63
+ while (element) {
64
+ element = element.$parent || element.parent;
65
+
66
+ if (element) {
67
+
68
+ if (anyType) {
69
+ if (isAny(element, anyType)) {
70
+ parents.push(element);
71
+ }
72
+ }
73
+ else {
74
+ parents.push(element);
75
+ }
76
+
77
+ }
78
+
79
+ }
80
+
81
+ return parents;
82
+ }
83
+
84
+ module.exports.getParents = getParents;
85
+
86
+ /**
87
+ * Return the parent of the element with any of the given types.
88
+ *
89
+ * @param {ModdleElement} element
90
+ * @param {String|Array<String>} anyType
91
+ *
92
+ * @return {ModdleElement}
93
+ */
94
+ function getParent(element, anyType) {
95
+
96
+ if (typeof anyType === 'string') {
97
+ anyType = [ anyType ];
98
+ }
99
+
100
+ while ((element = element.$parent || element.parent)) {
101
+ if (anyType) {
102
+ if (isAny(element, anyType)) {
103
+ return element;
104
+ }
105
+ }
106
+ else {
107
+ return element;
108
+ }
109
+ }
110
+
111
+ return null;
112
+ }
113
+
114
+ module.exports.getParent = getParent;
115
+
116
+
117
+ /**
118
+ * Return true if element has any of the given types.
119
+ *
120
+ * @param {djs.model.Base} element
121
+ * @param {Array<String>} types
122
+ *
123
+ * @return {Boolean}
124
+ */
125
+ function isAny(element, types) {
126
+ return some(types, function(t) {
127
+ return is(element, t);
128
+ });
129
+ }
130
+
131
+ module.exports.isAny = isAny;
132
+
133
+
134
+ function isLabel(element) {
135
+ return element instanceof Model.Label;
136
+ }
137
+
138
+ module.exports.isLabel = isLabel;
@@ -0,0 +1,183 @@
1
+ 'use strict';
2
+
3
+ var ModelUtil = require('../../../util/ModelUtil'),
4
+ is = ModelUtil.is,
5
+ getDefinition = ModelUtil.getDefinition,
6
+ getBusinessObject = ModelUtil.getBusinessObject;
7
+
8
+ var isAny = require('./ModelingUtil').isAny,
9
+ getParent = require('./ModelingUtil').getParent;
10
+
11
+ var eachElement = require('diagram-js/lib/util/Elements').eachElement;
12
+
13
+
14
+ /**
15
+ * Returns all contained discretionary items.
16
+ *
17
+ * @param {ModdleElement} element
18
+ *
19
+ * @return {Array<ModdleElement>} all discretionary items
20
+ */
21
+ function getAllDiscretionaryItems(element) {
22
+
23
+ element = getBusinessObject(element);
24
+
25
+ if (isItemCapable(element)) {
26
+ element = getDefinition(element);
27
+ }
28
+
29
+ var result = [];
30
+
31
+ if (isPlanningTableCapable(element)) {
32
+ element = element.planningTable;
33
+
34
+ if (element) {
35
+
36
+ var items = element.get('tableItems');
37
+ eachElement(items, function(item) {
38
+ if (isDiscretionaryItem(item)) {
39
+ result.push(item);
40
+ }
41
+ else {
42
+ return item.get('tableItems');
43
+ }
44
+ });
45
+ }
46
+ }
47
+
48
+ return result;
49
+ }
50
+
51
+ module.exports.getAllDiscretionaryItems = getAllDiscretionaryItems;
52
+
53
+
54
+ /**
55
+ * Returns all directed item capables elements of the given element.
56
+ *
57
+ * @param {ModdleElement} element
58
+ *
59
+ * @return {Array<ModdleElement>} all direct item capables
60
+ */
61
+ function getDirectItemCapables(element) {
62
+
63
+ element = getBusinessObject(element);
64
+
65
+ if (isItemCapable(element)) {
66
+ element = getDefinition(element);
67
+ }
68
+
69
+ var result = [];
70
+
71
+ function add(item) {
72
+ result.push(item);
73
+ }
74
+
75
+ if (element) {
76
+
77
+ var items;
78
+
79
+ if (is(element, 'cmmn:PlanFragment')) {
80
+ items = element.get('planItems');
81
+ eachElement(items, add);
82
+ }
83
+
84
+ if (isPlanningTableCapable(element)) {
85
+ items = getAllDiscretionaryItems(element);
86
+ eachElement(items, add);
87
+ }
88
+
89
+ }
90
+
91
+ return result;
92
+ }
93
+
94
+ module.exports.getDirectItemCapables = getDirectItemCapables;
95
+
96
+
97
+ /**
98
+ * Returns true if the given element is either a discretionary item
99
+ * or a plan item
100
+ *
101
+ * @param {djs.model.Base} element
102
+ *
103
+ * @return {boolean} when it is a discretionary item or a plan item
104
+ */
105
+ function isItemCapable(element) {
106
+ return isAny(element, [ 'cmmn:DiscretionaryItem', 'cmmn:PlanItem' ]);
107
+ }
108
+
109
+ module.exports.isItemCapable = isItemCapable;
110
+
111
+
112
+ /**
113
+ * Returns true if the given element is either a human task or
114
+ * a stage.
115
+ *
116
+ * @param {djs.model.Base} element
117
+ *
118
+ * @return {boolean} when it is a human task or stage
119
+ */
120
+ function isPlanningTableCapable(element) {
121
+ return isAny(element, [ 'cmmn:HumanTask', 'cmmn:Stage' ]);
122
+ }
123
+
124
+ module.exports.isPlanningTableCapable = isPlanningTableCapable;
125
+
126
+
127
+ /**
128
+ * Returns true if the given element is a discretionary item.
129
+ *
130
+ * @param {djs.model.Base} element
131
+ *
132
+ * @return {boolean} when it is a discretionary item
133
+ */
134
+ function isDiscretionaryItem(element) {
135
+ return is(element, 'cmmn:DiscretionaryItem');
136
+ }
137
+
138
+ module.exports.isDiscretionaryItem = isDiscretionaryItem;
139
+
140
+
141
+ /**
142
+ * Returns true if the given element is a discretionary to a human task.
143
+ *
144
+ * @param {djs.model.Base} element
145
+ *
146
+ * @return {boolean} when it is discretionary to a human task
147
+ */
148
+ function isDiscretionaryToHumanTask(element) {
149
+ var bo = getBusinessObject(element);
150
+ var parent = getParent(bo, 'cmmn:PlanItemDefinition');
151
+ return is(parent, 'cmmn:HumanTask');
152
+ }
153
+
154
+ module.exports.isDiscretionaryToHumanTask = isDiscretionaryToHumanTask;
155
+
156
+
157
+ /**
158
+ * Returns true if the given element is a human task.
159
+ *
160
+ * @param {djs.model.Base} element
161
+ *
162
+ * @return {boolean} when it is a human task
163
+ */
164
+ function isHumanTask(element) {
165
+ return is(element, 'cmmn:HumanTask');
166
+ }
167
+
168
+ module.exports.isHumanTask = isHumanTask;
169
+
170
+
171
+ /**
172
+ * Returns true if the given element is a plan fragment and not
173
+ * a stage.
174
+ *
175
+ * @param {djs.model.Base} element
176
+ *
177
+ * @return {boolean} when it is a plan fragment
178
+ */
179
+ function isPlanFragment(element) {
180
+ return is(element, 'cmmn:PlanFragment') && !is(element, 'cmmn:Stage');
181
+ }
182
+
183
+ module.exports.isPlanFragment = isPlanFragment;
@@ -0,0 +1,146 @@
1
+ 'use strict';
2
+
3
+ var inherits = require('inherits');
4
+
5
+ var OrderingProvider = require('diagram-js/lib/features/ordering/OrderingProvider').default;
6
+ var findIndex = require('min-dash').findIndex;
7
+ var find = require('min-dash').find;
8
+ var is = require('../../util/ModelUtil').is;
9
+ var isAny = require('../modeling/util/ModelingUtil').isAny;
10
+
11
+ function CmmnOrderingProvider(eventBus) {
12
+
13
+ OrderingProvider.call(this, eventBus);
14
+
15
+ var orders = [
16
+ { type: 'label', order: { level: 10 } },
17
+ { type: 'cmmn:Criterion', order: { level: 6 } },
18
+ {
19
+ type: 'cmmn:OnPart',
20
+ order: {
21
+ level: 9,
22
+ containers: [
23
+ 'cmmn:Stage'
24
+ ]
25
+ }
26
+ },
27
+ {
28
+ type: 'cmmn:Association',
29
+ order: {
30
+ level: 9,
31
+ containers: [
32
+ 'cmmndi:CMMNDiagram'
33
+ ]
34
+ }
35
+ },
36
+ {
37
+ type: 'cmmndi:CMMNEdge',
38
+ order: {
39
+ level: 9,
40
+ containers: [
41
+ 'cmmn:PlanItem',
42
+ 'cmmn:DiscretionaryItem',
43
+ 'cmmn:Stage'
44
+ ]
45
+ }
46
+ }
47
+ ];
48
+
49
+ function computeOrder(element) {
50
+
51
+ if (isCMMNEdge(element)) {
52
+ element = element.businessObject.cmmnElementRef || element;
53
+ }
54
+
55
+ var entry = find(orders, function(o) {
56
+ return is(element, o.type);
57
+ });
58
+
59
+ return entry && entry.order || { level: 1 };
60
+ }
61
+
62
+ function getOrder(element) {
63
+
64
+ var order = element.order;
65
+
66
+ if (!order) {
67
+ element.order = order = computeOrder(element);
68
+ }
69
+
70
+ return order;
71
+ }
72
+
73
+ function findActualParent(element, newParent, containers) {
74
+
75
+ var actualParent = newParent;
76
+
77
+ if (isCMMNEdge(element) && element.source) {
78
+ actualParent = element.source.parent;
79
+ }
80
+
81
+ while (actualParent) {
82
+
83
+ if (isAny(actualParent, containers)) {
84
+ break;
85
+ }
86
+
87
+ actualParent = actualParent.parent;
88
+ }
89
+
90
+ if (!actualParent) {
91
+ throw new Error('no parent for ' + element.id + ' in ' + newParent.id);
92
+ }
93
+
94
+ return actualParent;
95
+ }
96
+
97
+ this.getOrdering = function(element, newParent) {
98
+
99
+ var elementOrder = getOrder(element);
100
+
101
+ if (elementOrder.containers) {
102
+ newParent = findActualParent(element, newParent, elementOrder.containers);
103
+ }
104
+
105
+ var currentIndex = newParent.children.indexOf(element);
106
+
107
+ var insertIndex = findIndex(newParent.children, function(child) {
108
+
109
+ // do not compare with labels, they are created
110
+ // in the wrong order (right after elements) during import and
111
+ // mess up the positioning.
112
+ if (!element.labelTarget && child.labelTarget) {
113
+ return false;
114
+ }
115
+
116
+ return elementOrder.level < getOrder(child).level;
117
+ });
118
+
119
+
120
+ // if the element is already in the child list at
121
+ // a smaller index, we need to adjust the insert index.
122
+ // this takes into account that the element is being removed
123
+ // before being re-inserted
124
+ if (insertIndex !== -1) {
125
+ if (currentIndex !== -1 && currentIndex < insertIndex) {
126
+ insertIndex -= 1;
127
+ }
128
+ }
129
+
130
+ return {
131
+ index: insertIndex,
132
+ parent: newParent
133
+ };
134
+
135
+ };
136
+ }
137
+
138
+ CmmnOrderingProvider.$inject = [ 'eventBus' ];
139
+
140
+ inherits(CmmnOrderingProvider, OrderingProvider);
141
+
142
+ module.exports = CmmnOrderingProvider;
143
+
144
+ function isCMMNEdge(element) {
145
+ return is(element, 'cmmndi:CMMNEdge');
146
+ }
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ __init__: [ 'cmmnOrderingProvider' ],
3
+ cmmnOrderingProvider: [ 'type', require('./CmmnOrderingProvider') ]
4
+ };
@@ -0,0 +1,47 @@
1
+ 'use strict';
2
+
3
+ var BaseOutline = require('diagram-js/lib/features/outline/Outline').default;
4
+
5
+ var inherits = require('inherits');
6
+
7
+ var isCasePlanModel = require('../../util/ModelUtil').isCasePlanModel;
8
+
9
+ var svgAttr = require('tiny-svg').attr;
10
+
11
+
12
+ /**
13
+ * This is a subclass of the Outline module from diagram-js.
14
+ * It defines outlines which differ from the element size basis.
15
+ *
16
+ * @param {EventBus} eventBus
17
+ * @param {Styles} styles
18
+ * @param {ElementRegistry} elementRegistry
19
+ */
20
+ function Outline(eventBus, styles, elementRegistry) {
21
+ BaseOutline.call(this, eventBus, styles, elementRegistry);
22
+ }
23
+
24
+ inherits(Outline, BaseOutline);
25
+
26
+ Outline.$inject = [ 'eventBus', 'styles', 'elementRegistry' ];
27
+
28
+ Outline.prototype.baseUpdateShapeOutline = BaseOutline.prototype.updateShapeOutline;
29
+
30
+ Outline.prototype.updateShapeOutline = function(outline, element) {
31
+
32
+ if (!isCasePlanModel(element)) {
33
+
34
+ this.baseUpdateShapeOutline(outline, element);
35
+ } else {
36
+
37
+ // update outlines for casePlanModels
38
+ svgAttr(outline, {
39
+ x: -this.offset,
40
+ y: -this.offset - 18,
41
+ width: element.width + this.offset * 2,
42
+ height: element.height + 18 + this.offset * 2
43
+ });
44
+ }
45
+ };
46
+
47
+ module.exports = Outline;
@@ -0,0 +1,6 @@
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ __init__: [ 'outline' ],
5
+ outline: [ 'type', require('./Outline') ]
6
+ };