diff --git a/src/bubble-card.js b/src/bubble-card.js index 4e5cd1c4..e4aef1c8 100644 --- a/src/bubble-card.js +++ b/src/bubble-card.js @@ -604,6 +604,7 @@ class BubbleCard extends HTMLElement { } .card-content { width: 100% !important; + position: relative; } `; styleElement.innerHTML = styles; @@ -1227,40 +1228,46 @@ class BubbleCardEditor extends LitElement { return html``; } - const editorEvent = new CustomEvent("editor-event", { bubbles: true }); - document.dispatchEvent(editorEvent); - - const cardTypeList = [ - 'button', - 'cover', - 'empty-column', - 'horizontal-buttons-stack', - 'pop-up', - 'separator' - ]; - - const buttonTypeList = [ - 'switch', - 'slider' - ]; - - const allEntitiesList = Object.keys(this.hass.states); - - const lightList = Object.keys(this.hass.states).filter( - (eid) => eid.substr(0, eid.indexOf(".")) === "light" - ); - - const sensorList = Object.keys(this.hass.states).filter( - (eid) => eid.substr(0, eid.indexOf(".")) === "sensor" - ); - - const coverList = Object.keys(this.hass.states).filter( - (eid) => eid.substr(0, eid.indexOf(".")) === "cover" - ); - - // console.log(document.querySelector("body > home-assistant").shadowRoot.querySelector("hui-dialog-edit-card").shadowRoot.querySelector("ha-dialog > div.content > div.element-preview > hui-card-preview")); + if (!this.listsUpdated) { + const formateList = item => ({label: item, value: item}); + + this.allEntitiesList = Object.keys(this.hass.states).map(formateList); + + this.lightList = Object.keys(this.hass.states).filter( + (eid) => eid.substr(0, eid.indexOf(".")) === "light" + ).map(formateList); + + this.sensorList = Object.keys(this.hass.states).filter( + (eid) => eid.substr(0, eid.indexOf(".")) === "sensor" + ).map(formateList); + + this.coverList = Object.keys(this.hass.states).filter( + (eid) => eid.substr(0, eid.indexOf(".")) === "cover" + ).map(formateList); + + this.cardTypeList = [ + { 'label':'Button', 'value':'button' }, + { 'label':'Cover', 'value':'cover' }, + { 'label':'Empty column', 'value':'empty-column' }, + { 'label':'Horizontal buttons stack', 'value':'horizontal-buttons-stack' }, + { 'label':'Pop-up', 'value':'pop-up' }, + { 'label':'Separator', 'value':'separator' } + ]; + + this.buttonTypeList = [ + { 'label':'Switch', 'value':'switch' }, + { 'label':'Slider', 'value':'slider' } + ]; + + this.listsUpdated = true; + } - // this.shadowRoot.querySelector("ha-card").style.border = '1px solid white !important'; + const allEntitiesList = this.allEntitiesList; + const lightList = this.lightList; + const sensorList = this.sensorList; + const coverList = this.coverList; + const cardTypeList = this.cardTypeList; + const buttonTypeList = this.buttonTypeList; if (this._config.card_type === 'pop-up') { return html` @@ -1450,7 +1457,7 @@ class BubbleCardEditor extends LitElement { } makeDropdown(label, configValue, items) { - const formateList = item => ({icon: item, label: item, value: item}) ; + const formateList = item => ({label: item, value: item}); const hass = this.hass; if (label === 'Icon' || label === 'Open icon' || label === 'Closed icon') { @@ -1467,21 +1474,6 @@ class BubbleCardEditor extends LitElement { `; - } else if (label === 'Entity' || label === 'Temperature sensor' || label === 'Light') { - return html` -
- - -
- `; } else { return html`
@@ -1489,9 +1481,7 @@ class BubbleCardEditor extends LitElement { label="${label}" .value="${this['_' + configValue]}" .configValue="${configValue}" - .items="${items.map(formateList)}" - item-label-path="label" - item-value-path="value" + .items="${items}" @value-changed="${this._valueChanged}" > @@ -1541,7 +1531,7 @@ class BubbleCardEditor extends LitElement { label="Light / Light group (For background color)" .value="${this._config[i + '_entity']}" .configValue="${i}_entity" - .items="${allEntitiesList.map(formateList)}" + .items="${allEntitiesList}" item-label-path="label" item-value-path="value" @value-changed="${this._valueChanged}" @@ -1552,7 +1542,7 @@ class BubbleCardEditor extends LitElement { .value="${this._config[i + '_pir_sensor']}" .configValue="${i}_pir_sensor" .disabled=${!this._config.auto_order} - .items="${binarySensorList.map(formateList)}" + .items="${binarySensorList}" item-label-path="label" item-value-path="value" @value-changed="${this._valueChanged}" @@ -1607,9 +1597,9 @@ class BubbleCardEditor extends LitElement { return; } const target = ev.target; - if (this[`_${target.configValue}`] === ev.detail.value) { - return; - } + // if (this[`_${target.configValue}`] === ev.detail.value) { + // return; + // } if (target.configValue) { // Affiche la valeur de this._config avant la mise à jour console.log("Before update:", this._config); @@ -1698,5 +1688,4 @@ window.customCards.push({ description: "A cards collection for Home Assistant with a nice pop-up touch.", }); -// BETA 2 -// Thank you to samuel9554 for his CSS fix for smaller screens. +// BETA 4