From ac9654c1de2532b3fc375f0df0450953282bc628 Mon Sep 17 00:00:00 2001 From: Paul Bottein Date: Fri, 27 Sep 2024 11:19:19 +0200 Subject: [PATCH] Add heading card when creating a new view (#22123) --- .../editor/view-editor/hui-dialog-edit-view.ts | 14 +++++++++++++- src/panels/lovelace/views/hui-sections-view.ts | 4 +++- src/translations/en.json | 3 ++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/panels/lovelace/editor/view-editor/hui-dialog-edit-view.ts b/src/panels/lovelace/editor/view-editor/hui-dialog-edit-view.ts index a14e5b35a6..2d4c3c6bd3 100644 --- a/src/panels/lovelace/editor/view-editor/hui-dialog-edit-view.ts +++ b/src/panels/lovelace/editor/view-editor/hui-dialog-edit-view.ts @@ -379,7 +379,19 @@ export class HuiDialogEditView extends LitElement { }; if (viewConf.type === SECTION_VIEW_LAYOUT && !viewConf.sections?.length) { - viewConf.sections = [{ type: "grid", cards: [] }]; + viewConf.sections = [ + { + type: "grid", + cards: [ + { + type: "heading", + heading: this.hass!.localize( + "ui.panel.lovelace.editor.section.default_section_title" + ), + }, + ], + }, + ]; } else if (!viewConf.cards?.length) { viewConf.cards = []; } diff --git a/src/panels/lovelace/views/hui-sections-view.ts b/src/panels/lovelace/views/hui-sections-view.ts index 4e3c7e23bd..b04d433e0e 100644 --- a/src/panels/lovelace/views/hui-sections-view.ts +++ b/src/panels/lovelace/views/hui-sections-view.ts @@ -249,7 +249,9 @@ export class SectionsView extends LitElement implements LovelaceViewElement { cards: [ { type: "heading", - heading: "New Section", + heading: this.hass!.localize( + "ui.panel.lovelace.editor.section.default_section_title" + ), }, ], }); diff --git a/src/translations/en.json b/src/translations/en.json index c885fc97a0..ee8a3f1539 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -5669,7 +5669,8 @@ "section": { "add_badge": "Add badge", "add_card": "[%key:ui::panel::lovelace::editor::edit_card::add%]", - "create_section": "Create section" + "create_section": "Create section", + "default_section_title": "New section" }, "delete_section": { "title": "Delete section",