Backup and Share main structures with state of inner objects
This commit is contained in:
1 parent
37ad57d4c7
commit
1da5a7a364
2 files changed
+242
-185
No files matched your search
@@ -224,11 +224,39 @@ function newWorkspace () {
|
||||
functionLibraryNodeDeleter.deleteWorkspace(thisObject.workspaceNode, thisObject.workspaceNode.rootNodes)
|
||||
thisObject.workspaceNode = droppedNode
|
||||
functionLibraryUiObjectsFromNodes.recreateWorkspace(thisObject.workspaceNode)
|
||||
return
|
||||
} else {
|
||||
let rootNode = functionLibraryProtocolNode.getProtocolNode(droppedNode)
|
||||
thisObject.workspaceNode.rootNodes.push(rootNode)
|
||||
functionLibraryUiObjectsFromNodes.createUiObjectFromNode(rootNode, undefined, undefined)
|
||||
if (
|
||||
droppedNode.type === 'Definition' ||
|
||||
droppedNode.type === 'Network' ||
|
||||
droppedNode.type === 'Team'
|
||||
) {
|
||||
/* We will only respect the state of each object on these structures, if the structure does not yet exist inside the workspace */
|
||||
let alreadyExists = false
|
||||
for (let i = 0; i < thisObject.workspaceNode.rootNodes.length; i++) {
|
||||
let rootNode = thisObject.workspaceNode.rootNodes[i]
|
||||
if (droppedNode.id === rootNode.id) {
|
||||
alreadyExists = true
|
||||
}
|
||||
}
|
||||
if (alreadyExists === false) {
|
||||
/* It does not exist, so we recreeate it respecting the inner state of each object. */
|
||||
let positionOffset = {
|
||||
x: spawnPosition.x - droppedNode.savedPayload.targetPosition.x,
|
||||
y: spawnPosition.y - droppedNode.savedPayload.targetPosition.y
|
||||
}
|
||||
|
||||
thisObject.workspaceNode.rootNodes.push(droppedNode)
|
||||
functionLibraryUiObjectsFromNodes.createUiObjectFromNode(droppedNode, undefined, undefined, positionOffset)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* This is the default behaviour, which consists of cleaning all nodes that are not supported and then creating the UIObjects that remains on the data structure. */
|
||||
let rootNode = functionLibraryProtocolNode.getProtocolNode(droppedNode)
|
||||
thisObject.workspaceNode.rootNodes.push(rootNode)
|
||||
functionLibraryUiObjectsFromNodes.createUiObjectFromNode(rootNode, undefined, undefined)
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] spawn -> err = ' + err.stack) }
|
||||
}
|
||||
@@ -255,7 +283,17 @@ function newWorkspace () {
|
||||
break
|
||||
case 'Share':
|
||||
{
|
||||
let text = JSON.stringify(functionLibraryProtocolNode.getProtocolNode(payload.node, true))
|
||||
let text
|
||||
if (
|
||||
payload.node.type === 'Definition' ||
|
||||
payload.node.type === 'Network' ||
|
||||
payload.node.type === 'Team'
|
||||
) {
|
||||
text = JSON.stringify(functionLibraryProtocolNode.getProtocolNode(payload.node, true, false, true, true, true))
|
||||
} else {
|
||||
text = JSON.stringify(functionLibraryProtocolNode.getProtocolNode(payload.node, true))
|
||||
}
|
||||
|
||||
let nodeName = payload.node.name
|
||||
if (nodeName === undefined) {
|
||||
nodeName = ''
|
||||
@@ -269,7 +307,17 @@ function newWorkspace () {
|
||||
break
|
||||
case 'Backup':
|
||||
{
|
||||
let text = JSON.stringify(functionLibraryProtocolNode.getProtocolNode(payload.node, false))
|
||||
let text
|
||||
if (
|
||||
payload.node.type === 'Definition' ||
|
||||
payload.node.type === 'Network' ||
|
||||
payload.node.type === 'Team'
|
||||
) {
|
||||
text = JSON.stringify(functionLibraryProtocolNode.getProtocolNode(payload.node, false, false, true, true, true))
|
||||
} else {
|
||||
text = JSON.stringify(functionLibraryProtocolNode.getProtocolNode(payload.node, false))
|
||||
}
|
||||
|
||||
let nodeName = payload.node.name
|
||||
if (nodeName === undefined) {
|
||||
nodeName = ''
|
||||
|
||||
Reference in new issue
Block a user