Speichere Konfiguration in config/config.json
This commit is contained in:
parent
43b3631da2
commit
c38286bcc5
14 changed files with 249 additions and 78 deletions
|
@ -8,11 +8,11 @@ import (
|
|||
"sprechstundentool/models"
|
||||
)
|
||||
|
||||
func GetTimetable(officeHours []models.OfficeHour) (timetable map[models.Date]map[int]models.OfficeHour, slots []int) {
|
||||
func (b *BaseHandler) GetTimetable(officeHours []models.OfficeHour) (timetable map[models.Date]map[int]models.OfficeHour, slots []int) {
|
||||
var fullTimetable = make(map[models.Date]map[int]models.OfficeHour)
|
||||
for _, officeHour := range officeHours {
|
||||
var slot int = 0
|
||||
for minute := 0; minute < officeHour.Duration; minute += models.MinuteGranularity { // find slot id
|
||||
for minute := 0; minute < officeHour.Duration; minute += b.config.Date.MinuteGranularity { // find slot id
|
||||
_, exists := fullTimetable[models.GetEndDate(officeHour.Date, minute, true)]
|
||||
if exists {
|
||||
_, exists := fullTimetable[models.GetEndDate(officeHour.Date, minute, true)][slot]
|
||||
|
@ -25,7 +25,7 @@ func GetTimetable(officeHours []models.OfficeHour) (timetable map[models.Date]ma
|
|||
fullTimetable[models.GetEndDate(officeHour.Date, minute, true)] = make(map[int]models.OfficeHour)
|
||||
}
|
||||
}
|
||||
for minute := 0; minute < officeHour.Duration; minute += models.MinuteGranularity { // write officeHour id to timetable
|
||||
for minute := 0; minute < officeHour.Duration; minute += b.config.Date.MinuteGranularity { // write officeHour id to timetable
|
||||
fullTimetable[models.GetEndDate(officeHour.Date, minute, true)][slot] = officeHour
|
||||
}
|
||||
}
|
||||
|
@ -47,10 +47,10 @@ func GetTimetable(officeHours []models.OfficeHour) (timetable map[models.Date]ma
|
|||
return fullTimetable, slots
|
||||
}
|
||||
|
||||
func printTimetable(timetable map[models.Date]map[int]models.OfficeHour, slots []int, deleteIcons bool) template.HTML {
|
||||
func (b *BaseHandler) printTimetable(timetable map[models.Date]map[int]models.OfficeHour, slots []int, deleteIcons bool) template.HTML {
|
||||
var tableBody string
|
||||
for hour := 8; hour < 19; hour += 1 {
|
||||
for minute := 0; minute < 60; minute += models.MinuteGranularity {
|
||||
for minute := 0; minute < 60; minute += b.config.Date.MinuteGranularity {
|
||||
tableBody += "<tr>"
|
||||
if minute == 0 {
|
||||
tableBody += fmt.Sprintf("<td>%d Uhr</td>\n", hour)
|
||||
|
@ -65,10 +65,10 @@ func printTimetable(timetable map[models.Date]map[int]models.OfficeHour, slots [
|
|||
var continued bool = false // is this slot occupied by the same office hour the previous minute?
|
||||
var predecessorExists bool
|
||||
var predecessor models.OfficeHour
|
||||
if hour > 0 && minute < models.MinuteGranularity {
|
||||
predecessor, predecessorExists = timetable[models.Date{0, day, hour - 1, 60 - models.MinuteGranularity}][slot]
|
||||
if hour > 0 && minute < b.config.Date.MinuteGranularity {
|
||||
predecessor, predecessorExists = timetable[models.Date{0, day, hour - 1, 60 - b.config.Date.MinuteGranularity}][slot]
|
||||
} else {
|
||||
predecessor, predecessorExists = timetable[models.Date{0, day, hour, minute - models.MinuteGranularity}][slot]
|
||||
predecessor, predecessorExists = timetable[models.Date{0, day, hour, minute - b.config.Date.MinuteGranularity}][slot]
|
||||
}
|
||||
if predecessorExists {
|
||||
continued = (predecessor == current)
|
||||
|
@ -83,7 +83,7 @@ func printTimetable(timetable map[models.Date]map[int]models.OfficeHour, slots [
|
|||
OfficeHour models.OfficeHour
|
||||
MinuteGranularity int
|
||||
DeleteIcons bool
|
||||
}{current, models.MinuteGranularity, deleteIcons}
|
||||
}{current, b.config.Date.MinuteGranularity, deleteIcons}
|
||||
Templates.ExecuteTemplate(&celldata, "td.html", data)
|
||||
tableBody += celldata.String()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue