Fix schedule bug (#13521)

This commit is contained in:
Zack Barett 2022-08-30 20:45:00 -05:00 committed by GitHub
parent cb5621032d
commit c751b0b759
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -36,6 +36,7 @@ const defaultFullCalendarConfig: CalendarOptions = {
selectOverlap: false, selectOverlap: false,
eventOverlap: false, eventOverlap: false,
allDaySlot: false, allDaySlot: false,
slotMinTime: "00:00:59",
height: "parent", height: "parent",
locales: allLocales, locales: allLocales,
firstDay: 1, firstDay: 1,
@ -250,7 +251,7 @@ class HaScheduleForm extends LitElement {
value.push({ value.push({
from: formatTime24h(start), from: formatTime24h(start),
to: to:
isSameDay(start, end) || endFormatted === "0:00" !isSameDay(start, end) || endFormatted === "0:00"
? "24:00" ? "24:00"
: endFormatted, : endFormatted,
}); });
@ -261,7 +262,7 @@ class HaScheduleForm extends LitElement {
value: newValue, value: newValue,
}); });
if (isSameDay(start, end)) { if (!isSameDay(start, end)) {
this.calendar!.unselect(); this.calendar!.unselect();
} }
} }
@ -277,7 +278,7 @@ class HaScheduleForm extends LitElement {
newValue[day][index] = { newValue[day][index] = {
from: value.from, from: value.from,
to: to:
isSameDay(start, end) || endFormatted === "0:00" !isSameDay(start, end) || endFormatted === "0:00"
? "24:00" ? "24:00"
: endFormatted, : endFormatted,
}; };
@ -286,7 +287,7 @@ class HaScheduleForm extends LitElement {
value: newValue, value: newValue,
}); });
if (isSameDay(start, end)) { if (!isSameDay(start, end)) {
info.revert(); info.revert();
} }
} }
@ -302,7 +303,7 @@ class HaScheduleForm extends LitElement {
const event = { const event = {
from: formatTime24h(start), from: formatTime24h(start),
to: to:
isSameDay(start, end) || endFormatted === "0:00" !isSameDay(start, end) || endFormatted === "0:00"
? "24:00" ? "24:00"
: endFormatted, : endFormatted,
}; };
@ -320,7 +321,7 @@ class HaScheduleForm extends LitElement {
value: newValue, value: newValue,
}); });
if (isSameDay(start, end)) { if (!isSameDay(start, end)) {
info.revert(); info.revert();
} }
} }