working compound days + working public holidays
Some checks failed
Tests / Run Go Tests (push) Failing after 44s

This commit is contained in:
2025-12-24 01:38:16 +01:00
parent 3439fff841
commit 855cd6f34f
20 changed files with 1180 additions and 616 deletions

View File

@@ -87,7 +87,7 @@ templ defaultDayComponent(day models.IWorkDay) {
{{
user := ctx.Value("user").(models.User)
justify := "justify-center"
if day.IsWorkDay() && len(day.(*models.WorkDay).Bookings) > 1 {
if day.IsWorkDay() && !day.IsEmpty() {
justify = "justify-between"
}
}}
@@ -100,9 +100,8 @@ templ defaultDayComponent(day models.IWorkDay) {
</p>
if day.IsWorkDay() {
{{
workDay, _ := day.(*models.WorkDay)
work, pause, overtime := workDay.GetTimes(user, models.WorktimeBaseDay, true)
work = workDay.GetWorktime(user, models.WorktimeBaseDay, false)
work, pause, overtime := day.GetTimes(user, models.WorktimeBaseDay, true)
work = day.GetWorktime(user, models.WorktimeBaseDay, false)
}}
if day.RequiresAction() {
<p class="text-red-600">Bitte anpassen</p>
@@ -114,7 +113,7 @@ templ defaultDayComponent(day models.IWorkDay) {
if pause > 0 {
<p class="text-neutral-500 flex flex-row items-center"><span class="icon-[material-symbols-light--motion-photos-paused-outline]"></span>{ helper.FormatDuration(pause) }</p>
}
if overtime != 0 && len(workDay.Bookings) > 0 {
if overtime != 0 && day.IsEmpty() == false {
<p class="text-neutral-500 flex flex-row items-center">
<span class="icon-[material-symbols-light--more-time]"></span>
{ helper.FormatDuration(overtime) }
@@ -130,20 +129,25 @@ templ defaultDayComponent(day models.IWorkDay) {
switch day.Type() {
case models.DayTypeWorkday:
{{ workDay, _ := day.(*models.WorkDay) }}
@workdayComponent(workDay)
@newAbsenceComponent()
if len(workDay.Bookings) < 1 {
<p class="text group-[.edit]:hidden">Keine Buchung gefunden. Bitte Arbeitsstunden oder Grund der Abwesenheit eingeben!</p>
}
if workDay.IsKurzArbeit() && len(workDay.Bookings) > 0 {
@absenceComponent(workDay.GetKurzArbeit(), true)
}
for _, booking := range workDay.Bookings {
@bookingComponent(booking)
}
@newBookingComponent(workDay)
case models.DayTypeAbsence:
{{ absentDay, _ := day.(*models.Absence) }}
@absenceComponent(absentDay, false)
case models.DayTypeCompound:
for _, c := range day.(*models.CompoundDay).DayParts {
switch c.Type() {
case models.DayTypeWorkday:
{{ workDay, _ := c.(*models.WorkDay) }}
@workdayComponent(workDay)
@newAbsenceComponent()
case models.DayTypeAbsence:
{{ absentDay, _ := c.(*models.Absence) }}
@absenceComponent(absentDay, false)
default:
<p>{ c.ToString() }</p>
}
}
default:
<p>{ day.ToString() }</p>
}
@@ -156,9 +160,19 @@ templ defaultDayComponent(day models.IWorkDay) {
</div>
}
templ absentInput(a models.Absence) {
<input type="hidden" name="date_from" value={ a.DateFrom.Format(time.DateOnly) }/>
<input type="hidden" name="date_to" value={ a.DateTo.Format(time.DateOnly) }/>
<input type="hidden" name="aw_type" value={ a.AbwesenheitTyp.Id }/>
<input type="hidden" name="aw_id" value={ a.CounterId }/>
templ workdayComponent(workDay *models.WorkDay) {
if len(workDay.Bookings) < 1 {
<p class="text group-[.edit]:hidden">Keine Buchung gefunden. Bitte Arbeitsstunden oder Grund der Abwesenheit eingeben!</p>
}
if workDay.IsKurzArbeit() && len(workDay.Bookings) > 0 {
@absenceComponent(workDay.GetKurzArbeit(), true)
}
for _, booking := range workDay.Bookings {
@bookingComponent(booking)
}
@newBookingComponent(workDay)
}
templ holidayComponent(d models.IWorkDay) {
<p>{ d.ToString() }</p>
}