100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Appearance page: JSON Editor now updates the button depending on whether it is valid. (#1505)
Michael Rademaker0a60eff12fd1
diff --git a/ui/app/manager/src/components/configuration/or-conf-json.ts b/ui/app/manager/src/components/configuration/or-conf-json.tsindex 92c8cb367..9da6a721d 100644--- a/ui/app/manager/src/components/configuration/or-conf-json.ts+++ b/ui/app/manager/src/components/configuration/or-conf-json.ts@@ -23,7 +23,7 @@ import "@openremote/or-components/or-ace-editor";import { DialogAction } from "@openremote/or-mwc-components/or-mwc-dialog";import { OrMwcDialog, showDialog } from "@openremote/or-mwc-components/or-mwc-dialog";import { createRef, Ref, ref } from "lit/directives/ref.js";-import { OrAceEditor } from "@openremote/or-components/or-ace-editor";+import { OrAceEditor, OrAceEditorChangedEvent } from "@openremote/or-components/or-ace-editor";import { ManagerAppConfig } from "@openremote/model";@customElement("or-conf-json")@@ -47,7 +47,8 @@ export class OrConfJson extends LitElement {}protected _showManagerConfigDialog(){- const _saveConfig = ()=>{+ let dialog: OrMwcDialog;+ const _saveConfig = () => {const config = this.beforeSave()if (config) {this.managerConfig = config as ManagerAppConfig@@ -60,6 +61,7 @@ export class OrConfJson extends LitElement {}return false}+const dialogActions: DialogAction[] = [{actionName: "cancel",@@ -68,14 +70,26 @@ export class OrConfJson extends LitElement {{actionName: "ok",content: "update",- action: _saveConfig- },-+ action: _saveConfig,+ }];- showDialog(new OrMwcDialog()++ dialog = new OrMwcDialog().setActions(dialogActions).setHeading("manager_config.json")- .setContent(html `<or-ace-editor ${ref(this._aceEditor)} .value="${this.managerConfig}" ></or-ace-editor>`)+ .setContent(html`+ <or-ace-editor+ ${ref(this._aceEditor)}+ .value="${this.managerConfig}"+ @or-ace-editor-changed="${(ev: OrAceEditorChangedEvent) => {+ const okButton = dialog.actions?.find(action => action.actionName === "ok");+ if (okButton) {+ okButton.disabled = !ev.detail.valid;+ dialog.requestUpdate();+ }+ }}"+ ></or-ace-editor>+ `).setStyles(html`<style>.mdc-dialog__surface {@@ -94,8 +108,9 @@ export class OrConfJson extends LitElement {}</style>`)- .setDismissAction(null));+ .setDismissAction(null);+ showDialog(dialog);}render() {