bpmn-js 8.8.2 → 8.10.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.
@@ -105,7 +105,7 @@ export default function LabelEditingProvider(
105
105
 
106
106
  function activateDirectEdit(element, force) {
107
107
  if (force ||
108
- isAny(element, [ 'bpmn:Task', 'bpmn:TextAnnotation', 'bpmn:Group' ]) ||
108
+ isAny(element, [ 'bpmn:Task', 'bpmn:TextAnnotation' ]) ||
109
109
  isCollapsedSubProcess(element)) {
110
110
 
111
111
  directEditing.activate(element);
@@ -42,6 +42,10 @@ BpmnFactory.prototype._needsId = function(element) {
42
42
  };
43
43
 
44
44
  BpmnFactory.prototype._ensureId = function(element) {
45
+ if (element.id) {
46
+ this._model.ids.claim(element.id, element);
47
+ return;
48
+ }
45
49
 
46
50
  // generate semantic ids for elements
47
51
  // bpmn:SequenceFlow -> SequenceFlow_ID
@@ -112,7 +116,8 @@ BpmnFactory.prototype.createDiWaypoint = function(point) {
112
116
 
113
117
  BpmnFactory.prototype.createDiEdge = function(semantic, waypoints, attrs) {
114
118
  return this.create('bpmndi:BPMNEdge', assign({
115
- bpmnElement: semantic
119
+ bpmnElement: semantic,
120
+ waypoint: this.createDiWaypoints(waypoints)
116
121
  }, attrs));
117
122
  };
118
123
 
@@ -2,7 +2,7 @@ import inherits from 'inherits';
2
2
 
3
3
  import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
4
4
 
5
- import { is } from '../../../util/ModelUtil';
5
+ import { getBusinessObject, is } from '../../../util/ModelUtil';
6
6
 
7
7
  import { isLabel } from '../../../util/LabelUtil';
8
8
 
@@ -88,122 +88,97 @@ export default function CreateParticipantBehavior(canvas, eventBus, modeling) {
88
88
  }
89
89
  });
90
90
 
91
- function ensureCollaboration(context) {
92
- var parent = context.parent,
93
- collaboration;
94
-
91
+ // turn process into collaboration when creating first participant
92
+ function getOrCreateCollaboration() {
95
93
  var rootElement = canvas.getRootElement();
96
94
 
97
95
  if (is(rootElement, 'bpmn:Collaboration')) {
98
- collaboration = rootElement;
99
- } else {
100
-
101
- // update root element by making collaboration
102
- collaboration = modeling.makeCollaboration();
103
-
104
- // re-use process when creating first participant
105
- context.process = parent;
96
+ return rootElement;
106
97
  }
107
98
 
108
- context.parent = collaboration;
99
+ return modeling.makeCollaboration();
109
100
  }
110
101
 
111
- // turn process into collaboration before adding participant
112
- this.preExecute('shape.create', function(context) {
113
- var parent = context.parent,
114
- shape = context.shape;
115
-
116
- if (is(shape, 'bpmn:Participant') && is(parent, 'bpmn:Process')) {
117
- ensureCollaboration(context);
118
- }
119
- }, true);
120
-
121
- this.execute('shape.create', function(context) {
122
- var process = context.process,
123
- shape = context.shape;
124
-
125
- if (process) {
126
- context.oldProcessRef = shape.businessObject.processRef;
127
-
128
- // re-use process when creating first participant
129
- shape.businessObject.processRef = process.businessObject;
130
- }
131
- }, true);
102
+ // when creating mutliple elements through `elements.create` parent must be set to collaboration
103
+ // and passed to `shape.create` as hint
104
+ this.preExecute('elements.create', HIGH_PRIORITY, function(context) {
105
+ var elements = context.elements,
106
+ parent = context.parent,
107
+ participant = findParticipant(elements),
108
+ hints;
132
109
 
133
- this.revert('shape.create', function(context) {
134
- var process = context.process,
135
- shape = context.shape;
110
+ if (participant && is(parent, 'bpmn:Process')) {
111
+ context.parent = getOrCreateCollaboration();
136
112
 
137
- if (process) {
113
+ hints = context.hints = context.hints || {};
138
114
 
139
- // re-use process when creating first participant
140
- shape.businessObject.processRef = context.oldProcessRef;
115
+ hints.participant = participant;
116
+ hints.process = parent;
117
+ hints.processRef = getBusinessObject(participant).get('processRef');
141
118
  }
142
119
  }, true);
143
120
 
144
- this.postExecute('shape.create', function(context) {
145
- var process = context.process,
121
+ // when creating single shape through `shape.create` parent must be set to collaboration
122
+ // unless it was already set through `elements.create`
123
+ this.preExecute('shape.create', function(context) {
124
+ var parent = context.parent,
146
125
  shape = context.shape;
147
126
 
148
- if (process) {
149
-
150
- // move children from process to participant
151
- var processChildren = process.children.slice();
127
+ if (is(shape, 'bpmn:Participant') && is(parent, 'bpmn:Process')) {
128
+ context.parent = getOrCreateCollaboration();
152
129
 
153
- modeling.moveElements(processChildren, { x: 0, y: 0 }, shape);
130
+ context.process = parent;
131
+ context.processRef = getBusinessObject(shape).get('processRef');
154
132
  }
155
-
156
133
  }, true);
157
134
 
158
- // turn process into collaboration when creating participants
159
- this.preExecute('elements.create', HIGH_PRIORITY, function(context) {
160
- var elements = context.elements,
161
- parent = context.parent,
162
- participant;
163
-
164
- var hasParticipants = findParticipant(elements);
165
-
166
- if (hasParticipants && is(parent, 'bpmn:Process')) {
167
- ensureCollaboration(context);
168
-
169
- participant = findParticipant(elements);
135
+ // #execute necessary because #preExecute not called on CommandStack#redo
136
+ this.execute('shape.create', function(context) {
137
+ var hints = context.hints || {},
138
+ process = context.process || hints.process,
139
+ shape = context.shape,
140
+ participant = hints.participant;
170
141
 
171
- context.oldProcessRef = participant.businessObject.processRef;
142
+ // both shape.create and elements.create must be handled
143
+ if (process && (!participant || shape === participant)) {
172
144
 
173
- // re-use process when creating first participant
174
- participant.businessObject.processRef = parent.businessObject;
145
+ // monkey-patch process ref
146
+ getBusinessObject(shape).set('processRef', getBusinessObject(process));
175
147
  }
176
148
  }, true);
177
149
 
178
- this.revert('elements.create', function(context) {
179
- var elements = context.elements,
180
- process = context.process,
181
- participant;
150
+ this.revert('shape.create', function(context) {
151
+ var hints = context.hints || {},
152
+ process = context.process || hints.process,
153
+ processRef = context.processRef || hints.processRef,
154
+ shape = context.shape,
155
+ participant = hints.participant;
182
156
 
183
- if (process) {
184
- participant = findParticipant(elements);
157
+ // both shape.create and elements.create must be handled
158
+ if (process && (!participant || shape === participant)) {
185
159
 
186
- // re-use process when creating first participant
187
- participant.businessObject.processRef = context.oldProcessRef;
160
+ // monkey-patch process ref
161
+ getBusinessObject(shape).set('processRef', processRef);
188
162
  }
189
163
  }, true);
190
164
 
191
- this.postExecute('elements.create', function(context) {
192
- var elements = context.elements,
193
- process = context.process,
194
- participant;
165
+ this.postExecute('shape.create', function(context) {
166
+ var hints = context.hints || {},
167
+ process = context.process || context.hints.process,
168
+ shape = context.shape,
169
+ participant = hints.participant;
195
170
 
196
171
  if (process) {
197
- participant = findParticipant(elements);
198
-
199
- // move children from process to first participant
200
- var processChildren = process.children.slice();
201
-
202
- modeling.moveElements(processChildren, { x: 0, y: 0 }, participant);
172
+ var children = process.children.slice();
173
+
174
+ // both shape.create and elements.create must be handled
175
+ if (!participant) {
176
+ modeling.moveElements(children, { x: 0, y: 0 }, shape);
177
+ } else if (shape === participant) {
178
+ modeling.moveElements(children, { x: 0, y: 0 }, participant);
179
+ }
203
180
  }
204
-
205
181
  }, true);
206
-
207
182
  }
208
183
 
209
184
  CreateParticipantBehavior.$inject = [
@@ -59,12 +59,12 @@ export default function DropOnFlowBehavior(eventBus, bpmnRules, modeling) {
59
59
  dockingPoint = intersection.bendpoint ? waypoints[intersection.index] : mid;
60
60
 
61
61
  // if last waypointBefore is inside shape's bounds, ignore docking point
62
- if (!isPointInsideBBox(shape, waypointsBefore[waypointsBefore.length-1])) {
62
+ if (waypointsBefore.length === 1 || !isPointInsideBBox(shape, waypointsBefore[waypointsBefore.length-1])) {
63
63
  waypointsBefore.push(copy(dockingPoint));
64
64
  }
65
65
 
66
66
  // if first waypointAfter is inside shape's bounds, ignore docking point
67
- if (!isPointInsideBBox(shape, waypointsAfter[0])) {
67
+ if (waypointsAfter.length === 1 || !isPointInsideBBox(shape, waypointsAfter[0])) {
68
68
  waypointsAfter.unshift(copy(dockingPoint));
69
69
  }
70
70
  }
@@ -47,7 +47,9 @@ export default function UnclaimIdBehavior(canvas, injector, moddle, modeling) {
47
47
  var rootElement = canvas.getRootElement(),
48
48
  rootElementBo = rootElement.businessObject;
49
49
 
50
- moddle.ids.unclaim(rootElementBo.id);
50
+ if (is(rootElement, 'bpmn:Collaboration')) {
51
+ moddle.ids.unclaim(rootElementBo.id);
52
+ }
51
53
  });
52
54
  }
53
55
 
@@ -63,12 +63,26 @@ SetColorHandler.prototype.postExecute = function(context) {
63
63
  // TODO @barmac: remove once we drop bpmn.io properties
64
64
  ensureLegacySupport(assignedDi);
65
65
 
66
- self._commandStack.execute('element.updateProperties', {
67
- element: element,
68
- properties: {
69
- di: assignedDi
70
- }
71
- });
66
+ if (element.labelTarget) {
67
+
68
+ // set label colors as bpmndi:BPMNLabel#color
69
+ self._commandStack.execute('element.updateModdleProperties', {
70
+ element: element,
71
+ moddleElement: element.businessObject.di.label,
72
+ properties: {
73
+ color: di['background-color']
74
+ }
75
+ });
76
+ } else {
77
+
78
+ // set colors bpmndi:BPMNEdge or bpmndi:BPMNShape
79
+ self._commandStack.execute('element.updateProperties', {
80
+ element: element,
81
+ properties: {
82
+ di: assignedDi
83
+ }
84
+ });
85
+ }
72
86
  });
73
87
 
74
88
  };
@@ -1,24 +1,6 @@
1
- import {
2
- some
3
- } from 'min-dash';
4
-
5
- import { is } from '../../../util/ModelUtil';
6
-
7
-
8
- /**
9
- * Return true if element has any of the given types.
10
- *
11
- * @param {djs.model.Base} element
12
- * @param {Array<string>} types
13
- *
14
- * @return {boolean}
15
- */
16
- export function isAny(element, types) {
17
- return some(types, function(t) {
18
- return is(element, t);
19
- });
20
- }
1
+ export { is, isAny } from '../../../util/ModelUtil';
21
2
 
3
+ import { isAny } from '../../../util/ModelUtil';
22
4
 
23
5
  /**
24
6
  * Return the parent of the element with any of the given types.
@@ -88,7 +88,7 @@ PaletteProvider.prototype.getPaletteEntries = function(element) {
88
88
 
89
89
  create.start(event, [ subProcess, startEvent ], {
90
90
  hints: {
91
- autoSelect: [ startEvent ]
91
+ autoSelect: [ subProcess ]
92
92
  }
93
93
  });
94
94
  }
@@ -83,7 +83,7 @@ ReplaceMenuProvider.prototype.getEntries = function(element) {
83
83
  return this._createEntries(element, replaceOptions.DATA_OBJECT_REFERENCE);
84
84
  }
85
85
 
86
- if (is(businessObject, 'bpmn:DataStoreReference')) {
86
+ if (is(businessObject, 'bpmn:DataStoreReference') && !is(element.parent, 'bpmn:Collaboration')) {
87
87
  return this._createEntries(element, replaceOptions.DATA_STORE_REFERENCE);
88
88
  }
89
89
 
@@ -1,3 +1,8 @@
1
+ import {
2
+ some
3
+ } from 'min-dash';
4
+
5
+
1
6
  /**
2
7
  * Is an element of the given BPMN type?
3
8
  *
@@ -13,6 +18,20 @@ export function is(element, type) {
13
18
  }
14
19
 
15
20
 
21
+ /**
22
+ * Return true if element has any of the given types.
23
+ *
24
+ * @param {djs.model.Base} element
25
+ * @param {Array<string>} types
26
+ *
27
+ * @return {boolean}
28
+ */
29
+ export function isAny(element, types) {
30
+ return some(types, function(t) {
31
+ return is(element, t);
32
+ });
33
+ }
34
+
16
35
  /**
17
36
  * Return the business object for a given element.
18
37
  *
@@ -22,4 +41,17 @@ export function is(element, type) {
22
41
  */
23
42
  export function getBusinessObject(element) {
24
43
  return (element && element.businessObject) || element;
44
+ }
45
+
46
+ /**
47
+ * Return the di object for a given element.
48
+ *
49
+ * @param {djs.model.Base} element
50
+ *
51
+ * @return {ModdleElement}
52
+ */
53
+ export function getDi(element) {
54
+ var bo = getBusinessObject(element);
55
+
56
+ return bo && bo.di;
25
57
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpmn-js",
3
- "version": "8.8.2",
3
+ "version": "8.10.0",
4
4
  "description": "A bpmn 2.0 toolkit and web modeler",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -100,7 +100,7 @@
100
100
  "dependencies": {
101
101
  "bpmn-moddle": "^7.1.2",
102
102
  "css.escape": "^1.5.1",
103
- "diagram-js": "^7.5.0",
103
+ "diagram-js": "^7.8.2",
104
104
  "diagram-js-direct-editing": "^1.6.3",
105
105
  "ids": "^1.0.0",
106
106
  "inherits": "^2.0.4",