bpmn-js 12.1.0 → 13.0.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 (289) hide show
  1. package/dist/bpmn-modeler.development.js +5172 -2047
  2. package/dist/bpmn-modeler.production.min.js +35 -35
  3. package/dist/bpmn-navigated-viewer.development.js +1547 -589
  4. package/dist/bpmn-navigated-viewer.production.min.js +5 -5
  5. package/dist/bpmn-viewer.development.js +1525 -584
  6. package/dist/bpmn-viewer.production.min.js +5 -5
  7. package/lib/BaseModeler.d.ts +12 -5
  8. package/lib/BaseModeler.js +4 -5
  9. package/lib/BaseViewer.d.ts +160 -366
  10. package/lib/BaseViewer.js +136 -57
  11. package/lib/Modeler.d.ts +76 -15
  12. package/lib/Modeler.js +6 -4
  13. package/lib/NavigatedViewer.d.ts +8 -3
  14. package/lib/Viewer.d.ts +44 -3
  15. package/lib/core/index.d.ts +10 -0
  16. package/lib/draw/BpmnRenderUtil.d.ts +76 -0
  17. package/lib/draw/BpmnRenderUtil.js +73 -21
  18. package/lib/draw/BpmnRenderer.d.ts +124 -0
  19. package/lib/draw/BpmnRenderer.js +51 -0
  20. package/lib/draw/PathMap.d.ts +330 -0
  21. package/lib/draw/PathMap.js +9 -2
  22. package/lib/draw/TextRenderer.d.ts +74 -0
  23. package/lib/draw/TextRenderer.js +32 -11
  24. package/lib/draw/index.d.ts +10 -0
  25. package/lib/features/align-elements/AlignElementsContextPadProvider.d.ts +32 -0
  26. package/lib/features/align-elements/AlignElementsContextPadProvider.js +28 -5
  27. package/lib/features/align-elements/AlignElementsIcons.d.ts +10 -0
  28. package/lib/features/align-elements/AlignElementsMenuProvider.d.ts +32 -0
  29. package/lib/features/align-elements/AlignElementsMenuProvider.js +38 -10
  30. package/lib/features/align-elements/BpmnAlignElements.d.ts +9 -0
  31. package/lib/features/align-elements/BpmnAlignElements.js +7 -1
  32. package/lib/features/align-elements/index.d.ts +11 -0
  33. package/lib/features/auto-place/BpmnAutoPlace.d.ts +13 -0
  34. package/lib/features/auto-place/BpmnAutoPlace.js +3 -0
  35. package/lib/features/auto-place/BpmnAutoPlaceUtil.d.ts +47 -0
  36. package/lib/features/auto-place/BpmnAutoPlaceUtil.js +39 -11
  37. package/lib/features/auto-place/index.d.ts +7 -0
  38. package/lib/features/auto-resize/BpmnAutoResize.d.ts +25 -0
  39. package/lib/features/auto-resize/BpmnAutoResize.js +15 -7
  40. package/lib/features/auto-resize/BpmnAutoResizeProvider.d.ts +26 -0
  41. package/lib/features/auto-resize/BpmnAutoResizeProvider.js +16 -4
  42. package/lib/features/auto-resize/index.d.ts +8 -0
  43. package/lib/features/context-pad/ContextPadProvider.d.ts +60 -0
  44. package/lib/features/context-pad/ContextPadProvider.js +64 -9
  45. package/lib/features/context-pad/index.d.ts +7 -0
  46. package/lib/features/copy-paste/BpmnCopyPaste.d.ts +17 -0
  47. package/lib/features/copy-paste/BpmnCopyPaste.js +15 -7
  48. package/lib/features/copy-paste/ModdleCopy.d.ts +45 -0
  49. package/lib/features/copy-paste/ModdleCopy.js +17 -45
  50. package/lib/features/copy-paste/index.d.ts +9 -0
  51. package/lib/features/di-ordering/BpmnDiOrdering.d.ts +11 -0
  52. package/lib/features/di-ordering/BpmnDiOrdering.js +8 -0
  53. package/lib/features/di-ordering/index.d.ts +6 -0
  54. package/lib/features/distribute-elements/BpmnDistributeElements.d.ts +10 -0
  55. package/lib/features/distribute-elements/BpmnDistributeElements.js +9 -4
  56. package/lib/features/distribute-elements/DistributeElementsIcons.d.ts +5 -0
  57. package/lib/features/distribute-elements/DistributeElementsMenuProvider.d.ts +32 -0
  58. package/lib/features/distribute-elements/DistributeElementsMenuProvider.js +27 -4
  59. package/lib/features/distribute-elements/index.d.ts +9 -0
  60. package/lib/features/drilldown/DrilldownBreadcrumbs.d.ts +19 -0
  61. package/lib/features/drilldown/DrilldownBreadcrumbs.js +34 -24
  62. package/lib/features/drilldown/DrilldownCentering.d.ts +17 -0
  63. package/lib/features/drilldown/DrilldownCentering.js +7 -2
  64. package/lib/features/drilldown/DrilldownOverlayBehavior.d.ts +18 -0
  65. package/lib/features/drilldown/DrilldownOverlayBehavior.js +70 -40
  66. package/lib/features/drilldown/SubprocessCompatibility.d.ts +21 -0
  67. package/lib/features/drilldown/SubprocessCompatibility.js +80 -30
  68. package/lib/features/drilldown/index.d.ts +13 -0
  69. package/lib/features/editor-actions/BpmnEditorActions.d.ts +13 -0
  70. package/lib/features/editor-actions/BpmnEditorActions.js +4 -0
  71. package/lib/features/editor-actions/index.d.ts +6 -0
  72. package/lib/features/grid-snapping/BpmnGridSnapping.d.ts +9 -0
  73. package/lib/features/grid-snapping/BpmnGridSnapping.js +7 -0
  74. package/lib/features/grid-snapping/behavior/GridSnappingAutoPlaceBehavior.d.ts +12 -0
  75. package/lib/features/grid-snapping/behavior/GridSnappingAutoPlaceBehavior.js +16 -1
  76. package/lib/features/grid-snapping/behavior/GridSnappingLayoutConnectionBehavior.d.ts +27 -0
  77. package/lib/features/grid-snapping/behavior/GridSnappingLayoutConnectionBehavior.js +20 -8
  78. package/lib/features/grid-snapping/behavior/GridSnappingParticipantBehavior.d.ts +13 -0
  79. package/lib/features/grid-snapping/behavior/GridSnappingParticipantBehavior.js +11 -1
  80. package/lib/features/grid-snapping/behavior/index.d.ts +10 -0
  81. package/lib/features/grid-snapping/index.d.ts +11 -0
  82. package/lib/features/interaction-events/BpmnInteractionEvents.d.ts +18 -0
  83. package/lib/features/interaction-events/BpmnInteractionEvents.js +34 -9
  84. package/lib/features/interaction-events/index.d.ts +6 -0
  85. package/lib/features/keyboard/BpmnKeyboardBindings.d.ts +15 -0
  86. package/lib/features/keyboard/BpmnKeyboardBindings.js +5 -0
  87. package/lib/features/keyboard/index.d.ts +7 -0
  88. package/lib/features/label-editing/LabelEditingPreview.d.ts +13 -0
  89. package/lib/features/label-editing/LabelEditingPreview.js +13 -6
  90. package/lib/features/label-editing/LabelEditingProvider.d.ts +62 -0
  91. package/lib/features/label-editing/LabelEditingProvider.js +48 -11
  92. package/lib/features/label-editing/LabelUtil.d.ts +14 -0
  93. package/lib/features/label-editing/LabelUtil.js +16 -1
  94. package/lib/features/label-editing/cmd/UpdateLabelHandler.d.ts +22 -0
  95. package/lib/features/label-editing/cmd/UpdateLabelHandler.js +14 -3
  96. package/lib/features/label-editing/index.d.ts +9 -0
  97. package/lib/features/modeling/BpmnFactory.d.ts +67 -0
  98. package/lib/features/modeling/BpmnFactory.js +57 -8
  99. package/lib/features/modeling/BpmnLayouter.d.ts +26 -0
  100. package/lib/features/modeling/BpmnLayouter.js +25 -2
  101. package/lib/features/modeling/BpmnUpdater.d.ts +92 -0
  102. package/lib/features/modeling/BpmnUpdater.js +90 -29
  103. package/lib/features/modeling/ElementFactory.d.ts +116 -0
  104. package/lib/features/modeling/ElementFactory.js +114 -17
  105. package/lib/features/modeling/ElementFactory.test.ts +133 -0
  106. package/lib/features/modeling/Modeling.d.ts +150 -0
  107. package/lib/features/modeling/Modeling.js +124 -19
  108. package/lib/features/modeling/Modeling.test.ts +148 -0
  109. package/lib/features/modeling/behavior/AdaptiveLabelPositioningBehavior.d.ts +20 -0
  110. package/lib/features/modeling/behavior/AdaptiveLabelPositioningBehavior.js +16 -6
  111. package/lib/features/modeling/behavior/AppendBehavior.d.ts +6 -0
  112. package/lib/features/modeling/behavior/AppendBehavior.js +6 -5
  113. package/lib/features/modeling/behavior/AssociationBehavior.d.ts +11 -0
  114. package/lib/features/modeling/behavior/AssociationBehavior.js +9 -1
  115. package/lib/features/modeling/behavior/AttachEventBehavior.d.ts +15 -0
  116. package/lib/features/modeling/behavior/AttachEventBehavior.js +11 -3
  117. package/lib/features/modeling/behavior/BoundaryEventBehavior.d.ts +15 -0
  118. package/lib/features/modeling/behavior/BoundaryEventBehavior.js +8 -1
  119. package/lib/features/modeling/behavior/CreateBehavior.d.ts +9 -0
  120. package/lib/features/modeling/behavior/CreateBehavior.js +6 -0
  121. package/lib/features/modeling/behavior/CreateDataObjectBehavior.d.ts +15 -0
  122. package/lib/features/modeling/behavior/CreateDataObjectBehavior.js +10 -4
  123. package/lib/features/modeling/behavior/CreateParticipantBehavior.d.ts +19 -0
  124. package/lib/features/modeling/behavior/CreateParticipantBehavior.js +10 -0
  125. package/lib/features/modeling/behavior/DataInputAssociationBehavior.d.ts +21 -0
  126. package/lib/features/modeling/behavior/DataInputAssociationBehavior.js +5 -0
  127. package/lib/features/modeling/behavior/DataStoreBehavior.d.ts +19 -0
  128. package/lib/features/modeling/behavior/DataStoreBehavior.js +12 -1
  129. package/lib/features/modeling/behavior/DeleteLaneBehavior.d.ts +15 -0
  130. package/lib/features/modeling/behavior/DeleteLaneBehavior.js +9 -3
  131. package/lib/features/modeling/behavior/DetachEventBehavior.d.ts +15 -0
  132. package/lib/features/modeling/behavior/DetachEventBehavior.js +11 -3
  133. package/lib/features/modeling/behavior/DropOnFlowBehavior.d.ts +13 -0
  134. package/lib/features/modeling/behavior/DropOnFlowBehavior.js +11 -1
  135. package/lib/features/modeling/behavior/EventBasedGatewayBehavior.d.ts +11 -0
  136. package/lib/features/modeling/behavior/EventBasedGatewayBehavior.js +9 -0
  137. package/lib/features/modeling/behavior/FixHoverBehavior.d.ts +17 -0
  138. package/lib/features/modeling/behavior/FixHoverBehavior.js +6 -0
  139. package/lib/features/modeling/behavior/GroupBehavior.d.ts +26 -0
  140. package/lib/features/modeling/behavior/GroupBehavior.js +35 -13
  141. package/lib/features/modeling/behavior/ImportDockingFix.d.ts +13 -0
  142. package/lib/features/modeling/behavior/ImportDockingFix.js +3 -0
  143. package/lib/features/modeling/behavior/IsHorizontalFix.d.ts +10 -0
  144. package/lib/features/modeling/behavior/IsHorizontalFix.js +4 -0
  145. package/lib/features/modeling/behavior/LabelBehavior.d.ts +56 -0
  146. package/lib/features/modeling/behavior/LabelBehavior.js +22 -10
  147. package/lib/features/modeling/behavior/LayoutConnectionBehavior.d.ts +16 -0
  148. package/lib/features/modeling/behavior/LayoutConnectionBehavior.js +6 -2
  149. package/lib/features/modeling/behavior/MessageFlowBehavior.d.ts +15 -0
  150. package/lib/features/modeling/behavior/MessageFlowBehavior.js +8 -0
  151. package/lib/features/modeling/behavior/ModelingFeedback.d.ts +13 -0
  152. package/lib/features/modeling/behavior/ModelingFeedback.js +11 -0
  153. package/lib/features/modeling/behavior/RemoveElementBehavior.d.ts +13 -0
  154. package/lib/features/modeling/behavior/RemoveElementBehavior.js +11 -1
  155. package/lib/features/modeling/behavior/RemoveEmbeddedLabelBoundsBehavior.d.ts +16 -0
  156. package/lib/features/modeling/behavior/RemoveEmbeddedLabelBoundsBehavior.js +8 -0
  157. package/lib/features/modeling/behavior/RemoveParticipantBehavior.d.ts +15 -0
  158. package/lib/features/modeling/behavior/RemoveParticipantBehavior.js +8 -1
  159. package/lib/features/modeling/behavior/ReplaceConnectionBehavior.d.ts +15 -0
  160. package/lib/features/modeling/behavior/ReplaceConnectionBehavior.js +13 -1
  161. package/lib/features/modeling/behavior/ReplaceElementBehaviour.d.ts +23 -0
  162. package/lib/features/modeling/behavior/ReplaceElementBehaviour.js +19 -4
  163. package/lib/features/modeling/behavior/ResizeBehavior.d.ts +57 -0
  164. package/lib/features/modeling/behavior/ResizeBehavior.js +35 -0
  165. package/lib/features/modeling/behavior/ResizeLaneBehavior.d.ts +16 -0
  166. package/lib/features/modeling/behavior/ResizeLaneBehavior.js +10 -3
  167. package/lib/features/modeling/behavior/RootElementReferenceBehavior.d.ts +25 -0
  168. package/lib/features/modeling/behavior/RootElementReferenceBehavior.js +19 -0
  169. package/lib/features/modeling/behavior/SpaceToolBehavior.d.ts +10 -0
  170. package/lib/features/modeling/behavior/SpaceToolBehavior.js +14 -4
  171. package/lib/features/modeling/behavior/SubProcessPlaneBehavior.d.ts +28 -0
  172. package/lib/features/modeling/behavior/SubProcessPlaneBehavior.js +45 -23
  173. package/lib/features/modeling/behavior/SubProcessStartEventBehavior.d.ts +15 -0
  174. package/lib/features/modeling/behavior/SubProcessStartEventBehavior.js +6 -0
  175. package/lib/features/modeling/behavior/ToggleCollapseConnectionBehaviour.d.ts +14 -0
  176. package/lib/features/modeling/behavior/ToggleCollapseConnectionBehaviour.js +14 -1
  177. package/lib/features/modeling/behavior/ToggleElementCollapseBehaviour.d.ts +13 -0
  178. package/lib/features/modeling/behavior/ToggleElementCollapseBehaviour.js +11 -3
  179. package/lib/features/modeling/behavior/UnclaimIdBehavior.d.ts +19 -0
  180. package/lib/features/modeling/behavior/UnclaimIdBehavior.js +7 -0
  181. package/lib/features/modeling/behavior/UnsetDefaultFlowBehavior.d.ts +16 -0
  182. package/lib/features/modeling/behavior/UnsetDefaultFlowBehavior.js +6 -3
  183. package/lib/features/modeling/behavior/UpdateFlowNodeRefsBehavior.d.ts +17 -0
  184. package/lib/features/modeling/behavior/UpdateFlowNodeRefsBehavior.js +13 -10
  185. package/lib/features/modeling/behavior/index.d.ts +2 -0
  186. package/lib/features/modeling/behavior/index.js +3 -0
  187. package/lib/features/modeling/behavior/util/CategoryUtil.d.ts +49 -0
  188. package/lib/features/modeling/behavior/util/CategoryUtil.js +10 -6
  189. package/lib/features/modeling/behavior/util/ConnectionLayoutUtil.d.ts +19 -0
  190. package/lib/features/modeling/behavior/util/ConnectionLayoutUtil.js +11 -5
  191. package/lib/features/modeling/behavior/util/GeometricUtil.d.ts +1 -0
  192. package/lib/features/modeling/behavior/util/LabelLayoutUtil.d.ts +32 -0
  193. package/lib/features/modeling/behavior/util/LabelLayoutUtil.js +27 -18
  194. package/lib/features/modeling/behavior/util/LayoutUtil.d.ts +48 -0
  195. package/lib/features/modeling/behavior/util/LayoutUtil.js +35 -6
  196. package/lib/features/modeling/behavior/util/LineAttachmentUtil.d.ts +37 -0
  197. package/lib/features/modeling/behavior/util/LineAttachmentUtil.js +17 -5
  198. package/lib/features/modeling/behavior/util/LineIntersect.d.ts +13 -0
  199. package/lib/features/modeling/behavior/util/LineIntersect.js +4 -0
  200. package/lib/features/modeling/behavior/util/ResizeUtil.d.ts +1 -0
  201. package/lib/features/modeling/cmd/AddLaneHandler.d.ts +22 -0
  202. package/lib/features/modeling/cmd/AddLaneHandler.js +8 -0
  203. package/lib/features/modeling/cmd/IdClaimHandler.d.ts +22 -0
  204. package/lib/features/modeling/cmd/IdClaimHandler.js +15 -0
  205. package/lib/features/modeling/cmd/ResizeLaneHandler.d.ts +39 -0
  206. package/lib/features/modeling/cmd/ResizeLaneHandler.js +17 -4
  207. package/lib/features/modeling/cmd/SetColorHandler.d.ts +18 -0
  208. package/lib/features/modeling/cmd/SetColorHandler.js +25 -12
  209. package/lib/features/modeling/cmd/SplitLaneHandler.d.ts +22 -0
  210. package/lib/features/modeling/cmd/SplitLaneHandler.js +9 -0
  211. package/lib/features/modeling/cmd/UpdateCanvasRootHandler.d.ts +20 -0
  212. package/lib/features/modeling/cmd/UpdateCanvasRootHandler.js +16 -1
  213. package/lib/features/modeling/cmd/UpdateFlowNodeRefsHandler.d.ts +21 -0
  214. package/lib/features/modeling/cmd/UpdateFlowNodeRefsHandler.js +29 -4
  215. package/lib/features/modeling/cmd/UpdateModdlePropertiesHandler.d.ts +20 -0
  216. package/lib/features/modeling/cmd/UpdateModdlePropertiesHandler.js +17 -3
  217. package/lib/features/modeling/cmd/UpdatePropertiesHandler.d.ts +60 -0
  218. package/lib/features/modeling/cmd/UpdatePropertiesHandler.js +38 -14
  219. package/lib/features/modeling/cmd/UpdateSemanticParentHandler.d.ts +18 -0
  220. package/lib/features/modeling/cmd/UpdateSemanticParentHandler.js +15 -0
  221. package/lib/features/modeling/index.d.ts +27 -0
  222. package/lib/features/modeling/util/LaneUtil.d.ts +46 -0
  223. package/lib/features/modeling/util/LaneUtil.js +22 -13
  224. package/lib/features/modeling/util/ModelingUtil.d.ts +12 -0
  225. package/lib/features/modeling/util/ModelingUtil.js +10 -4
  226. package/lib/features/ordering/BpmnOrderingProvider.d.ts +21 -0
  227. package/lib/features/ordering/BpmnOrderingProvider.js +9 -3
  228. package/lib/features/ordering/index.d.ts +7 -0
  229. package/lib/features/palette/PaletteProvider.d.ts +34 -0
  230. package/lib/features/palette/PaletteProvider.js +26 -2
  231. package/lib/features/palette/index.d.ts +9 -0
  232. package/lib/features/popup-menu/ReplaceMenuProvider.d.ts +50 -0
  233. package/lib/features/popup-menu/ReplaceMenuProvider.js +226 -202
  234. package/lib/features/popup-menu/index.d.ts +11 -0
  235. package/lib/features/popup-menu/util/TypeUtil.d.ts +12 -0
  236. package/lib/features/popup-menu/util/TypeUtil.js +4 -1
  237. package/lib/features/replace/BpmnReplace.d.ts +47 -0
  238. package/lib/features/replace/BpmnReplace.js +81 -29
  239. package/lib/features/replace/ReplaceOptions.d.ts +70 -0
  240. package/lib/features/replace/ReplaceOptions.js +58 -0
  241. package/lib/features/replace/index.d.ts +9 -0
  242. package/lib/features/replace-preview/BpmnReplacePreview.d.ts +17 -0
  243. package/lib/features/replace-preview/BpmnReplacePreview.js +15 -1
  244. package/lib/features/replace-preview/index.d.ts +7 -0
  245. package/lib/features/rules/BpmnRules.d.ts +171 -0
  246. package/lib/features/rules/BpmnRules.js +295 -46
  247. package/lib/features/rules/index.d.ts +7 -0
  248. package/lib/features/search/BpmnSearchProvider.d.ts +29 -0
  249. package/lib/features/search/BpmnSearchProvider.js +30 -22
  250. package/lib/features/search/index.d.ts +7 -0
  251. package/lib/features/snapping/BpmnConnectSnapping.d.ts +17 -0
  252. package/lib/features/snapping/BpmnConnectSnapping.js +51 -3
  253. package/lib/features/snapping/BpmnCreateMoveSnapping.d.ts +41 -0
  254. package/lib/features/snapping/BpmnCreateMoveSnapping.js +47 -1
  255. package/lib/features/snapping/BpmnSnappingUtil.d.ts +11 -0
  256. package/lib/features/snapping/BpmnSnappingUtil.js +12 -0
  257. package/lib/features/snapping/index.d.ts +9 -0
  258. package/lib/features/space-tool/BpmnSpaceTool.d.ts +21 -0
  259. package/lib/features/space-tool/BpmnSpaceTool.js +20 -1
  260. package/lib/features/space-tool/index.d.ts +6 -0
  261. package/lib/import/BpmnImporter.d.ts +49 -0
  262. package/lib/import/BpmnImporter.js +37 -10
  263. package/lib/import/BpmnTreeWalker.d.ts +22 -0
  264. package/lib/import/BpmnTreeWalker.js +25 -22
  265. package/lib/import/Importer.d.ts +25 -0
  266. package/lib/import/Importer.js +15 -21
  267. package/lib/import/Util.d.ts +1 -0
  268. package/lib/import/index.d.ts +6 -0
  269. package/lib/model/Types.d.ts +24 -0
  270. package/lib/model/Types.ts +40 -0
  271. package/lib/util/CompatibilityUtil.d.ts +22 -0
  272. package/lib/util/CompatibilityUtil.js +13 -0
  273. package/lib/util/DiUtil.d.ts +53 -0
  274. package/lib/util/DiUtil.js +47 -13
  275. package/lib/util/DrilldownUtil.d.ts +39 -0
  276. package/lib/util/DrilldownUtil.js +12 -8
  277. package/lib/util/LabelUtil.d.ts +73 -0
  278. package/lib/util/LabelUtil.js +40 -16
  279. package/lib/util/ModelUtil.d.ts +40 -0
  280. package/lib/util/ModelUtil.js +9 -5
  281. package/lib/util/PoweredByUtil.d.ts +8 -0
  282. package/lib/util/Types.js +5 -0
  283. package/lib/util/Types.ts +4 -0
  284. package/package.json +10 -5
  285. package/test/matchers/ConnectionMatchers.js +1 -1
  286. package/lib/icons/dist/append.svg +0 -1
  287. package/lib/icons/dist/connect-context-pad.svg +0 -1
  288. package/lib/icons/dist/connect-palette.svg +0 -1
  289. package/lib/icons/dist/create.svg +0 -1
