Ask confirmation before deleting a schedule item (#17158)

This commit is contained in:
Bram Kragten 2023-07-04 12:13:26 +02:00 committed by GitHub
parent 94808b75b3
commit 75b6b9cfd9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -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}`]];

View File

@ -1223,6 +1223,10 @@
"timer": {
"duration": "Duration",
"restore": "Restore?"
},
"schedule": {
"delete": "Delete item?",
"confirm_delete": "Do you want to delete this item?"
}
},
"options_flow": {