Merge branch 'main' of https://gitea.internike.com/nike/buildoz
This commit is contained in:
+14
-6
@@ -414,6 +414,10 @@ class BZgraflow extends Buildoz{
|
||||
return(this.stagedNodes[nid])
|
||||
}
|
||||
|
||||
makeWireId(nid1, nid2){
|
||||
return(`${encodeURIComponent(nid1)}|${encodeURIComponent(nid2)}`)
|
||||
}
|
||||
|
||||
addWire(link){
|
||||
const [idNode1, idPort1] = link.from
|
||||
const [idNode2, idPort2] = link.to
|
||||
@@ -422,7 +426,7 @@ class BZgraflow extends Buildoz{
|
||||
return
|
||||
}
|
||||
const path = this.linkNodes(idNode1, idPort1, idNode2, idPort2)
|
||||
const id = `${idNode1}_${idNode2}`
|
||||
const id = this.makeWireId(idNode1, idNode2)
|
||||
this.stagedWires[id] = document.createElementNS('http://www.w3.org/2000/svg', 'path')
|
||||
this.stagedWires[id].setAttribute('d', path)
|
||||
this.stagedWires[id].setAttribute('fill', 'none')
|
||||
@@ -1018,10 +1022,14 @@ class BZgraflow extends Buildoz{
|
||||
|
||||
updateWires(nid, orientation, LondLinkfix = false){
|
||||
const wires = Object.keys(this.stagedWires)
|
||||
.filter(id => (id.startsWith(nid+'_')||id.endsWith('_'+nid)))
|
||||
.map(id => this.stagedWires[id])
|
||||
.filter(wire => {
|
||||
const lnk = wire?.link
|
||||
return(lnk && (lnk.from?.[0] == nid || lnk.to?.[0] == nid))
|
||||
})
|
||||
for(const wire of wires){
|
||||
const [nid1, nid2] = wire.dataset.id.split('_')
|
||||
const nid1 = wire.link.from[0]
|
||||
const nid2 = wire.link.to[0]
|
||||
const lnk = this.getLink(nid1, nid2)
|
||||
if(!lnk) continue
|
||||
if(!this.flow?.longLinks) this.flow.longLinks = []
|
||||
@@ -1038,7 +1046,7 @@ class BZgraflow extends Buildoz{
|
||||
}
|
||||
|
||||
getLink(nid1, nid2){
|
||||
const wire = this.stagedWires[`${nid1}_${nid2}`]
|
||||
const wire = this.stagedWires[this.makeWireId(nid1, nid2)]
|
||||
if(wire?.link) return wire.link
|
||||
return this._virtualLinks?.get(`${nid1}__${nid2}`) ?? null
|
||||
}
|
||||
@@ -1442,7 +1450,7 @@ class EditWires{
|
||||
return('')
|
||||
}
|
||||
this.graflow.addWire({ from: [idNode1, idPort1], to: [idNode2, idPort2] })
|
||||
this.graflow.fireEvent('wireAdded', { from: [idNode1, idPort1], to: [idNode2, idPort2], id: `${idNode1}_${idNode2}` })
|
||||
this.graflow.fireEvent('wireAdded', { from: [idNode1, idPort1], to: [idNode2, idPort2], id: this.graflow.makeWireId(idNode1, idNode2) })
|
||||
}
|
||||
|
||||
onSelectWire(e){
|
||||
@@ -1461,7 +1469,7 @@ class EditWires{
|
||||
const wireId = this.currentlySelectedWire.dataset.id
|
||||
const linkToRemove = this.graflow.stagedWires[wireId]?.link
|
||||
this.graflow.flow.links = this.graflow.flow.links.filter(link =>
|
||||
linkToRemove ? link !== linkToRemove : (link.from[0] + '_' + link.to[0] !== wireId)
|
||||
linkToRemove ? link !== linkToRemove : (this.graflow.makeWireId(link.from[0], link.to[0]) !== wireId)
|
||||
)
|
||||
this.graflow.stagedWires[wireId]?.remove()
|
||||
delete this.graflow.stagedWires[wireId]
|
||||
|
||||
Reference in New Issue
Block a user