Skip to content

armgit / core

Public Imported from GitHub
0

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

Bug fix for or-mwc-input

Rich Turner7bfed69c1227
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 00155a7df..e1a4c44b6 100644
--- a/ui/component/or-mwc-components/src/or-mwc-input.ts
+++ b/ui/component/or-mwc-components/src/or-mwc-input.ts
@@ -44,6 +44,7 @@ import {
WellknownValueTypes
} from "@openremote/model";
import {getItemTemplate, getListTemplate, ListItem, ListType} from "./or-mwc-list";
+import { i18next } from "@openremote/or-translate";
// TODO: Add webpack/rollup to build so consumers aren't forced to use the same tooling
const buttonStyle = require("@material/button/dist/mdc.button.css");
@@ -253,7 +254,7 @@ export const getValueHolderInputTemplateProvider: ValueInputProviderGenerator =
case WellknownValueTypes.TIMESTAMPISO8601:
inputType = InputType.DATETIME;
break;
- case WellknownValueTypes.TIMERCRONEXPRESSION:
+ case WellknownValueTypes.CRONEXPRESSION:
inputType = InputType.CRON;
break;
case WellknownValueTypes.TIMEDURATIONISO8601:
@@ -460,6 +461,7 @@ const style = css`
width: 32px;
line-height: 32px;
height: 32px;
+ cursor: pointer;
background-color: var(--or-app-color2);
font-size: 13px;
}
@@ -899,7 +901,7 @@ export class OrInput extends LitElement {
<span class="mdc-select__ripple"></span>
${outlined ? this.renderOutlined(labelTemplate) : labelTemplate}
<span class="mdc-select__selected-text-container">
- <span id="selected-text" class="mdc-select__selected-text">${this.getSelectedTextValue()}</span>
+ <span id="selected-text" class="mdc-select__selected-text">${this.getSelectedTextValue(opts)}</span>
</span>
<span class="mdc-select__dropdown-icon">
<svg
@@ -1154,10 +1156,10 @@ export class OrInput extends LitElement {
inputElem = html`
<label id="${componentId}" class="${classMap(classes)}">
${this.icon ? html`<or-icon class="mdc-text-field__icon mdc-text-field__icon--leading" aria-hidden="true" icon="${this.icon}"></or-icon>` : ``}
- ${outlined ? `` : html`<span class="mdc-text-field__ripple"></span>`}
+ <span class="mdc-text-field__ripple"></span>
${inputElem}
${outlined ? this.renderOutlined(labelTemplate) : labelTemplate}
- ${outlined ? `` : html`<span class="mdc-line-ripple"></span>`}
+ <span class="mdc-line-ripple"></span>
${this.iconTrailing ? html`<or-icon class="mdc-text-field__icon mdc-text-field__icon--trailing" aria-hidden="true" icon="${this.iconTrailing}"></or-icon>` : ``}
</label>
${hasHelper ? html`
@@ -1261,6 +1263,7 @@ export class OrInput extends LitElement {
break;
case InputType.RADIO:
+ case InputType.CHECKBOX_LIST:
break;
case InputType.BUTTON:
case InputType.BUTTON_MOMENTARY:
@@ -1436,17 +1439,17 @@ export class OrInput extends LitElement {
if (Array.isArray(options[0])) {
resolved = options as [string, string][];
} else {
- resolved = (options as string[]).map((option) => [option, option]);
+ resolved = (options as string[]).map((option) => [option, i18next.t(option, {defaultValue: Util.camelCaseToSentenceCase(option)})]);
}
}
return resolved;
}
- protected getSelectedTextValue(): string {
- const opts = this.resolveOptions(this.options);
+ protected getSelectedTextValue(options?: [string, string][] | undefined): string {
+ const opts = options || this.resolveOptions(this.options);
const value = this.value;
const values = Array.isArray(value) ? value as string[] : value ? [value as string] : undefined;
- return !opts || !values ? "" : values.map(v => opts.find(([optValue, optDisplay], index) => v === optValue)).map(opt => opt && opt[1]).join(",");
+ return !opts || !values ? "" : values.map(v => opts.find(([optValue, optDisplay], index) => v === optValue)).map((opt) => opt && opt[1]).join(",");
}
}
diff --git a/ui/component/or-mwc-components/src/or-mwc-list.ts b/ui/component/or-mwc-components/src/or-mwc-list.ts
index 3d5ae8d55..3b93dc3bb 100644
--- a/ui/component/or-mwc-components/src/or-mwc-list.ts
+++ b/ui/component/or-mwc-components/src/or-mwc-list.ts
@@ -14,6 +14,7 @@ import {ifDefined} from "lit-html/directives/if-defined";
import {MDCList, MDCListActionEvent} from "@material/list";
import { DefaultColor8, DefaultColor4, Util } from "@openremote/core";
import "@openremote/or-translate";
+import { i18next } from "@openremote/or-translate";
const listStyle = require("@material/list/dist/mdc.list.css");
const checkboxStyle = require("@material/checkbox/dist/mdc.checkbox.css");
@@ -184,15 +185,15 @@ export function getItemTemplate(item: ListItem | null, index: number, selectedVa
if (secondaryText !== undefined) {
textTemplate = html`
<span class="mdc-list-item__text">
- <span class="mdc-list-item__primary-text">${translate ? html`<or-translate .value="${text}"></or-translate>` : text}</span>
- <span class="mdc-list-item__secondary-text">${translate ? html`<or-translate .value="${secondaryText || ""}"></or-translate>` : secondaryText || ""}</span>
+ <span class="mdc-list-item__primary-text">${translate && !!text ? i18next.t(text) : text}</span>
+ <span class="mdc-list-item__secondary-text">${translate && !!secondaryText ? i18next.t(secondaryText) : secondaryText}</span>
</span>
`;
} else {
if (type === ListType.RADIO) {
- textTemplate = html`<label class="mdc-list-item__text" for="radio-item-${index+1}">${translate ? html`<or-translate .value="${text}"></or-translate>` : text}</label>`;
+ textTemplate = html`<label class="mdc-list-item__text" for="radio-item-${index+1}">${translate && !!text ? i18next.t(text) : text}</label>`;
} else {
- textTemplate = html`<span class="mdc-list-item__text">${translate ? html`<or-translate .value="${text}"></or-translate>` : text}</span>`;
+ textTemplate = html`<span class="mdc-list-item__text">${translate && !!text ? i18next.t(text) : text}</span>`;
}
}
}
diff --git a/ui/component/or-rules/src/or-rule-validity.ts b/ui/component/or-rules/src/or-rule-validity.ts
index 8925d5aad..71c768d20 100644
--- a/ui/component/or-rules/src/or-rule-validity.ts
+++ b/ui/component/or-rules/src/or-rule-validity.ts
@@ -302,7 +302,7 @@ export class OrRuleValidity extends translate(i18next)(LitElement) {
<div class="layout horizontal">
<or-mwc-input .value="${selectedOptions}" .type="${InputType.CHECKBOX_LIST}" .options="${options}" .label="${i18next.t("daysOfTheWeek")}" @or-mwc-input-changed="${(e: OrInputChangedEvent) => this.setRRuleValue(e.detail.value, "byweekday")}" ></or-mwc-input>
</div>
-
+
<label style="display:block; margin-top: 20px;"><or-translate value="repetitionEnds"></or-translate></label>
<div class="layout horizontal">
<or-mwc-input .value="${!this._rrule!.options.until}" @or-mwc-input-changed="${(e: OrInputChangedEvent) => this.setRRuleValue(e.detail.value, "never-ends")}" .type="${InputType.CHECKBOX}" .label="${i18next.t("never")}"></or-mwc-input>