IMplementing savePropertyAtNodeConfig
This commit is contained in:
1 parent
6ed3d64519
commit
43628bfa29
5 files changed
+35
-38
No files matched your search
@@ -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
@@ -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,4 +1,4 @@
|
||||
function newProductsPanel () {
|
||||
function newLayersPanel () {
|
||||
let thisObject = {
|
||||
name: 'Layers Panel',
|
||||
fitFunction: undefined,
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
Reference in new issue
Block a user