More work on Auto Reference

This commit is contained in:
Brenden Harrell committed 2021-07-27 17:45:02 -05:00
1 parent d9ec0c8c49
commit 9c1d79ec7d
3 files changed
+55 -9

No files matched your search

@@ -263,21 +263,24 @@ function newFoundationsFunctionLibraryProtocolNode() {
if (node.payload.referenceParentCombinedNodePath === undefined) {
let attachNodePath = UI.projects.foundations.utilities.hierarchy.getNodeNameTypePath(node.payload.referenceParent)
// Save path to reference parent for auto restore
savedPayload.referenceParentCombinedNodePath = { path: attachNodePath }
// savedPayload.referenceParentCombinedNodePath = { path: attachNodePath }
//console.log("this is the saved payload new save", savedPayload)
} else {
// Save path to reference parent for auto restore
savedPayload.referenceParentCombinedNodePath = { path: node.payload.referenceParentCombinedNodePath }
savedPayload.referenceParentCombinedNodePath = node.payload.referenceParentCombinedNodePath
console.log("this is the saved payload old save", savedPayload)
}
} else {
/* The referenceParent property can be inherited from the previous saved payload. */
if (node.savedPayload !== undefined) {
savedPayload.referenceParent = node.savedPayload.referenceParent
// Save path to reference parent for auto restore
savedPayload.referenceParentCombinedNodePath = node.payload.referenceParentCombinedNodePath
savedPayload.referenceParentCombinedNodePath = node.savedPayload.referenceParentCombinedNodePath
//console.log("this is the saved payload inherited", savedPayload)
}
}
}
console.log("this is the saved payload", savedPayload)
return savedPayload
}
}
@@ -21,7 +21,7 @@ function newFoundationsFunctionLibraryAttachDetach() {
function storeAttachNodePath(node, attachToNode) {
let attachNodePath = UI.projects.foundations.utilities.hierarchy.getNodeNameTypePath(attachToNode)
// Save attach path to active payload
node.payload.referenceParentCombinedNodePath = { path: attachNodePath }
node.payload.referenceParentCombinedNodePath = attachNodePath
}
// Clear the path to reference parent when the reference is cleared
@@ -308,11 +308,54 @@ function newFoundationsFunctionLibraryUiObjectsFromNodes() {
}
if (node.savedPayload !== undefined) {
if (node.savedPayload.referenceParent !== undefined) { // these are children recreated
// Reestablish based on Id
node.payload.referenceParent = mapOfNodes.get(node.savedPayload.referenceParent.id)
if (node.payload.referenceParent === undefined) {
//console.log('[WARN]' + node.type + ' ' + node.name + ' reference parent lost during re-binding phase.')
}
}
//console.log("this is the node we tried to connect to", node.payload.referenceParent)
if (node.payload.referenceParent === undefined) {
console.log('this node failed to connect' + node.type + ' ' + node.name, node )
let rawPath = node.savedPayload.referenceParentCombinedNodePath
if (rawPath !== undefined) {
console.log('this is a saved path',node.savedPayload.referenceParentCombinedNodePath)
// Attempt to reestablish reference based on saved path
let nodePath = []
let headNode = UI.projects.foundations.spaces.designSpace.workspace.getHierarchyHeadsByCodeNameAndNodeType(rawPath[0][0], rawPath[0][1])
console.log('this is our returned head node', headNode)
// Loop through saved Path and gather nodes
/*for (let i = 0; i < rawPath.length; i++) {
console.log("we are at this step in the node path", rawPath[i])
// Loop through map of nodes to find each node in path
for (let x = 0; x < mapOfNodes.length; x++) {
let mapNode = mapOfNodes[x]
let mapNodeCodeName = UI.projects.foundations.utilities.nodeConfig.loadConfigProperty(mapNode.payload, 'codeName')
if (mapNodeCodeName === rawPath[i][0] && mapNode.type === ) {
nodePath.push(mapNode)
}
}
console.log("nodePath", nodePath)
}*/
}
}
// need to figure out how to check that this has failed to move to path implimentation
function getMapNodeByCodeNameAndNodeType(codeName, nodeType) {
for (let i = 0; i < mapOfNodes.length; i++) {
let mapNode = mapOfNodes[i]
let mapNodeCodeName = UI.projects.foundations.utilities.nodeConfig.loadConfigProperty(mapNode.payload, 'codeName')
if (mapNodeCodeName === codeName && mapNode.type === nodeType) {
return mapNode
}
}
}
//console.log("this is the node", node, "saved path", path, "and map", mapOfNodes )
if (node.payload.referenceParent === undefined) {
//console.log('[WARN]' + node.type + ' ' + node.name + ' reference parent lost during re-binding phase.')
}
}
}
}
}