IMplementing savePropertyAtNodeConfig

This commit is contained in:
Luis Fernando Molina committed 2020-01-29 12:28:51 +01:00
1 parent 6ed3d64519
commit 43628bfa29
5 files changed
+35 -38

No files matched your search

+2 -2
View File
@@ -340,9 +340,9 @@ function newTimeMachine () {
function panelPhysics () {
if (thisObject.container.frame.isInViewPort()) {
canvas.panelsSpace.makeVisible(thisObject.payload.node.id)
canvas.panelsSpace.makeVisible(thisObject.payload.node.id, 'Layers Panel')
} else {
canvas.panelsSpace.makeInvisible(thisObject.payload.node.id)
canvas.panelsSpace.makeInvisible(thisObject.payload.node.id, 'Layers Panel')
}
}
+7 -29
View File
@@ -316,17 +316,11 @@ function newLayer () {
if (thisObject.panels.length > 0) {
panelsVisibleButton = newPanelsVisibleButton()
try {
let code = JSON.parse(thisObject.payload.node.code)
if (code.showPanels !== undefined) {
if (code.showPanels === true || code.showPanels === false) {
panelsVisibleButton.showPanels = code.showPanels
}
let storedValue = loadPropertyFromNodeConfig(thisObject.payload, 'showPanels')
if (storedValue !== undefined) {
if (storedValue === true || storedValue === false) {
panelsVisibleButton.showPanels = storedValue
}
thisObject.payload.node.code = JSON.stringify(code)
} catch (err) {
// we ignore errors here since most likely they will be parsing errors.
}
panelsVisibleButton.initialize(thisObject.panels)
@@ -334,14 +328,7 @@ function newLayer () {
}
}
} else {
/* Saving the new status at the node config */
try {
let code = JSON.parse(thisObject.payload.node.code)
code.showPanels = panelsVisibleButton.showPanels
thisObject.payload.node.code = JSON.stringify(code)
} catch (err) {
// we ignore errors here since most likely they will be parsing errors.
}
savePropertyAtNodeConfig(thisObject.payload, 'showPanels', panelsVisibleButton.showPanels)
}
}
}
@@ -349,8 +336,7 @@ function newLayer () {
function statusPhysics () {
/* We retrieve the stored status at the config. */
try {
let code = JSON.parse(thisObject.payload.node.code)
let storedValue = code.status
let storedValue = loadPropertyFromNodeConfig(thisObject.payload, 'status')
if (storedValue !== undefined) {
if (storedValue !== thisObject.status) {
@@ -392,15 +378,7 @@ function newLayer () {
}
}
/* Saving the new status at the node config */
try {
let code = JSON.parse(thisObject.payload.node.code)
code.status = thisObject.status
thisObject.payload.node.code = JSON.stringify(code)
} catch (err) {
// we ignore errors here since most likely they will be parsing errors.
}
savePropertyAtNodeConfig(thisObject.payload, 'status', thisObject.status)
let eventData = thisObject
thisObject.container.eventHandler.raiseEvent('Status Changed', eventData)
}
+1 -1
View File
@@ -1,4 +1,4 @@
function newProductsPanel () {
function newLayersPanel () {
let thisObject = {
name: 'Layers Panel',
fitFunction: undefined,
+7 -6
View File
@@ -42,9 +42,10 @@ function newPanelsSpace () {
case 'Layers Panel':
{
panel = newProductsPanel()
panel = newLayersPanel()
panel.fitFunction = canvas.chartSpace.fitFunction
panel.container.isVisibleFunction = canvas.chartSpace.isThisPointVisible
panel.type = 'Layers Panel'
break
}
case 'Plotter Panel':
@@ -62,7 +63,7 @@ function newPanelsSpace () {
panel.session = pSession
panel.initialize()
}
panel.type = 'Plotter Panel'
break
}
}
@@ -75,19 +76,19 @@ function newPanelsSpace () {
return panel.handle
}
function makeVisible (owner) {
function makeVisible (owner, type) {
for (let i = 0; i < thisObject.panels.length; i++) {
let panel = thisObject.panels[i]
if (panel.owner === owner) {
if (panel.owner === owner && panel.type === type) {
panel.isVisible = true
}
}
}
function makeInvisible (owner) {
function makeInvisible (owner, type) {
for (let i = 0; i < thisObject.panels.length; i++) {
let panel = thisObject.panels[i]
if (panel.owner === owner) {
if (panel.owner === owner && panel.type === type) {
panel.isVisible = false
}
}
+18
View File
@@ -1,3 +1,21 @@
function savePropertyAtNodeConfig (payload, propertyName, value) {
try {
let code = JSON.parse(payload.node.code)
code[propertyName] = value
payload.node.code = JSON.stringify(code)
} catch (err) {
// we ignore errors here since most likely they will be parsing errors.
}
}
function loadPropertyFromNodeConfig (payload, propertyName) {
try {
let code = JSON.parse(payload.node.code)
return code[propertyName]
} catch (err) {
// we ignore errors here since most likely they will be parsing errors.
}
}
function saveFrame (payload, frame) {
payload.frame = {