Add allow changing type of empty views (#19912)

pull/20210/head^2
Paul Bottein 2024-02-28 21:51:21 +01:00 committed by Bram Kragten
parent 7475cb56a1
commit 962912c43c
2 changed files with 7 additions and 3 deletions

View File

@ -95,12 +95,16 @@ export class HuiViewEditor extends LitElement {
: this._config.type || DEFAULT_VIEW_LAYOUT; : this._config.type || DEFAULT_VIEW_LAYOUT;
} }
private get _isEmpty(): boolean {
return !this._config.sections?.length && !this._config.cards?.length;
}
protected render() { protected render() {
if (!this.hass) { if (!this.hass) {
return nothing; return nothing;
} }
const schema = this._schema(this.hass.localize, this._type, this.isNew); const schema = this._schema(this.hass.localize, this._type, this._isEmpty);
const data = { const data = {
...this._config, ...this._config,
@ -165,7 +169,7 @@ export class HuiViewEditor extends LitElement {
"ui.panel.lovelace.editor.edit_view.subview_helper" "ui.panel.lovelace.editor.edit_view.subview_helper"
); );
case "type": case "type":
if (this.isNew) return undefined; if (this._isEmpty) return undefined;
return this._type === "sections" return this._type === "sections"
? this.hass.localize( ? this.hass.localize(
"ui.panel.lovelace.editor.edit_view.type_helper_others" "ui.panel.lovelace.editor.edit_view.type_helper_others"

View File

@ -5112,7 +5112,7 @@
"select_users": "Select which users should see this view in the navigation" "select_users": "Select which users should see this view in the navigation"
}, },
"type": "View type", "type": "View type",
"type_helper_sections": "You can not change your view to use the 'sections' view type, because migration is not supported yet. Start from scratch with a new view if you want to experiment with the 'sections' view.", "type_helper_sections": "You can not change your view to use the 'sections' view type because migration is not supported yet. Start from scratch with a new view if you want to experiment with the 'sections' view.",
"type_helper_others": "You can not change your view to an other type because migration is not supported yet. Start from scratch with a new view if you want to use another view type.", "type_helper_others": "You can not change your view to an other type because migration is not supported yet. Start from scratch with a new view if you want to use another view type.",
"types": { "types": {