@processmaker/modeler 1.30.2 → 1.31.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 (186) hide show
  1. package/dist/img/{boundary-event.5bf51421.svg → boundary-event.4e0fb9de.svg} +3 -3
  2. package/dist/img/clipboard.5fe6f79e.svg +3 -0
  3. package/dist/img/conditional-start-event.a56e4b5b.svg +4 -0
  4. package/dist/img/{connect-artifacts.5f8bed89.svg → connect-artifacts.496eb4b9.svg} +3 -3
  5. package/dist/img/{connect-elements.d4abedf2.svg → connect-elements.9ec5ca93.svg} +3 -3
  6. package/dist/img/copy-regular.2d678143.svg +3 -0
  7. package/dist/img/data-object.0d6d1585.svg +3 -0
  8. package/dist/img/data-store.32bed5ce.svg +3 -0
  9. package/dist/img/{default-flow.212147b4.svg → default-flow.156a793b.svg} +3 -3
  10. package/dist/img/end-event.9d1ff5c0.svg +3 -0
  11. package/dist/img/error-end-event.aab86eca.svg +11 -0
  12. package/dist/img/event-based-gateway.9960eee5.svg +6 -0
  13. package/dist/img/exclusive-gateway.26db4fae.svg +4 -0
  14. package/dist/img/generic-gateway.09ca6929.svg +3 -0
  15. package/dist/img/generic-intermediate-event.a711eb33.svg +4 -0
  16. package/dist/img/inclusive-gateway.754cb36f.svg +4 -0
  17. package/dist/img/intermediate-conditional-catch-event.e9ae6198.svg +5 -0
  18. package/dist/img/intermediate-message-catch-event.9d25208e.svg +5 -0
  19. package/dist/img/intermediate-message-throw-event.4309dc45.svg +5 -0
  20. package/dist/img/intermediate-signal-catch-event.74b65f17.svg +5 -0
  21. package/dist/img/intermediate-signal-throw-event.29cad018.svg +5 -0
  22. package/dist/img/intermediate-timer-event.1670a1c8.svg +5 -0
  23. package/dist/img/{lane-below.890c069b.svg → lane-below.e67f9823.svg} +12 -12
  24. package/dist/img/manual-task.374a73c3.svg +4 -0
  25. package/dist/img/message-end-event.f15b67f5.svg +4 -0
  26. package/dist/img/message-start-event.f2d4a5e6.svg +4 -0
  27. package/dist/img/mini-map.ae46890c.svg +3 -0
  28. package/dist/img/minus.ca21cc3b.svg +3 -0
  29. package/dist/img/parallel-gateway.877bb628.svg +4 -0
  30. package/dist/img/pin-angle-fill.0e4af645.svg +3 -0
  31. package/dist/img/pin-angle.3462c115.svg +3 -0
  32. package/dist/img/plus.afbb0b13.svg +3 -0
  33. package/dist/img/pool.98d4734c.svg +3 -0
  34. package/dist/img/redo.8425ce7e.svg +4 -0
  35. package/dist/img/script-task.3d8c664a.svg +4 -0
  36. package/dist/img/signal-end-event.a38a6616.svg +4 -0
  37. package/dist/img/signal-start-event.3d7b096c.svg +4 -0
  38. package/dist/img/start-event.7f1911cb.svg +3 -0
  39. package/dist/img/sub-task.52d09847.svg +4 -0
  40. package/dist/img/task.8a1c6c75.svg +3 -0
  41. package/dist/img/terminate-end-event.3aa5cd00.svg +4 -0
  42. package/dist/img/text-annotation.02df53cd.svg +3 -0
  43. package/dist/img/timer-start-event.55abac82.svg +4 -0
  44. package/dist/img/trash-alt-solid.58c408b8.svg +1 -0
  45. package/dist/img/undo.e0ffff93.svg +4 -0
  46. package/dist/modeler.common.js +19227 -12350
  47. package/dist/modeler.common.js.map +1 -1
  48. package/dist/modeler.umd.js +19227 -12350
  49. package/dist/modeler.umd.js.map +1 -1
  50. package/dist/modeler.umd.min.js +28 -3
  51. package/dist/modeler.umd.min.js.map +1 -1
  52. package/jsconfig.json +12 -0
  53. package/package.json +3 -1
  54. package/src/.DS_Store +0 -0
  55. package/src/ModelerApp.vue +21 -21
  56. package/src/assets/boundary-event.svg +3 -3
  57. package/src/assets/clipboard.svg +3 -1
  58. package/src/assets/cog-solid.svg +1 -0
  59. package/src/assets/connect-artifacts.svg +3 -3
  60. package/src/assets/connect-elements.svg +3 -3
  61. package/src/assets/copy-regular.svg +3 -1
  62. package/src/assets/default-flow.svg +3 -3
  63. package/src/assets/lane-below.svg +12 -12
  64. package/src/assets/palette.svg +1 -0
  65. package/src/assets/pin-angle-fill.svg +3 -0
  66. package/src/assets/pin-angle.svg +3 -0
  67. package/src/assets/railBottom/mini-map.svg +3 -0
  68. package/src/assets/railBottom/minus.svg +3 -0
  69. package/src/assets/railBottom/plus.svg +3 -0
  70. package/src/assets/railBottom/redo.svg +4 -0
  71. package/src/assets/railBottom/undo.svg +4 -0
  72. package/src/assets/scss/settings/_settings.variables.scss +5 -0
  73. package/src/assets/scss/tools/_tools.chevron.scss +1 -1
  74. package/src/assets/toolpanel/conditional-start-event.svg +4 -0
  75. package/src/assets/toolpanel/data-object.svg +2 -8
  76. package/src/assets/toolpanel/data-store.svg +2 -5
  77. package/src/assets/toolpanel/end-event.svg +3 -19
  78. package/src/assets/toolpanel/error-end-event.svg +11 -0
  79. package/src/assets/toolpanel/event-based-gateway.svg +6 -0
  80. package/src/assets/toolpanel/exclusive-gateway.svg +4 -0
  81. package/src/assets/toolpanel/generic-gateway.svg +2 -13
  82. package/src/assets/toolpanel/generic-intermediate-event.svg +3 -4
  83. package/src/assets/toolpanel/inclusive-gateway.svg +4 -0
  84. package/src/assets/toolpanel/intermediate-conditional-catch-event.svg +5 -0
  85. package/src/assets/toolpanel/intermediate-message-catch-event.svg +5 -0
  86. package/src/assets/toolpanel/intermediate-message-throw-event.svg +4 -5
  87. package/src/assets/toolpanel/intermediate-signal-catch-event.svg +5 -0
  88. package/src/assets/toolpanel/intermediate-signal-throw-event.svg +5 -0
  89. package/src/assets/toolpanel/intermediate-timer-event.svg +5 -0
  90. package/src/assets/toolpanel/manual-task.svg +4 -0
  91. package/src/assets/toolpanel/message-end-event.svg +4 -0
  92. package/src/assets/toolpanel/message-start-event.svg +3 -3
  93. package/src/assets/toolpanel/parallel-gateway.svg +4 -0
  94. package/src/assets/toolpanel/pool.svg +3 -11
  95. package/src/assets/toolpanel/script-task.svg +4 -0
  96. package/src/assets/toolpanel/signal-end-event.svg +4 -0
  97. package/src/assets/toolpanel/signal-start-event.svg +4 -0
  98. package/src/assets/toolpanel/start-event.svg +3 -19
  99. package/src/assets/toolpanel/sub-task.svg +4 -0
  100. package/src/assets/toolpanel/task.svg +3 -14
  101. package/src/assets/toolpanel/terminate-end-event.svg +4 -0
  102. package/src/assets/toolpanel/text-annotation.svg +3 -17
  103. package/src/assets/toolpanel/timer-start-event.svg +4 -0
  104. package/src/assets/trash-alt-solid.svg +1 -4
  105. package/src/components/crown/crownButtons/addLaneAboveButton.vue +6 -4
  106. package/src/components/crown/crownButtons/addLaneBelowButton.vue +6 -4
  107. package/src/components/crown/crownButtons/associationFlowButton.vue +1 -14
  108. package/src/components/crown/crownButtons/cloneButton.vue +1 -6
  109. package/src/components/crown/crownButtons/copyButton.vue +1 -4
  110. package/src/components/crown/crownButtons/crownBoundaryEventDropdown.vue +7 -2
  111. package/src/components/crown/crownButtons/crownButton.vue +36 -11
  112. package/src/components/crown/crownButtons/crownColorDropdown.vue +1 -1
  113. package/src/components/crown/crownButtons/crownDropdown.scss +4 -9
  114. package/src/components/crown/crownButtons/crownTaskDropdown.vue +1 -1
  115. package/src/components/crown/crownButtons/deleteButton.vue +1 -7
  116. package/src/components/crown/crownButtons/genericFlowButton.vue +4 -4
  117. package/src/components/crown/crownButtons/icons/faAlignBottom.js +11 -0
  118. package/src/components/crown/crownButtons/icons/faAlignLeft.js +11 -0
  119. package/src/components/crown/crownButtons/icons/faAlignRight.js +11 -0
  120. package/src/components/crown/crownButtons/icons/faAlignTop.js +11 -0
  121. package/src/components/crown/crownButtons/icons/faBoundaryEvent.js +11 -0
  122. package/src/components/crown/crownButtons/icons/faCenterHorizontally.js +11 -0
  123. package/src/components/crown/crownButtons/icons/faCenterVertically.js +11 -0
  124. package/src/components/crown/crownButtons/icons/faConnectElements.js +11 -0
  125. package/src/components/crown/crownButtons/icons/faDistributeHorizontally.js +11 -0
  126. package/src/components/crown/crownButtons/icons/faDistributeVertically.js +11 -0
  127. package/src/components/crown/crownButtons/icons/faLaneAbove.js +11 -0
  128. package/src/components/crown/crownButtons/icons/faLaneBelow.js +11 -0
  129. package/src/components/crown/crownButtons/icons/index.js +12 -0
  130. package/src/components/crown/crownConfig/crownConfig.scss +5 -4
  131. package/src/components/crown/crownConfig/crownConfig.vue +5 -4
  132. package/src/components/crown/crownMultiselect/crownAlign.scss +20 -0
  133. package/src/components/crown/crownMultiselect/crownAlign.vue +302 -0
  134. package/src/components/crown/crownMultiselect/crownMultiselect.vue +60 -14
  135. package/src/components/miniPaper/MiniPaper.vue +16 -2
  136. package/src/components/miniPaper/miniPaper.scss +6 -12
  137. package/src/components/modeler/Modeler.vue +29 -23
  138. package/src/components/modeler/ModelerReadonly.vue +996 -0
  139. package/src/components/modeler/Selection.vue +206 -18
  140. package/src/components/nodes/boundaryEvent/boundaryEvent.vue +0 -5
  141. package/src/components/nodes/endEvent/index.js +37 -0
  142. package/src/components/nodes/exclusiveGateway/index.js +30 -0
  143. package/src/components/nodes/genericFlow/SequenceFlow.js +2 -1
  144. package/src/components/nodes/index.js +1 -0
  145. package/src/components/nodes/intermediateTimerEvent/index.js +44 -0
  146. package/src/components/nodes/pool/pool.vue +0 -8
  147. package/src/components/nodes/startEvent/index.js +43 -0
  148. package/src/components/nodes/task/index.js +30 -0
  149. package/src/components/railBottom/RailBottom.vue +120 -0
  150. package/src/components/railBottom/controls/Controls.vue +148 -0
  151. package/src/components/railBottom/controls/SubmenuPopper/SubmenuPopper.vue +188 -0
  152. package/src/components/railBottom/controls/controls.scss +98 -0
  153. package/src/components/railBottom/icons/MinusIcon.vue +5 -0
  154. package/src/components/railBottom/icons/PlusIcon.vue +5 -0
  155. package/src/components/railBottom/icons/index.js +2 -0
  156. package/src/components/railBottom/miniPaperControl/MiniPaperControl.vue +46 -0
  157. package/src/components/railBottom/miniPaperControl/miniPaperControl.scss +45 -0
  158. package/src/components/railBottom/railBottom.scss +28 -0
  159. package/src/components/railBottom/undoRedoControl/UndoRedoControl.vue +89 -0
  160. package/src/components/railBottom/undoRedoControl/undoRedoControl.scss +51 -0
  161. package/src/components/railBottom/zoomControl/ZoomControl.vue +80 -0
  162. package/src/components/railBottom/zoomControl/zoomControl.scss +66 -0
  163. package/src/components/rails/explorer-rail/explorer-rail.scss +55 -0
  164. package/src/components/rails/explorer-rail/explorer.vue +93 -0
  165. package/src/components/rails/explorer-rail/filterNodeTypes/filterNodeTypes.vue +54 -0
  166. package/src/components/rails/explorer-rail/nodeTypesLoop/nodeTypesLoop.vue +234 -0
  167. package/src/components/rails/explorer-rail/rankConstants.js +1 -0
  168. package/src/components/toolbar/ToolBar.vue +0 -66
  169. package/src/main.js +6 -0
  170. package/src/mixins/linkConfig.js +16 -5
  171. package/src/mixins/resizeConfig.js +3 -1
  172. package/src/nodeTypesStore.js +118 -0
  173. package/src/store.js +5 -0
  174. package/dist/img/clipboard.bcc7796a.svg +0 -1
  175. package/dist/img/copy-regular.3eb4c04a.svg +0 -1
  176. package/dist/img/data-object.e931f8e7.svg +0 -9
  177. package/dist/img/data-store.7ca4c899.svg +0 -6
  178. package/dist/img/end-event.1ad31396.svg +0 -19
  179. package/dist/img/generic-gateway.3a76fc75.svg +0 -14
  180. package/dist/img/generic-intermediate-event.ba2e1d71.svg +0 -5
  181. package/dist/img/intermediate-message-throw-event.ac432d96.svg +0 -6
  182. package/dist/img/pool.ac62ddae.svg +0 -11
  183. package/dist/img/start-event.e895cee2.svg +0 -19
  184. package/dist/img/task.e7419065.svg +0 -14
  185. package/dist/img/text-annotation.926416f4.svg +0 -17
  186. package/dist/img/trash-alt-solid.f2f64c1f.svg +0 -4
