minor fixes in pdf generator + new booking input select
This commit is contained in:
@@ -51,7 +51,11 @@ func convertDayToTypstDayParts(day models.IWorkDay, user models.User) []typstDay
|
|||||||
for i := 0; i < len(workDay.Bookings); i += 2 {
|
for i := 0; i < len(workDay.Bookings); i += 2 {
|
||||||
var typstDayPart typstDayPart
|
var typstDayPart typstDayPart
|
||||||
typstDayPart.BookingFrom = workDay.Bookings[i].Timestamp.Format("15:04")
|
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.WorkType = workDay.Bookings[i].BookingType.Name
|
||||||
typstDayPart.IsWorkDay = true
|
typstDayPart.IsWorkDay = true
|
||||||
typstDayParts = append(typstDayParts, typstDayPart)
|
typstDayParts = append(typstDayParts, typstDayPart)
|
||||||
|
|||||||
@@ -15,7 +15,9 @@ function editWorkday(element, event, id, isWorkDay) {
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
let form = document.getElementById(id);
|
let form = document.getElementById(id);
|
||||||
if (form == null) {
|
if (form == null) {
|
||||||
form = element.closest(".grid-sub").querySelector(".all-booking-component > form");
|
form = element
|
||||||
|
.closest(".grid-sub")
|
||||||
|
.querySelector(".all-booking-component > form");
|
||||||
}
|
}
|
||||||
|
|
||||||
clearEditState();
|
clearEditState();
|
||||||
@@ -37,10 +39,21 @@ function editWorkday(element, event, id, isWorkDay) {
|
|||||||
const absenceForm = document.getElementById("absence_form");
|
const absenceForm = document.getElementById("absence_form");
|
||||||
|
|
||||||
if (id == 0) {
|
if (id == 0) {
|
||||||
absenceForm.querySelector("[name=date_from]").value = form.id.replace("time-", "");
|
absenceForm.querySelector("[name=date_from]").value = form.id.replace(
|
||||||
absenceForm.querySelector("[name=date_to]").value = form.id.replace("time-", "");
|
"time-",
|
||||||
|
"",
|
||||||
|
);
|
||||||
|
absenceForm.querySelector("[name=date_to]").value = form.id.replace(
|
||||||
|
"time-",
|
||||||
|
"",
|
||||||
|
);
|
||||||
} else {
|
} 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");
|
const form = document.getElementById("absence_form");
|
||||||
if (state) {
|
if (state) {
|
||||||
form.classList.remove("hidden");
|
form.classList.remove("hidden");
|
||||||
form.scrollIntoView({
|
|
||||||
behavior: "smooth",
|
|
||||||
block: "start",
|
|
||||||
inline: "nearest",
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
form.classList.add("hidden");
|
form.classList.add("hidden");
|
||||||
}
|
}
|
||||||
@@ -85,3 +93,12 @@ function checkAll(pattern, state) {
|
|||||||
input.checked = 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -127,10 +127,14 @@ templ defaultDayComponent(day models.IWorkDay) {
|
|||||||
</div>
|
</div>
|
||||||
<div class="all-booking-component grid-cell flex flex-row md:col-span-3 col-span-2 gap-2 w-full">
|
<div class="all-booking-component grid-cell flex flex-row md:col-span-3 col-span-2 gap-2 w-full">
|
||||||
@lineComponent()
|
@lineComponent()
|
||||||
<form id={ "time-" + day.Date().Format(time.DateOnly) } class={ "flex flex-col gap-2 w-full", justify } method="post">
|
<form id={ "time-" + day.Date().Format(time.DateOnly) } class={ "bookings flex flex-col gap-2 w-full", justify } method="post">
|
||||||
@newAbsenceComponent()
|
if (day.GetDayProgress(user) < 100 || day.IsWorkDay()) {
|
||||||
@timeDayTypeSwitch(day, true)
|
@newAbsenceComponent()
|
||||||
@newBookingComponent(day)
|
@timeDayTypeSwitch(day, true)
|
||||||
|
@newBookingComponent(day)
|
||||||
|
} else {
|
||||||
|
@timeDayTypeSwitch(day, true)
|
||||||
|
}
|
||||||
<input type="hidden" name="action" value="change"/> <!-- default action value for ändern button -->
|
<input type="hidden" name="action" value="change"/> <!-- default action value for ändern button -->
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
@@ -160,12 +164,14 @@ templ timeDayTypeSwitch(day models.IWorkDay, fromCompound bool) {
|
|||||||
templ workdayComponent(workDay *models.WorkDay) {
|
templ workdayComponent(workDay *models.WorkDay) {
|
||||||
if len(workDay.Bookings) < 1 {
|
if len(workDay.Bookings) < 1 {
|
||||||
<p class="text group-[.edit]:hidden">Keine Buchung gefunden. Bitte Arbeitsstunden oder Grund der Abwesenheit eingeben!</p>
|
<p class="text group-[.edit]:hidden">Keine Buchung gefunden. Bitte Arbeitsstunden oder Grund der Abwesenheit eingeben!</p>
|
||||||
}
|
} else {
|
||||||
if workDay.IsKurzArbeit() && len(workDay.Bookings) > 0 {
|
if workDay.IsKurzArbeit() && len(workDay.Bookings) > 0 {
|
||||||
@absenceComponent(workDay.GetKurzArbeit(), true)
|
@absenceComponent(workDay.GetKurzArbeit(), true)
|
||||||
}
|
}
|
||||||
for _, booking := range workDay.Bookings {
|
for _, booking := range workDay.Bookings {
|
||||||
@bookingComponent(booking)
|
@bookingComponent(booking)
|
||||||
|
}
|
||||||
|
<input type="hidden" name="select_kommen" value={ len(workDay.Bookings) > 0 && workDay.Bookings[len(workDay.Bookings)-1].CheckInOut%2 == 0 }/>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -375,7 +375,7 @@ func defaultDayComponent(day models.IWorkDay) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
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...)
|
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var17...)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
@@ -410,19 +410,34 @@ func defaultDayComponent(day models.IWorkDay) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = newAbsenceComponent().Render(ctx, templ_7745c5c3_Buffer)
|
if day.GetDayProgress(user) < 100 || day.IsWorkDay() {
|
||||||
if templ_7745c5c3_Err != nil {
|
templ_7745c5c3_Err = newAbsenceComponent().Render(ctx, templ_7745c5c3_Buffer)
|
||||||
return templ_7745c5c3_Err
|
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)
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, "<input type=\"hidden\" name=\"action\" value=\"change\"><!-- default action value for ändern button --></form></div><div class=\"grid-cell flex flex-row gap-2 items-end\">")
|
||||||
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, "<input type=\"hidden\" name=\"action\" value=\"change\"><!-- default action value for ändern button --></form></div><div class=\"grid-cell flex flex-row gap-2 items-end\">")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@@ -430,7 +445,7 @@ func defaultDayComponent(day models.IWorkDay) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, "</div></div>")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, "</div></div>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@@ -480,20 +495,20 @@ func timeDayTypeSwitch(day models.IWorkDay, fromCompound bool) templ.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, "<p>")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, "<p>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var21 string
|
var templ_7745c5c3_Var21 string
|
||||||
templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(day.ToString())
|
templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(day.ToString())
|
||||||
if templ_7745c5c3_Err != nil {
|
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))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, "</p>")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 38, "</p>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@@ -524,19 +539,37 @@ func workdayComponent(workDay *models.WorkDay) templ.Component {
|
|||||||
}
|
}
|
||||||
ctx = templ.ClearChildren(ctx)
|
ctx = templ.ClearChildren(ctx)
|
||||||
if len(workDay.Bookings) < 1 {
|
if len(workDay.Bookings) < 1 {
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, "<p class=\"text group-[.edit]:hidden\">Keine Buchung gefunden. Bitte Arbeitsstunden oder Grund der Abwesenheit eingeben!</p>")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, "<p class=\"text group-[.edit]:hidden\">Keine Buchung gefunden. Bitte Arbeitsstunden oder Grund der Abwesenheit eingeben!</p>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
if workDay.IsKurzArbeit() && len(workDay.Bookings) > 0 {
|
if workDay.IsKurzArbeit() && len(workDay.Bookings) > 0 {
|
||||||
templ_7745c5c3_Err = absenceComponent(workDay.GetKurzArbeit(), true).Render(ctx, templ_7745c5c3_Buffer)
|
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, " <input type=\"hidden\" name=\"select_kommen\" value=\"")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
}
|
var templ_7745c5c3_Var23 string
|
||||||
for _, booking := range workDay.Bookings {
|
templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(len(workDay.Bookings) > 0 && workDay.Bookings[len(workDay.Bookings)-1].CheckInOut%2 == 0)
|
||||||
templ_7745c5c3_Err = bookingComponent(booking).Render(ctx, templ_7745c5c3_Buffer)
|
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 {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@@ -561,25 +594,25 @@ func holidayComponent(d models.IWorkDay) templ.Component {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
ctx = templ.InitializeContext(ctx)
|
ctx = templ.InitializeContext(ctx)
|
||||||
templ_7745c5c3_Var23 := templ.GetChildren(ctx)
|
templ_7745c5c3_Var24 := templ.GetChildren(ctx)
|
||||||
if templ_7745c5c3_Var23 == nil {
|
if templ_7745c5c3_Var24 == nil {
|
||||||
templ_7745c5c3_Var23 = templ.NopComponent
|
templ_7745c5c3_Var24 = templ.NopComponent
|
||||||
}
|
}
|
||||||
ctx = templ.ClearChildren(ctx)
|
ctx = templ.ClearChildren(ctx)
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 38, "<p>")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 42, "<p>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var24 string
|
var templ_7745c5c3_Var25 string
|
||||||
templ_7745c5c3_Var24, templ_7745c5c3_Err = templ.JoinStringErrs(d.ToString())
|
templ_7745c5c3_Var25, templ_7745c5c3_Err = templ.JoinStringErrs(d.ToString())
|
||||||
if templ_7745c5c3_Err != nil {
|
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 {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, "</p>")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 43, "</p>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user