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
No related branches found
No related tags found
1 merge request!464Resolve "Allow using time slot numbers in long term absences dialog (instead of datetimes)"
Pipeline #195665 failed
......@@ -186,16 +186,19 @@ export default {
getPeriodsForWeekday(weekday) {
// Adapt from python conventions
const pythonWeekday = weekday - 1;
return this.periodsByDay.find(
let periodsForWeekday = this.periodsByDay.find(
(period) => period.weekday === pythonWeekday,
).periods;
);
if (!periodsForWeekday) return false;
return periodsForWeekday.periods;
},
handleStartDate(date) {
this.start = DateTime.fromISO(date);
if (this.periodsByDay.length > 0) {
if (this.periodsByDay && this.periodsByDay.length > 0) {
// Select periods for day
this.startPeriods = this.getPeriodsForWeekday(this.start.weekday);
if (!this.startPeriods) return;
// Sync PeriodSelect
const startTime = this.start.toFormat("HH:mm:ss");
this.startSlot = this.startPeriods.find(
......@@ -206,9 +209,10 @@ export default {
handleEndDate(date) {
this.end = DateTime.fromISO(date);
if (this.periodsByDay.length > 0) {
if (this.periodsByDay && this.periodsByDay.length > 0) {
// Select periods for day
this.endPeriods = this.getPeriodsForWeekday(this.end.weekday);
if (!this.endPeriods) return;
// Sync PeriodSelect
const endTime = this.end.toFormat("HH:mm:ss");
this.endSlot = this.endPeriods.find(
......
......@@ -368,7 +368,9 @@ class Query(graphene.ObjectType):
Slot = apps.get_model("lesrooster", "Slot")
ValidityRange = apps.get_model("lesrooster", "ValidityRange")
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")
.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