Skip to content
Snippets Groups Projects
Verified Commit 59e51290 authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Add fixes to slot select

parent 1cf488b1
1 merge request!464Resolve "Allow using time slot numbers in long term absences dialog (instead of datetimes)"
Checking pipeline status
...@@ -186,16 +186,19 @@ export default { ...@@ -186,16 +186,19 @@ export default {
getPeriodsForWeekday(weekday) { getPeriodsForWeekday(weekday) {
// Adapt from python conventions // Adapt from python conventions
const pythonWeekday = weekday - 1; const pythonWeekday = weekday - 1;
return this.periodsByDay.find( let periodsForWeekday = this.periodsByDay.find(
(period) => period.weekday === pythonWeekday, (period) => period.weekday === pythonWeekday,
).periods; );
if (!periodsForWeekday) return false;
return periodsForWeekday.periods;
}, },
handleStartDate(date) { handleStartDate(date) {
this.start = DateTime.fromISO(date); this.start = DateTime.fromISO(date);
if (this.periodsByDay.length > 0) { if (this.periodsByDay && this.periodsByDay.length > 0) {
// Select periods for day // Select periods for day
this.startPeriods = this.getPeriodsForWeekday(this.start.weekday); this.startPeriods = this.getPeriodsForWeekday(this.start.weekday);
if (!this.startPeriods) return;
// Sync PeriodSelect // Sync PeriodSelect
const startTime = this.start.toFormat("HH:mm:ss"); const startTime = this.start.toFormat("HH:mm:ss");
this.startSlot = this.startPeriods.find( this.startSlot = this.startPeriods.find(
...@@ -206,9 +209,10 @@ export default { ...@@ -206,9 +209,10 @@ export default {
handleEndDate(date) { handleEndDate(date) {
this.end = DateTime.fromISO(date); this.end = DateTime.fromISO(date);
if (this.periodsByDay.length > 0) { if (this.periodsByDay && this.periodsByDay.length > 0) {
// Select periods for day // Select periods for day
this.endPeriods = this.getPeriodsForWeekday(this.end.weekday); this.endPeriods = this.getPeriodsForWeekday(this.end.weekday);
if (!this.endPeriods) return;
// Sync PeriodSelect // Sync PeriodSelect
const endTime = this.end.toFormat("HH:mm:ss"); const endTime = this.end.toFormat("HH:mm:ss");
this.endSlot = this.endPeriods.find( this.endSlot = this.endPeriods.find(
......
...@@ -368,7 +368,9 @@ class Query(graphene.ObjectType): ...@@ -368,7 +368,9 @@ class Query(graphene.ObjectType):
Slot = apps.get_model("lesrooster", "Slot") Slot = apps.get_model("lesrooster", "Slot")
ValidityRange = apps.get_model("lesrooster", "ValidityRange") ValidityRange = apps.get_model("lesrooster", "ValidityRange")
slots = ( slots = (
Slot.objects.filter(time_grid__validity_range=ValidityRange.current) Slot.objects.filter(
time_grid__validity_range=ValidityRange.current, period__isnull=False
)
.order_by("weekday") .order_by("weekday")
.values("weekday", "period", "time_start", "time_end") .values("weekday", "period", "time_start", "time_end")
) )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment