Skip to content

Commit

Permalink
fix circular and root nodes connections were possible in tree view.
Browse files Browse the repository at this point in the history
When making a circular connection in interfaces view, other added 
products are randomly linked. Close #30
  • Loading branch information
shuart committed Jun 3, 2019
1 parent 452e54b commit 96b7c39
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ephemeris",
"version": "2.5.1",
"version": "2.5.2",
"description": "System Engineering and requirements management application",
"main": "index.js",
"scripts": {
Expand Down
26 changes: 21 additions & 5 deletions src/js/views/view.relations.js
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ var createRelationsView = function () {
}else {
push(act.remove("metaLinks",{uuid:d.uuid}))
}

update()
}
},
Expand Down Expand Up @@ -1045,13 +1045,29 @@ var createRelationsView = function () {
}else if (nodeTypes[0] =="Functions" && nodeTypes[1] == "Pbs") {
push(act.add("metaLinks",{type:"originFunction", source:previousSelectedNode.uuid, target:lastSelectedNode.uuid}))
}else if (nodeTypes[0] =="Pbs" && nodeTypes[1] == "Pbs") {
//check for circular references
if (addMode == "physical") {
push(act.add("interfaces",{type:"Physical connection", source:lastSelectedNode.uuid, target:previousSelectedNode.uuid}))
let isCircularRef = store.interfaces.items.find(i => (i.target == lastSelectedNode.uuid && i.source == previousSelectedNode.uuid)|| (i.source == lastSelectedNode.uuid && i.target == previousSelectedNode.uuid) )
if (!isCircularRef) {
push(act.add("interfaces",{type:"Physical connection", source:lastSelectedNode.uuid, target:previousSelectedNode.uuid}))
}else {
alert("Circular reference. Action not possible")
}
}else if (addMode == "compose") {
push(movePbs({origin:lastSelectedNode.uuid, target:previousSelectedNode.uuid}))
push(removePbsLink({target:previousSelectedNode.uuid}))
let isCircularRef = store.currentPbs.links.find(i => (i.target == lastSelectedNode.uuid && i.source == previousSelectedNode.uuid)|| (i.source == lastSelectedNode.uuid && i.target == previousSelectedNode.uuid) )
let targetIsRoot = !store.currentPbs.links.find(i=> i.target == previousSelectedNode.uuid)

if (!isCircularRef && !targetIsRoot) {
push(movePbs({origin:lastSelectedNode.uuid, target:previousSelectedNode.uuid}))
push(removePbsLink({target:previousSelectedNode.uuid}))

push(act.addLink("currentPbs",{ source:lastSelectedNode.uuid, target:previousSelectedNode.uuid}))
}else if(isCircularRef){
alert("Circular reference. Action not possible")
}else if(targetIsRoot){
alert("Cannot target the root node")
}

push(act.addLink("currentPbs",{ source:lastSelectedNode.uuid, target:previousSelectedNode.uuid}))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Ephemeris",
"version": "2.5.1",
"version": "2.5.2",
"description": "System Engineering and requirements management application",
"main": "index.html",
"window": {
Expand Down

0 comments on commit 96b7c39

Please sign in to comment.