Add allow changing type of empty views (#19912)

This commit is contained in:
Paul Bottein 2024-02-28 21:51:21 +01:00 committed by GitHub
parent 9ef07484dd
commit 8f67ddf968
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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;
}
private get _isEmpty(): boolean {
return !this._config.sections?.length && !this._config.cards?.length;
}
protected render() {
if (!this.hass) {
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 = {
...this._config,
@ -165,7 +169,7 @@ export class HuiViewEditor extends LitElement {
"ui.panel.lovelace.editor.edit_view.subview_helper"
);
case "type":
if (this.isNew) return undefined;
if (this._isEmpty) return undefined;
return this._type === "sections"
? this.hass.localize(
"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"
},
"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.",
"types": {