From 75b6b9cfd97421eeba28bff48f25d59a6ff1b775 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Tue, 4 Jul 2023 12:13:26 +0200 Subject: [PATCH] Ask confirmation before deleting a schedule item (#17158) --- .../config/helpers/forms/ha-schedule-form.ts | 15 ++++++++++++++- src/translations/en.json | 4 ++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/panels/config/helpers/forms/ha-schedule-form.ts b/src/panels/config/helpers/forms/ha-schedule-form.ts index 52c5dcf278..dbb0b92596 100644 --- a/src/panels/config/helpers/forms/ha-schedule-form.ts +++ b/src/panels/config/helpers/forms/ha-schedule-form.ts @@ -23,6 +23,7 @@ import { Schedule, ScheduleDay, weekdays } from "../../../../data/schedule"; import { haStyle } from "../../../../resources/styles"; import { HomeAssistant } from "../../../../types"; import { loadPolyfillIfNeeded } from "../../../../resources/resize-observer.polyfill"; +import { showConfirmationDialog } from "../../../../dialogs/generic/show-dialog-box"; const defaultFullCalendarConfig: CalendarOptions = { plugins: [timeGridPlugin, interactionPlugin], @@ -365,7 +366,19 @@ class HaScheduleForm extends LitElement { } } - private _handleEventClick(info: any) { + private async _handleEventClick(info: any) { + if ( + !(await showConfirmationDialog(this, { + title: this.hass.localize("ui.dialogs.helper_settings.schedule.delete"), + text: this.hass.localize( + "ui.dialogs.helper_settings.schedule.confirm_delete" + ), + destructive: true, + confirmText: this.hass.localize("ui.common.delete"), + })) + ) { + return; + } const [day, index] = info.event.id.split("-"); const value = [...this[`_${day}`]]; diff --git a/src/translations/en.json b/src/translations/en.json index 19b0fa9956..2be6dbba16 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -1223,6 +1223,10 @@ "timer": { "duration": "Duration", "restore": "Restore?" + }, + "schedule": { + "delete": "Delete item?", + "confirm_delete": "Do you want to delete this item?" } }, "options_flow": {