diff --git a/DesignSpace/Workspace/Workspace.js b/DesignSpace/Workspace/Workspace.js index 99914d692..aa8821124 100644 --- a/DesignSpace/Workspace/Workspace.js +++ b/DesignSpace/Workspace/Workspace.js @@ -13,6 +13,8 @@ function newWorkspace() { eventsServerClients: new Map(), replaceWorkspaceByLoadingOne: replaceWorkspaceByLoadingOne, save: saveWorkspace, + backup: backupWorkspace, + share: shareWorkspace, getHierarchyHeads: getHierarchyHeads, getHierarchyHeadsById: getHierarchyHeadsById, getHierarchyHeadsByType: getHierarchyHeadsByType, @@ -120,6 +122,7 @@ function newWorkspace() { let rootNode = thisObject.workspaceNode.rootNodes[i] if (rootNode.type === 'Network') { + if (rootNode.networkNodes === undefined) { continue } for (let j = 0; j < rootNode.networkNodes.length; j++) { let networkNode = rootNode.networkNodes[j] @@ -183,6 +186,22 @@ function newWorkspace() { } } + function backupWorkspace(action) { + let text = stringifyWorkspace(false) + let fileName = 'Backup - ' + action.node.type + ' - ' + action.node.name + '.json' + if (text !== undefined) { + downloadText(fileName, text) + } + } + + function shareWorkspace(action) { + let text = stringifyWorkspace(true) + let fileName = 'Share - ' + action.node.type + ' - ' + action.node.name + '.json' + if (text !== undefined) { + downloadText(fileName, text) + } + } + async function getNodeById(nodeId) { return await executeAction({ name: 'Get Node By Id', project: 'Superalgos', relatedNodeId: nodeId }) } diff --git a/FloatingSpace/CircularMenu.js b/FloatingSpace/CircularMenu.js index 2299dd0da..c099d9690 100644 --- a/FloatingSpace/CircularMenu.js +++ b/FloatingSpace/CircularMenu.js @@ -57,6 +57,7 @@ function newCircularMenu() { let menuItemInitialValue = menuItemsInitialValues[i] menuItem.action = menuItemInitialValue.action + menuItem.actionProject = menuItemInitialValue.actionProject menuItem.actionFunction = menuItemInitialValue.actionFunction menuItem.actionStatus = menuItemInitialValue.actionStatus menuItem.label = menuItemInitialValue.label diff --git a/FloatingSpace/CircularMenuItem.js b/FloatingSpace/CircularMenuItem.js index 289e4876d..e64d4e6a8 100644 --- a/FloatingSpace/CircularMenuItem.js +++ b/FloatingSpace/CircularMenuItem.js @@ -14,6 +14,7 @@ function newCircularMenuItem() { disableIfPropertyIsDefined: undefined, propertyToCheckFor: undefined, action: undefined, + actionProject: undefined, actionFunction: undefined, actionStatus: undefined, label: undefined, @@ -302,7 +303,7 @@ function newCircularMenuItem() { if (thisObject.label === undefined) { /* This is what we have in the case of menu items that are only Icons. In this situation there is no complex logic, just execute the specified action. */ - thisObject.actionFunction({ node: thisObject.payload.node, name: thisObject.action, project: thisObject.payload.node.project, relatedNodeType: thisObject.relatedUiObject }) + thisObject.actionFunction({ node: thisObject.payload.node, name: thisObject.action, project: thisObject.actionProject, relatedNodeType: thisObject.relatedUiObject }) return } @@ -339,7 +340,7 @@ function newCircularMenuItem() { } /* Execute the action and wait for callbacks to update our statuus. */ - thisObject.actionFunction({ node: thisObject.payload.node, name: thisObject.action, project: thisObject.payload.node.project, relatedNodeType: thisObject.relatedUiObject, callBackFunction: onPrimaryCallBack }) + thisObject.actionFunction({ node: thisObject.payload.node, name: thisObject.action, project: thisObject.actionProject, relatedNodeType: thisObject.relatedUiObject, callBackFunction: onPrimaryCallBack }) return } if (temporaryStatus === STATUS_PRIMARY_WORK_DONE && thisObject.secondaryAction !== undefined) { @@ -349,7 +350,7 @@ function newCircularMenuItem() { } /* Execute the action and wait for callbacks to update our statuus. */ - thisObject.actionFunction({ node: thisObject.payload.node, name: thisObject.secondaryAction, project: thisObject.payload.node.project, relatedNodeType: thisObject.relatedUiObject, callBackFunction: onSecondaryCallBack }) + thisObject.actionFunction({ node: thisObject.payload.node, name: thisObject.secondaryAction, project: thisObject.actionProject, relatedNodeType: thisObject.relatedUiObject, callBackFunction: onSecondaryCallBack }) return } diff --git a/FloatingSpace/UiObjectConstructor.js b/FloatingSpace/UiObjectConstructor.js index cba6ce3cf..f67204b6c 100644 --- a/FloatingSpace/UiObjectConstructor.js +++ b/FloatingSpace/UiObjectConstructor.js @@ -183,20 +183,9 @@ function newUiObjectConstructor() { for (let j = 0; j < menuItems.length; j++) { let item = menuItems[j] item.angle = undefined - if (item.action.indexOf('Add Missing Children') >= 0) { - item.action = 'Add Missing Children' - } - if (item.action.indexOf('Delete ') >= 0) { - // item.action = 'Delete UI Object' - } - if (item.action.indexOf('Configure ') >= 0) { - if (schemaNode.editors.config === true) { - // item.actionFunction = 'uiObject.configEditor.activate' - } - } - if (item.action.indexOf('Edit ') >= 0) { - if (schemaNode.editors.code === true) { - // item.actionFunction = 'uiObject.codeEditor.activate' + if (item.action !== undefined) { + if (item.action.indexOf('Add Missing Children') >= 0) { + item.action = 'Add Missing Children' } } if (item.actionFunction === undefined) { @@ -318,6 +307,7 @@ function newUiObjectConstructor() { { action: 'Backup', actionFunction: floatingObject.payload.executeAction, + actionProject: 'Superalgos', label: undefined, visible: true, iconPathOn: 'backup', @@ -332,6 +322,7 @@ function newUiObjectConstructor() { { action: 'Clone', actionFunction: floatingObject.payload.executeAction, + actionProject: 'Superalgos', label: undefined, visible: true, iconPathOn: 'clone', @@ -347,6 +338,7 @@ function newUiObjectConstructor() { { action: 'Share', actionFunction: floatingObject.payload.executeAction, + actionProject: 'Superalgos', label: undefined, visible: true, iconPathOn: 'share', @@ -362,6 +354,7 @@ function newUiObjectConstructor() { { action: 'Parent Detach', actionFunction: floatingObject.payload.executeAction, + actionProject: 'Superalgos', label: undefined, visible: true, iconPathOn: 'detach', @@ -376,6 +369,7 @@ function newUiObjectConstructor() { { action: 'Reference Detach', actionFunction: floatingObject.payload.executeAction, + actionProject: 'Superalgos', label: undefined, visible: true, iconPathOn: 'delink', @@ -391,6 +385,7 @@ function newUiObjectConstructor() { { action: 'Open Documentation', actionFunction: floatingObject.payload.executeAction, + actionProject: 'Superalgos', label: undefined, visible: true, iconPathOn: 'help', @@ -475,6 +470,10 @@ function newUiObjectConstructor() { newMenuItem.currentRadius = 0 } + if (newMenuItem.actionProject === undefined) { + newMenuItem.actionProject = 'Superalgos' + } + menuItemsInitialValues.push(newMenuItem) } } else {