mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 09:46:36 +00:00
Add a destructive confirmation when deleting a picture-elements element (#21541)
This commit is contained in:
parent
6dc80306e8
commit
5e75f6a6c2
@ -8,6 +8,7 @@ import "../../../components/ha-svg-icon";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
import "../../../components/ha-select";
|
||||
import type { HaSelect } from "../../../components/ha-select";
|
||||
import { showConfirmationDialog } from "../../../dialogs/generic/show-dialog-box";
|
||||
import {
|
||||
ConditionalElementConfig,
|
||||
IconElementConfig,
|
||||
@ -77,7 +78,7 @@ export class HuiPictureElementsCardRowEditor extends LitElement {
|
||||
`
|
||||
: nothing}
|
||||
<ha-icon-button
|
||||
.label=${this.hass!.localize("ui.common.clear")}
|
||||
.label=${this.hass!.localize("ui.common.delete")}
|
||||
.path=${mdiClose}
|
||||
class="remove-icon"
|
||||
.index=${index}
|
||||
@ -187,11 +188,28 @@ export class HuiPictureElementsCardRowEditor extends LitElement {
|
||||
|
||||
private _removeRow(ev: CustomEvent): void {
|
||||
const index = (ev.currentTarget as any).index;
|
||||
const newElements = this.elements!.concat();
|
||||
|
||||
newElements.splice(index, 1);
|
||||
|
||||
fireEvent(this, "elements-changed", { elements: newElements });
|
||||
const element = this.elements?.[index];
|
||||
if (!element) {
|
||||
return;
|
||||
}
|
||||
showConfirmationDialog(this, {
|
||||
text: this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.card.picture-elements.confirm_delete_element",
|
||||
{
|
||||
type:
|
||||
this.hass!.localize(
|
||||
`ui.panel.lovelace.editor.card.picture-elements.element_types.${element.type}`
|
||||
) || element.type,
|
||||
}
|
||||
),
|
||||
confirmText: this.hass!.localize("ui.common.delete"),
|
||||
destructive: true,
|
||||
confirm: () => {
|
||||
const newElements = this.elements!.concat();
|
||||
newElements.splice(index, 1);
|
||||
fireEvent(this, "elements-changed", { elements: newElements });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
private _editRow(ev: CustomEvent): void {
|
||||
|
@ -5990,6 +5990,7 @@
|
||||
"card_options": "Card Options",
|
||||
"elements": "Elements",
|
||||
"new_element": "Add new element",
|
||||
"confirm_delete_element": "Are you sure you want to delete the {type} element?",
|
||||
"dark_mode_image": "Dark mode image path",
|
||||
"state_filter": "State filter",
|
||||
"dark_mode_filter": "Dark mode state filter",
|
||||
|
Loading…
x
Reference in New Issue
Block a user