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
Bug fix for attribute picker in group asset viewer page
Rich Turner5ec0d50e530b
diff --git a/ui/component/or-asset-viewer/src/index.ts b/ui/component/or-asset-viewer/src/index.tsindex eaf29463e..c0a3bb1dd 100644--- a/ui/component/or-asset-viewer/src/index.ts+++ b/ui/component/or-asset-viewer/src/index.ts@@ -12,7 +12,7 @@ import "@openremote/or-survey-results";import "@openremote/or-table";import "@openremote/or-panel";import "@openremote/or-mwc-components/dist/or-mwc-dialog";-import {DialogAction, OrMwcDialog} from "@openremote/or-mwc-components/dist/or-mwc-dialog";+import {DialogAction, OrMwcDialog, showDialog} from "@openremote/or-mwc-components/dist/or-mwc-dialog";import "@openremote/or-mwc-components/dist/or-mwc-list";import {OrTranslate, translate} from "@openremote/or-translate";import {InputType, OrInput, OrInputChangedEvent} from "@openremote/or-input";@@ -408,7 +408,6 @@ export function getPanelContent(panelName: string, asset: Asset, attributes: Att// Determine available and selected attributes for the child asset typelet availableAttributes: string[] = [];let selectedAttributes: string[] = [];- const newlySelectedAttributes: string[] = []; // Updated when the dialog is openif (groupConfig.childAssetTypes && groupConfig.childAssetTypes[childAssetType]) {availableAttributes = groupConfig.childAssetTypes[childAssetType].availableAttributes ? groupConfig.childAssetTypes[childAssetType].availableAttributes! : [];@@ -426,44 +425,46 @@ export function getPanelContent(panelName: string, asset: Asset, attributes: AttselectedAttributes = [...availableAttributes];}- const attributePickerModalActions: DialogAction[] = [- {- actionName: "ok",- default: true,- content: html`<or-input class="button" .type="${InputType.BUTTON}" .label="${i18next.t("ok")}"></or-input>`,- action: () => {- selectedAttributes.length = 0;- selectedAttributes.push(...newlySelectedAttributes);- updateTable();- }- },- {- actionName: "cancel",- content: html`<or-input class="button" .type="${InputType.BUTTON}" .label="${i18next.t("cancel")}"></or-input>`,- action: () => {- // Nothing to do here- }- },- ];-const attributePickerModalOpen = () => {- const dialog: OrMwcDialog = hostElement.shadowRoot!.getElementById(panelName + "-attribute-modal") as OrMwcDialog;-- if (dialog) {- newlySelectedAttributes.length = 0;- newlySelectedAttributes.push(...selectedAttributes);- // Update content which will cause a re-render- dialog.dialogContent = html`- <div style="display:grid">++ const newlySelectedAttributes = [...selectedAttributes];+ let dialog: OrMwcDialog | undefined;++ const attributePickerModalActions: DialogAction[] = [+ {+ actionName: "ok",+ default: true,+ content: html`<or-input class="button" .type="${InputType.BUTTON}" .label="${i18next.t("ok")}"></or-input>`,+ action: () => {+ selectedAttributes.length = 0;+ selectedAttributes.push(...newlySelectedAttributes);+ updateTable();+ }+ },+ {+ actionName: "cancel",+ content: html`<or-input class="button" .type="${InputType.BUTTON}" .label="${i18next.t("cancel")}"></or-input>`,+ action: () => {+ // Nothing to do here+ }+ },+ ];++ showDialog(+ {+ title: "addRemoveAttributes",+ actions: attributePickerModalActions,+ content: html`+ <div style="display: grid">${availableAttributes.sort().map((attribute) =>- html`<div style="grid-column: 1 / -1;">- <or-input .type="${InputType.CHECKBOX}" .label="${i18next.t(attribute)}" .value="${!!newlySelectedAttributes.find((selected) => selected === attribute)}"+ html`<div style="grid-column: 1 / -1;">+ <or-input .type="${InputType.CHECKBOX}" .label="${i18next.t(attribute)}" .value="${!!selectedAttributes.find((selected) => selected === attribute)}"@or-input-changed="${(evt: OrInputChangedEvent) => evt.detail.value ? newlySelectedAttributes.push(attribute) : newlySelectedAttributes.splice(newlySelectedAttributes.findIndex((s) => s === attribute), 1)}"></or-input></div>`)}</div>- `;- dialog.open();- }+ `+ }+ );};// Function to update the table and message when assets or config changes@@ -530,7 +531,6 @@ export function getPanelContent(panelName: string, asset: Asset, attributes: Att<or-icon class="asset-group-add-remove-button" .id="${panelName}-add-remove-columns" icon="pencil" @click="${() => attributePickerModalOpen()}"></or-icon><or-table hidden .id="${panelName}-attribute-table" .options="{stickyFirstColumn:true}"></or-table><span><or-translate id="${panelName}-attribute-table-msg" value="loading"></or-translate></span>- <or-mwc-dialog id="${panelName}-attribute-modal" dialogTitle="addRemoveAttributes" .dialogActions="${attributePickerModalActions}"></or-mwc-dialog>`;}diff --git a/ui/component/or-asset-viewer/src/or-edit-asset-panel.ts b/ui/component/or-asset-viewer/src/or-edit-asset-panel.tsindex 8bbbeac1d..579b6a722 100644--- a/ui/component/or-asset-viewer/src/or-edit-asset-panel.ts+++ b/ui/component/or-asset-viewer/src/or-edit-asset-panel.ts@@ -103,6 +103,9 @@ const style = css`.padded-cell {padding: 10px 0;}+ .overflow-visible {+ overflow: visible;+ }`;export class OrEditAssetModifiedEvent extends CustomEvent<void> {@@ -218,8 +221,8 @@ export class OrEditAssetPanel extends LitElement {<tr class="mdc-data-table__row"><td class="padded-cell mdc-data-table__cell expander-cell"><or-icon icon="chevron-right"></or-icon><span>${attribute.name}</span></td><td class="padded-cell mdc-data-table__cell">${attribute.type}</td>- <td class="padded-cell mdc-data-table__cell">- <or-attribute-input compact .assetType="${assetType}" .label=${null} .readonly="${false}" .attribute="${attribute}" hasHelperText disableWrite disableSubscribe disableButton></or-attribute-input>+ <td class="padded-cell overflow-visible mdc-data-table__cell">+ <or-attribute-input compact .assetType="${assetType}" .label=${null} .readonly="${false}" .attribute="${attribute}" disableWrite disableSubscribe disableButton></or-attribute-input></td><td class="padded-cell mdc-data-table__cell actions-cell"><or-input type="${InputType.BUTTON}" icon="delete" @click="${deleteAttribute}"></td></tr>diff --git a/ui/component/or-mwc-components/src/or-mwc-dialog.ts b/ui/component/or-mwc-components/src/or-mwc-dialog.tsindex 94f38302e..eb1c69369 100644--- a/ui/component/or-mwc-components/src/or-mwc-dialog.ts+++ b/ui/component/or-mwc-components/src/or-mwc-dialog.ts@@ -224,8 +224,9 @@ export class OrMwcDialog extends LitElement {</ul>`}</div>+ </div>+ <div class="mdc-dialog__scrim"></div></div>- <div class="mdc-dialog__scrim"></div>`;}@@ -249,6 +250,10 @@ export class OrMwcDialog extends LitElement {matchedAction.action(this);}}+ if (this._mdcComponent) {+ this._mdcComponent.destroy();+ this._mdcComponent = undefined;+ }this.dispatchEvent(new OrMwcDialogClosedEvent(action));}}