diff --git a/platform/src/Button.js b/platform/src/Button.js index 2d817ee..46e1319 100644 --- a/platform/src/Button.js +++ b/platform/src/Button.js @@ -32,8 +32,17 @@ class Button { this.action = "runAction( '" + parentPanel + "', '" + buttonConfigObject.id +"' )"; } else if (buttonConfigObject["internal"] != undefined) { - this.action = buttonConfigObject.internal; - + + if ((buttonConfigObject.targetPanel) && (buttonConfigObject.internal === "show" || buttonConfigObject.internal === "hide")) { + if (buttonConfigObject.internal === "hide") { + this.action = "hidePanelById( '" + buttonConfigObject.targetPanel + "Panel' )"; + } else { + this.action = "showPanelById( '" + buttonConfigObject.targetPanel + "Panel' )"; + } + } else { + this.action = buttonConfigObject.internal; + } + } else { console.log( "Button '" + buttonConfigObject.id + "' with uknown key."); } diff --git a/platform/src/Playground.js b/platform/src/Playground.js index f345263..d1d7216 100644 --- a/platform/src/Playground.js +++ b/platform/src/Playground.js @@ -383,7 +383,7 @@ function createPanelForDefinitionId(panel){ // No activity defined buttons newPanel.addButtons( Button.createButtons( panelDefinition.buttons, panel.id)); - } else if (panel.buttons != null && panelDefinition.buttons != null) { + } else if (panel.buttons != null && panelDefinition.buttons == null) { // The activity has defined the buttons let resolvedButtonConfigs = panel.buttons.map(btn =>{ let resolvedButton; @@ -914,6 +914,23 @@ function runAction(source, sourceButton) { longNotification("Executing program"); } + + +function hidePanelById(elementId) { + const panelElement = document.getElementById(elementId); + if (panelElement) { + $("#" + panelElement.parentElement.id).hide(); + } +} + +function showPanelById(elementId) { + const panelElement = document.getElementById(elementId); + if (panelElement) { + $("#" + panelElement.parentElement.id).show(); + } +} + + function notification(title, message, cls="light"){ const crossIcon = "
" Metro.notify.create(crossIcon + "" + title + "" + "
" + message + "
", null, {keepOpen: true, cls: cls, width: 300}); @@ -1065,6 +1082,8 @@ async function checkEditorReady(statusUrl, editorInstanceUrl, editorPanelId, edi window.fit = fit; window.updateGutterVisibility = updateGutterVisibility; window.runAction = runAction; + window.hidePanelById = hidePanelById; + window.showPanelById = showPanelById; window.panels = panels; window.savePanelContents = savePanelContents; window.backend = backend;