mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-19 10:57:19 +00:00
Fix navigation after deleting a view and allow deleting view with cards (#5085)
* Fix navigation after deleting a view * Allow deleting views with cards
This commit is contained in:
parent
503dec7345
commit
9e07cf67a5
@ -207,7 +207,7 @@ export class HuiEditView extends LitElement {
|
||||
deleteView(this.lovelace!.config, this.viewIndex!)
|
||||
);
|
||||
this._closeDialog();
|
||||
navigate(this, `/lovelace/0`);
|
||||
navigate(this, `/${window.location.pathname.split("/")[1]}`);
|
||||
} catch (err) {
|
||||
showAlertDialog(this, {
|
||||
text: `Deleting failed: ${err.message}`,
|
||||
@ -216,15 +216,21 @@ export class HuiEditView extends LitElement {
|
||||
}
|
||||
|
||||
private _deleteConfirm(): void {
|
||||
if (this._cards && this._cards.length > 0) {
|
||||
showAlertDialog(this, {
|
||||
text: this.hass!.localize("ui.panel.lovelace.views.existing_cards"),
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
showConfirmationDialog(this, {
|
||||
text: this.hass!.localize("ui.panel.lovelace.views.confirm_delete"),
|
||||
title: this.hass!.localize(
|
||||
`ui.panel.lovelace.views.confirm_delete${
|
||||
this._cards?.length ? `_existing_cards` : ""
|
||||
}`
|
||||
),
|
||||
text: this.hass!.localize(
|
||||
`ui.panel.lovelace.views.confirm_delete${
|
||||
this._cards?.length ? `_existing_cards` : ""
|
||||
}_text`,
|
||||
"name",
|
||||
this._config?.title || "Unnamed view",
|
||||
"number",
|
||||
this._cards?.length || 0
|
||||
),
|
||||
confirm: () => this._delete(),
|
||||
});
|
||||
}
|
||||
|
@ -1875,8 +1875,10 @@
|
||||
"saving_failed": "Saving Lovelace UI configuration failed."
|
||||
},
|
||||
"views": {
|
||||
"confirm_delete": "Are you sure you want to delete this view?",
|
||||
"existing_cards": "You can't delete a view that has cards in it. Remove the cards first."
|
||||
"confirm_delete": "Delete view?",
|
||||
"confirm_delete_text": "Are you sure you want to delete your '{name}' view?",
|
||||
"confirm_delete_existing_cards": "Deleting this view will also remove the cards",
|
||||
"confirm_delete_existing_cards_text": "Are you sure you want to delete your '{name}' view? The view contains {number} cards that will be deleted. This action cannot be undone."
|
||||
},
|
||||
"menu": {
|
||||
"configure_ui": "Configure UI",
|
||||
|
Loading…
x
Reference in New Issue
Block a user