+ `}_renderCardEditor(){var t;const e=Object.assign({},this._config);return e.show_empty=null===(t=e.show_empty)||void 0===t||t,U`
+
+
{var e;return null!==(e=t.label)&&void 0!==e?e:t.name}}
+ .data=${e}
+ @value-changed=${this._changeCardOptions}
+ >
+ ${this._config.card?U`
+
${!this._cardEditorEl||this._cardGUIMode?"Show code editor":"Show Visual Editor"}
-
-
-
+ Change card type
+
- `:x`
+ `:U`
`}
@@ -184,31 +146,27 @@ function t(t,e,i,n){var s,o=arguments.length,r=o<3?e:null===n?n=Object.getOwnPro
border-bottom: 1px solid var(--divider-color);
}
- .filter,
- .card {
+ .box {
margin-top: 8px;
border: 1px solid var(--divider-color);
padding: 12px;
}
- .filter .option {
+ .option {
display: flex;
- align-items: flex-end;
- }
- .filter .option mwc-select {
- margin-right: 16px;
- width: 150px;
- }
- .filter .option paper-input {
- flex-grow: 2;
+ align-items: center;
+ gap: 8px;
}
- .filter .toolbar,
- .card .card-options {
+ .box .toolbar {
display: flex;
justify-content: flex-end;
width: 100%;
+ gap: 8px;
}
.gui-mode-button {
margin-right: auto;
}
- `]}}function jt(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(!(t instanceof Object&&e instanceof Object))return!1;for(const i in t)if(t.hasOwnProperty(i)){if(!e.hasOwnProperty(i))return!1;if(t[i]!==e[i]){if("object"!=typeof t[i])return!1;if(!jt(t[i],e[i]))return!1}}for(const i in e)if(e.hasOwnProperty(i)&&!t.hasOwnProperty(i))return!1;return!0}t([et()],St.prototype,"_config",void 0),t([tt()],St.prototype,"lovelace",void 0),t([tt()],St.prototype,"hass",void 0),t([et()],St.prototype,"_selectedTab",void 0),t([et()],St.prototype,"_cardGUIMode",void 0),t([et()],St.prototype,"_cardGUIModeAvailable",void 0),t([function(t,e){return(({finisher:t,descriptor:e})=>(i,n)=>{var s;if(void 0===n){const n=null!==(s=i.originalKey)&&void 0!==s?s:i.key,o=null!=e?{kind:"method",placement:"prototype",key:n,descriptor:e(i.key)}:{...i,key:n};return null!=t&&(o.finisher=function(e){t(e,n)}),o}{const s=i.constructor;void 0!==e&&Object.defineProperty(i,n,e(n)),null==t||t(s,n)}})({descriptor:i=>{const n={get(){var e,i;return null!==(i=null===(e=this.renderRoot)||void 0===e?void 0:e.querySelector(t))&&void 0!==i?i:null},enumerable:!0,configurable:!0};if(e){const e="symbol"==typeof i?Symbol():"__"+i;n.get=function(){var i,n;return void 0===this[e]&&(this[e]=null!==(n=null===(i=this.renderRoot)||void 0===i?void 0:i.querySelector(t))&&void 0!==n?n:null),this[e]}}return n}})}("hui-card-element-editor")],St.prototype,"_cardEditorEl",void 0),customElements.define("auto-entities-editor",St),window.customCards=window.customCards||[],window.customCards.push({type:"auto-entities",name:"Auto Entities",preview:!1,description:"Entity Filter on Steroids. Auto Entities allows you to fill other cards with entities automatically, based on a number of attributes."}),window.queueMicrotask=window.queueMicrotask||(t=>window.setTimeout(t,1));class Tt extends Z{constructor(){super(...arguments),this._updateCooldown={timer:void 0,rerun:!1},this._renderer=t=>{this._template="string"==typeof t?t.split(/[\s,]+/):t}}static getConfigElement(){return document.createElement("auto-entities-editor")}static getStubConfig(){return{card:{type:"entities"},filter:{include:[],exclude:[]}}}setConfig(t){var e,i;if(!t)throw new Error("No configuration.");if(!(null===(e=t.card)||void 0===e?void 0:e.type))throw new Error("No card type specified.");if(!t.filter&&!t.entities)throw new Error("No filters specified.");t=JSON.parse(JSON.stringify(t)),this._config=t,(null===(i=this._config.filter)||void 0===i?void 0:i.template)&&ct(this._config.filter.template)&&ht(this._renderer,this._config.filter.template,{config:t}),this._cardBuilt=new Promise((t=>this._cardBuiltResolve=t)),queueMicrotask((()=>this.update_all()))}connectedCallback(){var t,e;super.connectedCallback(),(null===(e=null===(t=this._config)||void 0===t?void 0:t.filter)||void 0===e?void 0:e.template)&&ct(this._config.filter.template)&&ht(this._renderer,this._config.filter.template,{config:this._config})}disconnectedCallback(){super.disconnectedCallback(),ut(this._renderer)}async update_all(){if(this.card&&(this.card.hass=this.hass),this._updateCooldown.timer)return void(this._updateCooldown.rerun=!0);this._updateCooldown.rerun=!1,this._updateCooldown.timer=window.setTimeout((()=>{this._updateCooldown.timer=void 0,this._updateCooldown.rerun&&this.update_all()}),500);const t=await this.update_entities();this.update_card(t)}async update_card(t){var e,i,n,s,o,r,a,l,c,d,h,u;if(this._entities&&jt(t,this._entities)&&jt(this._cardConfig,this._config.card))return;const f=(null===(e=this._cardConfig)||void 0===e?void 0:e.type)!==this._config.card.type;this._entities=t,this._cardConfig=JSON.parse(JSON.stringify(this._config.card));const g=Object.assign({[this._config.card_param||"entities"]:t},this._config.card);if(!this.card||f){const t=await window.loadCardHelpers();console.oldError=console.oldError||[];const e=console.error;console.oldError.push(e),console.error=(...t)=>{var i,n,s,o,r,a;3===t.length&&t[2].message&&((null===(n=(i=t[2].message).startsWith)||void 0===n?void 0:n.call(i,"Entities"))||(null===(o=(s=t[2].message).startsWith)||void 0===o?void 0:o.call(s,"Either entities"))||(null===(a=(r=t[2].message).endsWith)||void 0===a?void 0:a.call(r,"entity")))||e(...t)};try{if(this.card=await t.createCardElement(g),"hui-error-card"===this.card.localName){const t=this.card;await customElements.whenDefined("hui-error-card");let e=10;for(;!t._config&&e;)await new Promise((t=>window.setTimeout(t,100))),e--;if((null===(s=null===(n=null===(i=t._config)||void 0===i?void 0:i.error)||void 0===n?void 0:n.startsWith)||void 0===s?void 0:s.call(n,"Entities"))||(null===(a=null===(r=null===(o=t._config)||void 0===o?void 0:o.error)||void 0===r?void 0:r.startsWith)||void 0===a?void 0:a.call(r,"Either entities"))||(null===(d=null===(c=null===(l=t._config)||void 0===l?void 0:l.error)||void 0===c?void 0:c.endsWith)||void 0===d?void 0:d.call(c,"entity")))return this.card=void 0,this._entities=void 0,this._cardConfig=void 0,void(null===(h=this._cardBuiltResolve)||void 0===h||h.call(this))}}finally{console.error=console.oldError.pop()}}else this.card.setConfig(g);null===(u=this._cardBuiltResolve)||void 0===u||u.call(this),this.card.hass=this.hass;const v=0===t.length&&!1===this._config.show_empty;this.style.display=v?"none":null,this.style.margin=v?"0":null,this.card.requestUpdate&&(await this.updateComplete,this.card.requestUpdate())}async update_entities(){var t,e,i,n,s,o;const r=t=>t?"string"==typeof t?{entity:t.trim()}:t:null;let a=[...(null===(e=null===(t=this._config)||void 0===t?void 0:t.entities)||void 0===e?void 0:e.map(r))||[]];if(!this.hass)return a;if(this._template&&(a=a.concat(this._template.map(r))),a=a.filter(Boolean),null===(i=this._config.filter)||void 0===i?void 0:i.include){const t=Object.keys(this.hass.states).map(r);for(const e of this._config.filter.include){if(e.type){a.push(e);continue}let i=[];for(const n of t)await bt(this.hass,e,n.entity)&&i.push(JSON.parse(JSON.stringify(Object.assign(Object.assign({},n),e.options)).replace(/this.entity_id/g,n.entity)));if(e.sort&&(i=i.sort(Et(this.hass,e.sort)),e.sort.count)){const t=null!==(n=e.sort.first)&&void 0!==n?n:0;i=i.slice(t,t+e.sort.count)}a=a.concat(i)}}if(null===(s=this._config.filter)||void 0===s?void 0:s.exclude)for(const t of this._config.filter.exclude){const e=[];for(const i of a)void 0!==i.entity&&await bt(this.hass,t,i.entity)||e.push(i);a=e}if(this._config.sort&&(a=a.sort(Et(this.hass,this._config.sort)),this._config.sort.count)){const t=null!==(o=this._config.sort.first)&&void 0!==o?o:0;a=a.slice(t,t+this._config.sort.count)}if(this._config.unique){let t=[];for(const e of a)"entity"===this._config.unique&&e.entity&&t.some((t=>t.entity===e.entity))||t.some((t=>jt(t,e)))||t.push(e);a=t}return a}async updated(t){(t.has("_template")||t.has("hass")&&this.hass)&&queueMicrotask((()=>this.update_all()))}createRenderRoot(){return this}render(){return x`${this.card}`}async getCardSize(){var t,e;let i=0;return await this._cardBuilt,this.card&&this.card.getCardSize&&(i=await this.card.getCardSize()),1===i&&(null===(t=this._entities)||void 0===t?void 0:t.length)&&(i=this._entities.length),0===i&&(null===(e=this._config.filter)||void 0===e?void 0:e.include)&&(i=Object.keys(this._config.filter.include).length),i||5}}t([tt()],Tt.prototype,"_config",void 0),t([tt()],Tt.prototype,"hass",void 0),t([tt()],Tt.prototype,"card",void 0),t([tt()],Tt.prototype,"_template",void 0),customElements.get("auto-entities")||(customElements.define("auto-entities",Tt),console.info(`%cAUTO-ENTITIES ${At} IS INSTALLED`,"color: green; font-weight: bold",""));
+ a {
+ color: var(--primary-color);
+ }
+ `]}}t([et()],Pt.prototype,"_config",void 0),t([tt()],Pt.prototype,"lovelace",void 0),t([tt()],Pt.prototype,"hass",void 0),t([et()],Pt.prototype,"_selectedTab",void 0),t([et()],Pt.prototype,"_cardGUIMode",void 0),t([et()],Pt.prototype,"_cardGUIModeAvailable",void 0),t([function(t,e){return(({finisher:t,descriptor:e})=>(i,n)=>{var s;if(void 0===n){const n=null!==(s=i.originalKey)&&void 0!==s?s:i.key,o=null!=e?{kind:"method",placement:"prototype",key:n,descriptor:e(i.key)}:{...i,key:n};return null!=t&&(o.finisher=function(e){t(e,n)}),o}{const s=i.constructor;void 0!==e&&Object.defineProperty(i,n,e(n)),null==t||t(s,n)}})({descriptor:i=>{const n={get(){var e,i;return null!==(i=null===(e=this.renderRoot)||void 0===e?void 0:e.querySelector(t))&&void 0!==i?i:null},enumerable:!0,configurable:!0};if(e){const e="symbol"==typeof i?Symbol():"__"+i;n.get=function(){var i,n;return void 0===this[e]&&(this[e]=null!==(n=null===(i=this.renderRoot)||void 0===i?void 0:i.querySelector(t))&&void 0!==n?n:null),this[e]}}return n}})}("hui-card-element-editor")],Pt.prototype,"_cardEditorEl",void 0),customElements.define("auto-entities-editor",Pt),window.customCards=window.customCards||[],window.customCards.push({type:"auto-entities",name:"Auto Entities",preview:!1,description:"Entity Filter on Steroids. Auto Entities allows you to fill other cards with entities automatically, based on a number of attributes."}),window.queueMicrotask=window.queueMicrotask||(t=>window.setTimeout(t,1));class Mt extends Y{constructor(){super(...arguments),this._updateCooldown={timer:void 0,rerun:!1},this._renderer=t=>{this._template="string"==typeof t?t.split(/[\s,]+/):t}}static getConfigElement(){return document.createElement("auto-entities-editor")}static getStubConfig(){return{card:{type:"entities"},filter:{include:[],exclude:[]}}}setConfig(t){var e,i;if(!t)throw new Error("No configuration.");if(!(null===(e=t.card)||void 0===e?void 0:e.type))throw new Error("No card type specified.");if(!t.filter&&!t.entities)throw new Error("No filters specified.");t=JSON.parse(JSON.stringify(t)),this._config=t,(null===(i=this._config.filter)||void 0===i?void 0:i.template)&&ct(this._config.filter.template)&&ht(this._renderer,this._config.filter.template,{config:t}),this._cardBuilt=new Promise((t=>this._cardBuiltResolve=t)),queueMicrotask((()=>this.update_all()))}connectedCallback(){var t,e;super.connectedCallback(),(null===(e=null===(t=this._config)||void 0===t?void 0:t.filter)||void 0===e?void 0:e.template)&&ct(this._config.filter.template)&&ht(this._renderer,this._config.filter.template,{config:this._config})}disconnectedCallback(){super.disconnectedCallback(),ut(this._renderer)}async update_all(){if(this.card&&(this.card.hass=this.hass),this._updateCooldown.timer)return void(this._updateCooldown.rerun=!0);this._updateCooldown.rerun=!1,this._updateCooldown.timer=window.setTimeout((()=>{this._updateCooldown.timer=void 0,this._updateCooldown.rerun&&this.update_all()}),500);const t=await this.update_entities();this.update_card(t)}async update_card(t){var e,i,n,s,o,r,a,l,c,d,h,u;if(this._entities&&Ct(t,this._entities)&&Ct(this._cardConfig,this._config.card))return;const v=(null===(e=this._cardConfig)||void 0===e?void 0:e.type)!==this._config.card.type;this._entities=t,this._cardConfig=JSON.parse(JSON.stringify(this._config.card));const g=Object.assign({[this._config.card_param||"entities"]:t},this._config.card);if(!this.card||v){const t=await window.loadCardHelpers();console.oldError=console.oldError||[];const e=console.error;console.oldError.push(e),console.error=(...t)=>{var i,n,s,o,r,a;3===t.length&&t[2].message&&((null===(n=(i=t[2].message).startsWith)||void 0===n?void 0:n.call(i,"Entities"))||(null===(o=(s=t[2].message).startsWith)||void 0===o?void 0:o.call(s,"Either entities"))||(null===(a=(r=t[2].message).endsWith)||void 0===a?void 0:a.call(r,"entity")))||e(...t)};try{if(this.card=await t.createCardElement(g),"hui-error-card"===this.card.localName){const t=this.card;await customElements.whenDefined("hui-error-card");let e=10;for(;!t._config&&e;)await new Promise((t=>window.setTimeout(t,100))),e--;if((null===(s=null===(n=null===(i=t._config)||void 0===i?void 0:i.error)||void 0===n?void 0:n.startsWith)||void 0===s?void 0:s.call(n,"Entities"))||(null===(a=null===(r=null===(o=t._config)||void 0===o?void 0:o.error)||void 0===r?void 0:r.startsWith)||void 0===a?void 0:a.call(r,"Either entities"))||(null===(d=null===(c=null===(l=t._config)||void 0===l?void 0:l.error)||void 0===c?void 0:c.endsWith)||void 0===d?void 0:d.call(c,"entity")))return this.card=void 0,this._entities=void 0,this._cardConfig=void 0,void(null===(h=this._cardBuiltResolve)||void 0===h||h.call(this))}}finally{console.error=console.oldError.pop()}}else this.card.setConfig(g);null===(u=this._cardBuiltResolve)||void 0===u||u.call(this),this.card.hass=this.hass;const p=0===t.length&&!1===this._config.show_empty;this.style.display=p?"none":null,this.style.margin=p?"0":null,this.card.requestUpdate&&(await this.updateComplete,this.card.requestUpdate())}async update_entities(){var t,e,i,n,s,o;const r=t=>t?"string"==typeof t?{entity:t.trim()}:t:null;let a=[...(null===(e=null===(t=this._config)||void 0===t?void 0:t.entities)||void 0===e?void 0:e.map(r))||[]];if(!this.hass)return a;if(this._template&&(a=a.concat(this._template.map(r))),a=a.filter(Boolean),null===(i=this._config.filter)||void 0===i?void 0:i.include){const t=Object.keys(this.hass.states).map(r);for(const e of this._config.filter.include){if(e.type){a.push(e);continue}let i=[];for(const n of t)await bt(this.hass,e,n.entity)&&i.push(JSON.parse(JSON.stringify(Object.assign(Object.assign({},n),e.options)).replace(/this.entity_id/g,n.entity)));if(e.sort&&(i=i.sort(Et(this.hass,e.sort)),e.sort.count)){const t=null!==(n=e.sort.first)&&void 0!==n?n:0;i=i.slice(t,t+e.sort.count)}a=a.concat(i)}}if(null===(s=this._config.filter)||void 0===s?void 0:s.exclude)for(const t of this._config.filter.exclude){const e=[];for(const i of a)void 0!==i.entity&&await bt(this.hass,t,i.entity)||e.push(i);a=e}if(this._config.sort&&(a=a.sort(Et(this.hass,this._config.sort)),this._config.sort.count)){const t=null!==(o=this._config.sort.first)&&void 0!==o?o:0;a=a.slice(t,t+this._config.sort.count)}if(this._config.unique){let t=[];for(const e of a)"entity"===this._config.unique&&e.entity&&t.some((t=>t.entity===e.entity))||t.some((t=>Ct(t,e)))||t.push(e);a=t}return a}async updated(t){(t.has("_template")||t.has("hass")&&this.hass)&&queueMicrotask((()=>this.update_all()))}createRenderRoot(){return this}render(){return U`${this.card}`}async getCardSize(){var t,e;let i=0;return await this._cardBuilt,this.card&&this.card.getCardSize&&(i=await this.card.getCardSize()),1===i&&(null===(t=this._entities)||void 0===t?void 0:t.length)&&(i=this._entities.length),0===i&&(null===(e=this._config.filter)||void 0===e?void 0:e.include)&&(i=Object.keys(this._config.filter.include).length),i||5}}t([tt()],Mt.prototype,"_config",void 0),t([tt()],Mt.prototype,"hass",void 0),t([tt()],Mt.prototype,"card",void 0),t([tt()],Mt.prototype,"_template",void 0),customElements.get("auto-entities")||(customElements.define("auto-entities",Mt),console.groupCollapsed(`%cAUTO-ENTITIES ${At} IS INSTALLED`,"color: green; font-weight: bold"),console.log("Readme:","https://github.com/thomasloven/lovelace-auto-entities"),console.groupEnd());
diff --git a/package.json b/package.json
index 0833468..2feb444 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "auto-entities",
"private": true,
- "version": "1.10.1",
+ "version": "1.11.0",
"description": "",
"scripts": {
"build": "rollup -c",
diff --git a/src/auto-entities-editor.ts b/src/editor/auto-entities-editor.ts
similarity index 52%
rename from src/auto-entities-editor.ts
rename to src/editor/auto-entities-editor.ts
index b1f07ed..cad1293 100644
--- a/src/auto-entities-editor.ts
+++ b/src/editor/auto-entities-editor.ts
@@ -1,31 +1,16 @@
import { LitElement, html, CSSResultArray, css } from "lit";
import { property, state, query } from "lit/decorators.js";
-import { AutoEntitiesConfig } from "./types";
-
-const FILTER_OPTIONS = [
- "domain",
- "entity_id",
- "state",
- "name",
- "group",
- "device",
- "area",
- "integration",
- "last_changed",
- "last_updated",
- "last_triggered",
-];
-
-const SORT_METHODS = [
- "none",
- "domain",
- "entity_id",
- "friendly_name",
- "state",
- "last_changed",
- "last_updated",
- "last_triggered",
-];
+import { AutoEntitiesConfig } from "../types";
+import { loadHaForm } from "../helpers";
+import {
+ filterGroupSchema,
+ filterGroupOptionsSchema,
+ filter2form,
+ form2filter,
+ specialGroupSchema,
+ cardOptionsSchema,
+ sortSchema,
+} from "./schema";
class AutoEntitiesEditor extends LitElement {
@state() _config: AutoEntitiesConfig;
@@ -43,6 +28,11 @@ class AutoEntitiesEditor extends LitElement {
this._config = config;
}
+ connectedCallback(): void {
+ super.connectedCallback();
+ loadHaForm();
+ }
+
_handleSwitchTab(ev: CustomEvent) {
this._selectedTab = parseInt(ev.detail.index, 10);
}
@@ -51,7 +41,7 @@ class AutoEntitiesEditor extends LitElement {
if (!this._config) return;
const include = [...this._config.filter?.include];
- include.push({ domain: "" });
+ include.push({});
const filter = { ...this._config.filter, include };
this._config = { ...this._config, filter };
@@ -98,22 +88,11 @@ class AutoEntitiesEditor extends LitElement {
async _changeSpecialEntry(group, ev) {
if (!this._config) return;
- const include = [...this._config.filter?.include];
- include[group] = ev.detail.value;
- const filter = { ...this._config.filter, include };
- this._config = { ...this._config, filter };
-
- this.dispatchEvent(
- new CustomEvent("config-changed", { detail: { config: this._config } })
- );
- }
- async _changeGroupOptions(group, ev) {
- if (!this._config) return;
-
- const options = ev.detail.value;
+ const data = { ...ev.detail.value?.data } ?? { type: "" };
+ data.type = data.type ?? "";
const include = [...this._config.filter?.include];
- include[group] = { ...include[group], options };
+ include[group] = data;
const filter = { ...this._config.filter, include };
this._config = { ...this._config, filter };
@@ -121,33 +100,13 @@ class AutoEntitiesEditor extends LitElement {
new CustomEvent("config-changed", { detail: { config: this._config } })
);
}
-
- _addFilter(group) {
+ async _changeGroupOptions(group, ev) {
if (!this._config) return;
- const newFilter = FILTER_OPTIONS.find(
- (f) => this._config.filter.include[group][f] === undefined
- );
- if (newFilter === undefined) return;
-
- const include = [...this._config.filter?.include];
- include[group] = { ...include[group], [newFilter]: "" };
- const filter = { ...this._config.filter, include };
- this._config = { ...this._config, filter };
-
- this.dispatchEvent(
- new CustomEvent("config-changed", { detail: { config: this._config } })
- );
- }
- _removeFilter(group_index, key) {
- if (!this._config) return;
+ const data = ev.detail.value;
const include = [...this._config.filter?.include];
- const group = { ...include[group_index] };
- delete group[key];
- if (Object.keys(group).length === 0)
- return this._deleteFilterGroup(group_index);
- include[group_index] = group;
+ include[group] = { ...data };
const filter = { ...this._config.filter, include };
this._config = { ...this._config, filter };
@@ -155,63 +114,38 @@ class AutoEntitiesEditor extends LitElement {
new CustomEvent("config-changed", { detail: { config: this._config } })
);
}
- _changeFilterKey(group_index, oldFilter, ev) {
- if (!this._config) return;
- const newFilter = ev.target.value;
- if (newFilter === undefined || newFilter === oldFilter) return;
-
- const include = [...this._config.filter?.include];
- const group = { ...include[group_index] };
- if (group[oldFilter] === undefined) return;
- group[newFilter] = group[oldFilter];
- delete group[oldFilter];
- include[group_index] = group;
- const filter = { ...this._config.filter, include };
- this._config = { ...this._config, filter };
-
- this.dispatchEvent(
- new CustomEvent("config-changed", { detail: { config: this._config } })
- );
- }
- _changeFilterValue(group, filter_property, ev) {
+ _changeFilter(group, ev) {
if (!this._config) return;
+ const data = form2filter(this._config, ev.detail.value);
const include = [...this._config.filter?.include];
- const _group = { ...include[group] };
- _group[filter_property] = ev.target.value;
- include[group] = _group;
- const filter = { ...this._config.filter, include };
- this._config = { ...this._config, filter };
-
+ include[group] = { ...data, options: include[group].options };
+ this._config.filter = { ...this._config.filter, include };
this.dispatchEvent(
new CustomEvent("config-changed", { detail: { config: this._config } })
);
}
- _changeSortMethod(ev) {
+ _changeSortOptions(ev) {
if (!this._config) return;
-
- const method = ev.target.value;
- const sort = { ...this._config.sort, method };
+ const sort = ev.detail.value;
this._config = { ...this._config, sort };
-
this.dispatchEvent(
new CustomEvent("config-changed", { detail: { config: this._config } })
);
}
- _sortOptionToggle(option, ev) {
+
+ _changeCardOptions(ev) {
if (!this._config) return;
- const sort = { ...this._config.sort };
- sort[option] = ev.target.checked;
- this._config = { ...this._config, sort };
+ const data = ev.detail.value;
+ this._config = { ...this._config, ...data };
this.dispatchEvent(
new CustomEvent("config-changed", { detail: { config: this._config } })
);
}
-
_showEmptyToggle() {
if (!this._config) return;
@@ -240,18 +174,6 @@ class AutoEntitiesEditor extends LitElement {
cfg[this._config.card_param || "entities"] = [];
return cfg;
}
- _handleCardPicked(ev) {
- ev.stopPropagation();
- if (!this._config) return;
-
- const card = { ...ev.detail.config };
- delete card.entities;
- this._config = { ...this._config, card };
-
- this.dispatchEvent(
- new CustomEvent("config-changed", { detail: { config: this._config } })
- );
- }
_handleCardConfigChanged(ev) {
ev.stopPropagation();
if (!this._config) return;
@@ -300,6 +222,7 @@ class AutoEntitiesEditor extends LitElement {
+
@@ -307,26 +230,48 @@ class AutoEntitiesEditor extends LitElement {
this._renderFilterEditor,
this._renderSortEditor,
this._renderCardEditor,
+ this._renderHelp,
][this._selectedTab].bind(this)()}