Skip to content

Commit 236de8d

Browse files
committed
fix: change orderElements process, fixes
1 parent ff3064c commit 236de8d

File tree

3 files changed

+18
-24
lines changed

3 files changed

+18
-24
lines changed

src/js/elements/orderElement.js

+16-22
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { app } from "../app";
2+
import * as joint from "jointjs";
23

34
/**
45
* order graph elements from source to target
@@ -50,32 +51,25 @@ export const orderGraph = graph => {
5051
export const getOrderedElements = () => {
5152
const order = [];
5253
const { graph } = app;
53-
const sources = graph.getSources();
5454

5555
const addedBoxId = [];
5656

57-
for (const source of sources) {
58-
order.push(source);
59-
addedBoxId.push(source.attributes.boxId);
60-
61-
let children = graph.getNeighbors(source, { outbound: true });
62-
do {
63-
let allChildren = [];
64-
const noDuplicates = children.filter(
65-
({ attributes: { boxId } }) => !addedBoxId.includes(boxId)
66-
);
67-
//.sort((a,b) => graph.getNeighbors(b).length - graph.getNeighbors(a).length)
57+
let subgraph = new joint.dia.Graph();
58+
subgraph.addCells(graph.getCells());
6859

69-
for (const child of noDuplicates) {
70-
order.push(child);
71-
addedBoxId.push(child.attributes.boxId);
72-
allChildren = allChildren.concat(
73-
graph.getNeighbors(child, { outbound: true })
74-
);
75-
}
60+
do {
61+
const sources = subgraph.getSources();
62+
for (const source of sources) {
63+
order.push(source);
64+
addedBoxId.push(source.attributes.boxId);
65+
}
66+
let remainingEls = subgraph
67+
.getElements()
68+
.filter(el => !sources.includes(el));
69+
let remainingCells = subgraph.getSubgraph(remainingEls);
70+
subgraph = new joint.dia.Graph();
71+
subgraph.addCells(remainingCells);
72+
} while (subgraph.getElements().length);
7673

77-
children = allChildren;
78-
} while (children.length);
79-
}
8074
return order;
8175
};

src/js/workflows/saveWorkflow.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const saveWorkflow = async (jsonGraph, installation = false) => {
2424

2525
for (const [i, { attributes: box }] of orderedElements.entries()) {
2626
const { type, boxId } = box;
27-
const Name = DivaServices.buildNameForRequest(type);
27+
const Name = DivaServices.buildServiceNameForRequest(type, boxId);
2828
const No = i;
2929
const Inputs = { Parameter: [], Data: [] };
3030

yarn.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -2747,7 +2747,7 @@ diffie-hellman@^5.0.0:
27472747

27482748
"divaservices-utils@https://github.com/pyphilia/divaservices-utils":
27492749
version "1.0.0"
2750-
resolved "https://github.com/pyphilia/divaservices-utils#dc3bf6dd7dd75e0c7d02526d713ff665eddfd8a6"
2750+
resolved "https://github.com/pyphilia/divaservices-utils#c3a31e1c287ce1f479352f993e5796e91903bd0d"
27512751
dependencies:
27522752
eslint "^6.6.0"
27532753
node-fetch "^2.6.0"

0 commit comments

Comments
 (0)