mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-26 14:27:20 +00:00
Fix Logbook Icons, Card Editor Close/Cancel buttons, View Editor Dirty (#11153)
This commit is contained in:
parent
3ddcd2d0f6
commit
1a7164b466
@ -15,6 +15,7 @@ import { formatTimeWithSeconds } from "../../common/datetime/format_time";
|
|||||||
import { restoreScroll } from "../../common/decorators/restore-scroll";
|
import { restoreScroll } from "../../common/decorators/restore-scroll";
|
||||||
import { fireEvent } from "../../common/dom/fire_event";
|
import { fireEvent } from "../../common/dom/fire_event";
|
||||||
import { computeDomain } from "../../common/entity/compute_domain";
|
import { computeDomain } from "../../common/entity/compute_domain";
|
||||||
|
import { domainIcon } from "../../common/entity/domain_icon";
|
||||||
import { computeRTL, emitRTLDirection } from "../../common/util/compute_rtl";
|
import { computeRTL, emitRTLDirection } from "../../common/util/compute_rtl";
|
||||||
import "../../components/entity/state-badge";
|
import "../../components/entity/state-badge";
|
||||||
import "../../components/ha-circular-progress";
|
import "../../components/ha-circular-progress";
|
||||||
@ -150,7 +151,10 @@ class HaLogbook extends LitElement {
|
|||||||
html`
|
html`
|
||||||
<state-badge
|
<state-badge
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.overrideIcon=${item.icon}
|
.overrideIcon=${item.icon ||
|
||||||
|
(item.domain && !stateObj
|
||||||
|
? domainIcon(item.domain!)
|
||||||
|
: undefined)}
|
||||||
.overrideImage=${DOMAINS_WITH_DYNAMIC_PICTURE.has(domain)
|
.overrideImage=${DOMAINS_WITH_DYNAMIC_PICTURE.has(domain)
|
||||||
? ""
|
? ""
|
||||||
: stateObj?.attributes.entity_picture_local ||
|
: stateObj?.attributes.entity_picture_local ||
|
||||||
|
@ -245,7 +245,7 @@ export class HuiDialogEditCard
|
|||||||
<mwc-button @click=${this._cancel}>
|
<mwc-button @click=${this._cancel}>
|
||||||
${this.hass!.localize("ui.common.cancel")}
|
${this.hass!.localize("ui.common.cancel")}
|
||||||
</mwc-button>
|
</mwc-button>
|
||||||
${this._cardConfig !== undefined
|
${this._cardConfig !== undefined && this._dirty
|
||||||
? html`
|
? html`
|
||||||
<mwc-button
|
<mwc-button
|
||||||
?disabled=${!this._canSave || this._saving}
|
?disabled=${!this._canSave || this._saving}
|
||||||
@ -259,9 +259,7 @@ export class HuiDialogEditCard
|
|||||||
size="small"
|
size="small"
|
||||||
></ha-circular-progress>
|
></ha-circular-progress>
|
||||||
`
|
`
|
||||||
: this._dirty
|
: this.hass!.localize("ui.common.save")}
|
||||||
? this.hass!.localize("ui.common.save")
|
|
||||||
: this.hass!.localize("ui.common.close")}
|
|
||||||
</mwc-button>
|
</mwc-button>
|
||||||
`
|
`
|
||||||
: ``}
|
: ``}
|
||||||
|
@ -36,6 +36,7 @@ import {
|
|||||||
PANEL_VIEW_LAYOUT,
|
PANEL_VIEW_LAYOUT,
|
||||||
VIEWS_NO_BADGE_SUPPORT,
|
VIEWS_NO_BADGE_SUPPORT,
|
||||||
} from "../../views/const";
|
} from "../../views/const";
|
||||||
|
import { deepEqual } from "../../../../common/util/deep-equal";
|
||||||
|
|
||||||
@customElement("hui-dialog-edit-view")
|
@customElement("hui-dialog-edit-view")
|
||||||
export class HuiDialogEditView extends LitElement {
|
export class HuiDialogEditView extends LitElement {
|
||||||
@ -53,6 +54,8 @@ export class HuiDialogEditView extends LitElement {
|
|||||||
|
|
||||||
@state() private _curTab?: string;
|
@state() private _curTab?: string;
|
||||||
|
|
||||||
|
@state() private _dirty = false;
|
||||||
|
|
||||||
private _curTabIndex = 0;
|
private _curTabIndex = 0;
|
||||||
|
|
||||||
get _type(): string {
|
get _type(): string {
|
||||||
@ -71,6 +74,7 @@ export class HuiDialogEditView extends LitElement {
|
|||||||
this._config = {};
|
this._config = {};
|
||||||
this._badges = [];
|
this._badges = [];
|
||||||
this._cards = [];
|
this._cards = [];
|
||||||
|
this._dirty = false;
|
||||||
} else {
|
} else {
|
||||||
const { cards, badges, ...viewConfig } =
|
const { cards, badges, ...viewConfig } =
|
||||||
this._params.lovelace!.config.views[this._params.viewIndex];
|
this._params.lovelace!.config.views[this._params.viewIndex];
|
||||||
@ -85,6 +89,7 @@ export class HuiDialogEditView extends LitElement {
|
|||||||
this._params = undefined;
|
this._params = undefined;
|
||||||
this._config = {};
|
this._config = {};
|
||||||
this._badges = [];
|
this._badges = [];
|
||||||
|
this._dirty = false;
|
||||||
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,7 +219,7 @@ export class HuiDialogEditView extends LitElement {
|
|||||||
>
|
>
|
||||||
<mwc-button
|
<mwc-button
|
||||||
slot="primaryAction"
|
slot="primaryAction"
|
||||||
?disabled=${!this._config || this._saving}
|
?disabled=${!this._config || this._saving || !this._dirty}
|
||||||
@click=${this._save}
|
@click=${this._save}
|
||||||
>
|
>
|
||||||
${this._saving
|
${this._saving
|
||||||
@ -316,8 +321,13 @@ export class HuiDialogEditView extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _viewConfigChanged(ev: ViewEditEvent): void {
|
private _viewConfigChanged(ev: ViewEditEvent): void {
|
||||||
if (ev.detail && ev.detail.config) {
|
if (
|
||||||
|
ev.detail &&
|
||||||
|
ev.detail.config &&
|
||||||
|
!deepEqual(this._config, ev.detail.config)
|
||||||
|
) {
|
||||||
this._config = ev.detail.config;
|
this._config = ev.detail.config;
|
||||||
|
this._dirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,6 +337,7 @@ export class HuiDialogEditView extends LitElement {
|
|||||||
if (ev.detail.visible && this._config) {
|
if (ev.detail.visible && this._config) {
|
||||||
this._config.visible = ev.detail.visible;
|
this._config.visible = ev.detail.visible;
|
||||||
}
|
}
|
||||||
|
this._dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _badgesChanged(ev: EntitiesEditorEvent): void {
|
private _badgesChanged(ev: EntitiesEditorEvent): void {
|
||||||
@ -334,6 +345,7 @@ export class HuiDialogEditView extends LitElement {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._badges = processEditorEntities(ev.detail.entities);
|
this._badges = processEditorEntities(ev.detail.entities);
|
||||||
|
this._dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _isConfigChanged(): boolean {
|
private _isConfigChanged(): boolean {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user