diff --git a/src/components/modeler/Modeler.vue b/src/components/modeler/Modeler.vue index 88616c809..0663f5827 100644 --- a/src/components/modeler/Modeler.vue +++ b/src/components/modeler/Modeler.vue @@ -531,12 +531,7 @@ export default { }, getElementByNodeId(id) { const cells = this.paper.model.getCells(); - for (const cell of cells) { - if (cell.component && cell.component.id === id) { - return cell; - } - } - return null; // Return null if no matching element is found + return cells.find((cell) => cell.component && cell.component.id === id); }, async close() { this.$emit('close'); @@ -1112,9 +1107,9 @@ export default { 'processmaker-modeler-sequence-flow', 'processmaker-modeler-association', 'processmaker-modeler-data-input-association', - 'processmaker-modeler-data-output-association', + 'processmaker-modeler-data-input-association', ]; - const flowTypes =[ + const flowTypes = [ 'processmaker-modeler-sequence-flow', 'processmaker-modeler-message-flow', ]; @@ -1132,7 +1127,7 @@ export default { id: node.definition.id, isAddingLaneAbove: true, }; - if (node.pool && node.pool.component) { + if (node?.pool?.component) { defaultData['poolId'] = node.pool.component.id; } window.ProcessMaker.EventBus.$emit('multiplayer-addNode', defaultData); diff --git a/src/components/modeler/Selection.vue b/src/components/modeler/Selection.vue index 0f0cabd55..5606913d4 100644 --- a/src/components/modeler/Selection.vue +++ b/src/components/modeler/Selection.vue @@ -578,13 +578,12 @@ export default { this.overPoolStopDrag(); this.updateSelectionBox(); if (this.isMultiplayer) { - const changed = []; - this.getProperties(this.selected, changed); - window.ProcessMaker.EventBus.$emit('multiplayer-updateNodes', changed); + window.ProcessMaker.EventBus.$emit('multiplayer-updateNodes', this.getProperties(this.selected)); } }, - getProperties(shapes, changed) { + getProperties(shapes) { + let changed = []; const shapesToNotTranslate = [ 'PoolLane', 'standard.Link', @@ -595,7 +594,7 @@ export default { .forEach(shape => { if (shape.model.get('type') === 'processmaker.modeler.bpmn.pool') { const children = shape.model.component.getElementsUnderArea(shape.model, this.graph); - this.getContainerProperties(children, changed); + changed = [...changed, ...this.getContainerProperties(children, changed)]; } else { const { node } = shape.model.component; const defaultData = { @@ -607,14 +606,16 @@ export default { width: shape.model.get('size').width, }, }; - if (node.pool && node.pool.component) { + if (node?.pool?.component) { defaultData['poolId'] = node.pool.component.id; } changed.push(defaultData); } }); + return changed; }, - getContainerProperties(children, changed) { + getContainerProperties(children) { + const changed = []; children.forEach(model => { changed.push({ id: model.component.node.definition.id, @@ -626,6 +627,7 @@ export default { }, }); }); + return changed; }, /** * Selector will update the waypoints of the related flows diff --git a/src/components/nodes/pool/pool.vue b/src/components/nodes/pool/pool.vue index 89daaa83d..df6156ed1 100644 --- a/src/components/nodes/pool/pool.vue +++ b/src/components/nodes/pool/pool.vue @@ -179,7 +179,7 @@ export default { this.shape.unembed(element); toPool.component.addToPool(element); }, - async addLane(emitMultiplayer = true) { + async addLane(emitMultiplayer = true) { /* A Lane element must be contained in a LaneSet element. * Get the current laneSet element or create a new one. */ @@ -201,8 +201,8 @@ export default { lanes.push(this.pushNewLane()); - await Promise.all(lanes). - then((val) => { + await Promise.all(lanes) + .then((val) => { if (emitMultiplayer && this.$parent.isMultiplayer) { window.ProcessMaker.EventBus.$emit('multiplayer-addLanes', val); } @@ -217,7 +217,7 @@ export default { const laneSet = this.moddle.create('bpmn:LaneSet'); this.laneSet = laneSet; const generator = this.nodeIdGenerator; - const [laneSetId] = id ? id : generator.generate(); + const [laneSetId] = id ?? generator.generate(); this.laneSet.set('id', laneSetId); this.containingProcess.get('laneSets').push(laneSet); }, diff --git a/src/components/nodes/sequenceFlow/index.js b/src/components/nodes/sequenceFlow/index.js index 14b9f9673..fdf7d9418 100644 --- a/src/components/nodes/sequenceFlow/index.js +++ b/src/components/nodes/sequenceFlow/index.js @@ -86,8 +86,8 @@ export default { ], async multiplayerClient(modeler, data) { const { paper } = modeler; - const sourceElem = modeler.getElementByNodeId( data.sourceRefId); - const targetElem = modeler.getElementByNodeId( data.targetRefId); + const sourceElem = modeler.getElementByNodeId(data.sourceRefId); + const targetElem = modeler.getElementByNodeId(data.targetRefId); if (sourceElem && targetElem) { const flow = new SequenceFlow(modeler.nodeRegistry, modeler.moddle, paper); const actualFlow = flow.makeFlowNode(sourceElem, targetElem, data.waypoint); diff --git a/src/multiplayer/multiplayer.js b/src/multiplayer/multiplayer.js index be6ae3a94..137edd914 100644 --- a/src/multiplayer/multiplayer.js +++ b/src/multiplayer/multiplayer.js @@ -172,7 +172,7 @@ export default class Multiplayer { break ; } } - return found ? index: -1; + return found ? index : -1; } getNodeById(nodeId) { const node = this.modeler.nodes.find((element) => element.definition && element.definition.id === nodeId); @@ -312,7 +312,7 @@ export default class Multiplayer { width: lane.diagram.bounds.width, height: lane.diagram.bounds.height, poolId: lane.pool.component.node.definition.id, - laneSetId: lane.pool.component.laneSet.id, + laneSetId: lane.pool.component.laneSet.id, }; return data; }