This commit is contained in:
@@ -37,11 +37,40 @@ templ inputForm() {
|
||||
</div>
|
||||
}
|
||||
|
||||
templ dayComponent(workDay models.WorkDay, submitted bool) {
|
||||
templ defaultDayComponent(day models.IWorkDay) {
|
||||
if day.IsWorkDay() {
|
||||
{{
|
||||
workDay, _ := day.(*models.WorkDay)
|
||||
}}
|
||||
@workDayComponent(*workDay, false)
|
||||
} else {
|
||||
{{
|
||||
absentDay, _ := day.(*models.Absence)
|
||||
}}
|
||||
<div class={ "grid-sub divide-x-1 hover:bg-neutral-200 transition-colors" }>
|
||||
<div class="grid-cell md:col-span-1 flex flex-row gap-2">
|
||||
@timeGaugeComponent(100, false)
|
||||
<p><span class="font-bold uppercase hidden md:inline">{ day.Date().Format("Mon") }:</span> { day.Date().Format("02.01.2006") }</p>
|
||||
</div>
|
||||
<div class="grid-cell flex flex-row md:col-span-3 gap-2 w-full">
|
||||
@lineComponent()
|
||||
<div class="flex flex-col gap-2 group w-full justify-center">
|
||||
<p>{ absentDay.AbwesenheitTyp.Name } <span class="text-neutral-700">bis { absentDay.DateTo.Format("02.01.2006") }</span></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid-cell">
|
||||
@changeButtonComponent("time-" + absentDay.Date().Format("2006-01-02"))
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
templ workDayComponent(workDay models.WorkDay, submitted bool) {
|
||||
{{
|
||||
work, pause := workDay.GetWorkTimeString()
|
||||
// work, pause := workDay.GetWorkTimeString()
|
||||
user := ctx.Value("user").(models.User)
|
||||
overtime := helper.FormatDuration(workDay.CalcOvertime(user))
|
||||
work, pause, overtime := workDay.GetAllWorkTimesReal(user)
|
||||
// overtime := helper.FormatDuration(workDay.CalcOvertime(user))
|
||||
justify := ""
|
||||
if len(workDay.Bookings) <= 1 {
|
||||
justify = "justify-content: center"
|
||||
@@ -49,21 +78,21 @@ templ dayComponent(workDay models.WorkDay, submitted bool) {
|
||||
}}
|
||||
<div class={ "grid-sub divide-x-1 hover:bg-neutral-200 transition-colors", templ.KV("bg-neutral-100", submitted) }>
|
||||
<div class="grid-cell md:col-span-1 flex flex-row gap-2">
|
||||
@timeGaugeComponent(workDay.GetWorkDayProgress(ctx.Value("user").(models.User)), workDay.Day.Equal(time.Now().Truncate(24*time.Hour)), workDay.RequiresAction())
|
||||
@timeGaugeComponent(workDay.GetDayProgress(user), workDay.Day.Equal(time.Now().Truncate(24*time.Hour)))
|
||||
<div>
|
||||
<p class=""><span class="font-bold uppercase hidden md:inline">{ workDay.Day.Format("Mon") }:</span> { workDay.Day.Format("02.01.2006") }</p>
|
||||
if work!="" {
|
||||
<p class=" text-sm mt-1">Arbeitszeit:</p>
|
||||
if (workDay.RequiresAction()) {
|
||||
<p class="text-red-600">Bitte anpassen</p>
|
||||
} else {
|
||||
<p class="text-accent flex flex-row items-center"><span class="icon-[material-symbols-light--nest-clock-farsight-analog-outline]"></span>{ work }</p>
|
||||
if pause != "" {
|
||||
<p class="text-neutral-500 flex flex-row items-center"><span class="icon-[material-symbols-light--motion-photos-paused-outline]"></span>{ pause }</p>
|
||||
}
|
||||
if overtime != "" {
|
||||
<p class="text-neutral-500 flex flex-row items-center"><span class="icon-[material-symbols-light--more-time]"></span>{ overtime }</p>
|
||||
}
|
||||
if (workDay.RequiresAction()) {
|
||||
<p class="text-red-600">Bitte anpassen</p>
|
||||
} else {
|
||||
if work > 0 {
|
||||
<p class=" text-sm mt-1">Arbeitszeit:</p>
|
||||
<p class="text-accent flex flex-row items-center"><span class="icon-[material-symbols-light--nest-clock-farsight-analog-outline]"></span>{ helper.FormatDuration(work) }</p>
|
||||
}
|
||||
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 {
|
||||
<p class="text-neutral-500 flex flex-row items-center"><span class="icon-[material-symbols-light--more-time]"></span>{ helper.FormatDuration(overtime) }</p>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
@@ -71,10 +100,7 @@ templ dayComponent(workDay models.WorkDay, submitted bool) {
|
||||
<div class="all-booking-component flex flex-row md:col-span-3 gap-2 w-full grid-cell">
|
||||
@lineComponent()
|
||||
<form id={ "time-" + workDay.Day.Format("2006-01-02") } class="flex flex-col gap-2 group w-full justify-between" style={ justify } method="post">
|
||||
if (workDay.Absence != models.Absence{}) {
|
||||
<p>{ workDay.Absence.AbwesenheitTyp.Name }</p>
|
||||
}
|
||||
if len(workDay.Bookings) < 1 && (workDay.Absence == models.Absence{}) {
|
||||
if len(workDay.Bookings) < 1 {
|
||||
<p class="text group-[.edit]:hidden">Keine Buchung gefunden. Bitte Arbeitsstunden oder Grund der Abwesenheit eingeben!</p>
|
||||
@absenceComponent(workDay)
|
||||
@newBookingComponent(workDay)
|
||||
@@ -83,6 +109,9 @@ templ dayComponent(workDay models.WorkDay, submitted bool) {
|
||||
for _, booking := range workDay.Bookings {
|
||||
@bookingComponent(booking)
|
||||
}
|
||||
if workDay.IsKurzArbeit() {
|
||||
<p>Kurzarbeit</p>
|
||||
}
|
||||
@newBookingComponent(workDay)
|
||||
}
|
||||
<input type="hidden" name="action" value="change"/> <!-- default action value for ändern button -->
|
||||
@@ -105,11 +134,11 @@ templ changeButtonComponent(id string) {
|
||||
</button>
|
||||
}
|
||||
|
||||
templ timeGaugeComponent(progress uint8, today bool, warning bool) {
|
||||
templ timeGaugeComponent(progress int8, today bool) {
|
||||
{{
|
||||
var bgColor string
|
||||
switch {
|
||||
case (warning):
|
||||
case (0 > progress):
|
||||
bgColor = "bg-red-600"
|
||||
break
|
||||
case (progress > 0 && progress < 95):
|
||||
|
||||
Reference in New Issue
Block a user