mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Set hass when creating card (#7187)
This commit is contained in:
parent
cbdfaccdb2
commit
2ecf7bca97
@ -49,7 +49,6 @@ class HcLovelace extends LitElement {
|
|||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.lovelace=${lovelace}
|
.lovelace=${lovelace}
|
||||||
.index=${index}
|
.index=${index}
|
||||||
columns="2"
|
|
||||||
></hui-view>
|
></hui-view>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@ -67,7 +66,7 @@ class HcLovelace extends LitElement {
|
|||||||
|
|
||||||
if (configBackground) {
|
if (configBackground) {
|
||||||
(this.shadowRoot!.querySelector(
|
(this.shadowRoot!.querySelector(
|
||||||
"hui-view, hui-panel-view"
|
"hui-view"
|
||||||
) as HTMLElement)!.style.setProperty(
|
) as HTMLElement)!.style.setProperty(
|
||||||
"--lovelace-background",
|
"--lovelace-background",
|
||||||
configBackground
|
configBackground
|
||||||
|
@ -164,14 +164,12 @@ export class HUIView extends UpdatingElement {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const elements: HUIView["_badges"] = [];
|
|
||||||
const badges = processConfigEntities(config.badges as any);
|
const badges = processConfigEntities(config.badges as any);
|
||||||
badges.forEach((badge) => {
|
this._badges = badges.map((badge) => {
|
||||||
const element = createBadgeElement(badge);
|
const element = createBadgeElement(badge);
|
||||||
element.hass = this.hass;
|
element.hass = this.hass;
|
||||||
elements.push(element);
|
return element;
|
||||||
});
|
});
|
||||||
this._badges = elements;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private _createCards(config: LovelaceViewConfig): void {
|
private _createCards(config: LovelaceViewConfig): void {
|
||||||
@ -180,9 +178,11 @@ export class HUIView extends UpdatingElement {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._cards = config.cards.map((cardConfig) =>
|
this._cards = config.cards.map((cardConfig) => {
|
||||||
this.createCardElement(cardConfig)
|
const element = this.createCardElement(cardConfig);
|
||||||
);
|
element.hass = this.hass;
|
||||||
|
return element;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private _rebuildCard(
|
private _rebuildCard(
|
||||||
@ -190,6 +190,7 @@ export class HUIView extends UpdatingElement {
|
|||||||
config: LovelaceCardConfig
|
config: LovelaceCardConfig
|
||||||
): void {
|
): void {
|
||||||
const newCardEl = this.createCardElement(config);
|
const newCardEl = this.createCardElement(config);
|
||||||
|
newCardEl.hass = this.hass;
|
||||||
if (cardElToReplace.parentElement) {
|
if (cardElToReplace.parentElement) {
|
||||||
cardElToReplace.parentElement!.replaceChild(newCardEl, cardElToReplace);
|
cardElToReplace.parentElement!.replaceChild(newCardEl, cardElToReplace);
|
||||||
}
|
}
|
||||||
@ -203,7 +204,13 @@ export class HUIView extends UpdatingElement {
|
|||||||
config: LovelaceBadgeConfig
|
config: LovelaceBadgeConfig
|
||||||
): void {
|
): void {
|
||||||
const newBadgeEl = this.createBadgeElement(config);
|
const newBadgeEl = this.createBadgeElement(config);
|
||||||
badgeElToReplace.parentElement!.replaceChild(newBadgeEl, badgeElToReplace);
|
newBadgeEl.hass = this.hass;
|
||||||
|
if (badgeElToReplace.parentElement) {
|
||||||
|
badgeElToReplace.parentElement!.replaceChild(
|
||||||
|
newBadgeEl,
|
||||||
|
badgeElToReplace
|
||||||
|
);
|
||||||
|
}
|
||||||
this._badges = this._cards!.map((curBadgeEl) =>
|
this._badges = this._cards!.map((curBadgeEl) =>
|
||||||
curBadgeEl === badgeElToReplace ? newBadgeEl : curBadgeEl
|
curBadgeEl === badgeElToReplace ? newBadgeEl : curBadgeEl
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user