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