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: or-rules styling and bug fixes

Rich Turner13f3cd6a0288
diff --git a/ui/component/or-rules/src/json-viewer/or-rule-action-attribute.ts b/ui/component/or-rules/src/json-viewer/or-rule-action-attribute.ts
index a62588ebf..adff855a2 100644
--- a/ui/component/or-rules/src/json-viewer/or-rule-action-attribute.ts
+++ b/ui/component/or-rules/src/json-viewer/or-rule-action-attribute.ts
@@ -130,12 +130,12 @@ export class OrRuleActionAttribute extends translate(i18next)(LitElement) {
}
inputTemplate = getAttributeValueTemplate(assetType, attribute, this.readonly || false, false, (v: any) => this.setActionAttributeValue(v), this.config ? this.config.inputProvider : undefined, undefined,
- (attribute.type && (attribute.type.valueType == ValueType.BOOLEAN || attribute.type == AttributeValueType.BOOLEAN.name || attribute.type == AttributeValueType.SWITCH_TOGGLE.name)) ? `` : i18next.t("value"));
+ (attribute.type && (attribute.type.valueType === ValueType.BOOLEAN || attribute.type === AttributeValueType.BOOLEAN.name || attribute.type === AttributeValueType.SWITCH_TOGGLE.name)) ? "" : i18next.t("value"));
}
return html`
- <or-input id="matchSelect" .label="${i18next.t("asset")}" type="${InputType.SELECT}" @or-input-changed="${(e: OrInputChangedEvent) => this._assetId = (e.detail.value)}" ?readonly="${this.readonly}" .options="${idOptions}" .value="${idValue}"></or-input>
- <or-input id="attributeSelect" .label="${i18next.t("attribute")}" type="${InputType.SELECT}" @or-input-changed="${(e: OrInputChangedEvent) => this.setActionAttributeName(e.detail.value)}" ?readonly="${this.readonly}" .options="${attributes}" .value="${this.action.attributeName}"></or-input>
+ <or-input id="matchSelect" .label="${i18next.t("asset")}" .type="${InputType.SELECT}" @or-input-changed="${(e: OrInputChangedEvent) => this._assetId = (e.detail.value)}" ?readonly="${this.readonly}" .options="${idOptions}" .value="${idValue}"></or-input>
+ <or-input id="attributeSelect" .label="${i18next.t("attribute")}" .type="${InputType.SELECT}" @or-input-changed="${(e: OrInputChangedEvent) => this.setActionAttributeName(e.detail.value)}" ?readonly="${this.readonly}" .options="${attributes}" .value="${this.action.attributeName}"></or-input>
${inputTemplate ? inputTemplate(this.action.value) : ``}
`;
}
diff --git a/ui/component/or-rules/src/json-viewer/or-rule-asset-query.ts b/ui/component/or-rules/src/json-viewer/or-rule-asset-query.ts
index d42783e5d..5a19cd2a6 100644
--- a/ui/component/or-rules/src/json-viewer/or-rule-asset-query.ts
+++ b/ui/component/or-rules/src/json-viewer/or-rule-asset-query.ts
@@ -181,7 +181,7 @@ export class OrRuleAssetQuery extends translate(i18next)(LitElement) {
<div class="attribute-editor">
<or-input type="${InputType.SELECT}" @or-input-changed="${(e: OrSelectChangedEvent) => this.setAttributeName(attributePredicate, e.detail.value)}" ?readonly="${this.readonly}" .options="${attributes}" .value="${attributeName}" .label="${i18next.t("attribute")}"></or-input>
- ${attributeName ? html`<or-input type="${InputType.SELECT}" @or-input-changed="${(e: OrSelectChangedEvent) => this.setOperator(assetDescriptor, attribute, attributeName, attributePredicate, e.detail.value)}" ?readonly="${this.readonly}" .options="${operators}" .value="${i18next.t("operator")}" .label="${i18next.t("Operator")}"></or-input>` : ``}
+ ${attributeName ? html`<or-input type="${InputType.SELECT}" @or-input-changed="${(e: OrSelectChangedEvent) => this.setOperator(assetDescriptor, attribute, attributeName, attributePredicate, e.detail.value)}" ?readonly="${this.readonly}" .options="${operators}" .value="${operator}" .label="${i18next.t("operator")}"></or-input>` : ``}
${attributePredicate ? this.attributePredicateValueEditorTemplate(assetDescriptor, attributePredicate) : ``}
</div>
diff --git a/ui/component/or-rules/src/json-viewer/or-rule-json-viewer.ts b/ui/component/or-rules/src/json-viewer/or-rule-json-viewer.ts
index e88e55a34..684e2c93b 100644
--- a/ui/component/or-rules/src/json-viewer/or-rule-json-viewer.ts
+++ b/ui/component/or-rules/src/json-viewer/or-rule-json-viewer.ts
@@ -101,7 +101,11 @@ export class OrRuleJsonViewer extends translate(i18next)(LitElement) implements
if (!ruleset.rules) {
// New ruleset so start a new rule
- this._rule = {};
+ if (this.config && this.config.json && this.config.json.rule) {
+ this._rule = JSON.parse(JSON.stringify(this.config.json.rule)) as JsonRule;
+ } else {
+ this._rule = {};
+ }
} else {
try {
const rules = JSON.parse(ruleset.rules) as JsonRulesetDefinition;
diff --git a/ui/component/or-rules/src/json-viewer/or-rule-then-otherwise.ts b/ui/component/or-rules/src/json-viewer/or-rule-then-otherwise.ts
index 253cd0671..0b985d9ee 100644
--- a/ui/component/or-rules/src/json-viewer/or-rule-then-otherwise.ts
+++ b/ui/component/or-rules/src/json-viewer/or-rule-then-otherwise.ts
@@ -331,7 +331,7 @@ class OrRuleThenOtherwise extends translate(i18next)(LitElement) {
action: "write-attribute"
};
let template: RuleActionUnion | undefined;
- let templateConfig = this.config && this.config.json ? this.config.json : undefined;
+ const templateConfig = this.config && this.config.json ? this.config.json : undefined;
if (!otherwise) {
if (!this.rule.then) {
diff --git a/ui/component/or-rules/src/or-rule-viewer.ts b/ui/component/or-rules/src/or-rule-viewer.ts
index bdfc3993c..a54a3234a 100644
--- a/ui/component/or-rules/src/or-rule-viewer.ts
+++ b/ui/component/or-rules/src/or-rule-viewer.ts
@@ -44,7 +44,7 @@ export const style = css`
min-height: var(--internal-or-rules-header-height);
height: var(--internal-or-rules-header-height);
z-index: 1;
- padding: 0 20px;
+ padding: 10px 20px 0 20px;
--or-icon-fill: var(--internal-or-rules-panel-color);
}
@@ -105,7 +105,7 @@ export class OrRuleViewer extends translate(i18next)(LitElement) {
@property({attribute: false})
protected _supported = true;
- @query("#rule-viewer")
+ @query("#rule-view")
public view?: RuleView;
protected _focusName = false;