Merge pull request #2555 from alexandrustefan/develop
Auto fix missing references using checkForMissingReferences utility function
This commit is contained in:
2 files changed
+31
-2
No files matched your search
@@ -29,6 +29,7 @@ function newFoundationsDocsSearchEngine() {
|
|||||||
|
|
||||||
function finalize() {
|
function finalize() {
|
||||||
thisObject.docsIndex = undefined
|
thisObject.docsIndex = undefined
|
||||||
|
thisObject.documentIndex = undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUpSearchEngine(callbackFunction) {
|
function setUpSearchEngine(callbackFunction) {
|
||||||
|
|||||||
@@ -21,7 +21,9 @@ function newFoundationsFunctionLibraryWorkspaceFunctions() {
|
|||||||
|
|
||||||
if (alreadyExist === false) {
|
if (alreadyExist === false) {
|
||||||
let child = UI.projects.visualScripting.functionLibraries.uiObjectsFromNodes.addUIObject(node, project + ' Project', rootNodes, project)
|
let child = UI.projects.visualScripting.functionLibraries.uiObjectsFromNodes.addUIObject(node, project + ' Project', rootNodes, project)
|
||||||
if (child === undefined) { continue }
|
if (child === undefined) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
child.project = project
|
child.project = project
|
||||||
child.projectDefinition.name = project
|
child.projectDefinition.name = project
|
||||||
child.projectDefinition.config = "{ \n \"codeName\": \"" + project + "\"\n}"
|
child.projectDefinition.config = "{ \n \"codeName\": \"" + project + "\"\n}"
|
||||||
@@ -32,6 +34,9 @@ function newFoundationsFunctionLibraryWorkspaceFunctions() {
|
|||||||
// This function scales the current workspace and highlights any nodes that have unresolved references
|
// This function scales the current workspace and highlights any nodes that have unresolved references
|
||||||
function checkForMissingReferences(rootNodes) {
|
function checkForMissingReferences(rootNodes) {
|
||||||
let nodes
|
let nodes
|
||||||
|
let docIndex = UI.projects.education.spaces.docsSpace.searchEngine.documentIndex
|
||||||
|
|
||||||
|
|
||||||
for (let i = 0; i < rootNodes.length; i++) {
|
for (let i = 0; i < rootNodes.length; i++) {
|
||||||
if (rootNodes[i] !== undefined) {
|
if (rootNodes[i] !== undefined) {
|
||||||
nodes = UI.projects.visualScripting.utilities.hierarchy.getHiriarchyMap(rootNodes[i])
|
nodes = UI.projects.visualScripting.utilities.hierarchy.getHiriarchyMap(rootNodes[i])
|
||||||
@@ -39,10 +44,33 @@ function newFoundationsFunctionLibraryWorkspaceFunctions() {
|
|||||||
// Check nodes that have a saved reference parent
|
// Check nodes that have a saved reference parent
|
||||||
if (value.savedPayload.referenceParent !== undefined) {
|
if (value.savedPayload.referenceParent !== undefined) {
|
||||||
// Highlight nodes that do not have an active reference connected to their reference parent
|
// Highlight nodes that do not have an active reference connected to their reference parent
|
||||||
|
// Filter out data mines in the trading mine process dependencies
|
||||||
|
if (value.type !== 'Data Mine Data Dependencies' && value.type !== 'Data Dependency') {
|
||||||
if (value.payload.referenceParent === undefined) {
|
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)
|
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
|
UI.projects.foundations.spaces.floatingSpace.inMapMode = true
|
||||||
value.payload.uiObject.setWarningMessage('Reference Parent not found in the current workspace.', 10)
|
// value.payload.uiObject.setWarningMessage('Reference Parent not found in the current workspace.', 10)
|
||||||
|
|
||||||
|
// Search in the workspace for the reference and try to attach it
|
||||||
|
docIndex.search(value.savedPayload.referenceParent.type, {
|
||||||
|
pluck: 'docsSchemaDocument:type',
|
||||||
|
enrich: true,
|
||||||
|
limit: 1000
|
||||||
|
}).then(function (results) {
|
||||||
|
let workspaceItems = results.filter(function (result) {
|
||||||
|
return result.doc.category === 'Workspace'
|
||||||
|
})
|
||||||
|
if (workspaceItems.length > 0) {
|
||||||
|
// Not the wisest choice to get the first result, but the search engine will for sure return the most relevant doc as first.
|
||||||
|
UI.projects.foundations.spaces.designSpace.workspace.getNodeById(workspaceItems[0].doc.docsSchemaDocument.nodeId).then(function (node) {
|
||||||
|
console.log("Found a node to attach to: ", node)
|
||||||
|
UI.projects.visualScripting.functionLibraries.attachDetach.referenceAttachNode(value, node)
|
||||||
|
console.log("Attached successfully")
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user