mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-31 05:06:38 +00:00
Catch errors in preview and fix entity picker (#2183)
* Catch errors in preview and fix entity picker * Replace add button with entity-picker
This commit is contained in:
parent
de3a467697
commit
bfef3a96c8
@ -42,16 +42,23 @@ export class HuiEntityEditor extends LitElement {
|
|||||||
`;
|
`;
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
<ha-entity-picker
|
||||||
|
.hass="${this.hass}"
|
||||||
|
@change="${this._addEntity}"
|
||||||
|
></ha-entity-picker>
|
||||||
</div>
|
</div>
|
||||||
<paper-button noink raised @click="${this._addEntity}"
|
|
||||||
>Add Entity</paper-button
|
|
||||||
>
|
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _addEntity() {
|
private _addEntity(ev: Event): void {
|
||||||
const newConfigEntities = this.entities!.concat({ entity: "" });
|
const target = ev.target! as EditorTarget;
|
||||||
|
if (target.value === "") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const newConfigEntities = this.entities!.concat({
|
||||||
|
entity: target.value as string,
|
||||||
|
});
|
||||||
|
target.value = "";
|
||||||
fireEvent(this, "entities-changed", { entities: newConfigEntities });
|
fireEvent(this, "entities-changed", { entities: newConfigEntities });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,11 @@ export class HuiCardPreview extends HTMLElement {
|
|||||||
const tag = getCardElementTag(configValue.type);
|
const tag = getCardElementTag(configValue.type);
|
||||||
|
|
||||||
if (tag.toUpperCase() === this._element.tagName) {
|
if (tag.toUpperCase() === this._element.tagName) {
|
||||||
this._element.setConfig(configValue);
|
try {
|
||||||
|
this._element.setConfig(configValue);
|
||||||
|
} catch (err) {
|
||||||
|
this._createCard(createErrorCardConfig(err.message, configValue));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this._createCard(configValue);
|
this._createCard(configValue);
|
||||||
}
|
}
|
||||||
|
@ -160,6 +160,7 @@ export class HuiEditView extends hassLocalizeLitMixin(LitElement) {
|
|||||||
paper-tabs {
|
paper-tabs {
|
||||||
--paper-tabs-selection-bar-color: var(--primary-color);
|
--paper-tabs-selection-bar-color: var(--primary-color);
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
|
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
|
||||||
}
|
}
|
||||||
paper-button paper-spinner {
|
paper-button paper-spinner {
|
||||||
width: 14px;
|
width: 14px;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user