From 7c45ef6112f28e8eab2ecc417ce95118f2a674aa Mon Sep 17 00:00:00 2001
From: tom_trgr
Date: Sun, 4 Jan 2026 23:30:09 +0100
Subject: [PATCH] minor fixes in pdf generator + new booking input select
---
Backend/endpoints/pdf-create.go | 6 +-
Backend/static/script.js | 35 +++++++---
Backend/templates/timePage.templ | 26 +++++---
Backend/templates/timePage_templ.go | 99 +++++++++++++++++++----------
4 files changed, 113 insertions(+), 53 deletions(-)
diff --git a/Backend/endpoints/pdf-create.go b/Backend/endpoints/pdf-create.go
index 0ba4697..2557c0f 100644
--- a/Backend/endpoints/pdf-create.go
+++ b/Backend/endpoints/pdf-create.go
@@ -51,7 +51,11 @@ func convertDayToTypstDayParts(day models.IWorkDay, user models.User) []typstDay
for i := 0; i < len(workDay.Bookings); i += 2 {
var typstDayPart typstDayPart
typstDayPart.BookingFrom = workDay.Bookings[i].Timestamp.Format("15:04")
- typstDayPart.BookingTo = workDay.Bookings[i+1].Timestamp.Format("15:04")
+ if i+1 < len(workDay.Bookings) {
+ typstDayPart.BookingTo = workDay.Bookings[i+1].Timestamp.Format("15:04")
+ } else {
+ typstDayPart.BookingTo = workDay.Bookings[i].Timestamp.Format("15:04")
+ }
typstDayPart.WorkType = workDay.Bookings[i].BookingType.Name
typstDayPart.IsWorkDay = true
typstDayParts = append(typstDayParts, typstDayPart)
diff --git a/Backend/static/script.js b/Backend/static/script.js
index a47b0ce..c54487d 100644
--- a/Backend/static/script.js
+++ b/Backend/static/script.js
@@ -15,7 +15,9 @@ function editWorkday(element, event, id, isWorkDay) {
event.preventDefault();
let form = document.getElementById(id);
if (form == null) {
- form = element.closest(".grid-sub").querySelector(".all-booking-component > form");
+ form = element
+ .closest(".grid-sub")
+ .querySelector(".all-booking-component > form");
}
clearEditState();
@@ -37,10 +39,21 @@ function editWorkday(element, event, id, isWorkDay) {
const absenceForm = document.getElementById("absence_form");
if (id == 0) {
- absenceForm.querySelector("[name=date_from]").value = form.id.replace("time-", "");
- absenceForm.querySelector("[name=date_to]").value = form.id.replace("time-", "");
+ absenceForm.querySelector("[name=date_from]").value = form.id.replace(
+ "time-",
+ "",
+ );
+ absenceForm.querySelector("[name=date_to]").value = form.id.replace(
+ "time-",
+ "",
+ );
} else {
- syncFields(form, absenceForm, ["date_from", "date_to", "aw_type", "aw_id"]);
+ syncFields(form, absenceForm, [
+ "date_from",
+ "date_to",
+ "aw_type",
+ "aw_id",
+ ]);
}
}
}
@@ -49,11 +62,6 @@ function toggleAbsenceEdit(state) {
const form = document.getElementById("absence_form");
if (state) {
form.classList.remove("hidden");
- form.scrollIntoView({
- behavior: "smooth",
- block: "start",
- inline: "nearest",
- });
} else {
form.classList.add("hidden");
}
@@ -85,3 +93,12 @@ function checkAll(pattern, state) {
input.checked = state;
}
}
+
+bookingForms = document.querySelectorAll("form.bookings");
+for (form of bookingForms) {
+ let selectKommenInput = form.querySelector("input[name='select_kommen']");
+ let kommenGehenSelector = form.querySelector("select");
+ if (selectKommenInput) {
+ kommenGehenSelector.value = selectKommenInput.value == "true" ? 3 : 4;
+ }
+}
diff --git a/Backend/templates/timePage.templ b/Backend/templates/timePage.templ
index 6bc1d42..3dc9f03 100644
--- a/Backend/templates/timePage.templ
+++ b/Backend/templates/timePage.templ
@@ -127,10 +127,14 @@ templ defaultDayComponent(day models.IWorkDay) {
@lineComponent()
-
@@ -160,12 +164,14 @@ templ timeDayTypeSwitch(day models.IWorkDay, fromCompound bool) {
templ workdayComponent(workDay *models.WorkDay) {
if len(workDay.Bookings) < 1 {
Keine Buchung gefunden. Bitte Arbeitsstunden oder Grund der Abwesenheit eingeben!
- }
- if workDay.IsKurzArbeit() && len(workDay.Bookings) > 0 {
- @absenceComponent(workDay.GetKurzArbeit(), true)
- }
- for _, booking := range workDay.Bookings {
- @bookingComponent(booking)
+ } else {
+ if workDay.IsKurzArbeit() && len(workDay.Bookings) > 0 {
+ @absenceComponent(workDay.GetKurzArbeit(), true)
+ }
+ for _, booking := range workDay.Bookings {
+ @bookingComponent(booking)
+ }
+ 0 && workDay.Bookings[len(workDay.Bookings)-1].CheckInOut%2 == 0 }/>
}
}
diff --git a/Backend/templates/timePage_templ.go b/Backend/templates/timePage_templ.go
index 09cc9a6..5f55e8d 100644
--- a/Backend/templates/timePage_templ.go
+++ b/Backend/templates/timePage_templ.go
@@ -375,7 +375,7 @@ func defaultDayComponent(day models.IWorkDay) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- var templ_7745c5c3_Var17 = []any{"flex flex-col gap-2 w-full", justify}
+ var templ_7745c5c3_Var17 = []any{"bookings flex flex-col gap-2 w-full", justify}
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var17...)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
@@ -410,19 +410,34 @@ func defaultDayComponent(day models.IWorkDay) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- templ_7745c5c3_Err = newAbsenceComponent().Render(ctx, templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
+ if day.GetDayProgress(user) < 100 || day.IsWorkDay() {
+ templ_7745c5c3_Err = newAbsenceComponent().Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, " ")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = timeDayTypeSwitch(day, true).Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, " ")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = newBookingComponent(day).Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ } else {
+ templ_7745c5c3_Err = timeDayTypeSwitch(day, true).Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
}
- templ_7745c5c3_Err = timeDayTypeSwitch(day, true).Render(ctx, templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = newBookingComponent(day).Render(ctx, templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, "")
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, "
")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -430,7 +445,7 @@ func defaultDayComponent(day models.IWorkDay) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, "
")
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, "")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -480,20 +495,20 @@ func timeDayTypeSwitch(day models.IWorkDay, fromCompound bool) templ.Component {
}
}
default:
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, "")
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, "
")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var21 string
templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(day.ToString())
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 156, Col: 22}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 160, Col: 22}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, "
")
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 38, "
")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -524,19 +539,37 @@ func workdayComponent(workDay *models.WorkDay) templ.Component {
}
ctx = templ.ClearChildren(ctx)
if len(workDay.Bookings) < 1 {
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, "Keine Buchung gefunden. Bitte Arbeitsstunden oder Grund der Abwesenheit eingeben!
")
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, "Keine Buchung gefunden. Bitte Arbeitsstunden oder Grund der Abwesenheit eingeben!
")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- }
- if workDay.IsKurzArbeit() && len(workDay.Bookings) > 0 {
- templ_7745c5c3_Err = absenceComponent(workDay.GetKurzArbeit(), true).Render(ctx, templ_7745c5c3_Buffer)
+ } else {
+ if workDay.IsKurzArbeit() && len(workDay.Bookings) > 0 {
+ templ_7745c5c3_Err = absenceComponent(workDay.GetKurzArbeit(), true).Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ }
+ for _, booking := range workDay.Bookings {
+ templ_7745c5c3_Err = bookingComponent(booking).Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ }
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 40, " 0 && workDay.Bookings[len(workDay.Bookings)-1].CheckInOut%2 == 0)
+ if templ_7745c5c3_Err != nil {
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 174, Col: 140}
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23))
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 41, "\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -561,25 +594,25 @@ func holidayComponent(d models.IWorkDay) templ.Component {
}()
}
ctx = templ.InitializeContext(ctx)
- templ_7745c5c3_Var23 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var23 == nil {
- templ_7745c5c3_Var23 = templ.NopComponent
+ templ_7745c5c3_Var24 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var24 == nil {
+ templ_7745c5c3_Var24 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 38, "")
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 42, "
")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- var templ_7745c5c3_Var24 string
- templ_7745c5c3_Var24, templ_7745c5c3_Err = templ.JoinStringErrs(d.ToString())
+ var templ_7745c5c3_Var25 string
+ templ_7745c5c3_Var25, templ_7745c5c3_Err = templ.JoinStringErrs(d.ToString())
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 173, Col: 18}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 179, Col: 18}
}
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var24))
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var25))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, "
")
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 43, "")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}