mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-13 13:00:24 +00:00
Allow to clear due date (#19201)
This commit is contained in:
@@ -50,6 +50,15 @@ export class HaDialogDatePicker extends LitElement {
|
||||
@datepicker-value-updated=${this._valueChanged}
|
||||
.firstDayOfWeek=${this._params.firstWeekday}
|
||||
></app-datepicker>
|
||||
${this._params.canClear
|
||||
? html`<mwc-button
|
||||
slot="secondaryAction"
|
||||
@click=${this._clear}
|
||||
class="warning"
|
||||
>
|
||||
${this.hass.localize("ui.dialogs.date-picker.clear")}
|
||||
</mwc-button>`
|
||||
: nothing}
|
||||
<mwc-button slot="secondaryAction" @click=${this._setToday}>
|
||||
${this.hass.localize("ui.dialogs.date-picker.today")}
|
||||
</mwc-button>
|
||||
@@ -66,6 +75,11 @@ export class HaDialogDatePicker extends LitElement {
|
||||
this._value = ev.detail.value;
|
||||
}
|
||||
|
||||
private _clear() {
|
||||
this._params?.onChange(undefined);
|
||||
this.closeDialog();
|
||||
}
|
||||
|
||||
private _setToday() {
|
||||
const today = new Date();
|
||||
this._value = format(today, "yyyy-MM-dd");
|
||||
|
||||
Reference in New Issue
Block a user