@@ -15,14 +15,45 @@ import {
15
15
  import {
16
16
  forEach,
17
17
  filter,
18
+ isArray,
18
19
  isUndefined
19
20
  } from 'min-dash';
20
21
 
21
22
  import * as replaceOptions from '../replace/ReplaceOptions';
22
23
 
24
+ /**
25
+ * @typedef {import('../features/BpmnFactory').default} BpmnFactory
26
+ * @typedef {import('diagram-js/lib/features/popup-menu/PopupMenu').default} PopupMenu
27
+ * @typedef {import('../features/Modeling').default} Modeling
28
+ * @typedef {import('../features/BpmnReplace').default} BpmnReplace
29
+ * @typedef {import('diagram-js/lib/features/Rules').default} Rules
30
+ * @typedef {import('diagram-js/lib/i18n/translate/translate').default} Translate
31
+ *
32
+ * @typedef {import('../../model/Types').Element} Element
33
+ * @typedef {import('../../model/Types').Moddle} Moddle
34
+ *
35
+ * @typedef {import('diagram-js/lib/features/popup-menu/PopupMenuProvider').PopupMenuEntries} PopupMenuEntries
36
+ * @typedef {import('diagram-js/lib/features/popup-menu/PopupMenuProvider').PopupMenuEntry} PopupMenuEntry
37
+ * @typedef {import('diagram-js/lib/features/popup-menu/PopupMenuProvider').PopupMenuEntryAction} PopupMenuEntryAction
38
+ * @typedef {import('diagram-js/lib/features/popup-menu/PopupMenuProvider').PopupMenuHeaderEntries} PopupMenuHeaderEntries
39
+ * @typedef {import('diagram-js/lib/features/popup-menu/PopupMenuProvider').default} PopupMenuProvider
40
+ * @typedef {import('diagram-js/lib/features/popup-menu/PopupMenu').PopupMenuTarget} PopupMenuTarget
41
+ *
42
+ * @typedef {import('./ReplaceOptions').ReplaceOption} ReplaceOption
43
+ */
23
44
 
24
45
  /**
25
- * This module is an element agnostic replace menu provider for the popup menu.
46
+ * A BPMN-specific popup menu provider.
47
+ *
48
+ * @implements {PopupMenuProvider}
49
+ *
50
+ * @param {BpmnFactory} bpmnFactory
51
+ * @param {PopupMenu} popupMenu
52
+ * @param {Modeling} modeling
53
+ * @param {Moddle} moddle
54
+ * @param {BpmnReplace} bpmnReplace
55
+ * @param {Rules} rules
56
+ * @param {Translate} translate
26
57
  */
27
58
  export default function ReplaceMenuProvider(
28
59
  bpmnFactory, popupMenu, modeling, moddle,
@@ -36,7 +67,7 @@ export default function ReplaceMenuProvider(
36
67
  this._rules = rules;
37
68
  this._translate = translate;
38
69
 
39
- this.register();
70
+ this._register();
40
71
  }
41
72
 
42
73
  ReplaceMenuProvider.$inject = [
@@ -49,112 +80,104 @@ ReplaceMenuProvider.$inject = [
49
80
  'translate'
50
81
  ];
51
82
 
52
-
53
- /**
54
- * Register replace menu provider in the popup menu
55
- */
56
- ReplaceMenuProvider.prototype.register = function() {
83
+ ReplaceMenuProvider.prototype._register = function() {
57
84
  this._popupMenu.registerProvider('bpmn-replace', this);
58
85
  };
59
86
 
60
-
61
87
  /**
62
- * Get all entries from replaceOptions for the given element and apply filters
63
- * on them. Get for example only elements, which are different from the current one.
64
- *
65
- * @param {djs.model.Base} element
88
+ * @param {PopupMenuTarget} target
66
89
  *
67
- * @return {Array<Object>} a list of menu entry items
90
+ * @return {PopupMenuEntries}
68
91
  */
69
- ReplaceMenuProvider.prototype.getEntries = function(element) {
92
+ ReplaceMenuProvider.prototype.getPopupMenuEntries = function(target) {
70
93
 
71
- var businessObject = element.businessObject;
94
+ var businessObject = target.businessObject;
72
95
 
73
96
  var rules = this._rules;
74
97
 
75
- var entries;
98
+ var filteredReplaceOptions = [];
76
99
 
77
- if (!rules.allowed('shape.replace', { element: element })) {
78
- return [];
100
+ if (isArray(target) || !rules.allowed('shape.replace', { element: target })) {
101
+ return {};
79
102
  }
80
103
 
81
- var differentType = isDifferentType(element);
104
+ var differentType = isDifferentType(target);
82
105
 
83
106
  if (is(businessObject, 'bpmn:DataObjectReference')) {
84
- return this._createEntries(element, replaceOptions.DATA_OBJECT_REFERENCE);
107
+ return this._createEntries(target, replaceOptions.DATA_OBJECT_REFERENCE);
85
108
  }
86
109
 
87
- if (is(businessObject, 'bpmn:DataStoreReference') && !is(element.parent, 'bpmn:Collaboration')) {
88
- return this._createEntries(element, replaceOptions.DATA_STORE_REFERENCE);
110
+ if (is(businessObject, 'bpmn:DataStoreReference') && !is(target.parent, 'bpmn:Collaboration')) {
111
+ return this._createEntries(target, replaceOptions.DATA_STORE_REFERENCE);
89
112
  }
90
113
 
91
114
  // start events outside sub processes
92
115
  if (is(businessObject, 'bpmn:StartEvent') && !is(businessObject.$parent, 'bpmn:SubProcess')) {
93
116
 
94
- entries = filter(replaceOptions.START_EVENT, differentType);
117
+ filteredReplaceOptions = filter(replaceOptions.START_EVENT, differentType);
95
118
 
96
- return this._createEntries(element, entries);
119
+ return this._createEntries(target, filteredReplaceOptions);
97
120
  }
98
121
 
99
122
  // expanded/collapsed pools
100
123
  if (is(businessObject, 'bpmn:Participant')) {
101
124
 
102
- entries = filter(replaceOptions.PARTICIPANT, function(entry) {
103
- return isExpanded(element) !== entry.target.isExpanded;
125
+ filteredReplaceOptions = filter(replaceOptions.PARTICIPANT, function(replaceOption) {
126
+ return isExpanded(target) !== replaceOption.target.isExpanded;
104
127
  });
105
128
 
106
- return this._createEntries(element, entries);
129
+ return this._createEntries(target, filteredReplaceOptions);
107
130
  }
108
131
 
109
132
  // start events inside event sub processes
110
133
  if (is(businessObject, 'bpmn:StartEvent') && isEventSubProcess(businessObject.$parent)) {
111
- entries = filter(replaceOptions.EVENT_SUB_PROCESS_START_EVENT, function(entry) {
134
+ filteredReplaceOptions = filter(replaceOptions.EVENT_SUB_PROCESS_START_EVENT, function(replaceOption) {
112
135
 
113
- var target = entry.target;
136
+ var target = replaceOption.target;
114
137
 
115
138
  var isInterrupting = target.isInterrupting !== false;
116
139
 
117
- var isInterruptingEqual = getBusinessObject(element).isInterrupting === isInterrupting;
140
+ var isInterruptingEqual = getBusinessObject(target).isInterrupting === isInterrupting;
118
141
 
119
142
  // filters elements which types and event definition are equal but have have different interrupting types
120
- return differentType(entry) || !differentType(entry) && !isInterruptingEqual;
143
+ return differentType(replaceOption) || !differentType(replaceOption) && !isInterruptingEqual;
121
144
 
122
145
  });
123
146
 
124
- return this._createEntries(element, entries);
147
+ return this._createEntries(target, filteredReplaceOptions);
125
148
  }
126
149
 
127
150
  // start events inside sub processes
128
151
  if (is(businessObject, 'bpmn:StartEvent') && !isEventSubProcess(businessObject.$parent)
129
152
  && is(businessObject.$parent, 'bpmn:SubProcess')) {
130
- entries = filter(replaceOptions.START_EVENT_SUB_PROCESS, differentType);
153
+ filteredReplaceOptions = filter(replaceOptions.START_EVENT_SUB_PROCESS, differentType);
131
154
 
132
- return this._createEntries(element, entries);
155
+ return this._createEntries(target, filteredReplaceOptions);
133
156
  }
134
157
 
135
158
  // end events
136
159
  if (is(businessObject, 'bpmn:EndEvent')) {
137
160
 
138
- entries = filter(replaceOptions.END_EVENT, function(entry) {
139
- var target = entry.target;
161
+ filteredReplaceOptions = filter(replaceOptions.END_EVENT, function(replaceOption) {
162
+ var target = replaceOption.target;
140
163
 
141
164
  // hide cancel end events outside transactions
142
165
  if (target.eventDefinitionType == 'bpmn:CancelEventDefinition' && !is(businessObject.$parent, 'bpmn:Transaction')) {
143
166
  return false;
144
167
  }
145
168
 
146
- return differentType(entry);
169
+ return differentType(replaceOption);
147
170
  });
148
171
 
149
- return this._createEntries(element, entries);
172
+ return this._createEntries(target, filteredReplaceOptions);
150
173
  }
151
174
 
152
175
  // boundary events
153
176
  if (is(businessObject, 'bpmn:BoundaryEvent')) {
154
177
 
155
- entries = filter(replaceOptions.BOUNDARY_EVENT, function(entry) {
178
+ filteredReplaceOptions = filter(replaceOptions.BOUNDARY_EVENT, function(replaceOption) {
156
179
 
157
- var target = entry.target;
180
+ var target = replaceOption.target;
158
181
 
159
182
  if (target.eventDefinitionType == 'bpmn:CancelEventDefinition' &&
160
183
  !is(businessObject.attachedToRef, 'bpmn:Transaction')) {
@@ -164,121 +187,129 @@ ReplaceMenuProvider.prototype.getEntries = function(element) {
164
187
 
165
188
  var isCancelActivityEqual = businessObject.cancelActivity == cancelActivity;
166
189
 
167
- return differentType(entry) || !differentType(entry) && !isCancelActivityEqual;
190
+ return differentType(replaceOption) || !differentType(replaceOption) && !isCancelActivityEqual;
168
191
  });
169
192
 
170
- return this._createEntries(element, entries);
193
+ return this._createEntries(target, filteredReplaceOptions);
171
194
  }
172
195
 
173
196
  // intermediate events
174
197
  if (is(businessObject, 'bpmn:IntermediateCatchEvent') ||
175
198
  is(businessObject, 'bpmn:IntermediateThrowEvent')) {
176
199
 
177
- entries = filter(replaceOptions.INTERMEDIATE_EVENT, differentType);
200
+ filteredReplaceOptions = filter(replaceOptions.INTERMEDIATE_EVENT, differentType);
178
201
 
179
- return this._createEntries(element, entries);
202
+ return this._createEntries(target, filteredReplaceOptions);
180
203
  }
181
204
 
182
205
  // gateways
183
206
  if (is(businessObject, 'bpmn:Gateway')) {
184
207
 
185
- entries = filter(replaceOptions.GATEWAY, differentType);
208
+ filteredReplaceOptions = filter(replaceOptions.GATEWAY, differentType);
186
209
 
187
- return this._createEntries(element, entries);
210
+ return this._createEntries(target, filteredReplaceOptions);
188
211
  }
189
212
 
190
213
  // transactions
191
214
  if (is(businessObject, 'bpmn:Transaction')) {
192
215
 
193
- entries = filter(replaceOptions.TRANSACTION, differentType);
216
+ filteredReplaceOptions = filter(replaceOptions.TRANSACTION, differentType);
194
217
 
195
- return this._createEntries(element, entries);
218
+ return this._createEntries(target, filteredReplaceOptions);
196
219
  }
197
220
 
198
221
  // expanded event sub processes
199
- if (isEventSubProcess(businessObject) && isExpanded(element)) {
222
+ if (isEventSubProcess(businessObject) && isExpanded(target)) {
200
223
 
201
- entries = filter(replaceOptions.EVENT_SUB_PROCESS, differentType);
224
+ filteredReplaceOptions = filter(replaceOptions.EVENT_SUB_PROCESS, differentType);
202
225
 
203
- return this._createEntries(element, entries);
226
+ return this._createEntries(target, filteredReplaceOptions);
204
227
  }
205
228
 
206
229
  // expanded sub processes
207
- if (is(businessObject, 'bpmn:SubProcess') && isExpanded(element)) {
230
+ if (is(businessObject, 'bpmn:SubProcess') && isExpanded(target)) {
208
231
 
209
- entries = filter(replaceOptions.SUBPROCESS_EXPANDED, differentType);
232
+ filteredReplaceOptions = filter(replaceOptions.SUBPROCESS_EXPANDED, differentType);
210
233
 
211
- return this._createEntries(element, entries);
234
+ return this._createEntries(target, filteredReplaceOptions);
212
235
  }
213
236
 
214
237
  // collapsed ad hoc sub processes
215
- if (is(businessObject, 'bpmn:AdHocSubProcess') && !isExpanded(element)) {
238
+ if (is(businessObject, 'bpmn:AdHocSubProcess') && !isExpanded(target)) {
216
239
 
217
- entries = filter(replaceOptions.TASK, function(entry) {
240
+ filteredReplaceOptions = filter(replaceOptions.TASK, function(replaceOption) {
218
241
 
219
- var target = entry.target;
242
+ var target = replaceOption.target;
220
243
 
221
244
  var isTargetSubProcess = target.type === 'bpmn:SubProcess';
222
245
 
223
246
  var isTargetExpanded = target.isExpanded === true;
224
247
 
225
- return isDifferentType(element, target) && (!isTargetSubProcess || isTargetExpanded);
248
+ return isDifferentType(target, target) && (!isTargetSubProcess || isTargetExpanded);
226
249
  });
227
250
 
228
- return this._createEntries(element, entries);
251
+ return this._createEntries(target, filteredReplaceOptions);
229
252
  }
230
253
 
231
254
  // sequence flows
232
255
  if (is(businessObject, 'bpmn:SequenceFlow')) {
233
- return this._createSequenceFlowEntries(element, replaceOptions.SEQUENCE_FLOW);
256
+ return this._createSequenceFlowEntries(target, replaceOptions.SEQUENCE_FLOW);
234
257
  }
235
258
 
236
259
  // flow nodes
237
260
  if (is(businessObject, 'bpmn:FlowNode')) {
238
- entries = filter(replaceOptions.TASK, differentType);
261
+ filteredReplaceOptions = filter(replaceOptions.TASK, differentType);
239
262
 
240
- // collapsed SubProcess can not be replaced with itself
241
- if (is(businessObject, 'bpmn:SubProcess') && !isExpanded(element)) {
242
- entries = filter(entries, function(entry) {
243
- return entry.label !== 'Sub Process (collapsed)';
263
+ // collapsed sub process cannot be replaced with itself
264
+ if (is(businessObject, 'bpmn:SubProcess') && !isExpanded(target)) {
265
+ filteredReplaceOptions = filter(filteredReplaceOptions, function(replaceOption) {
266
+ return replaceOption.label !== 'Sub Process (collapsed)';
244
267
  });
245
268
  }
246
269
 
247
- return this._createEntries(element, entries);
270
+ return this._createEntries(target, filteredReplaceOptions);
248
271
  }
249
272
 
250
- return [];
273
+ return {};
251
274
  };
252
275
 
253
-
254
276
  /**
255
- * Get a list of header items for the given element. This includes buttons
256
- * for multi instance markers and for the ad hoc marker.
277
+ * @param {PopupMenuTarget} target
257
278
  *
258
- * @param {djs.model.Base} element
259
- *
260
- * @return {Array<Object>} a list of menu entry items
279
+ * @return {PopupMenuHeaderEntries}
261
280
  */
262
- ReplaceMenuProvider.prototype.getHeaderEntries = function(element) {
281
+ ReplaceMenuProvider.prototype.getPopupMenuHeaderEntries = function(target) {
263
282
 
264
- var headerEntries = [];
283
+ var headerEntries = {};
265
284
 
266
- if (is(element, 'bpmn:Activity') && !isEventSubProcess(element)) {
267
- headerEntries = headerEntries.concat(this._getLoopEntries(element));
285
+ if (is(target, 'bpmn:Activity') && !isEventSubProcess(target)) {
286
+ headerEntries = {
287
+ ...headerEntries,
288
+ ...this._getLoopCharacteristicsHeaderEntries(target)
289
+ };
268
290
  }
269
291
 
270
- if (is(element, 'bpmn:DataObjectReference')) {
271
- headerEntries = headerEntries.concat(this._getDataObjectIsCollection(element));
292
+ if (is(target, 'bpmn:DataObjectReference')) {
293
+ headerEntries = {
294
+ ...headerEntries,
295
+ ...this._getCollectionHeaderEntries(target)
296
+ };
272
297
  }
273
298
 
274
- if (is(element, 'bpmn:Participant')) {
275
- headerEntries = headerEntries.concat(this._getParticipantMultiplicity(element));
299
+ if (is(target, 'bpmn:Participant')) {
300
+ headerEntries = {
301
+ ...headerEntries,
302
+ ...this._getParticipantMultiplicityHeaderEntries(target)
303
+ };
276
304
  }
277
305
 
278
- if (is(element, 'bpmn:SubProcess') &&
279
- !is(element, 'bpmn:Transaction') &&
280
- !isEventSubProcess(element)) {
281
- headerEntries.push(this._getAdHocEntry(element));
306
+ if (is(target, 'bpmn:SubProcess') &&
307
+ !is(target, 'bpmn:Transaction') &&
308
+ !isEventSubProcess(target)) {
309
+ headerEntries = {
310
+ ...headerEntries,
311
+ ...this._getAdHocHeaderEntries(target)
312
+ };
282
313
  }
283
314
 
284
315
  return headerEntries;
@@ -286,50 +317,47 @@ ReplaceMenuProvider.prototype.getHeaderEntries = function(element) {
286
317
 
287
318
 
288
319
  /**
289
- * Creates an array of menu entry objects for a given element and filters the replaceOptions
290
- * according to a filter function.
320
+ * Create popup menu entries for the given target.
291
321
  *
292
- * @param {djs.model.Base} element
293
- * @param {Object} replaceOptions
322
+ * @param {PopupMenuTarget} target
323
+ * @param {ReplaceOption[]} replaceOptions
294
324
  *
295
- * @return {Array<Object>} a list of menu items
325
+ * @return {PopupMenuEntries}
296
326
  */
297
- ReplaceMenuProvider.prototype._createEntries = function(element, replaceOptions) {
298
- var menuEntries = [];
327
+ ReplaceMenuProvider.prototype._createEntries = function(target, replaceOptions) {
328
+ var entries = {};
299
329
 
300
330
  var self = this;
301
331
 
302
- forEach(replaceOptions, function(definition) {
303
- var entry = self._createMenuEntry(definition, element);
304
-
305
- menuEntries.push(entry);
332
+ forEach(replaceOptions, function(replaceOption) {
333
+ entries[ replaceOption.actionName ] = self._createEntry(replaceOption, target);
306
334
  });
307
335
 
308
- return menuEntries;
336
+ return entries;
309
337
  };
310
338
 
311
339
  /**
312
- * Creates an array of menu entry objects for a given sequence flow.
340
+ * Creates popup menu entries for the given sequence flow.
313
341
  *
314
- * @param {djs.model.Base} element
315
- * @param {Object} replaceOptions
316
-
317
- * @return {Array<Object>} a list of menu items
342
+ * @param {PopupMenuTarget} target
343
+ * @param {ReplaceOption[]} replaceOptions
344
+ *
345
+ * @return {PopupMenuEntries}
318
346
  */
319
- ReplaceMenuProvider.prototype._createSequenceFlowEntries = function(element, replaceOptions) {
347
+ ReplaceMenuProvider.prototype._createSequenceFlowEntries = function(target, replaceOptions) {
320
348
 
321
- var businessObject = getBusinessObject(element);
349
+ var businessObject = getBusinessObject(target);
322
350
 
323
- var menuEntries = [];
351
+ var entries = {};
324
352
 
325
353
  var modeling = this._modeling,
326
354
  moddle = this._moddle;
327
355
 
328
356
  var self = this;
329
357
 
330
- forEach(replaceOptions, function(entry) {
358
+ forEach(replaceOptions, function(replaceOption) {
331
359
 
332
- switch (entry.actionName) {
360
+ switch (replaceOption.actionName) {
333
361
  case 'replace-with-default-flow':
334
362
  if (businessObject.sourceRef.default !== businessObject &&
335
363
  (is(businessObject.sourceRef, 'bpmn:ExclusiveGateway') ||
@@ -337,97 +365,103 @@ ReplaceMenuProvider.prototype._createSequenceFlowEntries = function(element, rep
337
365
  is(businessObject.sourceRef, 'bpmn:ComplexGateway') ||
338
366
  is(businessObject.sourceRef, 'bpmn:Activity'))) {
339
367
 
340
- menuEntries.push(self._createMenuEntry(entry, element, function() {
341
- modeling.updateProperties(element.source, { default: businessObject });
342
- }));
368
+ entries = {
369
+ ...entries,
370
+ [ replaceOption.actionName ]: self._createEntry(replaceOption, target, function() {
371
+ modeling.updateProperties(target.source, { default: businessObject });
372
+ })
373
+ };
343
374
  }
344
375
  break;
345
376
  case 'replace-with-conditional-flow':
346
377
  if (!businessObject.conditionExpression && is(businessObject.sourceRef, 'bpmn:Activity')) {
347
378
 
348
- menuEntries.push(self._createMenuEntry(entry, element, function() {
349
- var conditionExpression = moddle.create('bpmn:FormalExpression', { body: '' });
379
+ entries = {
380
+ ...entries,
381
+ [ replaceOption.actionName ]: self._createEntry(replaceOption, target, function() {
382
+ var conditionExpression = moddle.create('bpmn:FormalExpression', { body: '' });
350
383
 
351
- modeling.updateProperties(element, { conditionExpression: conditionExpression });
352
- }));
384
+ modeling.updateProperties(target, { conditionExpression: conditionExpression });
385
+ })
386
+ };
353
387
  }
354
388
  break;
355
389
  default:
356
390
 
357
- // default flows
391
+ // conditional flow -> sequence flow
358
392
  if (is(businessObject.sourceRef, 'bpmn:Activity') && businessObject.conditionExpression) {
359
- return menuEntries.push(self._createMenuEntry(entry, element, function() {
360
- modeling.updateProperties(element, { conditionExpression: undefined });
361
- }));
393
+ entries = {
394
+ ...entries,
395
+ [ replaceOption.actionName ]: self._createEntry(replaceOption, target, function() {
396
+ modeling.updateProperties(target, { conditionExpression: undefined });
397
+ })
398
+ };
362
399
  }
363
400
 
364
- // conditional flows
401
+ // default flow -> sequence flow
365
402
  if ((is(businessObject.sourceRef, 'bpmn:ExclusiveGateway') ||
366
403
  is(businessObject.sourceRef, 'bpmn:InclusiveGateway') ||
367
404
  is(businessObject.sourceRef, 'bpmn:ComplexGateway') ||
368
405
  is(businessObject.sourceRef, 'bpmn:Activity')) &&
369
406
  businessObject.sourceRef.default === businessObject) {
370
-
371
- return menuEntries.push(self._createMenuEntry(entry, element, function() {
372
- modeling.updateProperties(element.source, { default: undefined });
373
- }));
407
+ entries = {
408
+ ...entries,
409
+ [ replaceOption.actionName ]: self._createEntry(replaceOption, target, function() {
410
+ modeling.updateProperties(target.source, { default: undefined });
411
+ })
412
+ };
374
413
  }
375
414
  }
376
415
  });
377
416
 
378
- return menuEntries;
417
+ return entries;
379
418
  };
380
419
 
381
-
382
420
  /**
383
- * Creates and returns a single menu entry item.
421
+ * Create a popup menu entry for the given replace option.
384
422
  *
385
- * @param {Object} definition a single replace options definition object
386
- * @param {djs.model.Base} element
387
- * @param {Function} [action] an action callback function which gets called when
388
- * the menu entry is being triggered.
423
+ * @param {ReplaceOption} replaceOption
424
+ * @param {PopupMenuTarget} target
425
+ * @param {PopupMenuEntryAction} [action]
389
426
  *
390
- * @return {Object} menu entry item
427
+ * @return {PopupMenuEntry}
391
428
  */
392
- ReplaceMenuProvider.prototype._createMenuEntry = function(definition, element, action) {
429
+ ReplaceMenuProvider.prototype._createEntry = function(replaceOption, target, action) {
393
430
  var translate = this._translate;
394
431
  var replaceElement = this._bpmnReplace.replaceElement;
395
432
 
396
433
  var replaceAction = function() {
397
- return replaceElement(element, definition.target);
434
+ return replaceElement(target, replaceOption.target);
398
435
  };
399
436
 
400
- var label = definition.label;
437
+ var label = replaceOption.label;
401
438
  if (label && typeof label === 'function') {
402
- label = label(element);
439
+ label = label(target);
403
440
  }
404
441
 
405
442
  action = action || replaceAction;
406
443
 
407
- var menuEntry = {
444
+ return {
408
445
  label: translate(label),
409
- className: definition.className,
410
- id: definition.actionName,
446
+ className: replaceOption.className,
411
447
  action: action
412
448
  };
413
-
414
- return menuEntry;
415
449
  };
416
450
 
417
451
  /**
418
- * Get a list of menu items containing buttons for multi instance markers
452
+ * Get popup menu header entries for the loop characteristics of the given BPMN element.
419
453
  *
420
- * @param {djs.model.Base} element
454
+ * @param {PopupMenuTarget} target
421
455
  *
422
- * @return {Array<Object>} a list of menu items
456
+ * @return {PopupMenuHeaderEntries}
423
457
  */
424
- ReplaceMenuProvider.prototype._getLoopEntries = function(element) {
458
+ ReplaceMenuProvider.prototype._getLoopCharacteristicsHeaderEntries = function(target) {
425
459
 
426
460
  var self = this;
427
461
  var translate = this._translate;
428
462
 
429
463
  function toggleLoopEntry(event, entry) {
430
- var newLoopCharacteristics = getBusinessObject(element).loopCharacteristics;
464
+ var newLoopCharacteristics = getBusinessObject(target).loopCharacteristics;
431
465
 
432
466
  if (entry.active) {
433
467
  newLoopCharacteristics = undefined;
@@ -439,10 +473,10 @@ ReplaceMenuProvider.prototype._getLoopEntries = function(element) {
439
473
 
440
474
  newLoopCharacteristics.isSequential = entry.options.isSequential;
441
475
  }
442
- self._modeling.updateProperties(element, { loopCharacteristics: newLoopCharacteristics });
476
+ self._modeling.updateProperties(target, { loopCharacteristics: newLoopCharacteristics });
443
477
  }
444
478
 
445
- var businessObject = getBusinessObject(element),
479
+ var businessObject = getBusinessObject(target),
446
480
  loopCharacteristics = businessObject.loopCharacteristics;
447
481
 
448
482
  var isSequential,
@@ -456,9 +490,8 @@ ReplaceMenuProvider.prototype._getLoopEntries = function(element) {
456
490
  }
457
491
 
458
492
 
459
- var loopEntries = [
460
- {
461
- id: 'toggle-parallel-mi',
493
+ return {
494
+ 'toggle-parallel-mi' : {
462
495
  className: 'bpmn-icon-parallel-mi-marker',
463
496
  title: translate('Parallel Multi Instance'),
464
497
  active: isParallel,
@@ -468,8 +501,7 @@ ReplaceMenuProvider.prototype._getLoopEntries = function(element) {
468
501
  isSequential: false
469
502
  }
470
503
  },
471
- {
472
- id: 'toggle-sequential-mi',
504
+ 'toggle-sequential-mi': {
473
505
  className: 'bpmn-icon-sequential-mi-marker',
474
506
  title: translate('Sequential Multi Instance'),
475
507
  active: isSequential,
@@ -479,8 +511,7 @@ ReplaceMenuProvider.prototype._getLoopEntries = function(element) {
479
511
  isSequential: true
480
512
  }
481
513
  },
482
- {
483
- id: 'toggle-loop',
514
+ 'toggle-loop': {
484
515
  className: 'bpmn-icon-loop-marker',
485
516
  title: translate('Loop'),
486
517
  active: isLoop,
@@ -489,57 +520,54 @@ ReplaceMenuProvider.prototype._getLoopEntries = function(element) {
489
520
  loopCharacteristics: 'bpmn:StandardLoopCharacteristics'
490
521
  }
491
522
  }
492
- ];
493
- return loopEntries;
523
+ };
494
524
  };
495
525
 
496
526
  /**
497
- * Get a list of menu items containing a button for the collection marker
527
+ * Get popup menu header entries for the collection property of the given BPMN element.
498
528
  *
499
- * @param {djs.model.Base} element
529
+ * @param {PopupMenuTarget} target
500
530
  *
501
- * @return {Array<Object>} a list of menu items
531
+ * @return {PopupMenuHeaderEntries}
502
532
  */
503
- ReplaceMenuProvider.prototype._getDataObjectIsCollection = function(element) {
533
+ ReplaceMenuProvider.prototype._getCollectionHeaderEntries = function(target) {
504
534
 
505
535
  var self = this;
506
536
  var translate = this._translate;
507
537
 
508
- var dataObject = element.businessObject.dataObjectRef;
538
+ var dataObject = target.businessObject.dataObjectRef;
509
539
 
510
540
  if (!dataObject) {
511
- return [];
541
+ return {};
512
542
  }
513
543
 
514
544
  function toggleIsCollection(event, entry) {
515
545
  self._modeling.updateModdleProperties(
516
- element,
546
+ target,
517
547
  dataObject,
518
548
  { isCollection: !entry.active });
519
549
  }
520
550
 
521
551
  var isCollection = dataObject.isCollection;
522
552
 
523
- var dataObjectEntries = [
524
- {
525
- id: 'toggle-is-collection',
553
+ return {
554
+ 'toggle-is-collection': {
526
555
  className: 'bpmn-icon-parallel-mi-marker',
527
556
  title: translate('Collection'),
528
557
  active: isCollection,
529
558
  action: toggleIsCollection,
530
559
  }
531
- ];
532
- return dataObjectEntries;
560
+ };
533
561
  };
534
562
 
535
563
  /**
536
- * Get a list of menu items containing a button for the participant multiplicity marker
564
+ * Get popup menu header entries for the participant multiplicity property of the given BPMN element.
537
565
  *
538
- * @param {djs.model.Base} element
566
+ * @param {PopupMenuTarget} target
539
567
  *
540
- * @return {Array<Object>} a list of menu items
568
+ * @return {PopupMenuHeaderEntries}
541
569
  */
542
- ReplaceMenuProvider.prototype._getParticipantMultiplicity = function(element) {
570
+ ReplaceMenuProvider.prototype._getParticipantMultiplicityHeaderEntries = function(target) {
543
571
 
544
572
  var self = this;
545
573
  var bpmnFactory = this._bpmnFactory;
@@ -554,33 +582,30 @@ ReplaceMenuProvider.prototype._getParticipantMultiplicity = function(element) {
554
582
  }
555
583
 
556
584
  self._modeling.updateProperties(
557
- element,
585
+ target,
558
586
  { participantMultiplicity: participantMultiplicity });
559
587
  }
560
588
 
561
- var participantMultiplicity = element.businessObject.participantMultiplicity;
589
+ var participantMultiplicity = target.businessObject.participantMultiplicity;
562
590
 
563
- var participantEntries = [
564
- {
565
- id: 'toggle-participant-multiplicity',
591
+ return {
592
+ 'toggle-participant-multiplicity': {
566
593
  className: 'bpmn-icon-parallel-mi-marker',
567
594
  title: translate('Participant Multiplicity'),
568
595
  active: !!participantMultiplicity,
569
596
  action: toggleParticipantMultiplicity,
570
597
  }
571
- ];
572
- return participantEntries;
598
+ };
573
599
  };
574
600
 
575
-
576
601
  /**
577
- * Get the menu items containing a button for the ad hoc marker
602
+ * Get popup menu header entries for the ad-hoc property of the given BPMN element.
578
603
  *
579
- * @param {djs.model.Base} element
604
+ * @param {PopupMenuTarget} target
580
605
  *
581
- * @return {Object} a menu item
606
+ * @return {PopupMenuHeaderEntries}
582
607
  */
583
- ReplaceMenuProvider.prototype._getAdHocEntry = function(element) {
608
+ ReplaceMenuProvider.prototype._getAdHocHeaderEntries = function(element) {
584
609
  var translate = this._translate;
585
610
  var businessObject = getBusinessObject(element);
586
611
 
@@ -588,25 +613,24 @@ ReplaceMenuProvider.prototype._getAdHocEntry = function(element) {
588
613
 
589
614
  var replaceElement = this._bpmnReplace.replaceElement;
590
615
 
591
- var adHocEntry = {
592
- id: 'toggle-adhoc',
593
- className: 'bpmn-icon-ad-hoc-marker',
594
- title: translate('Ad-hoc'),
595
- active: isAdHoc,
596
- action: function(event, entry) {
597
- if (isAdHoc) {
598
- return replaceElement(element, { type: 'bpmn:SubProcess' }, {
599
- autoResize: false,
600
- layoutConnection: false
601
- });
602
- } else {
603
- return replaceElement(element, { type: 'bpmn:AdHocSubProcess' }, {
604
- autoResize: false,
605
- layoutConnection: false
606
- });
616
+ return {
617
+ 'toggle-adhoc': {
618
+ className: 'bpmn-icon-ad-hoc-marker',
619
+ title: translate('Ad-hoc'),
620
+ active: isAdHoc,
621
+ action: function(event, entry) {
622
+ if (isAdHoc) {
623
+ return replaceElement(element, { type: 'bpmn:SubProcess' }, {
624
+ autoResize: false,
625
+ layoutConnection: false
626
+ });
627
+ } else {
628
+ return replaceElement(element, { type: 'bpmn:AdHocSubProcess' }, {
629
+ autoResize: false,
630
+ layoutConnection: false
631
+ });
632
+ }
607
633
  }
608
634
  }
609
635
  };
610
-
611
- return adHocEntry;
612
636
  };