@@ -0,0 +1,996 @@
1
+ <template>
2
+ <span data-test="body-container">
3
+ <div class="modeler h-100">
4
+ <controls
5
+ v-if="showControls"
6
+ class="controls h-100 rounded-0 border-top-0 border-bottom-0 border-left-0"
7
+ :nodeTypes="nodeTypes"
8
+ :compressed="panelsCompressed"
9
+ :parent-height="parentHeight"
10
+ :allowDrop="allowDrop"
11
+ :canvas-drag-position="canvasDragPosition"
12
+ @drag="validateDropTarget"
13
+ @handleDrop="handleDrop"
14
+ />
15
+ <b-col
16
+ ref="paper-container"
17
+ class="paper-container h-100 pr-4"
18
+ :class="[cursor, { 'grabbing-cursor' : isGrabbing }]"
19
+ :style="{ width: parentWidth, height: parentHeight }"
20
+ >
21
+
22
+ <div ref="paper" data-test="paper" class="main-paper" />
23
+ </b-col>
24
+
25
+ <component
26
+ ref="nodeComponent"
27
+ v-for="node in nodes"
28
+ :is="node.type"
29
+ :key="node._modelerId"
30
+ :graph="graph"
31
+ :paper="paper"
32
+ :node="node"
33
+ :id="node.id"
34
+ :highlighted="highlightedNodes.includes(node)"
35
+ :border-outline="borderOutline(node.id)"
36
+ :collaboration="collaboration"
37
+ :process-node="processNode"
38
+ :processes="processes"
39
+ :plane-elements="planeElements"
40
+ :moddle="moddle"
41
+ :nodeRegistry="nodeRegistry"
42
+ :root-elements="definitions.get('rootElements')"
43
+ :isRendering="isRendering"
44
+ :paperManager="paperManager"
45
+ :auto-validate="autoValidate"
46
+ :is-active="node === activeNode"
47
+ :node-id-generator="nodeIdGenerator"
48
+ @add-node="addNode"
49
+ @set-cursor="cursor = $event"
50
+ @set-pool-target="poolTarget = $event"
51
+ @unset-pools="unsetPools"
52
+ @clearSelection="clearSelection"
53
+ @set-pools="setPools"
54
+ @set-shape-stacking="setShapeStacking"
55
+ @default-flow="toggleDefaultFlow"
56
+ />
57
+
58
+ <div class="rail-container">
59
+ <div class="rail-left">
60
+ <ZoomControl
61
+ :paper-manager="paperManager"
62
+ />
63
+ </div>
64
+ </div>
65
+
66
+ <Selection
67
+ v-if="paper"
68
+ ref="selector"
69
+ :graph="graph"
70
+ :paperManager="paperManager"
71
+ :useModelGeometry="false"
72
+ :processNode="processNode"
73
+ />
74
+ </div>
75
+ </span>
76
+ </template>
77
+
78
+ <script>
79
+ import Vue from 'vue';
80
+ import _ from 'lodash';
81
+ import { dia } from 'jointjs';
82
+ import boundaryEventConfig from '../nodes/boundaryEvent';
83
+ import BpmnModdle from 'bpmn-moddle';
84
+ import controls from '../controls/controls';
85
+ import pull from 'lodash/pull';
86
+ import remove from 'lodash/remove';
87
+ import store from '@/store';
88
+ import undoRedoStore from '@/undoRedoStore';
89
+ import { Linter } from 'bpmnlint';
90
+ import linterConfig from '../../../.bpmnlintrc';
91
+ import { getNodeIdGenerator } from '../../NodeIdGenerator';
92
+ import Process from '../inspectors/process';
93
+ import runningInCypressTest from '@/runningInCypressTest';
94
+ import getValidationProperties from '@/targetValidationUtils';
95
+ import { id as laneId } from '@/components/nodes/poolLane/config';
96
+ import { id as sequenceFlowId } from '../nodes/sequenceFlow';
97
+ import { id as associationId } from '../nodes/association';
98
+ import { id as messageFlowId } from '../nodes/messageFlow/config';
99
+ import { id as dataOutputAssociationFlowId } from '../nodes/dataOutputAssociation/config';
100
+ import { id as dataInputAssociationFlowId } from '../nodes/dataInputAssociation/config';
101
+ import { id as genericFlowId } from '@/components/nodes/genericFlow/config';
102
+
103
+ import PaperManager from '../paperManager';
104
+ import registerInspectorExtension from '@/components/InspectorExtensionManager';
105
+
106
+ import ensureShapeIsNotCovered from '@/components/shapeStackUtils';
107
+ import Node from '@/components/nodes/node';
108
+ import { addNodeToProcess } from '@/components/nodeManager';
109
+ import TimerEventNode from '@/components/nodes/timerEventNode';
110
+ import focusNameInputAndHighlightLabel from '@/components/modeler/focusNameInputAndHighlightLabel';
111
+ import XMLManager from '@/components/modeler/XMLManager';
112
+ import { NodeMigrator } from '@/components/modeler/NodeMigrator';
113
+ import addLoopCharacteristics from '@/setup/addLoopCharacteristics';
114
+ import Selection from './Selection';
115
+ import ZoomControl from '@/components/railBottom/zoomControl/ZoomControl.vue';
116
+
117
+ export default {
118
+ components: {
119
+ controls,
120
+ Selection,
121
+ ZoomControl,
122
+ },
123
+ props: {
124
+ owner: Object,
125
+ decorations: {
126
+ type: Object,
127
+ default() {
128
+ return {};
129
+ },
130
+ },
131
+ readOnly: {
132
+ type: Boolean,
133
+ default: true,
134
+ },
135
+ },
136
+ data() {
137
+ return {
138
+ pasteInProgress: false,
139
+ cloneInProgress: false,
140
+ internalClipboard: [],
141
+
142
+ /* Custom parsers for handling certain bpmn node types */
143
+ parsers: {},
144
+
145
+ // What bpmn moddle extensions should we register
146
+ extensions: [],
147
+ // Our node types, keyed by the id
148
+ nodeRegistry: {},
149
+
150
+ // Our jointjs data graph model
151
+ graph: null,
152
+ paper: null,
153
+ paperManager: null,
154
+
155
+ definitions: null,
156
+ nodeIdGenerator: null,
157
+ planeElements: null,
158
+ canvasDragPosition: null,
159
+ processNode: null,
160
+ collaboration: null,
161
+ moddle: null,
162
+ allowDrop: true,
163
+ poolTarget: null,
164
+ processes: [],
165
+ cursor: null,
166
+ parentHeight: null,
167
+ parentWidth: null,
168
+ linter: null,
169
+ validationErrors: {},
170
+ miniMapOpen: false,
171
+ panelsCompressed: false,
172
+ isGrabbing: false,
173
+ isRendering: false,
174
+ allWarnings: [],
175
+ nodeTypes: [],
176
+ activeNode: null,
177
+ xmlManager: null,
178
+ previouslyStackedShape: null,
179
+ canvasScale: 1,
180
+ initialScale: 1,
181
+ minimumScale: 0.2,
182
+ scaleStep: 0.1,
183
+ isDragging: false,
184
+ isSelecting: false,
185
+ isIntoTheSelection: false,
186
+ dragStart: null,
187
+ };
188
+ },
189
+ watch: {
190
+ isRendering() {
191
+ const loadingMessage = 'Loading process, please be patient.';
192
+
193
+ if (this.isRendering) {
194
+ window.ProcessMaker.alert(loadingMessage, 'warning');
195
+ document.body.style.cursor = 'wait !important';
196
+ this.cursor = 'wait';
197
+ return;
198
+ }
199
+
200
+ window.ProcessMaker.navbar.alerts = window.ProcessMaker.navbar.alerts.filter(alert => {
201
+ return alert.alertText !== loadingMessage;
202
+ });
203
+ document.body.style.cursor = 'auto';
204
+ this.cursor = null;
205
+ },
206
+ currentXML() {
207
+ this.validateIfAutoValidateIsOn();
208
+ },
209
+ definitions() {
210
+ this.validateIfAutoValidateIsOn();
211
+ },
212
+ autoValidate() {
213
+ this.validateIfAutoValidateIsOn();
214
+ },
215
+ canvasScale(canvasScale) {
216
+ this.paperManager.scale = canvasScale;
217
+ },
218
+
219
+ },
220
+ computed: {
221
+ showControls() {
222
+ return !this.readOnly;
223
+ },
224
+ autoValidate: () => store.getters.autoValidate,
225
+ nodes: () => store.getters.nodes,
226
+ currentXML() {
227
+ return undoRedoStore.getters.currentState;
228
+ },
229
+ /* connectors expect a highlightedNode property */
230
+ highlightedNode: () => store.getters.highlightedNodes[0],
231
+ highlightedNodes: () => store.getters.highlightedNodes,
232
+ },
233
+ methods: {
234
+ toggleDefaultFlow(flow) {
235
+ const source = flow.definition.sourceRef;
236
+ if (source.default && source.default.id === flow.id) {
237
+ flow = null;
238
+ }
239
+ source.set('default', flow);
240
+ },
241
+ borderOutline(nodeId) {
242
+ return this.decorations.borderOutline && this.decorations.borderOutline[nodeId];
243
+ },
244
+ cleanPlaneElements() {
245
+ remove(this.planeElements, diagram => !diagram.bpmnElement);
246
+ },
247
+ validateIfAutoValidateIsOn() {
248
+ if (this.autoValidate) {
249
+ this.validateBpmnDiagram();
250
+ }
251
+ },
252
+ translateConfig(inspectorConfig) {
253
+ if (inspectorConfig.config) {
254
+ const config = inspectorConfig.config;
255
+
256
+ config.label = this.$t(config.label);
257
+ config.helper = this.$t(config.helper);
258
+ }
259
+
260
+ if (inspectorConfig.items) {
261
+ inspectorConfig.items.forEach(this.translateConfig);
262
+ }
263
+ },
264
+ getXmlFromDiagram() {
265
+ return new Promise((resolve, reject) => {
266
+ this.toXML((error, xml) => {
267
+ if (error) {
268
+ reject(error);
269
+ } else {
270
+ resolve(xml);
271
+ }
272
+ });
273
+ });
274
+ },
275
+ async validateBpmnDiagram() {
276
+ if (!store.getters.globalProcesses || store.getters.globalProcesses.length === 0) {
277
+ await store.dispatch('fetchGlobalProcesses');
278
+ }
279
+ this.validationErrors = await this.linter.lint(this.definitions);
280
+ this.$emit('validate', this.validationErrors);
281
+ },
282
+ setPools(poolDefinition) {
283
+ if (!this.collaboration) {
284
+ this.collaboration = this.moddle.create('bpmn:Collaboration');
285
+ this.definitions.get('rootElements').push(this.collaboration);
286
+ this.collaboration.set('id', 'collaboration_0');
287
+ this.plane.set('bpmnElement', this.collaboration);
288
+ }
289
+
290
+ if (poolDefinition.get('processRef')) {
291
+ if (!this.collaboration.get('participants').includes(poolDefinition)) {
292
+ this.collaboration.get('participants').push(poolDefinition);
293
+ }
294
+
295
+ return;
296
+ }
297
+
298
+ let process;
299
+ if (this.collaboration.get('participants').length === 0) {
300
+ process = this.processNode.definition;
301
+ } else {
302
+ process = this.moddle.create('bpmn:Process');
303
+ this.processes.push(process);
304
+ process.set('id', `process_${this.processes.length}`);
305
+
306
+ this.definitions.get('rootElements').push(process);
307
+ }
308
+
309
+ poolDefinition.set('processRef', process);
310
+ this.collaboration.get('participants').push(poolDefinition);
311
+ },
312
+ unsetPools() {
313
+ pull(this.definitions.get('rootElements'), this.collaboration);
314
+ this.plane.set('bpmnElement', this.processNode.definition);
315
+ this.collaboration = null;
316
+ },
317
+ highlightNode(node, event) {
318
+ if (!node || !this.highlightedNode) {
319
+ return;
320
+ }
321
+
322
+ if (event && event.shiftKey) {
323
+ store.commit('addToHighlightedNodes', [node]);
324
+ return;
325
+ }
326
+
327
+ let isSameHighlightedNode = _.isEqual(node.id, this.highlightedNode.id);
328
+
329
+ if (!isSameHighlightedNode) {
330
+ store.commit('highlightNode', node);
331
+ }
332
+
333
+ return;
334
+ },
335
+ blurFocusedScreenBuilderElement() {
336
+ const elementsToBlur = ['INPUT', 'SELECT'];
337
+ if (elementsToBlur.includes(document.activeElement && document.activeElement.tagName)) {
338
+ document.activeElement.blur();
339
+ }
340
+ },
341
+ registerStatusBar(component) {
342
+ this.owner.validationBar.push(component);
343
+ },
344
+ /**
345
+ * Register a mixin into a node component.
346
+ * Used during "modeler-before-init"
347
+ *
348
+ */
349
+ registerComponentMixin(component, mixin) {
350
+ if (!component.mixins) {
351
+ component.mixins = [];
352
+ }
353
+ component.mixins.push(mixin);
354
+ },
355
+ /**
356
+ * Register a BPMN Moddle extension in order to support extensions to the bpmn xml format.
357
+ * This is used to support new attributes and elements that would be needed for specific
358
+ * bpmn execution environments.
359
+ */
360
+ registerBpmnExtension(namespace, extension) {
361
+ this.extensions[namespace] = extension;
362
+ },
363
+ registerNode(nodeType, customParser) {
364
+ const defaultParser = () => nodeType.id;
365
+ const implementationParser = definition => {
366
+ if (definition.get('implementation') === nodeType.implementation) {
367
+ return nodeType.id;
368
+ }
369
+ return undefined;
370
+ };
371
+
372
+ this.translateConfig(nodeType.inspectorConfig[0]);
373
+ addLoopCharacteristics(nodeType);
374
+ this.nodeRegistry[nodeType.id] = nodeType;
375
+
376
+ Vue.component(nodeType.id, nodeType.component);
377
+ this.nodeTypes.push(nodeType);
378
+
379
+ const types = Array.isArray(nodeType.bpmnType)
380
+ ? nodeType.bpmnType
381
+ : [nodeType.bpmnType];
382
+
383
+ types.forEach(bpmnType => {
384
+ if (!this.parsers[bpmnType]) {
385
+ this.parsers[bpmnType] = { custom: [], implementation: [], default: []};
386
+ }
387
+
388
+ if (customParser) {
389
+ this.parsers[bpmnType].custom.push(customParser);
390
+ return;
391
+ }
392
+
393
+ if (nodeType.implementation) {
394
+ this.parsers[bpmnType].implementation.push(implementationParser);
395
+ return;
396
+ }
397
+
398
+ this.parsers[bpmnType].default.push(defaultParser);
399
+ });
400
+ },
401
+ addMessageFlows() {
402
+ if (this.collaboration) {
403
+ this.collaboration
404
+ .get('messageFlows')
405
+ .filter(this.hasSourceAndTarget)
406
+ .forEach(this.setNode);
407
+ }
408
+ },
409
+ loadAssociations(flowElements, artifacts) {
410
+ artifacts
411
+ .filter(definition => definition.$type === 'bpmn:Association' && this.hasSourceAndTarget(definition))
412
+ .forEach(definition => this.setNode(definition, flowElements, artifacts));
413
+ },
414
+ loadDataAssociations(flowElements) {
415
+ const tasksThatHaveDataOutputAssociations = flowElements.filter(task => task.get('dataOutputAssociations') &&
416
+ task.get('dataOutputAssociations').length > 0);
417
+
418
+ tasksThatHaveDataOutputAssociations.forEach(task => {
419
+ task.get('dataOutputAssociations').forEach(dataAssociationLink => {
420
+ this.setNode(dataAssociationLink, flowElements);
421
+ });
422
+ });
423
+
424
+ const tasksThatHaveDataInputAssociations = flowElements.filter(task => task.get('dataInputAssociations') &&
425
+ task.get('dataInputAssociations').length > 0);
426
+
427
+ tasksThatHaveDataInputAssociations.forEach(task => {
428
+ task.get('dataInputAssociations').forEach(dataAssociationLink => {
429
+ this.setNode(dataAssociationLink, flowElements);
430
+ });
431
+ });
432
+ },
433
+ loadArtifacts(flowElements, artifacts) {
434
+ artifacts
435
+ .filter(definition => definition.$type !== 'bpmn:Association')
436
+ .forEach(definition => this.setNode(definition, flowElements, artifacts));
437
+ },
438
+ loadSequenceFlows(flowElements, artifacts) {
439
+ flowElements
440
+ .filter(definition => definition.$type === 'bpmn:SequenceFlow' && this.hasSourceAndTarget(definition))
441
+ .forEach(definition => this.setNode(definition, flowElements, artifacts));
442
+ },
443
+ loadFlowElements(flowElements, artifacts) {
444
+ flowElements
445
+ .filter(definition => definition.$type !== 'bpmn:SequenceFlow')
446
+ .forEach(definition => this.setNode(definition, flowElements, artifacts));
447
+ },
448
+ addLanes(process) {
449
+ if (process.get('laneSets')[0]) {
450
+ process.laneSets[0].lanes.forEach(this.setNode);
451
+ }
452
+ },
453
+ addPools() {
454
+ if (!this.collaboration) {
455
+ return;
456
+ }
457
+ this.collaboration.get('participants').forEach(this.setNode);
458
+ },
459
+ setUpDiagram() {
460
+ this.processes.forEach(process => {
461
+ this.ensureCancelActivityIsAddedToBoundaryEvents(process);
462
+
463
+ this.addLanes(process);
464
+
465
+ const flowElements = process.get('flowElements');
466
+ const artifacts = process.get('artifacts');
467
+
468
+ this.loadFlowElements(flowElements, artifacts);
469
+ this.loadSequenceFlows(flowElements, artifacts);
470
+ this.loadArtifacts(flowElements, artifacts);
471
+ this.loadAssociations(flowElements, artifacts);
472
+ this.loadDataAssociations(flowElements);
473
+ });
474
+
475
+ store.commit('setRootElements', this.definitions.rootElements);
476
+
477
+ this.addMessageFlows();
478
+
479
+ store.commit('highlightNode', this.processNode);
480
+ },
481
+ getCollaboration() {
482
+ return this.definitions.rootElements.find(({ $type }) => $type === 'bpmn:Collaboration');
483
+ },
484
+ getProcesses() {
485
+ return this.definitions.rootElements.filter(({ $type }) => $type === 'bpmn:Process');
486
+ },
487
+ getPlane() {
488
+ return this.definitions.diagrams[0].plane;
489
+ },
490
+ getPlaneElements() {
491
+ return this.plane.get('planeElement');
492
+ },
493
+ parse() {
494
+ this.collaboration = this.getCollaboration();
495
+ this.processes = this.getProcesses();
496
+ this.plane = this.getPlane();
497
+ this.planeElements = this.getPlaneElements();
498
+
499
+ this.cleanPlaneElements();
500
+
501
+ this.processNode = new Node(
502
+ 'processmaker-modeler-process',
503
+ this.processes[0],
504
+ this.planeElements.find(diagram => diagram.bpmnElement.id === this.processes[0].id),
505
+ );
506
+ },
507
+ removeUnsupportedElementAttributes(definition) {
508
+ const unsupportedElements = ['extensionElements'];
509
+
510
+ unsupportedElements.filter(name => definition.get(name))
511
+ .forEach(name => definition.set(name, undefined));
512
+ },
513
+ getCustomParser(definition) {
514
+ const parsers = this.parsers[(definition.$type)];
515
+
516
+ if (!parsers) {
517
+ return;
518
+ }
519
+
520
+ const customParser = parsers.custom.find(parser => parser(definition, this.moddle));
521
+ const implementationParser = parsers.implementation.find(parser => parser(definition, this.moddle));
522
+ const defaultParser = parsers.default.find(parser => parser(definition, this.moddle));
523
+
524
+ return customParser || implementationParser || defaultParser;
525
+ },
526
+ handleUnsupportedElement(bpmnType, flowElements, definition, artifacts, diagram) {
527
+ pull(flowElements, definition);
528
+ pull(artifacts, definition);
529
+ pull(this.planeElements, diagram);
530
+ if (this.collaboration) {
531
+ pull(this.collaboration.get('messageFlows'), definition);
532
+ }
533
+
534
+ const incomingFlows = definition.get('incoming');
535
+ if (incomingFlows) {
536
+ pull(flowElements, incomingFlows);
537
+ }
538
+
539
+ const outgoingFlows = definition.get('outgoing');
540
+ if (outgoingFlows) {
541
+ pull(flowElements, outgoingFlows);
542
+ }
543
+ },
544
+ setNode(definition, flowElements, artifacts) {
545
+ const diagram = this.planeElements.find(diagram => diagram.bpmnElement.id === definition.id);
546
+ const bpmnType = definition.$type;
547
+ const parser = this.getCustomParser(definition);
548
+
549
+ if (!parser) {
550
+ this.handleUnsupportedElement(bpmnType, flowElements, definition, artifacts, diagram);
551
+ return;
552
+ }
553
+
554
+ this.removeUnsupportedElementAttributes(definition);
555
+ const type = parser(definition, this.moddle);
556
+
557
+ const unnamedElements = ['bpmn:TextAnnotation', 'bpmn:Association', 'bpmn:DataOutputAssociation', 'bpmn:DataInputAssociation'];
558
+ const requireName = unnamedElements.indexOf(bpmnType) === -1;
559
+ if (requireName && !definition.get('name')) {
560
+ definition.set('name', '');
561
+ }
562
+
563
+ const node = this.createNode(type, definition, diagram);
564
+
565
+ store.commit('addNode', node);
566
+ },
567
+ createNode(type, definition, diagram) {
568
+ if (Node.isTimerType(type)) {
569
+ return new TimerEventNode(type, definition, diagram);
570
+ }
571
+ // Remove undefined or null properties
572
+ Object.keys(definition).forEach(key => {
573
+ if (definition[key] === undefined || definition[key] === null) {
574
+ delete definition[key];
575
+ }
576
+ });
577
+ return new Node(type, definition, diagram);
578
+ },
579
+ hasSourceAndTarget(definition) {
580
+ const hasSource = definition.sourceRef && this.parsers[definition.sourceRef.$type];
581
+ const hasTarget = definition.targetRef && this.parsers[definition.targetRef.$type];
582
+
583
+ return hasSource && hasTarget;
584
+ },
585
+ async waitForCursorToChange() {
586
+ const cursorWaitTime = 300;
587
+ await this.$nextTick();
588
+ return new Promise(resolve => setTimeout(resolve, cursorWaitTime));
589
+ },
590
+ async renderPaper() {
591
+ this.isRendering = true;
592
+ await this.paperManager.performAtomicAction(async() => {
593
+ await this.waitForCursorToChange();
594
+ this.parse();
595
+ this.addPools();
596
+ this.setUpDiagram();
597
+ });
598
+ await this.paperManager.awaitScheduledUpdates();
599
+ this.isRendering = false;
600
+ this.$emit('parsed');
601
+ },
602
+ async loadXML(xml = null) {
603
+ let emitChangeEvent = false;
604
+ if (xml === null) {
605
+ xml = this.currentXML;
606
+ emitChangeEvent = true;
607
+ }
608
+ this.definitions = await this.xmlManager.getDefinitionsFromXml(xml);
609
+ this.xmlManager.definitions = this.definitions;
610
+ this.nodeIdGenerator = getNodeIdGenerator(this.definitions);
611
+ store.commit('clearNodes');
612
+ await this.renderPaper();
613
+ if (emitChangeEvent) {
614
+ window.ProcessMaker.EventBus.$emit('modeler-change');
615
+ }
616
+ },
617
+ getBoundaryEvents(process) {
618
+ return process.get('flowElements').filter(({ $type }) => $type === 'bpmn:BoundaryEvent');
619
+ },
620
+ createBoundaryEvent(definition) {
621
+ const boundaryEvent = boundaryEventConfig.definition(this.moddle, this.$t);
622
+ boundaryEvent.set('id', definition.get('id'));
623
+ boundaryEvent.set('name', definition.get('name'));
624
+ boundaryEvent.set('eventDefinitions', definition.get('eventDefinitions'));
625
+ boundaryEvent.set('cancelActivity', definition.get('cancelActivity'));
626
+ boundaryEvent.set('attachedToRef', definition.get('attachedToRef'));
627
+ boundaryEvent.set('color', definition.get('color'));
628
+ boundaryEvent.$parent = definition.$parent;
629
+ if (definition.get('outgoing').length > 0) {
630
+ boundaryEvent.set('outgoing', definition.get('outgoing'));
631
+ }
632
+ return boundaryEvent;
633
+ },
634
+ ensureCancelActivityIsAddedToBoundaryEvents(process) {
635
+ this.getBoundaryEvents(process).forEach(definition => {
636
+ const boundaryEvent = this.createBoundaryEvent(definition);
637
+ definition.get('outgoing').forEach(outgoing => outgoing.set('sourceRef', boundaryEvent));
638
+ this.replaceDefinition(definition, boundaryEvent, process);
639
+ });
640
+ },
641
+ replaceDefinition(definition, boundaryEvent, process) {
642
+ const definitionIndex = process.get('flowElements').indexOf(definition);
643
+ process.flowElements[definitionIndex] = boundaryEvent;
644
+ const boundaryEventDiagram = this.planeElements.find((diagram) => {
645
+ return diagram.bpmnElement === definition;
646
+ });
647
+ boundaryEventDiagram.bpmnElement = boundaryEvent;
648
+ },
649
+ toXML(cb) {
650
+ this.moddle.toXML(this.definitions, { format: true }, cb);
651
+ },
652
+ async handleDrop({ clientX, clientY, control, nodeThatWillBeReplaced }) {
653
+ this.validateDropTarget({ clientX, clientY, control });
654
+
655
+ if (!this.allowDrop) {
656
+ return;
657
+ }
658
+
659
+ const definition = this.nodeRegistry[control.type].definition(this.moddle, this.$t);
660
+
661
+ const diagram = this.nodeRegistry[control.type].diagram(this.moddle);
662
+
663
+ const { x, y } = this.paperManager.clientToGridPoint(clientX, clientY);
664
+ diagram.bounds.x = x;
665
+ diagram.bounds.y = y;
666
+
667
+ const newNode = this.createNode(control.type, definition, diagram);
668
+
669
+ if (newNode.isBpmnType('bpmn:BoundaryEvent')) {
670
+ this.setShapeCenterUnderCursor(diagram);
671
+ }
672
+
673
+ this.highlightNode(newNode);
674
+ await this.addNode(newNode);
675
+ if (!nodeThatWillBeReplaced) {
676
+ return;
677
+ }
678
+
679
+ const nodeMigrator = new NodeMigrator(
680
+ nodeThatWillBeReplaced,
681
+ definition,
682
+ this.graph,
683
+ newNode,
684
+ this.processes,
685
+ this.collaboration,
686
+ );
687
+ nodeMigrator.migrate();
688
+
689
+ return newNode;
690
+ },
691
+ setShapeCenterUnderCursor(diagram) {
692
+ diagram.bounds.x -= (diagram.bounds.width / 2);
693
+ diagram.bounds.y -= (diagram.bounds.height / 2);
694
+ },
695
+ async selectNewNode(node) {
696
+ await this.$nextTick();
697
+ await this.paperManager.awaitScheduledUpdates();
698
+ const newNodeComponent = this.$refs.nodeComponent.find(component => component.node === node);
699
+ const view = newNodeComponent.shapeView;
700
+ await this.$refs.selector.selectElement(view);
701
+ },
702
+ async addNode(node) {
703
+ if (!node.pool) {
704
+ node.pool = this.poolTarget;
705
+ }
706
+
707
+ const targetProcess = node.getTargetProcess(this.processes, this.processNode);
708
+ addNodeToProcess(node, targetProcess);
709
+ node.setIds(this.nodeIdGenerator);
710
+
711
+ this.planeElements.push(node.diagram);
712
+ store.commit('addNode', node);
713
+ this.poolTarget = null;
714
+
715
+ // add processmaker-modeler-generic-flow
716
+ if ([
717
+ sequenceFlowId,
718
+ laneId,
719
+ associationId,
720
+ messageFlowId,
721
+ dataOutputAssociationFlowId,
722
+ dataInputAssociationFlowId,
723
+ genericFlowId,
724
+ ].includes(node.type)) {
725
+ return;
726
+ }
727
+
728
+ // Select the node after it has been added to the store (does not apply to flows)
729
+ this.selectNewNode(node);
730
+ },
731
+ async addClonedNodes(nodes) {
732
+ nodes.forEach(node => {
733
+ if (!node.pool) {
734
+ node.pool = this.poolTarget;
735
+ }
736
+
737
+ const targetProcess = node.getTargetProcess(this.processes, this.processNode);
738
+ addNodeToProcess(node, targetProcess);
739
+
740
+ this.planeElements.push(node.diagram);
741
+ store.commit('addNode', node);
742
+ this.poolTarget = null;
743
+ });
744
+ },
745
+ handleResize() {
746
+ const { clientWidth, clientHeight } = this.$el.parentElement;
747
+ this.parentWidth = clientWidth + 'px';
748
+ this.parentHeight = clientHeight + 'px';
749
+
750
+ this.paperManager.setPaperDimensions(clientWidth, clientHeight);
751
+ },
752
+ validateDropTarget({ clientX, clientY, control }) {
753
+ const { allowDrop, poolTarget } = getValidationProperties(clientX, clientY, control, this.paperManager.paper, this.graph, this.collaboration, this.$refs['paper-container']);
754
+ this.allowDrop = allowDrop;
755
+ this.poolTarget = poolTarget;
756
+ },
757
+ isBpmnNode(shape) {
758
+ return shape.component != null;
759
+ },
760
+ setShapeStacking(shape) {
761
+ if (this.isRendering || (!shape.component.node.isType('processmaker-modeler-pool') && shape === this.previouslyStackedShape)) {
762
+ return;
763
+ }
764
+
765
+ this.previouslyStackedShape = shape;
766
+ this.paperManager.performAtomicAction(() => ensureShapeIsNotCovered(shape, this.graph));
767
+ },
768
+ clearSelection(){
769
+ this.$refs.selector.clearSelection();
770
+ },
771
+ isPointInSelection(event) {
772
+ const selector = this.$refs.selector.$el;
773
+ if (typeof selector.getBoundingClientRect === 'function') {
774
+ // check if mouse was clicked inside the selector
775
+ const { x: sx, y: sy, width:swidth, height: sheight } = selector.getBoundingClientRect();
776
+ if (event.clientX >= sx && event.clientX <= sx + swidth && event.clientY >= sy && event.clientY <= sy + sheight) {
777
+ return true;
778
+ }
779
+ }
780
+ return false;
781
+ },
782
+ async pointerDownInShape(event, element) {
783
+ const { clientX: x, clientY: y } = event;
784
+ const shapeView = this.paper.findViewByModel(element);
785
+ this.isDragging = false;
786
+ this.isSelecting = false;
787
+ this.isIntoTheSelection = false;
788
+ this.dragStart = { x, y };
789
+ // Verify if is in the selection box
790
+ if (this.isPointInSelection(event)) {
791
+ this.isIntoTheSelection = true;
792
+ } else {
793
+ if (!event.shiftKey) {
794
+ await this.$refs.selector.selectElement(shapeView);
795
+ await this.$nextTick();
796
+ }
797
+ }
798
+ this.$refs.selector.startDrag({
799
+ clientX: event.clientX,
800
+ clientY: event.clientY,
801
+ });
802
+ },
803
+ pointerUpHandler(event, cellView) {
804
+ // is clicked over the shape
805
+ if (cellView) {
806
+ this.$refs.selector.selectElement(cellView);
807
+ } else {
808
+ this.clearSelection();
809
+ }
810
+
811
+ this.isDragging = false;
812
+ this.dragStart = null;
813
+ this.isSelecting = false;
814
+ },
815
+ },
816
+ created() {
817
+ if (runningInCypressTest()) {
818
+ /* Add reference to store on window; this is used in testing to verify rendered nodes */
819
+ window.store = store;
820
+ }
821
+
822
+ this.$t = this.$t.bind(this);
823
+ /**
824
+ * Before Initialize the BpmnModdle and its extensions.
825
+ * In this stage the node components were not yet registered,
826
+ * so they could be extended.
827
+ */
828
+ window.ProcessMaker.EventBus.$emit('modeler-before-init', {
829
+ registerComponentMixin: this.registerComponentMixin,
830
+ });
831
+
832
+ this.registerNode(Process);
833
+ /* Initialize the BpmnModdle and its extensions */
834
+ window.ProcessMaker.EventBus.$emit('modeler-init', {
835
+ registerInspectorExtension,
836
+ registerBpmnExtension: this.registerBpmnExtension,
837
+ registerNode: this.registerNode,
838
+ registerStatusBar: this.registerStatusBar,
839
+ });
840
+
841
+ this.moddle = new BpmnModdle(this.extensions);
842
+ this.linter = new Linter(linterConfig);
843
+ this.xmlManager = new XMLManager(this.moddle);
844
+ this.$emit('set-xml-manager', this.xmlManager);
845
+ },
846
+ mounted() {
847
+ store.commit('setReadOnly', this.readOnly);
848
+
849
+ this.graph = new dia.Graph();
850
+ store.commit('setGraph', this.graph);
851
+ this.graph.set('interactiveFunc', cellView => {
852
+ const isPoolEdge = cellView.model.get('type') === 'standard.EmbeddedImage';
853
+ return {
854
+ elementMove: isPoolEdge,
855
+ labelMove: false,
856
+ };
857
+ });
858
+
859
+ this.paperManager = PaperManager.factory(this.$refs.paper, this.graph.get('interactiveFunc'), this.graph);
860
+ this.paper = this.paperManager.paper;
861
+
862
+ this.paperManager.addEventHandler('cell:pointerdblclick', focusNameInputAndHighlightLabel);
863
+
864
+ this.handleResize();
865
+ window.addEventListener('resize', this.handleResize);
866
+
867
+ store.commit('setPaper', this.paperManager.paper);
868
+
869
+ this.paperManager.addEventHandler('element:pointerclick', this.blurFocusedScreenBuilderElement, this);
870
+
871
+ this.paperManager.addEventHandler('blank:pointerdown', (event, x, y) => {
872
+ const scale = this.paperManager.scale;
873
+ this.canvasDragPosition = { x: x * scale.sx, y: y * scale.sy };
874
+ this.isGrabbing = true;
875
+ }, this);
876
+
877
+ this.paperManager.addEventHandler('cell:mouseover element:mouseover', ({ model: shape }) => {
878
+ if (this.isBpmnNode(shape) && shape.attr('body/cursor') !== 'default' && !this.isGrabbing) {
879
+ shape.attr('body/cursor', 'move');
880
+ }
881
+ // If the user is panning the Paper while hovering an element, ignore the default move cursor
882
+ if (this.isGrabbing && this.isBpmnNode(shape)) {
883
+ shape.attr('body/cursor', 'grabbing');
884
+ }
885
+ });
886
+ this.paperManager.addEventHandler('blank:pointerup', (event) => {
887
+ this.canvasDragPosition = null;
888
+ this.isGrabbing = false;
889
+ this.activeNode = null;
890
+ this.pointerUpHandler(event);
891
+ }, this);
892
+
893
+ this.paperManager.addEventHandler('cell:pointerup', (cellView, event) => {
894
+ this.canvasDragPosition = null;
895
+ this.activeNode = null;
896
+ this.pointerUpHandler(event, cellView);
897
+ }, this);
898
+
899
+ this.$el.addEventListener('mousemove', event => {
900
+ if (this.canvasDragPosition) {
901
+ this.paperManager.translate(
902
+ event.offsetX - this.canvasDragPosition.x,
903
+ event.offsetY - this.canvasDragPosition.y,
904
+ );
905
+ }
906
+ }, this);
907
+
908
+ this.$el.addEventListener('mouseenter', () => {
909
+ store.commit('setClientLeftPaper', false);
910
+ });
911
+
912
+ this.$el.addEventListener('mouseleave', () => {
913
+ this.paperManager.removeEventHandler('blank:pointermove');
914
+ store.commit('setClientLeftPaper', true);
915
+ });
916
+
917
+ this.paperManager.addEventHandler('cell:pointerclick', (cellView, evt, x, y) => {
918
+ const clickHandler = cellView.model.get('onClick');
919
+ if (clickHandler) {
920
+ clickHandler(cellView, evt, x, y);
921
+ }
922
+ });
923
+
924
+ this.paperManager.addEventHandler('cell:pointerclick', ({ model: shape }, event) => {
925
+ if (!this.isBpmnNode(shape)) {
926
+ return;
927
+ }
928
+
929
+ // ignore click event if the user is Grabbing the paper
930
+ if (this.isGrabbing) return;
931
+
932
+ shape.component.$emit('click', event);
933
+ });
934
+
935
+ this.paperManager.addEventHandler('cell:pointerdown', ({ model: shape }, event) => {
936
+ if (!this.isBpmnNode(shape)) {
937
+ return;
938
+ }
939
+ // If the user is pressing Space (grabbing) and clicking on a Cell, return
940
+ if (this.isGrabbing) {
941
+ return;
942
+ }
943
+ this.setShapeStacking(shape);
944
+ this.activeNode = shape.component.node;
945
+ this.isOverShape = true;
946
+ this.pointerDownInShape(event, shape);
947
+ });
948
+ // If the user is grabbing the paper while he clicked in a cell, move the paper and not the cell
949
+ this.paperManager.addEventHandler('cell:pointermove', (_, event, x, y) => {
950
+ if (this.isGrabbing) {
951
+ if (!this.canvasDragPosition) {
952
+ const scale = this.paperManager.scale;
953
+ this.canvasDragPosition = { x: x * scale.sx, y: y * scale.sy };
954
+ }
955
+ if (this.canvasDragPosition && !this.clientLeftPaper) {
956
+ this.paperManager.translate(
957
+ event.offsetX - this.canvasDragPosition.x,
958
+ event.offsetY - this.canvasDragPosition.y
959
+ );
960
+ }
961
+ }
962
+ });
963
+
964
+ /* Register custom nodes */
965
+ window.ProcessMaker.EventBus.$emit('modeler-start', {
966
+ loadXML: async(xml) => {
967
+ await this.loadXML(xml);
968
+ },
969
+ });
970
+ },
971
+ };
972
+ </script>
973
+ <style lang="scss" src="./modeler.scss" />
974
+ <style lang="scss">
975
+ svg {
976
+ overflow: visible !important;
977
+ }
978
+
979
+ .rail {
980
+ &-container {
981
+ position: relative;
982
+ bottom: 60px;
983
+ display: inline-block;
984
+ height: 48px;
985
+ max-height: 48px;
986
+ z-index: 2;
987
+ }
988
+
989
+ &-left {
990
+ position: absolute;
991
+ display: inline;
992
+ width: auto;
993
+ padding: 0 12px;
994
+ }
995
+ }
996
+ </style>