Skip to content

armgit / core

Public Imported from GitHub
0

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

UI update: or-asset-viewer modified state updated on keyup event (#666)

vlichtenberg18ceff86e4bc
diff --git a/ui/component/or-asset-viewer/src/index.ts b/ui/component/or-asset-viewer/src/index.ts
index cddfd7b1c..b668ee7d0 100644
--- a/ui/component/or-asset-viewer/src/index.ts
+++ b/ui/component/or-asset-viewer/src/index.ts
@@ -1106,8 +1106,10 @@ export class OrAssetViewer extends subscribe(manager)(translate(i18next)(LitElem
protected _loading: boolean = false;
@state()
- protected _validationResults: ValidatorResult[] = [];
protected _assetModified = false;
+
+ @state()
+ protected _validationResults: ValidatorResult[] = [];
protected _viewerConfig?: AssetViewerConfig;
protected _attributes?: { [index: string]: Attribute<any> };
protected resizeHandler = () => OrAssetViewer.generateGrid(this.shadowRoot);
@@ -1130,6 +1132,7 @@ export class OrAssetViewer extends subscribe(manager)(translate(i18next)(LitElem
this.addEventListener(OrChartEvent.NAME, () => OrAssetViewer.generateGrid(this.shadowRoot));
this.addEventListener(OrAttributeHistoryEvent.NAME, () => OrAssetViewer.generateGrid(this.shadowRoot));
this.addEventListener(OrEditAssetModifiedEvent.NAME, (ev: OrEditAssetModifiedEvent) => this._onAssetModified(ev.detail));
+ this.addEventListener('keyup', () => this._assetModified = true)
}
public isModified() {
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 e39989f94..4fd169eb4 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
@@ -298,7 +298,11 @@ export class OrEditAssetPanel extends LitElement {
<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">${Util.getValueDescriptorLabel(attribute.type!)}</td>
<td class="padded-cell overflow-visible mdc-data-table__cell">
- <or-attribute-input ${ref(attributeInputRef)} compact .comfortable="${true}" .assetType="${assetType}" .label=${null} .readonly="${false}" .attribute="${attribute}" .assetId="${this.asset.id!}" disableWrite disableSubscribe disableButton @or-attribute-input-changed="${(e: OrAttributeInputChangedEvent) => this._onAttributeModified(attribute, e.detail.value)}"></or-attribute-input>
+ <or-attribute-input ${ref(attributeInputRef)}
+ .comfortable="${true}" .assetType="${assetType}" .label=${null}
+ .readonly="${false}" .attribute="${attribute}" .assetId="${this.asset.id!}"
+ 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>
</tr>