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: minor

Rich Turner8a75d2a9859e
diff --git a/ui/component/or-asset-viewer/src/index.ts b/ui/component/or-asset-viewer/src/index.ts
index 4cdcfc6b8..4a09a30a9 100644
--- a/ui/component/or-asset-viewer/src/index.ts
+++ b/ui/component/or-asset-viewer/src/index.ts
@@ -1,4 +1,4 @@
-import {customElement, html, LitElement, property, PropertyValues, query, TemplateResult} from "lit-element";
+import {customElement, html, LitElement, property, PropertyValues, TemplateResult} from "lit-element";
import "@openremote/or-select";
import "@openremote/or-icon";
import "@openremote/or-input";
@@ -15,8 +15,7 @@ import {
Attribute,
AttributeEvent,
AttributeType,
- MetaItemType,
- AttributeValueType
+ MetaItemType
} from "@openremote/model";
import {style} from "./style";
import "@openremote/or-panel";
@@ -29,7 +28,7 @@ import {styleMap} from "lit-html/directives/style-map";
import "@openremote/or-map";
import {Type as MapType} from "@openremote/or-map";
import {getLngLat} from "@openremote/or-map/dist/util";
-import {OrAttributeHistory, HistoryConfig} from "@openremote/or-attribute-history";
+import {HistoryConfig, OrAttributeHistory} from "@openremote/or-attribute-history";
export type PanelType = "property" | "location" | "attribute" | "history";
@@ -47,6 +46,11 @@ export interface PanelConfig {
export interface AssetViewerConfig {
panels: {[name: string] : PanelConfig};
viewerStyles?: { [style: string]: string };
+ propertyViewProvider?: (property: string, value: any, viewerConfig: AssetViewerConfig, panelConfig: PanelConfig) => TemplateResult | undefined;
+ attributeViewProvider?: (attribute: Attribute, viewerConfig: AssetViewerConfig, panelConfig: PanelConfig) => TemplateResult | undefined;
+ panelViewProvider?: (attributes: AssetAttribute[], panelName: string, viewerConfig: AssetViewerConfig, panelConfig: PanelConfig) => TemplateResult | undefined;
+ mapType?: MapType;
+ historyConfig?: HistoryConfig;
}
export interface ViewerConfig {
@@ -152,28 +156,38 @@ export class OrAssetViewer extends subscribe(openremote)(translate(i18next)(LitE
@property({type: Object})
public config?: ViewerConfig;
- @query("#property-path")
- protected _pathFieldInput!: OrInput;
-
@property()
protected _loading: boolean = false;
- @query("#history-attribute-picker")
- protected _historyAttributePicker?: OrInput;
- @query("#attribute-history")
- protected _attributeHistory?: OrAttributeHistory;
+ protected _viewerConfig?: AssetViewerConfig;
+ protected _attributes?: AssetAttribute[];
+
+ shouldUpdate(changedProperties: PropertyValues): boolean {
+
+ if (changedProperties.has("asset")) {
+ this._viewerConfig = undefined;
+ this._attributes = undefined;
+
+ if (this.asset) {
+ this._viewerConfig = this._getPanelConfig(this.asset);
+ this._attributes = getAssetAttributes(this.asset);
+ }
+ }
+
+ return super.shouldUpdate(changedProperties);
+ }
protected render() {
if (this._loading) {
return html`
- <div id="loading"><or-translate value="loading"></or-translate></div>
+ <div class="msg"><or-translate value="loading"></or-translate></div>
`;
}
if (!this.asset && !this.assetId) {
return html`
- <div id="noneselected"><or-translate value="noAssetSelected"></or-translate></div>
+ <div class="msg"><or-translate value="noAssetSelected"></or-translate></div>
`;
}
@@ -183,13 +197,14 @@ export class OrAssetViewer extends subscribe(openremote)(translate(i18next)(LitE
`;
}
- const viewerConfig = this._getPanelConfig(this.asset!);
- const attributes = getAssetAttributes(this.asset);
+ if (!this._attributes || !this._viewerConfig) {
+ return html``;
+ }
return html`
- <div id="container" style="${viewerConfig.viewerStyles ? styleMap(viewerConfig.viewerStyles) : ""}">
- ${html`${Object.entries(viewerConfig.panels).map(([name, panelConfig]) => {
- const panelTemplate = this._getPanel(name, panelConfig, this._getPanelContent(attributes, name, viewerConfig, panelConfig));
+ <div id="container" style="${this._viewerConfig.viewerStyles ? styleMap(this._viewerConfig.viewerStyles) : ""}">
+ ${html`${Object.entries(this._viewerConfig.panels).map(([name, panelConfig]) => {
+ const panelTemplate = OrAssetViewer.getPanel(name, this.asset!, this._attributes!, this._viewerConfig!, panelConfig, this.shadowRoot);
return panelTemplate || ``;
})}`
}`;
@@ -209,7 +224,7 @@ export class OrAssetViewer extends subscribe(openremote)(translate(i18next)(LitE
}
}
- protected _getInfoProperties(config?: PanelConfig): string[] {
+ public static getInfoProperties(config?: PanelConfig): string[] {
let properties = config && config.include ? config.include : OrAssetViewer.DEFAULT_INFO_PROPERTIES;
if (config && config.exclude) {
@@ -219,25 +234,43 @@ export class OrAssetViewer extends subscribe(openremote)(translate(i18next)(LitE
return properties;
}
- protected _getPanel(name: string, config: PanelConfig | undefined, content: TemplateResult | undefined) {
+ public static getPanel(name: string, asset: Asset, attributes: AssetAttribute[], viewerConfig: AssetViewerConfig, panelConfig: PanelConfig, shadowRoot: ShadowRoot | null) {
+
+ const content = OrAssetViewer.getPanelContent(name, asset, attributes, viewerConfig, panelConfig, shadowRoot);
+
if (!content) {
return;
}
return html`
- <div class="panel" id="${name}-panel" style="${config && config.panelStyles ? styleMap(config.panelStyles) : ""}">
- ${content}
+ <div class="panel" id="${name}-panel" style="${panelConfig && panelConfig.panelStyles ? styleMap(panelConfig.panelStyles) : ""}">
+ <div class="panel-title">
+ <or-translate value="${name}"></or-translate>
+ </div>
+ ${!panelConfig || panelConfig.scrollable === undefined || panelConfig.scrollable ? html`
+ <or-panel class="panel-content-wrapper">
+ <div class="panel-content">
+ ${content}
+ </div>
+ </or-panel>
+ `: html`
+ <div class="panel-content-wrapper">
+ <div class="panel-content">
+ ${content}
+ </div>
+ </div>
+ `}
</div>
`;
}
- protected _getPanelContent(attributes: AssetAttribute[], panelName: string, viewerConfig: AssetViewerConfig, panelConfig: PanelConfig): TemplateResult | undefined {
+ public static getPanelContent(panelName: string, asset: Asset, attributes: AssetAttribute[], viewerConfig: AssetViewerConfig, panelConfig: PanelConfig, shadowRoot: ShadowRoot | null): TemplateResult | undefined {
if (panelConfig.hide || attributes.length === 0) {
return;
}
- if (this.config && this.config.panelViewProvider) {
- const template = this.config.panelViewProvider(attributes, panelName, viewerConfig, panelConfig);
+ if (viewerConfig.panelViewProvider) {
+ const template = viewerConfig.panelViewProvider(attributes, panelName, viewerConfig, panelConfig);
if (template) {
return template;
}
@@ -251,27 +284,45 @@ export class OrAssetViewer extends subscribe(openremote)(translate(i18next)(LitE
(!includedAttributes || includedAttributes.indexOf(attr.name!) >= 0)
&& (!excludedAttributes || excludedAttributes.indexOf(attr.name!) < 0));
- let innerContent: TemplateResult | undefined;
+ let content: TemplateResult | undefined;
if (panelConfig && panelConfig.type === "property") {
// Special handling for info panel which only shows properties
- let properties = this._getInfoProperties(panelConfig);
+ let properties = OrAssetViewer.getInfoProperties(panelConfig);
if (properties.length === 0) {
return;
}
- innerContent = html`
+ content = html`
${properties.map((prop) => {
let style = styles ? styles[prop!] : undefined;
- return prop === "attributes" ? `` : this._getField(prop, true, style, this._getPropertyTemplate(prop, (this.asset! as {[index: string]:any})[prop], viewerConfig, panelConfig));
+ return prop === "attributes" ? `` : OrAssetViewer.getField(prop, true, style, OrAssetViewer.getPropertyTemplate(prop, (asset as {[index: string]:any})[prop], viewerConfig, panelConfig, shadowRoot));
})}
`;
} else if (panelConfig && panelConfig.type === "history") {
// Special handling for history panel which shows an attribute selector and a graph/data table of historical values
const historyAttrs = attrs.filter((attr) => getFirstMetaItem(attr, MetaItemType.STORE_DATA_POINTS.urn!));
if (historyAttrs.length > 0) {
- innerContent = html`
+
+ const attributeChanged = (attributeName: string) => {
+ if (shadowRoot) {
+ const attributeHistory = shadowRoot.getElementById("attribute-history") as OrAttributeHistory;
+
+ if (attributeHistory) {
+
+ let attribute: AssetAttribute | undefined;
+
+ if (attributeName) {
+ attribute = getAssetAttribute(asset, attributeName);
+ }
+
+ attributeHistory.attribute = attribute;
+ }
+ }
+ };
+
+ content = html`
<style>
#history-container {
height: 100%;
@@ -294,9 +345,9 @@ export class OrAssetViewer extends subscribe(openremote)(translate(i18next)(LitE
</style>
<div id="history-container">
<div id="history-controls">
- <or-input id="history-attribute-picker" @or-input-changed="${(evt: OrInputChangedEvent) => this._historyAttributeChanged(evt.detail.value)}" .type="${InputType.SELECT}" .options="${historyAttrs.map((attr) => [attr.name, getAttributeLabel(attr)])}"></or-input>
+ <or-input id="history-attribute-picker" noempty @or-input-changed="${(evt: OrInputChangedEvent) => attributeChanged(evt.detail.value)}" .type="${InputType.SELECT}" .options="${historyAttrs.map((attr) => [attr.name, getAttributeLabel(attr)])}"></or-input>
</div>
- <or-attribute-history id="attribute-history" .config="${this.config ? this.config.historyConfig : undefined}" .assetType="${this.asset!.type}"></or-attribute-history>
+ <or-attribute-history id="attribute-history" .config="${viewerConfig.historyConfig}" .assetType="${asset.type}"></or-attribute-history>
</div>
`;
}
@@ -304,12 +355,12 @@ export class OrAssetViewer extends subscribe(openremote)(translate(i18next)(LitE
const attribute = attrs.find((attr) => attr.name === AttributeType.LOCATION.attributeName);
if (attribute) {
// Special handling for location panel which shows an attribute selector and a map showing the location of the attribute
- const mapType = this.config && this.config.mapType ? this.config.mapType : OrAssetViewer.DEFAULT_MAP_TYPE;
+ const mapType = viewerConfig.mapType || OrAssetViewer.DEFAULT_MAP_TYPE;
const lngLat = getLngLat(attribute);
const center = lngLat ? lngLat.toArray() : undefined;
const showOnMapMeta = getFirstMetaItem(attribute, MetaItemType.SHOW_ON_DASHBOARD.urn!);
- return html`
+ content = html`
<style>
#location-container {
height: 100%;
@@ -328,7 +379,7 @@ export class OrAssetViewer extends subscribe(openremote)(translate(i18next)(LitE
</style>
<div id="location-container">
<or-map id="location-map" class="or-map" .center="${center}" type="${mapType}">
- <or-map-marker-asset active .asset="${this.asset}"></or-map-marker-asset>
+ <or-map-marker-asset active .asset="${asset}"></or-map-marker-asset>
</or-map>
${attribute.name === AttributeType.LOCATION.attributeName ? html`
<or-input id="location-map-input" type="${InputType.SWITCH}" readonly dense .value="${showOnMapMeta ? showOnMapMeta.value : undefined}" label="${i18next.t("showOnMap")}"></or-input>
@@ -337,58 +388,24 @@ export class OrAssetViewer extends subscribe(openremote)(translate(i18next)(LitE
`;
}
} else {
- innerContent = html`
+ content = html`
${attrs.sort((attr1, attr2) => attr1.name! < attr2.name! ? -1 : attr1.name! > attr2.name! ? 1 : 0).map((attr) => {
let style = styles ? styles[attr.name!] : undefined;
- return this._getField(attr.name!, false, style, this._getAttributeTemplate(attr, viewerConfig, panelConfig));
+ return this.getField(attr.name!, false, style, OrAssetViewer.getAttributeTemplate(asset, attr, viewerConfig, panelConfig));
})}
`;
}
- if (!innerContent) {
- return;
- }
-
- return html`
- <div class="panel-title">
- <or-translate value="${name}"></or-translate>
- </div>
- ${!panelConfig || panelConfig.scrollable === undefined || panelConfig.scrollable ? html`
- <or-panel class="panel-content-wrapper">
- <div class="panel-content">
- ${innerContent}
- </div>
- </or-panel>
- `: html`
- <div class="panel-content-wrapper">
- <div class="panel-content">
- ${innerContent}
- </div>
- </div>
- `}
- `;
- }
-
- protected _historyAttributeChanged(attributeName: string | undefined) {
- if (this._historyAttributePicker && this._attributeHistory) {
-
- let attribute: AssetAttribute | undefined;
-
- if (attributeName) {
- attribute = getAssetAttribute(this.asset!, attributeName);
- }
-
- this._attributeHistory.attribute = attribute;
- }
+ return content;
}
- protected _getPropertyTemplate(property: string, value: any, viewerConfig: AssetViewerConfig, panelConfig: PanelConfig) {
+ public static getPropertyTemplate(property: string, value: any, viewerConfig: AssetViewerConfig, panelConfig: PanelConfig, shadowRoot: ShadowRoot | null) {
let type = InputType.TEXT;
let minLength: number | undefined;
let maxLength: number | undefined;
- if (this.config && this.config.propertyViewProvider) {
- const result = this.config.propertyViewProvider(property, value, viewerConfig, panelConfig);
+ if (viewerConfig.propertyViewProvider) {
+ const result = viewerConfig.propertyViewProvider(property, value, viewerConfig, panelConfig);
if (result) {
return result;
}
@@ -401,10 +418,13 @@ export class OrAssetViewer extends subscribe(openremote)(translate(i18next)(LitE
}
// Populate value when we get the response
- this._getAssetNames(value as string[]).then(
+ OrAssetViewer.getAssetNames(value as string[]).then(
(names) => {
- if (this._pathFieldInput) {
- this._pathFieldInput.value = names.reverse().join(" > ");
+ if (shadowRoot) {
+ const pathField = shadowRoot.getElementById("property-path") as OrInput;
+ if (pathField) {
+ pathField.value = names.reverse().join(" > ");
+ }
}
}
);
@@ -425,23 +445,20 @@ export class OrAssetViewer extends subscribe(openremote)(translate(i18next)(LitE
return html`<or-input id="property-${property}" type="${type}" .minLength="${minLength}" .maxLength="${maxLength}" dense .value="${value}" readonly label="${i18next.t(property)}"></or-input>`;
}
- protected _getAttributeTemplate(attribute: AssetAttribute, viewerConfig: AssetViewerConfig, panelConfig: PanelConfig) {
- if (this.config && this.config.attributeViewProvider) {
- const result = this.config.attributeViewProvider(attribute, viewerConfig, panelConfig);
+ public static getAttributeTemplate(asset: Asset, attribute: AssetAttribute, viewerConfig: AssetViewerConfig, panelConfig: PanelConfig) {
+ if (viewerConfig.attributeViewProvider) {
+ const result = viewerConfig.attributeViewProvider(attribute, viewerConfig, panelConfig);
if (result) {
return result;
}
}
- // Default panel type
- const panelType = panelConfig ? panelConfig.type : OrAssetViewer.DEFAULT_PANEL_TYPE;
-
return html`
- <or-attribute-input dense .assetType="${this.asset!.type}" .attribute="${attribute}" .label="${i18next.t(attribute.name!)}"></or-attribute-input>
+ <or-attribute-input dense .assetType="${asset!.type}" .attribute="${attribute}" .label="${i18next.t(attribute.name!)}"></or-attribute-input>
`;
}
- protected _getField(name: string, isProperty: boolean, styles: { [style: string]: string } | undefined, content: TemplateResult | undefined) {
+ public static getField(name: string, isProperty: boolean, styles: { [style: string]: string } | undefined, content: TemplateResult | undefined) {
if (!content) {
return ``;
}
@@ -454,7 +471,7 @@ export class OrAssetViewer extends subscribe(openremote)(translate(i18next)(LitE
}
// TODO: Add debounce in here to minimise render calls
- public onAttributeEvent(event: AttributeEvent) {
+ onAttributeEvent(event: AttributeEvent) {
const attrName = event.attributeState!.attributeRef!.attributeName!;
if (this.asset && this.asset.attributes && this.asset.attributes.hasOwnProperty(attrName)) {
@@ -470,25 +487,26 @@ export class OrAssetViewer extends subscribe(openremote)(translate(i18next)(LitE
}
}
- public onAssetEvent(event: AssetEvent) {
+ onAssetEvent(event: AssetEvent) {
this.asset = event.asset;
this._loading = false;
}
protected _getPanelConfig(asset: Asset): AssetViewerConfig {
let config = {...OrAssetViewer.DEFAULT_CONFIG};
+
if (this.config) {
- if (!config.viewerStyles) {
- config.viewerStyles = {};
- }
- if (!config.panels) {
- config.panels = {};
- }
- if (this.config.assetTypes && this.config.assetTypes.hasOwnProperty(asset.type!)) {
- const assetConfig = this.config.assetTypes[asset.type!];
+
+ config.viewerStyles = {...config.viewerStyles};
+ config.panels = {...config.panels};
+ const assetConfig = this.config.assetTypes && this.config.assetTypes.hasOwnProperty(asset.type!) ? this.config.assetTypes[asset.type!] : this.config.default;
+
+ if (assetConfig) {
+
if (assetConfig.viewerStyles) {
Object.assign(config.viewerStyles, assetConfig.viewerStyles);
}
+
if (assetConfig.panels) {
Object.entries(assetConfig.panels).forEach(([name, assetPanelConfig]) => {
if (config.panels.hasOwnProperty(name)) {
@@ -502,13 +520,19 @@ export class OrAssetViewer extends subscribe(openremote)(translate(i18next)(LitE
}
});
}
+
+ config.attributeViewProvider = assetConfig.attributeViewProvider || this.config.attributeViewProvider;
+ config.panelViewProvider = assetConfig.panelViewProvider || this.config.panelViewProvider;
+ config.propertyViewProvider = assetConfig.propertyViewProvider || this.config.propertyViewProvider;
+ config.mapType = assetConfig.mapType || this.config.mapType;
+ config.historyConfig = assetConfig.historyConfig || this.config.historyConfig;
}
}
return config;
}
- protected async _getAssetNames(ids: string[]): Promise<string[]> {
+ public static async getAssetNames(ids: string[]): Promise<string[]> {
const response = await rest.api.AssetResource.queryAssets({
select: {
excludePath: true,
diff --git a/ui/component/or-asset-viewer/src/style.ts b/ui/component/or-asset-viewer/src/style.ts
index 31486f448..c0438128d 100644
--- a/ui/component/or-asset-viewer/src/style.ts
+++ b/ui/component/or-asset-viewer/src/style.ts
@@ -110,7 +110,7 @@ export const style = css`
box-sizing: border-box;
}
- #loading, #noneselected {
+ .msg {
display: flex;
justify-content: center;
align-items: center;
diff --git a/ui/component/or-attribute-history/src/index.ts b/ui/component/or-attribute-history/src/index.ts
index d8e459a4c..53a15dc0d 100644
--- a/ui/component/or-attribute-history/src/index.ts
+++ b/ui/component/or-attribute-history/src/index.ts
@@ -34,6 +34,7 @@ export interface TableColumnConfig {
path?: string;
stringify?: boolean;
styles?: { [style: string]: string };
+ headerStyles?: { [style: string]: string };
contentProvider?: (datapoint: ValueDatapoint<any>, value: any, config: TableColumnConfig) => TemplateResult | any | undefined;
}
@@ -93,6 +94,7 @@ const style = css`
display: flex;
width: 100%;
height: 100%;
+ flex-direction: column;
}
#container > * {
@@ -102,6 +104,13 @@ const style = css`
#msg {
height: 100%;
width: 100%;
+ justify-content: center;
+ align-items: center;
+ text-align: center;
+ }
+
+ #msg:not([hidden]) {
+ display: flex;
}
#history-wrapper:not([hidden]) {
@@ -243,7 +252,9 @@ export class OrAttributeHistory extends translate(i18next)(LitElement) {
return html`
<div id="container">
- <div id="msg" ?hidden="${!this._loading && hasData}"><or-translate value="${this._loading ? "loading" : "noData"}"></or-translate></div>
+ <div id="msg" ?hidden="${!this._loading && hasData}">
+ <or-translate value="${this._loading ? "loading" : "noData"}"></or-translate>
+ </div>
<div id="history-wrapper" ?hidden="${this._loading || !hasData}">
<div id="chart-controls">
<or-input .type="${InputType.SELECT}" .options="${this._getIntervalOptions()}"></or-input>
@@ -454,7 +465,7 @@ export class OrAttributeHistory extends translate(i18next)(LitElement) {
<table style="${config.styles ? styleMap(config.styles) : ""}" class="mdc-data-table__table" aria-label="${attributeName + " history"}">
<thead>
<tr class="mdc-data-table__header-row">
- ${config.columns.map((c) => html`<th style="${c.styles ? styleMap(c.styles) : ""}" class="mdc-data-table__header-cell ${c.numeric ? "mdc-data-table__header-cell--numeric" : ""}" role="columnheader" scope="col"><or-translate value="${c.header}"></or-translate></th>`)}
+ ${config.columns.map((c) => html`<th style="${c.headerStyles ? styleMap(c.headerStyles) : ""}" class="mdc-data-table__header-cell ${c.numeric ? "mdc-data-table__header-cell--numeric" : ""}" role="columnheader" scope="col"><or-translate value="${c.header}"></or-translate></th>`)}
</tr>
</thead>
<tbody class="mdc-data-table__content">
diff --git a/ui/component/or-input/src/index.ts b/ui/component/or-input/src/index.ts
index b68d18e9e..55fee0f73 100644
--- a/ui/component/or-input/src/index.ts
+++ b/ui/component/or-input/src/index.ts
@@ -142,6 +142,12 @@ export class OrInput extends LitElement {
@property({type: Array})
public options?: string[] | [string, string][];
+ @property({type: Boolean})
+ public noEmpty?: boolean;
+
+ @property({type: Boolean})
+ public noAutoSize?: boolean;
+
/* STYLING PROPERTIES BELOW */
@property({type: String})
@@ -234,7 +240,7 @@ export class OrInput extends LitElement {
`;
case InputType.SELECT:
return html`
- <or-select .required="${this.required}" .options="${this.options}" .value="${this._processedValue}" .readonly="${this.readonly}" @or-select-changed="${(e: OrSelectChangedEvent) => this.onValueChange(e.detail.value)}"></or-select>
+ <or-select .required="${this.required}" .noEmpty="${this.noEmpty}" .noAutoSize="${this.noAutoSize}" .options="${this.options}" .value="${this._processedValue}" .readonly="${this.readonly}" @or-select-changed="${(e: OrSelectChangedEvent) => this.onValueChange(e.detail.value)}"></or-select>
`;
case InputType.BUTTON:
case InputType.BUTTON_MOMENTARY: {
diff --git a/ui/component/or-select/src/index.ts b/ui/component/or-select/src/index.ts
index 8f5a15730..114874d50 100644
--- a/ui/component/or-select/src/index.ts
+++ b/ui/component/or-select/src/index.ts
@@ -47,10 +47,10 @@ export class OrSelect extends LitElement {
public required?: boolean;
@property({type: Boolean})
- public autoSize?: boolean = true;
+ public noAutoSize?: boolean;
@property({type: Boolean, attribute: true})
- public showEmptyOption?: boolean = true;
+ public noEmpty?: boolean;
@property({type: Array})
public options!: string[] | [string, string][];
@@ -79,7 +79,7 @@ export class OrSelect extends LitElement {
return;
}
- if (this.autoSize) {
+ if (!this.noAutoSize) {
this._resize();
}
const previousValue = this.value;
@@ -93,7 +93,7 @@ export class OrSelect extends LitElement {
if (_changedProperties.has("options") || _changedProperties.has("value")) {
let val = this.value;
- if (this.options.length === 1 || (!this.showEmptyOption && !val)) {
+ if (this.options.length === 1 || (!this.noEmpty && !val)) {
const opt = this.options[0];
const firstValue = Array.isArray(opt) ? opt[0] : opt;
if (this.value !== firstValue) {
@@ -102,7 +102,7 @@ export class OrSelect extends LitElement {
}
let index: number;
- if (this.options.length === 1 || (!this.showEmptyOption && !val)) {
+ if (this.options.length === 1 || (this.noEmpty && !val)) {
index = 0;
} else {
index = this.options.findIndex((opt: string | [string, string]) => {
@@ -110,7 +110,7 @@ export class OrSelect extends LitElement {
return value === val;
});
- if(this.showEmptyOption) {
+ if(!this.noEmpty) {
index = index + 1;
}
}
@@ -121,7 +121,7 @@ export class OrSelect extends LitElement {
if (val !== this.value) {
this.onChange();
} else {
- if (this.autoSize) {
+ if (!this.noAutoSize) {
this._resize();
}
}
@@ -134,7 +134,7 @@ export class OrSelect extends LitElement {
return html`
<div class="mdc-select">
<select id="or-select" ?required="${this.required}" @change="${this.onChange}" ?disabled="${this.readonly || isSingular}">
- ${this.showEmptyOption && !isSingular ? html`<option value=""></option>` : ``}
+ ${!this.noEmpty && !isSingular ? html`<option value=""></option>` : ``}
${this.options.length > 0 && Array.isArray(this.options[0]) ?
(this.options as [string, string][]).map((option: [string, string]) => {
return html`<option style="color: ${this._optColor || optionColorVar};" value="${option[0]}">${option[1]}</option>`;