Skip to content

Commit

Permalink
Add allow changing type of empty views (#19912)
Browse files Browse the repository at this point in the history
  • Loading branch information
piitaya authored Feb 28, 2024
1 parent 9ef0748 commit 8f67ddf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/panels/lovelace/editor/view-editor/hui-view-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down

0 comments on commit 8f67ddf

Please sign in to comment.