Skip to content

armgit / core

Public Imported from GitHub
0

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

UI updates: Prevent disabled button click events (#718)

Rich Turnerd59e54d3d953
diff --git a/ui/app/manager/src/pages/page-realms.ts b/ui/app/manager/src/pages/page-realms.ts
index 9a1a5c677..e2b62dea2 100644
--- a/ui/app/manager/src/pages/page-realms.ts
+++ b/ui/app/manager/src/pages/page-realms.ts
@@ -309,12 +309,12 @@ export class PageRealms extends Page<AppStateKeyed> {
<div class="row" style="margin-bottom: 0;">
${realm.id && !readonly ? html`
${realm.name !== "master" && manager.isSuperUser() ? html`
- <or-mwc-input .label="${i18next.t("delete")}" .type="${InputType.BUTTON}" .disabled="${manager.displayRealm === realm.name}" @click="${() => this._deleteRealm(realm)}"></or-mwc-input>
+ <or-mwc-input .label="${i18next.t("delete")}" .type="${InputType.BUTTON}" .disabled="${manager.displayRealm === realm.name}" @or-mwc-input-changed="${() => this._deleteRealm(realm)}"></or-mwc-input>
` : ``}
- <or-mwc-input style="margin-left: auto;" .label="${i18next.t("save")}" .type="${InputType.BUTTON}" @click="${() => this._updateRealm(realm)}"></or-mwc-input>
+ <or-mwc-input style="margin-left: auto;" .label="${i18next.t("save")}" .type="${InputType.BUTTON}" @or-mwc-input-changed="${() => this._updateRealm(realm)}"></or-mwc-input>
` : html`
- <or-mwc-input .label="${i18next.t("cancel")}" .type="${InputType.BUTTON}" @click="${() => {this._realms.splice(-1,1); this._realms = [...this._realms]}}"></or-mwc-input>
- <or-mwc-input style="margin-left: auto;" .label="${i18next.t("create")}" .type="${InputType.BUTTON}" @click="${() => this._createRealm(realm)}"></or-mwc-input>
+ <or-mwc-input .label="${i18next.t("cancel")}" .type="${InputType.BUTTON}" @or-mwc-input-changed="${() => {this._realms.splice(-1,1); this._realms = [...this._realms]}}"></or-mwc-input>
+ <or-mwc-input style="margin-left: auto;" .label="${i18next.t("create")}" .type="${InputType.BUTTON}" @or-mwc-input-changed="${() => this._createRealm(realm)}"></or-mwc-input>
`}
</div>
</div>
@@ -397,7 +397,7 @@ export class PageRealms extends Page<AppStateKeyed> {
{
actionName: "ok",
disabled: true,
- content: html`<or-mwc-input .type="${InputType.BUTTON}" ${ref(okBtnRef)} @click="${(ev: MouseEvent) => {if ((ev.currentTarget as OrMwcInput).disabled) ev.stopPropagation()}}" disabled .label="${i18next.t("ok")}"></or-mwc-input>`,
+ content: html`<or-mwc-input .type="${InputType.BUTTON}" ${ref(okBtnRef)} @or-mwc-input-changed="${(ev: MouseEvent) => {if ((ev.currentTarget as OrMwcInput).disabled) ev.stopPropagation()}}" disabled .label="${i18next.t("ok")}"></or-mwc-input>`,
action: doDelete
},
{
diff --git a/ui/component/or-asset-tree/src/index.ts b/ui/component/or-asset-tree/src/index.ts
index 05a00d8b6..e16a2c863 100644
--- a/ui/component/or-asset-tree/src/index.ts
+++ b/ui/component/or-asset-tree/src/index.ts
@@ -410,11 +410,11 @@ export class OrAssetTree extends subscribe(manager)(LitElement) {
</div>
<div id="header-btns">
- <or-mwc-input ?hidden="${!this.selectedIds || this.selectedIds.length === 0 || !this.showDeselectBtn}" type="${InputType.BUTTON}" icon="close" @click="${() => this._onDeselectClicked()}"></or-mwc-input>
- <or-mwc-input ?hidden="${this._isReadonly() || !this.selectedIds || this.selectedIds.length !== 1}" type="${InputType.BUTTON}" icon="content-copy" @click="${() => this._onCopyClicked()}"></or-mwc-input>
- <or-mwc-input ?hidden="${this._isReadonly() || !this.selectedIds || this.selectedIds.length === 0 || this.selectedNodes.some((node) => this.isAncestorSelected(node))}" type="${InputType.BUTTON}" icon="delete" @click="${() => this._onDeleteClicked()}"></or-mwc-input>
- <or-mwc-input ?hidden="${this._isReadonly() || !this._canAdd()}" type="${InputType.BUTTON}" icon="plus" @click="${() => this._onAddClicked()}"></or-mwc-input>
- <or-mwc-input hidden type="${InputType.BUTTON}" icon="magnify" @click="${() => this._onSearchClicked()}"></or-mwc-input>
+ <or-mwc-input ?hidden="${!this.selectedIds || this.selectedIds.length === 0 || !this.showDeselectBtn}" type="${InputType.BUTTON}" icon="close" @or-mwc-input-changed="${() => this._onDeselectClicked()}"></or-mwc-input>
+ <or-mwc-input ?hidden="${this._isReadonly() || !this.selectedIds || this.selectedIds.length !== 1}" type="${InputType.BUTTON}" icon="content-copy" @or-mwc-input-changed="${() => this._onCopyClicked()}"></or-mwc-input>
+ <or-mwc-input ?hidden="${this._isReadonly() || !this.selectedIds || this.selectedIds.length === 0 || this.selectedNodes.some((node) => this.isAncestorSelected(node))}" type="${InputType.BUTTON}" icon="delete" @or-mwc-input-changed="${() => this._onDeleteClicked()}"></or-mwc-input>
+ <or-mwc-input ?hidden="${this._isReadonly() || !this._canAdd()}" type="${InputType.BUTTON}" icon="plus" @or-mwc-input-changed="${() => this._onAddClicked()}"></or-mwc-input>
+ <or-mwc-input hidden type="${InputType.BUTTON}" icon="magnify" @or-mwc-input-changed="${() => this._onSearchClicked()}"></or-mwc-input>
${getContentWithMenuTemplate(
html`<or-mwc-input type="${InputType.BUTTON}" ?hidden="${!this.showSortBtn}" icon="sort-variant"></or-mwc-input>`,
@@ -519,7 +519,7 @@ export class OrAssetTree extends subscribe(manager)(LitElement) {
style="margin-top: 14px;"
disabled></or-mwc-input>
<div>
- <or-mwc-input style="float: right;" style="margin-top: 14px;" type="${ InputType.BUTTON }" .label="${i18next.t("filter.action")}" raised @click="${() => {
+ <or-mwc-input style="float: right;" style="margin-top: 14px;" type="${ InputType.BUTTON }" .label="${i18next.t("filter.action")}" raised @or-mwc-input-changed="${() => {
this._filterFromSettings();
}}"></or-mwc-input>
</div>
diff --git a/ui/component/or-asset-tree/src/or-add-asset-dialog.ts b/ui/component/or-asset-tree/src/or-add-asset-dialog.ts
index fe845264f..20628d50c 100644
--- a/ui/component/or-asset-tree/src/or-add-asset-dialog.ts
+++ b/ui/component/or-asset-tree/src/or-add-asset-dialog.ts
@@ -263,8 +263,8 @@ export class OrAddAssetDialog extends LitElement {
<or-mwc-input id="name-input" .type="${InputType.TEXT}" min="1" max="1023" required .label="${i18next.t("name")}" .value="${this.name}" @or-mwc-input-changed="${(e: OrInputChangedEvent) => this.onNameChanged(e.detail.value)}"></or-mwc-input>
<div id="parent-wrapper">
<or-mwc-input id="parent" .type="${InputType.TEXT}" readonly .label="${i18next.t("parent")}" .value="${parentStr}" @click="${() => this._onToggleParentAssetSelector()}"></or-mwc-input>
- <or-mwc-input id="remove-parent" ?disabled="${!this.parent}" type="${InputType.BUTTON}" icon="close" @click="${() => this._onDeselectClicked()}"></or-mwc-input>
- <or-mwc-input id="toggle-parent-selector" icon="${this.showParentAssetSelector ? "pencil-off" : "pencil"}" type="${InputType.BUTTON}" @click="${() => this._onToggleParentAssetSelector()}"></or-mwc-input>
+ <or-mwc-input id="remove-parent" ?disabled="${!this.parent}" type="${InputType.BUTTON}" icon="close" @or-mwc-input-changed="${() => this._onDeselectClicked()}"></or-mwc-input>
+ <or-mwc-input id="toggle-parent-selector" icon="${this.showParentAssetSelector ? "pencil-off" : "pencil"}" type="${InputType.BUTTON}" @or-mwc-input-changed="${() => this._onToggleParentAssetSelector()}"></or-mwc-input>
</div>
</div>
diff --git a/ui/component/or-asset-viewer/src/index.ts b/ui/component/or-asset-viewer/src/index.ts
index ba3668fcf..13d9502ce 100644
--- a/ui/component/or-asset-viewer/src/index.ts
+++ b/ui/component/or-asset-viewer/src/index.ts
@@ -492,18 +492,18 @@ export function getPanelContent(panelName: string, asset: Asset, attributes: { [
if (descriptor.assetImport) {
content = html`
<div id="fileupload">
- <or-mwc-input outlined .label="${i18next.t("selectFile")}" .type="${InputType.BUTTON}" @click="${() => hostElement.shadowRoot!.getElementById('fileupload-elem')!.click()}">
+ <or-mwc-input outlined .label="${i18next.t("selectFile")}" .type="${InputType.BUTTON}" @or-mwc-input-changed="${() => hostElement.shadowRoot!.getElementById('fileupload-elem')!.click()}">
<input id="fileupload-elem" name="configfile" type="file" accept=".json, .knxproj, .vlp" @change="${() => updateFileName()}"/>
</or-mwc-input>
<or-mwc-input id="filename-elem" .type="${InputType.TEXT}" disabled></or-mwc-input>
- <or-mwc-input id="fileupload-btn" icon="upload" .type="${InputType.BUTTON}" @click="${() => fileToBase64()}" disabled></or-mwc-input>
+ <or-mwc-input id="fileupload-btn" icon="upload" .type="${InputType.BUTTON}" @or-mwc-input-changed="${() => fileToBase64()}" disabled></or-mwc-input>
</div>
`;
}
else if (descriptor.assetDiscovery) {
content = html`
- <or-mwc-input outlined id="discover-btn" .type="${InputType.BUTTON}" .label="${i18next.t("discoverAssets")}" @click="${() => discoverAssets()}"></or-mwc-input>
- <or-mwc-input id="cancel-discover-btn" .type="${InputType.BUTTON}" .label="${i18next.t("cancel")}" @click="${() => cancelDiscovery()}" hidden style="margin-left:20px"></or-mwc-input>
+ <or-mwc-input outlined id="discover-btn" .type="${InputType.BUTTON}" .label="${i18next.t("discoverAssets")}" @or-mwc-input-changed="${() => discoverAssets()}"></or-mwc-input>
+ <or-mwc-input id="cancel-discover-btn" .type="${InputType.BUTTON}" .label="${i18next.t("cancel")}" @or-mwc-input-changed="${() => cancelDiscovery()}" hidden style="margin-left:20px"></or-mwc-input>
`;
} else {
showSnackbar(undefined, "agent type doesn't support a known protocol to add assets", i18next.t("dismiss"));
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 a330e1450..4a9e261ba 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
@@ -250,7 +250,7 @@ export class OrEditAssetPanel extends LitElement {
<tr class="mdc-data-table__row">
<td colspan="4">
<div class="item-add-attribute">
- <or-mwc-input .type="${InputType.BUTTON}" .label="${i18next.t("addAttribute")}" icon="plus" @click="${() => this._addAttribute()}"></or-mwc-input>
+ <or-mwc-input .type="${InputType.BUTTON}" .label="${i18next.t("addAttribute")}" icon="plus" @or-mwc-input-changed="${() => this._addAttribute()}"></or-mwc-input>
</div>
</td>
</tr>
@@ -314,7 +314,7 @@ export class OrEditAssetPanel extends LitElement {
${metaTemplatesAndValidators.map((metaTemplateAndValidator) => metaTemplateAndValidator.template)}
</div>
<div class="item-add">
- <or-mwc-input .type="${InputType.BUTTON}" .label="${i18next.t("addMetaItems")}" icon="plus" @click="${() => this._addMetaItems(attribute)}"></or-mwc-input>
+ <or-mwc-input .type="${InputType.BUTTON}" .label="${i18next.t("addMetaItems")}" icon="plus" @or-mwc-input-changed="${() => this._addMetaItems(attribute)}"></or-mwc-input>
</div>
</div>
</div>
@@ -456,7 +456,7 @@ export class OrEditAssetPanel extends LitElement {
}
},
content: html`<or-mwc-input id="add-btn" .type="${InputType.BUTTON}" disabled .label="${i18next.t("add")}"
- @click="${(ev: Event) => { if (isDisabled(attr)) { ev.stopPropagation(); return false; } } }"></or-mwc-input>`
+ @or-mwc-input-changed="${(ev: Event) => { if (isDisabled(attr)) { ev.stopPropagation(); return false; } } }"></or-mwc-input>`
}
])
.setDismissAction(null));
diff --git a/ui/component/or-attribute-card/src/index.ts b/ui/component/or-attribute-card/src/index.ts
index 57b0c2410..3e5ce1ad1 100644
--- a/ui/component/or-attribute-card/src/index.ts
+++ b/ui/component/or-attribute-card/src/index.ts
@@ -335,7 +335,7 @@ export class OrAttributeCard extends LitElement {
<div class="panel panel-empty">
<div class="panel-content-wrapper">
<div class="panel-content">
- <or-mwc-input class="button" .type="${InputType.BUTTON}" label="${i18next.t("selectAttribute")}" icon="plus" @click="${() => this._openDialog("editAttribute")}"></or-mwc-input>
+ <or-mwc-input class="button" .type="${InputType.BUTTON}" label="${i18next.t("selectAttribute")}" icon="plus" @or-mwc-input-changed="${() => this._openDialog("editAttribute")}"></or-mwc-input>
</div>
</div>
</div>
@@ -348,7 +348,7 @@ export class OrAttributeCard extends LitElement {
<div class="panel-content-wrapper">
<div class="panel-content">
<span>${i18next.t("couldNotRetrieveAttribute")}</span>
- <or-mwc-input class="button" .type="${InputType.BUTTON}" label="${i18next.t("selectAttribute")}" icon="plus" @click="${() => this._openDialog("editAttribute")}"></or-mwc-input>
+ <or-mwc-input class="button" .type="${InputType.BUTTON}" label="${i18next.t("selectAttribute")}" icon="plus" @or-mwc-input-changed="${() => this._openDialog("editAttribute")}"></or-mwc-input>
</div>
</div>
</div>
diff --git a/ui/component/or-attribute-picker/src/index.ts b/ui/component/or-attribute-picker/src/index.ts
index 7ece85b2d..c450701d0 100644
--- a/ui/component/or-attribute-picker/src/index.ts
+++ b/ui/component/or-attribute-picker/src/index.ts
@@ -147,7 +147,7 @@ export class OrAttributePicker extends OrMwcDialog {
actionName: "add",
content: html`<or-mwc-input id="add-btn" class="button" label="${i18next.t("add")}"
.type="${InputType.BUTTON}" ?disabled="${!this.selectedAttributes.length}"
- @click="${(ev: MouseEvent) => { if (!this.selectedAttributes.length) { ev.stopPropagation(); return false; } } }"></or-mwc-input>`,
+ @or-mwc-input-changed="${(ev: Event) => { if (!this.selectedAttributes.length) { ev.stopPropagation(); return false; } } }"></or-mwc-input>`,
action: () => {
if (!this.selectedAttributes.length) {
diff --git a/ui/component/or-chart/src/index.ts b/ui/component/or-chart/src/index.ts
index 10e2636d3..b586050af 100644
--- a/ui/component/or-chart/src/index.ts
+++ b/ui/component/or-chart/src/index.ts
@@ -549,9 +549,9 @@ export class OrChart extends translate(i18next)(LitElement) {
(value) => this.setPeriodOption(value))}
${!!this.compareTimestamp ? html `
- <or-mwc-input style="margin-left:auto;" .type="${InputType.BUTTON}" .label="${i18next.t("period")}" @click="${() => this.setPeriodCompare(false)}" icon="minus"></or-mwc-input>
+ <or-mwc-input style="margin-left:auto;" .type="${InputType.BUTTON}" .label="${i18next.t("period")}" @or-mwc-input-changed="${() => this.setPeriodCompare(false)}" icon="minus"></or-mwc-input>
` : html`
- <or-mwc-input style="margin-left:auto;" .type="${InputType.BUTTON}" .label="${i18next.t("period")}" @click="${() => this.setPeriodCompare(true)}" icon="plus"></or-mwc-input>
+ <or-mwc-input style="margin-left:auto;" .type="${InputType.BUTTON}" .label="${i18next.t("period")}" @or-mwc-input-changed="${() => this.setPeriodCompare(true)}" icon="plus"></or-mwc-input>
`}
</div>
@@ -601,7 +601,7 @@ export class OrChart extends translate(i18next)(LitElement) {
`
})}
</div>
- <or-mwc-input class="button" .type="${InputType.BUTTON}" ?disabled="${disabled}" label="${i18next.t("selectAttributes")}" icon="plus" @click="${() => this._openDialog()}"></or-mwc-input>
+ <or-mwc-input class="button" .type="${InputType.BUTTON}" ?disabled="${disabled}" label="${i18next.t("selectAttributes")}" icon="plus" @or-mwc-input-changed="${() => this._openDialog()}"></or-mwc-input>
</div>
</div>
`;
diff --git a/ui/component/or-json-forms/src/controls/control-array-element.ts b/ui/component/or-json-forms/src/controls/control-array-element.ts
index 5a02b6ac8..2c0da3e7d 100644
--- a/ui/component/or-json-forms/src/controls/control-array-element.ts
+++ b/ui/component/or-json-forms/src/controls/control-array-element.ts
@@ -147,7 +147,7 @@ export class ControlArrayElement extends ControlBaseElement {
<div id="errors">
${!this.errors ? `` : html`<or-icon icon="alert"></or-icon><span>${this.errors}</span>`}
</div>
- <div id="header-buttons"><or-mwc-input .type="${InputType.BUTTON}" outlined .label="${i18next.t("json")}" icon="pencil" @click="${(ev: MouseEvent) => this._showJson(ev)}"></or-mwc-input></div>
+ <div id="header-buttons"><or-mwc-input .type="${InputType.BUTTON}" outlined .label="${i18next.t("json")}" icon="pencil" @or-mwc-input-changed="${(ev: Event) => this._showJson(ev)}"></or-mwc-input></div>
</div>
`;
@@ -173,7 +173,7 @@ export class ControlArrayElement extends ControlBaseElement {
</div>
${this.errors ? `` : html`
<div id="footer">
- <or-mwc-input .disabled="${itemCount && itemCount >= maxItems}" .type="${InputType.BUTTON}" .label="${i18next.t("addItem")}" icon="plus" @click="${() => this.doAddItem()}"></or-mwc-input>
+ <or-mwc-input .disabled="${itemCount && itemCount >= maxItems}" .type="${InputType.BUTTON}" .label="${i18next.t("addItem")}" icon="plus" @or-mwc-input-changed="${() => this.doAddItem()}"></or-mwc-input>
</div>
`}
</div>
@@ -256,7 +256,7 @@ export class ControlArrayElement extends ControlBaseElement {
}
}
- protected _showJson(ev: MouseEvent) {
+ protected _showJson(ev: Event) {
ev.stopPropagation();
showJsonEditor(this.title || this.schema.title || "", this.data, ((newValue) => {
diff --git a/ui/component/or-json-forms/src/layouts/layout-vertical-element.ts b/ui/component/or-json-forms/src/layouts/layout-vertical-element.ts
index 0b848718e..1ea487bc6 100644
--- a/ui/component/or-json-forms/src/layouts/layout-vertical-element.ts
+++ b/ui/component/or-json-forms/src/layouts/layout-vertical-element.ts
@@ -132,7 +132,7 @@ export class LayoutVerticalElement extends LayoutBaseElement<VerticalLayout | Gr
<div id="errors">
${!this.errors ? `` : html`<or-icon icon="alert"></or-icon><span>${this.errors}</span>`}
</div>
- <div id="header-buttons"><or-mwc-input .type="${InputType.BUTTON}" outlined .label="${i18next.t("json")}" icon="pencil" @click="${(ev: MouseEvent) => this._showJson(ev)}"></or-mwc-input></div>
+ <div id="header-buttons"><or-mwc-input .type="${InputType.BUTTON}" outlined .label="${i18next.t("json")}" icon="pencil" @or-mwc-input-changed="${(ev: Event) => this._showJson(ev)}"></or-mwc-input></div>
</div>
`;
@@ -172,7 +172,7 @@ export class LayoutVerticalElement extends LayoutBaseElement<VerticalLayout | Gr
${this.errors || (optionalProps.length === 0 && !dynamic) ? `` : html`
<div id="footer">
- <or-mwc-input .type="${InputType.BUTTON}" .label="${i18next.t("addParameter")}" icon="plus" @click="${() => this._addParameter(rootSchema, optionalProps, dynamicPropertyRegex, dynamicValueSchema)}"></or-mwc-input>
+ <or-mwc-input .type="${InputType.BUTTON}" .label="${i18next.t("addParameter")}" icon="plus" @or-mwc-input-changed="${() => this._addParameter(rootSchema, optionalProps, dynamicPropertyRegex, dynamicValueSchema)}"></or-mwc-input>
</div>`}
</div>
`;
@@ -248,7 +248,7 @@ export class LayoutVerticalElement extends LayoutBaseElement<VerticalLayout | Gr
`;
}
- protected _showJson(ev: MouseEvent) {
+ protected _showJson(ev: Event) {
ev.stopPropagation();
showJsonEditor(this.title || this.schema.title || "", this.data, (newValue) => {
diff --git a/ui/component/or-json-forms/src/standard-renderers.ts b/ui/component/or-json-forms/src/standard-renderers.ts
index d20e83c04..15eddf2d1 100644
--- a/ui/component/or-json-forms/src/standard-renderers.ts
+++ b/ui/component/or-json-forms/src/standard-renderers.ts
@@ -259,7 +259,7 @@ export const anyOfOneOfControlRenderer = (state: JsonFormsStateContext, props: C
// We have data that doesn't match a schema so show invalid template
console.warn("Cannot match " + keyword + " schema to instance data");
- const showJson = (ev: MouseEvent) => {
+ const showJson = (ev: Event) => {
ev.stopPropagation();
showJsonEditor(label, data, ((newValue) => {
@@ -268,7 +268,7 @@ export const anyOfOneOfControlRenderer = (state: JsonFormsStateContext, props: C
};
return html`
- <div class="item-container no-match-container"><span>${label}:</span><b><or-translate value="validation.noSchemaMatchFound"></b><or-mwc-input .type="${InputType.BUTTON}" outlined .label="${i18next.t("json")}" icon="pencil" @click="${(ev: MouseEvent) => showJson(ev)}"></or-mwc-input></div>
+ <div class="item-container no-match-container"><span>${label}:</span><b><or-translate value="validation.noSchemaMatchFound"></b><or-mwc-input .type="${InputType.BUTTON}" outlined .label="${i18next.t("json")}" icon="pencil" @or-mwc-input-changed="${(ev: Event) => showJson(ev)}"></or-mwc-input></div>
`;
} else {
// We have no data so show a schema picker
diff --git a/ui/component/or-log-viewer/src/index.ts b/ui/component/or-log-viewer/src/index.ts
index bb985ebda..a60e1ac06 100644
--- a/ui/component/or-log-viewer/src/index.ts
+++ b/ui/component/or-log-viewer/src/index.ts
@@ -299,18 +299,18 @@ export class OrLogViewer extends translate(i18next)(LitElement) {
<or-mwc-input .type="${ InputType.SELECT}" id="limit-select" ?disabled="${disabled}" .label="${i18next.t("limit")}" @or-mwc-input-changed="${(evt: OrInputChangedEvent) => this._onLimitChanged(evt.detail.value)}" .value="${"" + this.getLimit()}" .options="${this._getLimitOptions()}"></or-mwc-input>
</div>
<div id="page-controls" ?hidden="${isLive || !this._pageCount || !this._data || this._data.length === 0}">
- <or-mwc-input class="button" .type="${InputType.BUTTON}" ?disabled="${disabled || isLive || this._currentPage === 1}" icon="chevron-left" @click="${() => this._updatePage(false)}"></or-mwc-input>
+ <or-mwc-input class="button" .type="${InputType.BUTTON}" ?disabled="${disabled || isLive || this._currentPage === 1}" icon="chevron-left" @or-mwc-input-changed="${() => this._updatePage(false)}"></or-mwc-input>
<span>${this._currentPage}</span><or-translate value="of"></or-translate><span>${this._pageCount}</span>
- <or-mwc-input class="button" .type="${InputType.BUTTON}" ?disabled="${disabled || isLive || this._currentPage === this._pageCount || (this._data && this._data.length < this.getLimit())}" icon="chevron-right" @click="${() => this._updatePage(true)}"></or-mwc-input>
+ <or-mwc-input class="button" .type="${InputType.BUTTON}" ?disabled="${disabled || isLive || this._currentPage === this._pageCount || (this._data && this._data.length < this.getLimit())}" icon="chevron-right" @or-mwc-input-changed="${() => this._updatePage(true)}"></or-mwc-input>
</div>
<div id="time-controls">
<or-mwc-input id="live-button" .type="${InputType.CHECKBOX}" ?disabled="${disabled}" .label="${i18next.t("live")}" @or-mwc-input-changed="${(evt: OrInputChangedEvent) => this._onLiveChanged(evt.detail.value)}" .value="${this.live}"></or-mwc-input>
<or-mwc-input .type="${InputType.SELECT}" id="period-select" ?disabled="${disabled || isLive}" .label="${i18next.t("period")}" @or-mwc-input-changed="${(evt: OrInputChangedEvent) => this.interval = evt.detail.value}" .value="${this.interval}" .options="${this._getIntervalOptions()}"></or-mwc-input>
<div id="ending-controls">
- <or-mwc-input class="button" .type="${InputType.BUTTON}" ?disabled="${disabled || isLive}" icon="chevron-left" @click="${() => this.timestamp = this._calculateTimestamp(this.timestamp!, false)}"></or-mwc-input>
+ <or-mwc-input class="button" .type="${InputType.BUTTON}" ?disabled="${disabled || isLive}" icon="chevron-left" @or-mwc-input-changed="${() => this.timestamp = this._calculateTimestamp(this.timestamp!, false)}"></or-mwc-input>
<or-mwc-input id="ending-date" .type="${InputType.DATETIME}" ?disabled="${disabled || isLive}" label="${i18next.t("ending")}" .value="${this.timestamp}" @or-mwc-input-changed="${(evt: OrInputChangedEvent) => this.timestamp = this._calculateTimestamp(moment(evt.detail.value as string).toDate())}"></or-mwc-input>
- <or-mwc-input class="button" .type="${InputType.BUTTON}" ?disabled="${disabled || isLive}" icon="chevron-right" @click="${() => this.timestamp = this._calculateTimestamp(this.timestamp!, true)}"></or-mwc-input>
- <or-mwc-input class="button" .type="${InputType.BUTTON}" ?disabled="${disabled || isLive}" icon="chevron-double-right" @click="${() => this.timestamp = this._calculateTimestamp(new Date())}"></or-mwc-input>
+ <or-mwc-input class="button" .type="${InputType.BUTTON}" ?disabled="${disabled || isLive}" icon="chevron-right" @or-mwc-input-changed="${() => this.timestamp = this._calculateTimestamp(this.timestamp!, true)}"></or-mwc-input>
+ <or-mwc-input class="button" .type="${InputType.BUTTON}" ?disabled="${disabled || isLive}" icon="chevron-double-right" @or-mwc-input-changed="${() => this.timestamp = this._calculateTimestamp(new Date())}"></or-mwc-input>
</div>
</div>
</div>
diff --git a/ui/component/or-map/src/index.ts b/ui/component/or-map/src/index.ts
index bd987fa00..50f7d1584 100644
--- a/ui/component/or-map/src/index.ts
+++ b/ui/component/or-map/src/index.ts
@@ -368,7 +368,7 @@ export const geoJsonPointInputTemplateProvider: ValueInputProviderGenerator = (a
</style>
<div id="geo-json-point-input-compact-wrapper">
<or-mwc-input style="width: auto;" .comfortable="${comfortable}" .type="${InputType.TEXT}" .value="${centerStr}" .pattern="${CoordinatesRegexPattern}" @keyup="${(e: KeyboardEvent) => getCoordinatesInputKeyHandler(valueChangeHandler)(e)}"></or-mwc-input>
- <or-mwc-input style="width: auto;" .type="${InputType.BUTTON}" compact icon="crosshairs-gps" @click="${onClick}"></or-mwc-input>
+ <or-mwc-input style="width: auto;" .type="${InputType.BUTTON}" compact icon="crosshairs-gps" @or-mwc-input-changed="${onClick}"></or-mwc-input>
</div>
`;
}
diff --git a/ui/component/or-map/src/or-map-asset-card.ts b/ui/component/or-map/src/or-map-asset-card.ts
index f5362d34e..1087a932d 100644
--- a/ui/component/or-map/src/or-map-asset-card.ts
+++ b/ui/component/or-map/src/or-map-asset-card.ts
@@ -178,7 +178,7 @@ export class OrMapAssetCard extends subscribe(manager)(LitElement) {
</div>
${cardConfig && cardConfig.hideViewAsset ? html`` : html`
<div id="footer">
- <or-mwc-input .type="${InputType.BUTTON}" .label="${i18next.t("viewAsset")}" @click="${(e: MouseEvent) => {e.preventDefault(); this._loadAsset(this.asset!.id!);}}"></or-mwc-input>
+ <or-mwc-input .type="${InputType.BUTTON}" .label="${i18next.t("viewAsset")}" @or-mwc-input-changed="${(e: MouseEvent) => {e.preventDefault(); this._loadAsset(this.asset!.id!);}}"></or-mwc-input>
</div>
`}
</div>
diff --git a/ui/component/or-mwc-components/src/or-mwc-dialog.ts b/ui/component/or-mwc-components/src/or-mwc-dialog.ts
index 2c2a80f3f..dbb763f0f 100644
--- a/ui/component/or-mwc-components/src/or-mwc-dialog.ts
+++ b/ui/component/or-mwc-components/src/or-mwc-dialog.ts
@@ -289,7 +289,7 @@ export class OrMwcDialog extends LitElement {
${this.actions ? this.actions.map((action) => {
return html`
<div class="mdc-button mdc-dialog__button" ?data-mdc-dialog-button-default="${action.default}" data-mdc-dialog-action="${action.actionName}">
- ${typeof(action.content) === "string" ? html`<or-mwc-input .type="${InputType.BUTTON}" @click="${(ev: MouseEvent) => {if ((ev.currentTarget as OrMwcInput).disabled) ev.stopPropagation()}}" .disabled="${action.disabled}" .label="${action.content}"></or-mwc-input>` : action.content}
+ ${typeof(action.content) === "string" ? html`<or-mwc-input .type="${InputType.BUTTON}" @or-mwc-input-changed="${(ev: Event) => {if ((ev.currentTarget as OrMwcInput).disabled) ev.stopPropagation()}}" .disabled="${action.disabled}" .label="${action.content}"></or-mwc-input>` : action.content}
</div>`;
}) : ``}
</footer>
diff --git a/ui/component/or-mwc-components/src/or-mwc-input.ts b/ui/component/or-mwc-components/src/or-mwc-input.ts
index d5cbf934b..8e13edf6f 100644
--- a/ui/component/or-mwc-components/src/or-mwc-input.ts
+++ b/ui/component/or-mwc-components/src/or-mwc-input.ts
@@ -1086,6 +1086,27 @@ export class OrMwcInput extends LitElement {
`;
case InputType.BUTTON:
case InputType.BUTTON_MOMENTARY: {
+
+ const onMouseDown = (ev: MouseEvent) => {
+ if (this.disabled) {
+ ev.stopPropagation();
+ }
+
+ if (isMomentary) this.dispatchEvent(new OrInputChangedEvent(true, null))
+ };
+ const onMouseUp = (ev: MouseEvent) => {
+ if (this.disabled) {
+ ev.stopPropagation();
+ }
+
+ isMomentary ? this.dispatchEvent(new OrInputChangedEvent(false, true)) : this.dispatchEvent(new OrInputChangedEvent(true, null))
+ };
+ const onClick = (ev: MouseEvent) => {
+ if (this.disabled) {
+ ev.stopPropagation();
+ }
+ }
+
const isMomentary = this.type === InputType.BUTTON_MOMENTARY;
const isIconButton = !this.action && !this.label;
let classes = {
@@ -1103,7 +1124,8 @@ export class OrMwcInput extends LitElement {
<button id="component" class="${classMap(classes)}"
?readonly="${this.readonly}"
?disabled="${this.disabled}"
- @mousedown="${() => {if (isMomentary) this.dispatchEvent(new OrInputChangedEvent(true, null))}}" @mouseup="${() => isMomentary ? this.dispatchEvent(new OrInputChangedEvent(false, true)) : this.dispatchEvent(new OrInputChangedEvent(true, null))}">
+ @click="${(ev: MouseEvent) => onClick(ev)}"
+ @mousedown="${(ev: MouseEvent) => onMouseDown(ev)}" @mouseup="${(ev: MouseEvent) => onMouseUp(ev)}">
${!isIconButton ? html`<div class="mdc-button__ripple"></div>` : ``}
${this.icon ? html`<or-icon class="${isIconButton ? "" : this.action ? "mdc-fab__icon" : "mdc-button__icon"}" aria-hidden="true" icon="${this.icon}"></or-icon>` : ``}
${this.label ? html`<span class="${this.action ? "mdc-fab__label" : "mdc-button__label"}">${this.label}</span>` : ``}
diff --git a/ui/component/or-rules/src/flow-viewer/components/confirmation-dialog.ts b/ui/component/or-rules/src/flow-viewer/components/confirmation-dialog.ts
index b4ff221ec..4642b3a9b 100644
--- a/ui/component/or-rules/src/flow-viewer/components/confirmation-dialog.ts
+++ b/ui/component/or-rules/src/flow-viewer/components/confirmation-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("confirmation-dialog")
export class ConfirmationDialog extends translate(i18next)(LitElement) {
@@ -28,12 +29,12 @@ export class ConfirmationDialog extends translate(i18next)(LitElement) {
return html`
<div class="question">${this.question}</div>
<div class="container">
- <or-mwc-input type="button" unElevated label="${this.agreeText}"
- @click="${() => { this.dispatchEvent(new CustomEvent("agreed")); }}">
+ <or-mwc-input type="${InputType.BUTTON}" unElevated label="${this.agreeText}"
+ @or-mwc-input-changed="${() => { this.dispatchEvent(new CustomEvent("agreed")); }}">
</or-mwc-input>
<or-mwc-input type="button" label="${this.disagreeText}"
- @click="${() => { this.dispatchEvent(new CustomEvent("disagreed")); }}">
+ @or-mwc-input-changed="${() => { this.dispatchEvent(new CustomEvent("disagreed")); }}">
</or-mwc-input>
</div>
`;
diff --git a/ui/component/or-rules/src/flow-viewer/components/editor-workspace.ts b/ui/component/or-rules/src/flow-viewer/components/editor-workspace.ts
index cd5f76e53..06c8ebecd 100644
--- a/ui/component/or-rules/src/flow-viewer/components/editor-workspace.ts
+++ b/ui/component/or-rules/src/flow-viewer/components/editor-workspace.ts
@@ -13,6 +13,7 @@ import { ContextMenu } from "./context-menu";
import { project, input, copyPasteManager, FlowEditor } from "./flow-editor";
import { Camera } from "../models/camera";
import { createContextMenuButtons } from "./workspace-contextmenu-options";
+import { InputType } from "@openremote/or-mwc-components/or-mwc-input";
@customElement("editor-workspace")
export class EditorWorkspace extends translate(i18next)(LitElement) {
@@ -214,8 +215,8 @@ export class EditorWorkspace extends translate(i18next)(LitElement) {
</svg>
<selection-box .workspace="${this}"></selection-box>
<div class="view-options" style="z-index: ${this.topNodeZindex + 1}">
- ${!this.isCameraInDefaultPosition ? html`<or-mwc-input type="button" icon="vector-square" @click="${this.resetCamera}" label="${i18next.t("resetView", "Reset view")!}"></or-mwc-input>` : null}
- ${project.nodes.length !== 0 ? html`<or-mwc-input type="button" icon="fit-to-page-outline" @click="${() => this.fitCamera(project.nodes)}" label="${i18next.t("fitView", "Fit view")!}"></or-mwc-input>` : null}
+ ${!this.isCameraInDefaultPosition ? html`<or-mwc-input type="${InputType.BUTTON}" icon="vector-square" @or-mwc-input-changed="${this.resetCamera}" label="${i18next.t("resetView", "Reset view")!}"></or-mwc-input>` : null}
+ ${project.nodes.length !== 0 ? html`<or-mwc-input type="button" icon="fit-to-page-outline" @or-mwc-input-changed="${() => this.fitCamera(project.nodes)}" label="${i18next.t("fitView", "Fit view")!}"></or-mwc-input>` : null}
</div>
`;
}
diff --git a/ui/component/or-rules/src/flow-viewer/components/internal-picker.ts b/ui/component/or-rules/src/flow-viewer/components/internal-picker.ts
index e60622dca..bf61dfdeb 100644
--- a/ui/component/or-rules/src/flow-viewer/components/internal-picker.ts
+++ b/ui/component/or-rules/src/flow-viewer/components/internal-picker.ts
@@ -212,7 +212,7 @@ export class InternalPicker extends translate(i18next)(LitElement) {
<div class="asset-attribute">${selectedAttrLabel}</div>
</div>
</div>` :
- html`<or-mwc-input class="attribute-label-white" .type="${InputType.BUTTON}" label="${i18next.t("attribute")}" icon="plus" @click="${() => openDialog()}"></or-mwc-input>`
+ html`<or-mwc-input class="attribute-label-white" .type="${InputType.BUTTON}" label="${i18next.t("attribute")}" icon="plus" @or-mwc-input-changed="${() => openDialog()}"></or-mwc-input>`
)}
</div>`;
}
diff --git a/ui/component/or-rules/src/flow-viewer/components/top-bar.ts b/ui/component/or-rules/src/flow-viewer/components/top-bar.ts
index 81d32ed03..f5807035a 100644
--- a/ui/component/or-rules/src/flow-viewer/components/top-bar.ts
+++ b/ui/component/or-rules/src/flow-viewer/components/top-bar.ts
@@ -1,7 +1,7 @@
import { LitElement, html, css } from "lit";
import {customElement, property} from "lit/decorators.js";
import { IdentityDomLink } from "../node-structure";
-import { OrInputChangedEvent } from "@openremote/or-mwc-components/or-mwc-input";
+import {InputType, OrInputChangedEvent } from "@openremote/or-mwc-components/or-mwc-input";
import { Utilities } from "../utils";
import { i18next, translate } from "@openremote/or-translate";
import { project, modal, input, exporter, FlowEditor } from "./flow-editor";
@@ -98,8 +98,8 @@ export class TopBar extends translate(i18next)(LitElement) {
@or-mwc-input-changed="${(e: OrInputChangedEvent) => { chosenDesc = e.detail.value; }}"
></or-mwc-input>
<div>
- <or-mwc-input style="text-align: left; margin-right: 10px" type="button" label="${i18next.t("cancel", "Cancel")!}" @click="${modal.element.close}"></or-mwc-input>
- <or-mwc-input style="text-align: right" type="button" unelevated label="${i18next.t("save", "Save")!}" @click="${() => {
+ <or-mwc-input style="text-align: left; margin-right: 10px" type="${InputType.BUTTON}" label="${i18next.t("cancel", "Cancel")!}" @or-mwc-input-changed="${modal.element.close}"></or-mwc-input>
+ <or-mwc-input style="text-align: right" type="${InputType.BUTTON}" unelevated label="${i18next.t("save", "Save")!}" @or-mwc-input-changed="${() => {
if (!chosenName) { return; }
exporter.exportAsNew(project.toNodeCollection(chosenName, chosenDesc));
modal.element.close();
diff --git a/ui/component/or-rules/src/json-viewer/modals/or-rule-notification-modal.ts b/ui/component/or-rules/src/json-viewer/modals/or-rule-notification-modal.ts
index f2de171a2..9ed4c03d3 100644
--- a/ui/component/or-rules/src/json-viewer/modals/or-rule-notification-modal.ts
+++ b/ui/component/or-rules/src/json-viewer/modals/or-rule-notification-modal.ts
@@ -114,7 +114,7 @@ export class OrRuleNotificationModal extends translate(i18next)(LitElement) {
},
{
actionName: "",
- content: html`<or-mwc-input class="button" .type="${InputType.BUTTON}" .label="${i18next.t("ok")}" @click="${this.checkForm}"></or-mwc-input>`
+ content: html`<or-mwc-input class="button" .type="${InputType.BUTTON}" .label="${i18next.t("ok")}" @or-mwc-input-changed="${this.checkForm}"></or-mwc-input>`
}
];
@@ -127,7 +127,7 @@ export class OrRuleNotificationModal extends translate(i18next)(LitElement) {
};
return html`
- <or-mwc-input .type="${InputType.BUTTON}" .label="${i18next.t("message")}" @click="${notificationPickerModalOpen}"></or-mwc-input>
+ <or-mwc-input .type="${InputType.BUTTON}" .label="${i18next.t("message")}" @or-mwc-input-changed="${notificationPickerModalOpen}"></or-mwc-input>
<or-mwc-dialog id="notification-modal" heading="${this.title}" .actions="${notificationPickerModalActions}"></or-mwc-dialog>
<slot class="notification-form-slot"></slot>
`
diff --git a/ui/component/or-rules/src/json-viewer/modals/or-rule-radial-modal.ts b/ui/component/or-rules/src/json-viewer/modals/or-rule-radial-modal.ts
index f5ee5adce..c6a79ab55 100644
--- a/ui/component/or-rules/src/json-viewer/modals/or-rule-radial-modal.ts
+++ b/ui/component/or-rules/src/json-viewer/modals/or-rule-radial-modal.ts
@@ -151,7 +151,7 @@ export class OrRuleRadialModal extends translate(i18next)(LitElement) {
this.renderDialogHTML(value);
return html`
- <or-mwc-input .type="${InputType.BUTTON}" .label="${i18next.t("area")}" @click="${radialPickerModalOpen}"></or-mwc-input>
+ <or-mwc-input .type="${InputType.BUTTON}" .label="${i18next.t("area")}" @or-mwc-input-changed="${radialPickerModalOpen}"></or-mwc-input>
<or-mwc-dialog id="radial-modal" heading="area" .actions="${radiusPickerModalActions}"></or-mwc-dialog>
`
}
diff --git a/ui/component/or-rules/src/or-rule-list.ts b/ui/component/or-rules/src/or-rule-list.ts
index f8de0f463..e036ba2cb 100644
--- a/ui/component/or-rules/src/or-rule-list.ts
+++ b/ui/component/or-rules/src/or-rule-list.ts
@@ -245,7 +245,7 @@ export class OrRuleList extends translate(i18next)(LitElement) {
this.language,
(v) => this._onAddClicked(v as RulesetLang));
} else {
- addTemplate = html`<or-mwc-input type="${InputType.BUTTON}" icon="plus" @click="${() => this._onAddClicked(this.language!)}"></or-mwc-input>`;
+ addTemplate = html`<or-mwc-input type="${InputType.BUTTON}" icon="plus" @or-mwc-input-changed="${() => this._onAddClicked(this.language!)}"></or-mwc-input>`;
}
}
return html`
@@ -268,10 +268,10 @@ export class OrRuleList extends translate(i18next)(LitElement) {
</div>
<div id="header-btns">
- <or-mwc-input ?hidden="${this._isReadonly() || !this.selectedIds || this.selectedIds.length === 0}" type="${InputType.BUTTON}" icon="content-copy" @click="${() => this._onCopyClicked()}"></or-mwc-input>
- <or-mwc-input ?hidden="${this._isReadonly() || !this.selectedIds || this.selectedIds.length === 0}" type="${InputType.BUTTON}" icon="delete" @click="${() => this._onDeleteClicked()}"></or-mwc-input>
+ <or-mwc-input ?hidden="${this._isReadonly() || !this.selectedIds || this.selectedIds.length === 0}" type="${InputType.BUTTON}" icon="content-copy" @or-mwc-input-changed="${() => this._onCopyClicked()}"></or-mwc-input>
+ <or-mwc-input ?hidden="${this._isReadonly() || !this.selectedIds || this.selectedIds.length === 0}" type="${InputType.BUTTON}" icon="delete" @or-mwc-input-changed="${() => this._onDeleteClicked()}"></or-mwc-input>
${addTemplate}
- <or-mwc-input hidden type="${InputType.BUTTON}" icon="magnify" @click="${() => this._onSearchClicked()}"></or-mwc-input>
+ <or-mwc-input hidden type="${InputType.BUTTON}" icon="magnify" @or-mwc-input-changed="${() => this._onSearchClicked()}"></or-mwc-input>
${getContentWithMenuTemplate(
html`<or-mwc-input type="${InputType.BUTTON}" icon="sort-variant" ></or-mwc-input>`,
diff --git a/ui/component/or-rules/src/or-rule-validity.ts b/ui/component/or-rules/src/or-rule-validity.ts
index 077bc687f..71be59ae2 100644
--- a/ui/component/or-rules/src/or-rule-validity.ts
+++ b/ui/component/or-rules/src/or-rule-validity.ts
@@ -234,7 +234,7 @@ export class OrRuleValidity extends translate(i18next)(LitElement) {
if(!this.ruleset) return html``;
return html`
- <or-mwc-input .type="${InputType.BUTTON}" .label="${this.timeLabel()}" @click="${() => this.showDialog()}"></or-mwc-input>
+ <or-mwc-input .type="${InputType.BUTTON}" .label="${this.timeLabel()}" @or-mwc-input-changed="${() => this.showDialog()}"></or-mwc-input>
`;
}