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` -