@processmaker/modeler 1.46.2 → 1.46.4
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.
- package/dist/modeler.common.js +199 -85
- package/dist/modeler.common.js.map +1 -1
- package/dist/modeler.umd.js +199 -85
- package/dist/modeler.umd.js.map +1 -1
- package/dist/modeler.umd.min.js +1 -1
- package/dist/modeler.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/components/nodes/sequenceFlow/sequenceFlow.vue +4 -1
- package/src/mixins/linkConfig.js +97 -14
package/package.json
CHANGED
|
@@ -49,7 +49,7 @@ export default {
|
|
|
49
49
|
},
|
|
50
50
|
computed: {
|
|
51
51
|
isValidConnection() {
|
|
52
|
-
return
|
|
52
|
+
return this.isValid({
|
|
53
53
|
sourceShape: this.sourceShape,
|
|
54
54
|
targetShape: this.target,
|
|
55
55
|
targetConfig: this.targetConfig,
|
|
@@ -94,6 +94,9 @@ export default {
|
|
|
94
94
|
},
|
|
95
95
|
},
|
|
96
96
|
methods: {
|
|
97
|
+
isValid(params) {
|
|
98
|
+
return SequenceFlow.isValid(params);
|
|
99
|
+
},
|
|
97
100
|
setDefaultMarker(value) {
|
|
98
101
|
this.shape.attr('line', {
|
|
99
102
|
sourceMarker: {
|
package/src/mixins/linkConfig.js
CHANGED
|
@@ -30,6 +30,7 @@ export default {
|
|
|
30
30
|
listeningToMouseleave: false,
|
|
31
31
|
vertices: null,
|
|
32
32
|
anchorPointFunction: getDefaultAnchorPoint,
|
|
33
|
+
onChangeWasFired: false,
|
|
33
34
|
};
|
|
34
35
|
},
|
|
35
36
|
watch: {
|
|
@@ -159,6 +160,9 @@ export default {
|
|
|
159
160
|
this.shape.listenTo(targetShape, 'change:position', this.updateWaypoints);
|
|
160
161
|
|
|
161
162
|
this.shape.listenTo(this.paper, 'link:mouseleave', this.storeWaypoints);
|
|
163
|
+
// Listens to the 'pointerup' event when a link is interacted with on the shape.
|
|
164
|
+
// When the event occurs, the 'pointerUpHandler' method is invoked to handle the pointer up action.
|
|
165
|
+
this.shape.listenTo(this.paper, 'link:pointerup', this.pointerUpHandler);
|
|
162
166
|
|
|
163
167
|
const sourceShape = this.shape.getSourceElement();
|
|
164
168
|
sourceShape.embed(this.shape);
|
|
@@ -200,23 +204,97 @@ export default {
|
|
|
200
204
|
|
|
201
205
|
window.ProcessMaker.EventBus.$emit('multiplayer-updateNodes', changes);
|
|
202
206
|
}
|
|
203
|
-
|
|
204
207
|
this.listeningToMouseleave = true;
|
|
205
208
|
this.$emit('save-state');
|
|
206
209
|
}
|
|
207
210
|
},
|
|
211
|
+
|
|
208
212
|
/**
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
if (
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
213
|
+
* Handles the pointer up event.
|
|
214
|
+
* Performs actions based on changes in the target shape.
|
|
215
|
+
* @async
|
|
216
|
+
*/
|
|
217
|
+
async pointerUpHandler() {
|
|
218
|
+
// Check if the 'onChange' event was fired. If not, exit the method.
|
|
219
|
+
if (!this.onChangeWasFired) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
// Check if the target shape has changed.
|
|
223
|
+
const targetChanged = this.target.id !== this.currentTarget.id;
|
|
224
|
+
if (targetChanged) {
|
|
225
|
+
// Disable the 'onChange' event to prevent redundant processing.
|
|
226
|
+
this.onChangeWasFired = false;
|
|
227
|
+
// Extract information about the new target shape
|
|
228
|
+
const targetNode = get(this.currentTarget, 'component.node');
|
|
229
|
+
const targetConfig = targetNode && this.nodeRegistry[targetNode.type];
|
|
230
|
+
// Validate the flow with the new target node.
|
|
231
|
+
const isValid = this.isValid?.({
|
|
232
|
+
sourceShape: this.sourceShape,
|
|
233
|
+
targetShape: this.currentTarget,
|
|
234
|
+
targetConfig,
|
|
235
|
+
});
|
|
236
|
+
// If the flow is valid, update the target and related information.
|
|
237
|
+
if (isValid) {
|
|
238
|
+
this.setTarget(this.currentTarget);
|
|
239
|
+
this.target = this.currentTarget;
|
|
240
|
+
// Optionally update definition links.
|
|
241
|
+
if (this.updateDefinitionLinks) {
|
|
242
|
+
this.updateDefinitionLinks();
|
|
243
|
+
}
|
|
244
|
+
this.listeningToMouseleave = true;
|
|
245
|
+
// Store waypoints asynchronously.
|
|
246
|
+
await this.storeWaypoints();
|
|
247
|
+
} else {
|
|
248
|
+
// If the flow is not valid, revert to the previous target.
|
|
249
|
+
this.setTarget(this.target);
|
|
250
|
+
}
|
|
251
|
+
} else {
|
|
252
|
+
// the target was not changed, set the target with the anchor offset.
|
|
253
|
+
this.setTarget(this.target, this.getAnchorOffset());
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Calculates the offset between the target anchor point and the position of the target element.
|
|
259
|
+
*
|
|
260
|
+
* @returns {Object} An object representing the offset with 'x' and 'y' properties.
|
|
261
|
+
*/
|
|
262
|
+
getAnchorOffset() {
|
|
263
|
+
// Get the waypoints of the sequence flow
|
|
264
|
+
const sequenceFlowWaypoints = this.node.diagram.waypoint;
|
|
265
|
+
// Get the last waypoint, which is the target anchor point
|
|
266
|
+
const targetAnchorPoint = sequenceFlowWaypoints[sequenceFlowWaypoints.length - 1];
|
|
267
|
+
// Get the position (x, y) of the target element
|
|
268
|
+
const { x: targetX, y: targetY } = this.target.position();
|
|
269
|
+
// Calculate and return the offset between the target anchor point and the target element position
|
|
270
|
+
return {
|
|
271
|
+
x: targetAnchorPoint.x - targetX,
|
|
272
|
+
y: targetAnchorPoint.y - targetY,
|
|
273
|
+
};
|
|
274
|
+
},
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Handles changes in target shapes for a link.
|
|
278
|
+
* @async
|
|
279
|
+
* @param {Link} link - The link whose target is being changed.
|
|
280
|
+
* @param {Vertices} vertices - The new vertices information.
|
|
281
|
+
* @param {Object} options - Additional options.
|
|
282
|
+
*/
|
|
283
|
+
async onChangeTargets(link, vertices, options) {
|
|
284
|
+
this.onChangeWasFired = true;
|
|
285
|
+
if (options?.ui && vertices.id) {
|
|
286
|
+
const newTarget = this.paper.getModelById(vertices.id);
|
|
287
|
+
if (this.currentTarget.id !== newTarget.id) {
|
|
288
|
+
// Change the target if it's different from the current target
|
|
289
|
+
this.currentTarget = newTarget;
|
|
290
|
+
this.listeningToMouseleave = true;
|
|
291
|
+
} else {
|
|
292
|
+
// If the target is the same, wait for the next update and store waypoints
|
|
293
|
+
await this.$nextTick();
|
|
294
|
+
await this.waitForUpdateWaypoints();
|
|
295
|
+
this.listeningToMouseleave = false;
|
|
296
|
+
await this.storeWaypoints();
|
|
297
|
+
}
|
|
220
298
|
}
|
|
221
299
|
},
|
|
222
300
|
async onChangeVertices(link, vertices, options){
|
|
@@ -319,10 +397,15 @@ export default {
|
|
|
319
397
|
|
|
320
398
|
const sourceAnchorTool = new linkTools.SourceAnchor({ snap: this.getAnchorPointFunction('source') });
|
|
321
399
|
const targetAnchorTool = new linkTools.TargetAnchor({ snap: this.getAnchorPointFunction('target') });
|
|
322
|
-
|
|
400
|
+
let toolsView = new dia.ToolsView({
|
|
323
401
|
tools: [verticesTool, sourceAnchorTool, targetAnchorTool],
|
|
324
402
|
});
|
|
325
|
-
|
|
403
|
+
if (this.shape.component.node.type === 'processmaker-modeler-sequence-flow') {
|
|
404
|
+
toolsView = new dia.ToolsView({
|
|
405
|
+
tools: [verticesTool, sourceAnchorTool, targetAnchorTool, new linkTools.TargetArrowhead()],
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
this.currentTarget = this.shape.getTargetElement();
|
|
326
409
|
this.shapeView.addTools(toolsView);
|
|
327
410
|
this.shapeView.hideTools();
|
|
328
411
|
},
|