From a5a9d933bf914d95dffd288058e0250198016fb6 Mon Sep 17 00:00:00 2001 From: Brenden Harrell Date: Fri, 6 Aug 2021 21:51:25 -0500 Subject: [PATCH] Implement Check for missing reference parent action --- .../Schemas/App-Schema/workspace.json | 1 - .../UI/Function-Libraries/ActionSwitch.js | 2 +- .../Function-Libraries/UiObjectsFromNodes.js | 3 --- .../Function-Libraries/WorkspaceFunctions.js | 24 +++++++++++++++++-- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Projects/Foundations/Schemas/App-Schema/workspace.json b/Projects/Foundations/Schemas/App-Schema/workspace.json index 7bfa79ca7..3d8838f08 100644 --- a/Projects/Foundations/Schemas/App-Schema/workspace.json +++ b/Projects/Foundations/Schemas/App-Schema/workspace.json @@ -41,7 +41,6 @@ { "action": "Check For Missing References", "label": "Check For Missing References", - "workDoneLabel": "Done", "relatedUiObject": "Workspace", "actionFunction": "payload.executeAction" } diff --git a/Projects/Foundations/UI/Function-Libraries/ActionSwitch.js b/Projects/Foundations/UI/Function-Libraries/ActionSwitch.js index 1d3e14e67..7f7a90d8f 100644 --- a/Projects/Foundations/UI/Function-Libraries/ActionSwitch.js +++ b/Projects/Foundations/UI/Function-Libraries/ActionSwitch.js @@ -726,7 +726,7 @@ function newFoundationsActionSwitch() { break case 'Check For Missing References': { - UI.projects.foundations.functionLibraries.workspaceFunctions.checkForMissingReferences() + UI.projects.foundations.functionLibraries.workspaceFunctions.checkForMissingReferences(action.rootNodes) } break case 'Switch To Forward Testing': diff --git a/Projects/Foundations/UI/Function-Libraries/UiObjectsFromNodes.js b/Projects/Foundations/UI/Function-Libraries/UiObjectsFromNodes.js index 09e342d08..9a93e5e21 100644 --- a/Projects/Foundations/UI/Function-Libraries/UiObjectsFromNodes.js +++ b/Projects/Foundations/UI/Function-Libraries/UiObjectsFromNodes.js @@ -383,9 +383,6 @@ function newFoundationsFunctionLibraryUiObjectsFromNodes() { } } } - } - if (node.payload.referenceParent === undefined) { - console.log('[WARN]' + node.type + ' ' + node.name + ' reference parent lost during re-binding phase.') } } diff --git a/Projects/Foundations/UI/Function-Libraries/WorkspaceFunctions.js b/Projects/Foundations/UI/Function-Libraries/WorkspaceFunctions.js index 2f89d3cb3..e3576dc9c 100644 --- a/Projects/Foundations/UI/Function-Libraries/WorkspaceFunctions.js +++ b/Projects/Foundations/UI/Function-Libraries/WorkspaceFunctions.js @@ -28,7 +28,27 @@ function newFoundationsFunctionLibraryWorkspaceFunctions() { } } - function checkForMissingReferences() { - console.log("this action is working") + // This function scales the current workspace and highlights any nodes that have unresolved references + function checkForMissingReferences(rootNodes) { + let nodes + for (let i = 0; i < rootNodes.length; i++) { + if (rootNodes[i] !== undefined) { + nodes = UI.projects.foundations.utilities.hierarchy.getHiriarchyMap(rootNodes[i]) + for (let [key, value] of nodes) { + // Check nodes that have a saved reference parent + if (value.savedPayload.referenceParent !== undefined) { + // Highlight nodes that do not have an active reference connected to their referance parent + if (value.payload.referenceParent === undefined) { + console.log("[WARN] Reference Parent not found in the current workspace.\n Node:", value.name, " Type:", value.type, " ID:", key, " Node Object:", value) + UI.projects.foundations.spaces.floatingSpace.inMapMode = true + value.payload.uiObject.setWarningMessage('Reference Parent not found in the current workspace.', 10) + } + + } + } + + } + } + } }