Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

UI fix certain buttons being clickable while disabled (#2055)

Ekhorn0e727f48254e
diff --git a/ui/app/manager/src/components/configuration/or-conf-json.ts b/ui/app/manager/src/components/configuration/or-conf-json.ts
index 082cf932d..ce2de1716 100644
--- a/ui/app/manager/src/components/configuration/or-conf-json.ts
+++ b/ui/app/manager/src/components/configuration/or-conf-json.ts
@@ -25,6 +25,7 @@ import { OrMwcDialog, showDialog } from "@openremote/or-mwc-components/or-mwc-di
import { createRef, Ref, ref } from "lit/directives/ref.js";
import { OrAceEditor, OrAceEditorChangedEvent } from "@openremote/or-components/or-ace-editor";
import { ManagerAppConfig, MapConfig } from "@openremote/model";
+import { InputType } from "@openremote/or-mwc-components/or-mwc-input";
@customElement("or-conf-json")
export class OrConfJson extends LitElement {
@@ -117,7 +118,7 @@ export class OrConfJson extends LitElement {
render() {
return html`
- <or-mwc-input type="button" label="JSON" outlined icon="pencil" @click="${() => {this._showConfigDialog()}}"></or-mwc-input>
+ <or-mwc-input type="${InputType.BUTTON}" label="JSON" outlined icon="pencil" @or-mwc-input-changed="${() => {this._showConfigDialog()}}"></or-mwc-input>
`
}
}
diff --git a/ui/app/manager/src/components/configuration/or-conf-map/or-conf-map-card.ts b/ui/app/manager/src/components/configuration/or-conf-map/or-conf-map-card.ts
index d92fb3747..2e147df48 100644
--- a/ui/app/manager/src/components/configuration/or-conf-map/or-conf-map-card.ts
+++ b/ui/app/manager/src/components/configuration/or-conf-map/or-conf-map-card.ts
@@ -303,7 +303,7 @@ export class OrConfMapCard extends LitElement {
${when(this.canRemove, () => html`
<or-mwc-input outlined .type="${InputType.BUTTON}" id="remove-map"
label="configuration.deleteMapCustomization"
- @click="${() => { this._showRemoveMapDialog(); }}"
+ @or-mwc-input-changed="${() => { this._showRemoveMapDialog(); }}"
></or-mwc-input>
`)}
</div>`
diff --git a/ui/app/manager/src/components/configuration/or-conf-map/or-conf-map-geojson.ts b/ui/app/manager/src/components/configuration/or-conf-map/or-conf-map-geojson.ts
index e0117eb4a..e213330f5 100644
--- a/ui/app/manager/src/components/configuration/or-conf-map/or-conf-map-geojson.ts
+++ b/ui/app/manager/src/components/configuration/or-conf-map/or-conf-map-geojson.ts
@@ -4,6 +4,7 @@ import { html, LitElement } from "lit";
import { customElement, property, state, query } from "lit/decorators.js";
import "@openremote/or-components/or-ace-editor";
import { OrAceEditorChangedEvent } from "@openremote/or-components/or-ace-editor";
+import { InputType } from "@openremote/or-mwc-components/or-mwc-input";
@customElement("or-conf-map-geojson")
export class OrConfMapGeoJson extends LitElement {
@@ -68,7 +69,7 @@ export class OrConfMapGeoJson extends LitElement {
</style>
`
return html`
- <or-mwc-input type="button" label="geoJson" outlined icon="pencil" @click="${() => {this.openJsonEditor()}}"></or-mwc-input>
+ <or-mwc-input type="${InputType.BUTTON}" label="geoJson" outlined icon="pencil" @or-mwc-input-changed="${() => {this.openJsonEditor()}}"></or-mwc-input>
<or-mwc-dialog id="geojson-modal" .heading="${heading}" .content="${content}" .actions="${actions}" .styles="${styles}" .dismissAction="${null}"></or-mwc-dialog>
`
}
diff --git a/ui/app/manager/src/components/configuration/or-conf-panel.ts b/ui/app/manager/src/components/configuration/or-conf-panel.ts
index 6b23eeb97..9afb3f8fb 100644
--- a/ui/app/manager/src/components/configuration/or-conf-panel.ts
+++ b/ui/app/manager/src/components/configuration/or-conf-panel.ts
@@ -98,7 +98,7 @@ export class OrConfPanel extends LitElement {
<div style="display: flex; justify-content: space-between;">
${when(availableRealms.length > 0, () => html`
<or-mwc-input id="btn-add-realm" .type="${InputType.BUTTON}" label="${type === 'mapconfig' ? 'configuration.addMapCustomization' : 'configuration.addRealmCustomization'}" icon="plus"
- @click="${() => this._showAddingRealmDialog()}"
+ @or-mwc-input-changed="${() => this._showAddingRealmDialog()}"
></or-mwc-input>
`)}
</div>
diff --git a/ui/app/manager/src/components/configuration/or-conf-realm/or-conf-realm-card.ts b/ui/app/manager/src/components/configuration/or-conf-realm/or-conf-realm-card.ts
index 40eeb47e1..32cb16071 100644
--- a/ui/app/manager/src/components/configuration/or-conf-realm/or-conf-realm-card.ts
+++ b/ui/app/manager/src/components/configuration/or-conf-realm/or-conf-realm-card.ts
@@ -412,7 +412,7 @@ export class OrConfRealmCard extends LitElement {
${when(app.canRemove, () => html`
<or-mwc-input outlined id="remove-realm" .type="${InputType.BUTTON}"
label="configuration.deleteRealmCustomization"
- @click="${() => { app._showRemoveRealmDialog(); }}"
+ @or-mwc-input-changed="${() => { app._showRemoveRealmDialog(); }}"
></or-mwc-input>
`)}
</div>
diff --git a/ui/app/manager/src/pages/page-assets.ts b/ui/app/manager/src/pages/page-assets.ts
index ab26b66dc..fe900847e 100644
--- a/ui/app/manager/src/pages/page-assets.ts
+++ b/ui/app/manager/src/pages/page-assets.ts
@@ -239,7 +239,7 @@ export class PageAssets extends Page<AssetsStateKeyed> {
<div class="multipleAssetsView hideMobile">
<div>
<or-translate value="multiAssetSelected" .options="${ { assetNbr: this._assetIds.length } }"></or-translate>
- <or-mwc-input .type="${InputType.BUTTON}" label="changeParent" @click="${() => this._onParentChangeClick()}" outlined></or-mwc-input>
+ <or-mwc-input .type="${InputType.BUTTON}" label="changeParent" @or-mwc-input-changed="${() => this._onParentChangeClick()}" outlined></or-mwc-input>
</div>
</div>
`;
diff --git a/ui/app/manager/src/pages/page-export.ts b/ui/app/manager/src/pages/page-export.ts
index f56f89636..1398d2cf9 100644
--- a/ui/app/manager/src/pages/page-export.ts
+++ b/ui/app/manager/src/pages/page-export.ts
@@ -267,8 +267,8 @@ export class PageExport extends Page<AppStateKeyed> {
<or-mwc-input .type="${InputType.DATETIME}" label="${Util.capitaliseFirstLetter(i18next.t("to"))}" .value="${moment(this.latestTimestamp).toDate()}" @or-mwc-input-changed="${(evt: OrInputChangedEvent) => this.latestTimestamp = evt.detail.value}"></or-mwc-input>
</div>
<div class="export-btn-wrapper">
- <or-mwc-input .disabled="${this.isClearExportBtnDisabled}" class="button" .type="${InputType.BUTTON}" label="clearTable" @click="${() => this.clearSelection()}"></or-mwc-input>
- <or-mwc-input .disabled="${this.isExportBtnDisabled}" class="button" raised .type="${InputType.BUTTON}" label="export" @click="${() => this.export()}"></or-mwc-input>
+ <or-mwc-input .disabled="${this.isClearExportBtnDisabled}" class="button" .type="${InputType.BUTTON}" label="clearTable" @or-mwc-input-changed="${() => this.clearSelection()}"></or-mwc-input>
+ <or-mwc-input .disabled="${this.isExportBtnDisabled}" class="button" raised .type="${InputType.BUTTON}" label="export" @or-mwc-input-changed="${() => this.export()}"></or-mwc-input>
</div>
</div>
</div>
diff --git a/ui/app/manager/src/pages/page-gateway.ts b/ui/app/manager/src/pages/page-gateway.ts
index 0dd4b7636..8e61cd968 100644
--- a/ui/app/manager/src/pages/page-gateway.ts
+++ b/ui/app/manager/src/pages/page-gateway.ts
@@ -285,7 +285,7 @@ export class PageGateway extends Page<AppStateKeyed> {
@or-mwc-input-changed="${(e: OrInputChangedEvent) => this._setConnectionProperty("disabled", !e.detail.value)}"
></or-mwc-input>
</div>
- <or-mwc-input label="save" ?disabled="${!this._dirty || !this._invalid || disabled}" .type="${InputType.BUTTON}" raised @click="${() => this._save()}"></or-mwc-input>
+ <or-mwc-input label="save" ?disabled="${!this._dirty || !this._invalid || disabled}" .type="${InputType.BUTTON}" raised @or-mwc-input-changed="${() => this._save()}"></or-mwc-input>
</div>
</div>
`;
diff --git a/ui/app/manager/src/pages/page-provisioning.ts b/ui/app/manager/src/pages/page-provisioning.ts
index 17f29dcbd..ab6cd7d4d 100644
--- a/ui/app/manager/src/pages/page-provisioning.ts
+++ b/ui/app/manager/src/pages/page-provisioning.ts
@@ -451,16 +451,16 @@ export class PageProvisioning extends Page<AppStateKeyed> {
<div class="row" style="margin-bottom: 0;">
${config.id ? html`<or-mwc-input label="delete"
.type="${InputType.BUTTON}"
- @click="${() => this._deleteConfig(config)}"></or-mwc-input>
+ @or-mwc-input-changed="${() => this._deleteConfig(config)}"></or-mwc-input>
` : ``}
${!config.id ? html`<or-mwc-input label="cancel"
.type="${InputType.BUTTON}"
- @click="${() => addCancel()}"></or-mwc-input>
+ @or-mwc-input-changed="${() => addCancel()}"></or-mwc-input>
` : ``}
<or-mwc-input class="savebtn" style="margin-left: auto;"
label="${config.id ? "save" : "create"}"
.type="${InputType.BUTTON}"
- @click="${() => this._createUpdateConfig(config)}"></or-mwc-input>
+ @or-mwc-input-changed="${() => this._createUpdateConfig(config)}"></or-mwc-input>
</div>
</div>
</td>
diff --git a/ui/app/manager/src/pages/page-realms.ts b/ui/app/manager/src/pages/page-realms.ts
index 583cbbbc2..860c4fe58 100644
--- a/ui/app/manager/src/pages/page-realms.ts
+++ b/ui/app/manager/src/pages/page-realms.ts
@@ -388,6 +388,7 @@ export class PageRealms extends Page<AppStateKeyed> {
let okBtnRef: Ref<OrMwcInput> = createRef();
const doDelete = async (dialog: OrMwcDialog) => {
+ if (okBtnRef.value.disabled) return;
try {
await manager.rest.api.RealmResource.delete(realm.name);
this._realms = this._realms.filter(r => r !== realm);
@@ -411,7 +412,7 @@ export class PageRealms extends Page<AppStateKeyed> {
const dialogActions: DialogAction[] = [
{
actionName: "ok",
- content: html`<or-mwc-input .type="${InputType.BUTTON}" ${ref(okBtnRef)} @click="${(ev: MouseEvent) => {if ((ev.currentTarget as OrMwcInput).disabled) ev.stopPropagation()}}" disabled label="ok"></or-mwc-input>`,
+ content: html`<or-mwc-input .type="${InputType.BUTTON}" ${ref(okBtnRef)} disabled label="ok"></or-mwc-input>`,
action: doDelete
},
{
diff --git a/ui/app/manager/src/pages/page-roles.ts b/ui/app/manager/src/pages/page-roles.ts
index a78bacfaf..ce0a840a9 100644
--- a/ui/app/manager/src/pages/page-roles.ts
+++ b/ui/app/manager/src/pages/page-roles.ts
@@ -405,11 +405,11 @@ export class PageRoles extends Page<AppStateKeyed> {
${readonly ? html`` : html`
<div class="row" style="margin-bottom: 0;">
${role.id ? html`
- <or-mwc-input label="delete" .type="${InputType.BUTTON}" @click="${() => this._deleteRole(role, index)}"></or-mwc-input>
- <or-mwc-input ?disabled="${this._compositeRoles.some(role => role.compositeRoleIds.length === 0)}" style="margin-left: auto;" label="save" .type="${InputType.BUTTON}" @click="${() => this._updateRoles()}"></or-mwc-input>
+ <or-mwc-input label="delete" .type="${InputType.BUTTON}" @or-mwc-input-changed="${() => this._deleteRole(role, index)}"></or-mwc-input>
+ <or-mwc-input ?disabled="${this._compositeRoles.some(role => role.compositeRoleIds.length === 0)}" style="margin-left: auto;" label="save" .type="${InputType.BUTTON}" @or-mwc-input-changed="${() => this._updateRoles()}"></or-mwc-input>
` : html`
- <or-mwc-input label="cancel" .type="${InputType.BUTTON}" @click="${() => { this._compositeRoles.splice(-1, 1); this._compositeRoles = [...this._compositeRoles] }}"></or-mwc-input>
- <or-mwc-input ?disabled="${this._compositeRoles.some(role => role.compositeRoleIds.length === 0)}" style="margin-left: auto;" label="create" .type="${InputType.BUTTON}" @click="${() => this._updateRoles()}"></or-mwc-input>
+ <or-mwc-input label="cancel" .type="${InputType.BUTTON}" @or-mwc-input-changed="${() => { this._compositeRoles.splice(-1, 1); this._compositeRoles = [...this._compositeRoles] }}"></or-mwc-input>
+ <or-mwc-input ?disabled="${this._compositeRoles.some(role => role.compositeRoleIds.length === 0)}" style="margin-left: auto;" label="create" .type="${InputType.BUTTON}" @or-mwc-input-changed="${() => this._updateRoles()}"></or-mwc-input>
`}
</div>
`}
diff --git a/ui/app/manager/src/pages/page-users.ts b/ui/app/manager/src/pages/page-users.ts
index b87089303..42aa5f346 100644
--- a/ui/app/manager/src/pages/page-users.ts
+++ b/ui/app/manager/src/pages/page-users.ts
@@ -1044,7 +1044,7 @@ export class PageUsers extends Page<AppStateKeyed> {
<or-mwc-input style="margin: 0;" outlined ?disabled="${readonly}"
.label="${i18next.t("delete")}"
.type="${InputType.BUTTON}"
- @click="${() => this._deleteUser(user)}"
+ @or-mwc-input-changed="${() => this._deleteUser(user)}"
></or-mwc-input>
`)}
<div style="display: flex; align-items: center; gap: 16px; margin: 0 0 0 auto;">
diff --git a/ui/component/or-asset-viewer/src/index.ts b/ui/component/or-asset-viewer/src/index.ts
index 4329dd469..3ebc260c3 100644
--- a/ui/component/or-asset-viewer/src/index.ts
+++ b/ui/component/or-asset-viewer/src/index.ts
@@ -772,7 +772,7 @@ function getPanelContent(id: string, assetInfo: AssetInfo, hostElement: LitEleme
opacity: 1;
}
</style>
- <or-mwc-input .type="${InputType.BUTTON}" class="asset-group-add-remove-button" icon="pencil" @click="${() => attributePickerModalOpen()}"></or-mwc-input>
+ <or-mwc-input .type="${InputType.BUTTON}" class="asset-group-add-remove-button" icon="pencil" @or-mwc-input-changed="${() => attributePickerModalOpen()}"></or-mwc-input>
<or-mwc-table .columns="${headersAndRows[0]}" .rows="${headersAndRows[1]}" .id="${id}-attribute-table" .config="${{stickyFirstColumn: true}}"></or-mwc-table>
`;
}
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.ts
index a940410c0..600473c3e 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
@@ -366,7 +366,7 @@ export class OrEditAssetPanel extends LitElement {
disableWrite disableSubscribe disableButton compact
@or-attribute-input-changed="${(e: OrAttributeInputChangedEvent) => this._onAttributeModified(attribute, e.detail.value)}"></or-attribute-input>
</td>
- <td class="padded-cell mdc-data-table__cell actions-cell">${canDelete ? html`<or-mwc-input type="${InputType.BUTTON}" icon="delete" @click="${deleteAttribute}">` : ``}</td>
+ <td class="padded-cell mdc-data-table__cell actions-cell">${canDelete ? html`<or-mwc-input type="${InputType.BUTTON}" icon="delete" @or-mwc-input-changed="${deleteAttribute}">` : ``}</td>
</tr>
<tr class="attribute-meta-row">
<td colspan="4">
@@ -520,13 +520,12 @@ export class OrEditAssetPanel extends LitElement {
default: true,
actionName: "add",
action: () => {
- if (attr) {
+ if (!isDisabled(attr)) {
this.asset.attributes![attr.name!] = attr;
this._onModified();
}
},
- content: html`<or-mwc-input id="add-btn" .type="${InputType.BUTTON}" disabled label="add"
- @or-mwc-input-changed="${(ev: Event) => { if (isDisabled(attr)) { ev.stopPropagation(); return false; } } }"></or-mwc-input>`
+ content: html`<or-mwc-input id="add-btn" .type="${InputType.BUTTON}" disabled label="add"></or-mwc-input>`
}
])
.setDismissAction(null));
diff --git a/ui/component/or-rules/src/flow-viewer/components/notification-dialog.ts b/ui/component/or-rules/src/flow-viewer/components/notification-dialog.ts
index c717af287..a78708c93 100644
--- a/ui/component/or-rules/src/flow-viewer/components/notification-dialog.ts
+++ b/ui/component/or-rules/src/flow-viewer/components/notification-dialog.ts
@@ -1,6 +1,7 @@
import { LitElement, html, css } from "lit";
import {customElement, property} from "lit/decorators.js";
import { i18next, translate } from "@openremote/or-translate";
+import { InputType } from "@openremote/or-mwc-components/or-mwc-input";
@customElement("notification-dialog")
export class NotificationDialog extends translate(i18next)(LitElement) {
@@ -30,8 +31,8 @@ export class NotificationDialog extends translate(i18next)(LitElement) {
return html`
<div class="message">${this.message}</div>
<div class="container">
- <or-mwc-input type="button" unElevated label="${this.buttonText}"
- @click="${() => { this.dispatchEvent(new CustomEvent("closed")); }}">
+ <or-mwc-input type="${InputType.BUTTON}" unElevated label="${this.buttonText}"
+ @or-mwc-input-changed="${() => { this.dispatchEvent(new CustomEvent("closed")); }}">
</or-mwc-input>
</div>
`;