mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 09:46:36 +00:00
Set initial calendar event date based on active calendar view (#14516)
This commit is contained in:
parent
00274ebf66
commit
96080f3c78
@ -73,7 +73,11 @@ class DialogCalendarEventEditor extends LitElement {
|
||||
}
|
||||
} else {
|
||||
this._allDay = false;
|
||||
this._dtstart = startOfHour(new Date());
|
||||
// If we have been provided a selected date (e.g. based on the currently displayed
|
||||
// day in a calendar view), use that as the starting value.
|
||||
this._dtstart = startOfHour(
|
||||
params.selectedDate ? params.selectedDate : new Date()
|
||||
);
|
||||
this._dtend = addHours(this._dtstart, 1);
|
||||
}
|
||||
}
|
||||
|
@ -276,8 +276,19 @@ export class HAFullCalendar extends LitElement {
|
||||
}
|
||||
|
||||
private _createEvent(_info) {
|
||||
// Logic for selectedDate: In week and day view, use the start of the week or the selected day.
|
||||
// If we are in month view, we only use the start of the month, if we are not showing the
|
||||
// current actual month, as for that one the current day is automatically highlighted and
|
||||
// defaulting to a different day in the event creation dialog would be weird.
|
||||
showCalendarEventEditDialog(this, {
|
||||
calendars: this._mutableCalendars,
|
||||
selectedDate:
|
||||
this._activeView === "dayGridWeek" ||
|
||||
this._activeView === "dayGridDay" ||
|
||||
(this._activeView === "dayGridMonth" &&
|
||||
this.calendar!.view.currentStart.getMonth() !== new Date().getMonth())
|
||||
? this.calendar!.view.currentStart
|
||||
: undefined,
|
||||
updated: () => {
|
||||
this._fireViewChanged();
|
||||
},
|
||||
|
@ -2,7 +2,7 @@ import { fireEvent } from "../../common/dom/fire_event";
|
||||
import { Calendar, CalendarEventData } from "../../data/calendar";
|
||||
|
||||
export interface CalendarEventDetailDialogParams {
|
||||
calendars: Calendar[]; // When creating new events, is the list of events that support creation
|
||||
calendars: Calendar[]; // When creating new events, is the list of calendar entities that support creation
|
||||
calendarId?: string;
|
||||
entry?: CalendarEventData;
|
||||
canDelete?: boolean;
|
||||
|
@ -2,8 +2,9 @@ import { fireEvent } from "../../common/dom/fire_event";
|
||||
import { Calendar, CalendarEventData } from "../../data/calendar";
|
||||
|
||||
export interface CalendarEventEditDialogParams {
|
||||
calendars: Calendar[]; // When creating new events, is the list of events that support creation
|
||||
calendars: Calendar[]; // When creating new events, is the list of calendar entities that support creation
|
||||
calendarId?: string;
|
||||
selectedDate?: Date; // When provided is used as the pre-filled date for the event creation dialog
|
||||
entry?: CalendarEventData;
|
||||
canDelete?: boolean;
|
||||
updated: () => void;
|
||||
|
Loading…
x
Reference in New Issue
Block a user