Skip to content

Commit

Permalink
Set correct index for relation
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Kuhlmay committed Nov 20, 2023
1 parent 7f7d8b6 commit 3196e06
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
28 changes: 20 additions & 8 deletions Build/Sources/components/ActionButtonsComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,25 +113,37 @@ export const ActionButtonsComponent = (props) => {
modules.push(module);
});

let wires = edges.map((edge) => {
let sourceRelationCount = new Map();

let wires = edges.map((edge, index) => {
// Ermittle die Indizes der Nodes
let sourceIndex = nodes.findIndex(n => n.id === edge.source);
let targetIndex = nodes.findIndex(n => n.id === edge.target);

// Aktualisiere die Zählung für die Source Node
if (!sourceRelationCount.has(sourceIndex)) {
sourceRelationCount.set(sourceIndex, 0);
}
let relationIndex = sourceRelationCount.get(sourceIndex);
sourceRelationCount.set(sourceIndex, relationIndex + 1);

return {
"src": {
// Get module index from array
"moduleId": modules.findIndex(node => node.name === nodes.find(n => n.id === edge.source).data.label),
"moduleName": nodes.find(n => n.id === edge.source).data.label,
"terminal": "relationWire_0",
"moduleId": modules.findIndex(node => node.name === nodes[sourceIndex].data.label),
"moduleName": nodes[sourceIndex].data.label,
"terminal": `relationWire_${relationIndex}`,
"uid": edge.id
},
"tgt": {
// Get module index from array
"moduleId": modules.findIndex(node => node.name === nodes.find(n => n.id === edge.target).data.label),
"moduleName": nodes.find(n => n.id === edge.target).data.label,
"moduleId": modules.findIndex(node => node.name === nodes[targetIndex].data.label),
"moduleName": nodes[targetIndex].data.label,
"terminal": "SOURCES",
"uid": edge.source
}
}
});


let working = {
"modules": modules,
"properties": {
Expand Down
Loading

0 comments on commit 3196e06

Please sign in to comment.