From 75946731dfbb6525cfc0274367281c785b34d28a Mon Sep 17 00:00:00 2001 From: Johannes Date: Sun, 9 Jul 2023 15:26:58 +0200 Subject: [PATCH] ux: hide officeHourTable if it has no entries at all --- controllers/timetable.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/controllers/timetable.go b/controllers/timetable.go index 58267dd..cedc11c 100644 --- a/controllers/timetable.go +++ b/controllers/timetable.go @@ -51,6 +51,7 @@ func (b *BaseHandler) GetTimetable(officeHours []models.OfficeHour) (timetable m func (b *BaseHandler) printTimetable(timetable map[models.Date]map[int]models.OfficeHour, slots []int, deleteIcons bool) template.HTML { var tableBody string + var anyOfficeHourExists bool = false // do not show table if no entry in there for hour := 8; hour < 19; hour += 1 { for minute := 0; minute < 60; minute += b.config.Date.MinuteGranularity { tableBody += "" @@ -93,6 +94,7 @@ func (b *BaseHandler) printTimetable(timetable map[models.Date]map[int]models.Of // TODO: better error wrapping up to top-level request handler } tableBody += celldata.String() + anyOfficeHourExists = true } } else { if slot+1 == slots[day] { @@ -106,6 +108,9 @@ func (b *BaseHandler) printTimetable(timetable map[models.Date]map[int]models.Of tableBody += "\n" } } + if !anyOfficeHourExists { + return template.HTML("

Aktuell sind keine passenden Sprechstunden eingetragen.

") + } var table bytes.Buffer tableData := struct {