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!)
|
deleteView(this.lovelace!.config, this.viewIndex!)
|
||||||
);
|
);
|
||||||
this._closeDialog();
|
this._closeDialog();
|
||||||
navigate(this, `/lovelace/0`);
|
navigate(this, `/${window.location.pathname.split("/")[1]}`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
showAlertDialog(this, {
|
showAlertDialog(this, {
|
||||||
text: `Deleting failed: ${err.message}`,
|
text: `Deleting failed: ${err.message}`,
|
||||||
|
@ -216,15 +216,21 @@ export class HuiEditView extends LitElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
private _deleteConfirm(): void {
|
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, {
|
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(),
|
confirm: () => this._delete(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1875,8 +1875,10 @@
|
||||||
"saving_failed": "Saving Lovelace UI configuration failed."
|
"saving_failed": "Saving Lovelace UI configuration failed."
|
||||||
},
|
},
|
||||||
"views": {
|
"views": {
|
||||||
"confirm_delete": "Are you sure you want to delete this view?",
|
"confirm_delete": "Delete view?",
|
||||||
"existing_cards": "You can't delete a view that has cards in it. Remove the cards first."
|
"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": {
|
"menu": {
|
||||||
"configure_ui": "Configure UI",
|
"configure_ui": "Configure UI",
|
||||||
|
|
Loading…
Reference in New Issue