node path

This commit is contained in:
Luis Fernando Molina committed 2020-08-28 20:30:06 +02:00
1 parent 80ecf31f02
commit 1c09156478
3 files changed
+104 -1

No files matched your search

@@ -0,0 +1,56 @@
function newNodePath() {
thisObject = {
getNodePath: getNodePath
}
return thisObject
function getNodePath(node) {
let nodePath = 'value'
recursiveGet(node)
return 'tradingEngine.' + nodePath
function recursiveGet(node) {
if (node.payload === undefined) { return }
if (node.payload.parentNode === undefined) { return }
let nodeDefinition = getNodeDefinition(node.payload.parentNode)
if (nodeDefinition === undefined) { return }
if (nodeDefinition.properties === undefined) { return }
for (let i = 0; i < nodeDefinition.properties.length; i++) {
let property = nodeDefinition.properties[i]
let parentProperty = node.payload.parentNode[property.name]
if (parentProperty === undefined) { continue }
switch (property.type) {
case 'node': {
if (parentProperty.id === node.id) {
/* We found it */
nodePath = property.name + '.' + nodePath
recursiveGet(node.payload.parentNode)
}
}
break
case 'array': {
for (let j = 0; j < parentProperty.length; j++) {
let arrayProperty = parentProperty[j]
if (arrayProperty === undefined) {continue}
if (arrayProperty.id === node.id) {
/* We found it */
nodePath = property.name + '[' + j + ']' + '.' + nodePath
recursiveGet(node.payload.parentNode)
}
}
}
break
}
}
}
}
}
+13 -1
View File
@@ -64,6 +64,7 @@ function newWorkspace() {
let functionLibraryCCXTFunctions = newCCXTFunctions()
let functionLibraryWebhookFunctions = newWebhookFunctions()
let functionLibraryDependenciesFilter = newDependenciesFilter()
let functionLibraryNodePath = newNodePath()
thisObject.nodeChildren = newNodeChildren()
@@ -323,7 +324,7 @@ function newWorkspace() {
if (stringifyReadyNodes.length > 0) {
return JSON.stringify(workspace)
} else {
return
return
}
}
@@ -454,6 +455,17 @@ function newWorkspace() {
async function onMenuItemClick(payload, action, relatedUiObject, callBackFunction) {
switch (action) {
case 'Copy Node Path':
{
let nodePath = functionLibraryNodePath.getNodePath(payload.node)
copyTextToClipboard(nodePath)
canvas.cockpitSpace.setStatus(
nodePath + ' copied to the Clipboard.'
, 50, canvas.cockpitSpace.statusTypes.ALL_GOOD)
}
break
case 'Add UI Object':
{
functionLibraryUiObjectsFromNodes.addUIObject(payload.node, relatedUiObject)