55 lines
2.3 KiB
Plaintext
55 lines
2.3 KiB
Plaintext
package templates
|
|
|
|
import (
|
|
"arbeitszeitmessung/models"
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
templ weekPicker(weekStart time.Time) {
|
|
{{ year, kw := weekStart.ISOWeek() }}
|
|
<form method="get" class="flex flex-row gap-4 items-center justify-around">
|
|
<input type="date" class="hidden" name="submission_date" value={ weekStart.Format(time.DateOnly) }/>
|
|
<button onclick={ templ.JSFuncCall("navigateWeek", templ.JSExpression("this"), templ.JSExpression("event"), "-1") } class="btn">
|
|
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" class="chevron-left size-4 mx-auto" viewBox="0 0 16 16">
|
|
<path fill-rule="evenodd" d="M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0"></path>
|
|
</svg>
|
|
</button>
|
|
<p class="whitespace-nowrap">KW { fmt.Sprintf("%02d, %d", kw, year) }</p>
|
|
<button disabled?={ time.Since(weekStart) < 24*7*time.Hour } onclick={ templ.JSFuncCall("navigateWeek", templ.JSExpression("this"), templ.JSExpression("event"), "1") } class="btn disabled:pointer-events-none disabled:opacity-50">
|
|
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" class="chevron-right size-4 mx-auto" viewBox="0 0 16 16">
|
|
<path fill-rule="evenodd" d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708"></path>
|
|
</svg>
|
|
</button>
|
|
</form>
|
|
}
|
|
|
|
templ workDayWeekComponent(workDay *models.WorkDay) {
|
|
if !workDay.RequiresAction() {
|
|
<div class="flex flex-row gap-2 items-center">
|
|
<span class="icon-[material-symbols-light--schedule-outline] flex-shrink-0"></span>
|
|
switch {
|
|
case !workDay.TimeFrom.Equal(workDay.TimeTo):
|
|
<span>{ workDay.TimeFrom.Format("15:04") }</span>
|
|
<span>-</span>
|
|
<span>{ workDay.TimeTo.Format("15:04") }</span>
|
|
default:
|
|
<p>Keine Anwesenheit</p>
|
|
}
|
|
</div>
|
|
} else {
|
|
<p class="text-red-600">Bitte anpassen</p>
|
|
}
|
|
}
|
|
|
|
templ userPresenceComponent(user models.User, present bool) {
|
|
<div class="grid-cell group flex flex-row gap-2">
|
|
if present {
|
|
<div class="h-8 bg-accent rounded-md group-hover:text-black md:text-transparent text-center p-1">Anwesend</div>
|
|
} else {
|
|
<div class="h-8 bg-red-600 rounded-md group-hover:text-white md:text-transparent text-center p-1">Abwesend</div>
|
|
}
|
|
<p>{ user.Vorname } { user.Name }</p>
|
|
</div>
|
|
}
|