From 7f0c9f751e44e9fbc85087f5bb60061fbb1cd0fd Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 11 Nov 2019 13:29:31 +0100 Subject: [PATCH] Status Dependency with Code --- .../FunctionLibraries/ProtocolNode.js | 29 ++++++++++++++----- .../FunctionLibraries/UiObjectsFromNodes.js | 3 +- FloatingSpace/UiObjectConstructor.js | 23 +++++++++++++-- 3 files changed, 45 insertions(+), 10 deletions(-) diff --git a/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js b/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js index 453dffc93..d89ff6f61 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js +++ b/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js @@ -1443,11 +1443,15 @@ function newProtocolNode () { let object = { type: node.type, subType: node.subType, - name: node.name + name: node.name, + code: node.code } if (includeIds) { object.id = node.id } + if (parseCode) { + object.code = JSON.parse(node.code) + } if (includePayload) { object.savedPayload = getSavedPayload(node, includeReferences) } @@ -1479,17 +1483,23 @@ function newProtocolNode () { subType: node.subType, name: node.name, code: node.code, - record: getProtocolNode(node.record, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren), datasets: [] } - if (node.datasets !== undefined) { - for (let m = 0; m < node.datasets.length; m++) { - let dataset = getProtocolNode(node.datasets[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren) - if (dataset !== undefined) { - object.datasets.push(dataset) + if (followAncestors) { + object.parentNode = getProtocolNode(node.payload.parentNode, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren) + } + if (excludeChildren !== true) { + if (node.datasets !== undefined) { + for (let m = 0; m < node.datasets.length; m++) { + let dataset = getProtocolNode(node.datasets[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren) + if (dataset !== undefined) { + object.datasets.push(dataset) + } } } + object.record = getProtocolNode(node.record, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren) } + if (parseCode) { object.code = JSON.parse(node.code) } @@ -1553,6 +1563,11 @@ function newProtocolNode () { if (parseCode) { object.code = JSON.parse(node.code) } + if (includeParent) { + followAncestors = true + excludeChildren = true + object.parentNode = getProtocolNode(node.payload.parentNode, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren) + } if (includeIds) { object.id = node.id } diff --git a/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js b/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js index 362c263c2..aa4365fd7 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js +++ b/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js @@ -1246,7 +1246,8 @@ function newUiObjectsFromNodes () { function addStatusDependency (node) { let object = { type: 'Status Dependency', - name: 'New Status Dependency' + name: 'New Status Dependency', + code: '{"mainUtility": "Self Reference|Market Starting Point|Market Ending Point"}' } if (node.statusDependencies === undefined) { node.statusDependencies = [] diff --git a/FloatingSpace/UiObjectConstructor.js b/FloatingSpace/UiObjectConstructor.js index c3bb37d3f..269a4d13b 100644 --- a/FloatingSpace/UiObjectConstructor.js +++ b/FloatingSpace/UiObjectConstructor.js @@ -1170,7 +1170,26 @@ function newUiObjectConstructor () { break } case 'Status Dependency': { + uiObject.codeEditor = newCodeEditor() + uiObject.codeEditor.isVisibleFunction = uiObject.isVisibleFunction + uiObject.codeEditor.initialize() + uiObject.codeEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) addLeftIcons(menuItemsInitialValues, floatingObject) + menuItemsInitialValues.push( + { + action: 'Edit Status Dependency', + actionFunction: uiObject.codeEditor.activate, + label: 'Edit Status Dependency', + visible: true, + iconPathOn: 'html', + iconPathOff: 'html', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -40, + dontShowAtFullscreen: true + } + ) menuItemsInitialValues.push( { action: 'Delete Status Dependency', @@ -1184,7 +1203,7 @@ function newUiObjectConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: -20 + angle: 0 } ) menuItemsInitialValues.push( @@ -1198,7 +1217,7 @@ function newUiObjectConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: 20 + angle: 40 } ) break