fixed #50, added default action input to defaultDayComponent #51

Merged
tom_trgr merged 1 commits from dev/ui into main 2025-10-07 13:01:25 +02:00
8 changed files with 23 additions and 20 deletions

View File

@@ -127,6 +127,7 @@ func updateBooking(w http.ResponseWriter, r *http.Request) {
log.Println("No user found!", err)
return
}
switch r.FormValue("action") {
case "add":
timestamp, err := time.ParseInLocation("2006-01-02|15:04", r.FormValue("date")+"|"+r.FormValue("timestamp"), loc)
@@ -149,14 +150,14 @@ func updateBooking(w http.ResponseWriter, r *http.Request) {
log.Printf("Error inserting booking %v -> %v\n", newBooking, err)
}
case "change":
absenceType, err := strconv.Atoi(r.FormValue("absence"))
if err != nil {
log.Println("Error parsing absence type.", err)
absenceType = 0
}
if absenceType != 0 {
createAbsence(absenceType, user, loc, r)
}
// absenceType, err := strconv.Atoi(r.FormValue("absence"))
// if err != nil {
// log.Println("Error parsing absence type.", err)
// absenceType = 0
// }
// if absenceType != 0 {
// createAbsence(absenceType, user, loc, r)
// }
for index, possibleBooking := range r.PostForm {
if len(index) > 7 && index[:7] == "booking" {
booking_id, err := strconv.Atoi(index[8:])
@@ -174,10 +175,11 @@ func updateBooking(w http.ResponseWriter, r *http.Request) {
log.Println("Error parsing time!", err)
continue
}
// log.Println("Parsing time", parsedTime)
booking.UpdateTime(parsedTime)
}
}
default:
log.Println("No action from /time found")
}
getBookings(w, r)
}

View File

@@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT.
// templ: version: v0.3.943
// templ: version: v0.3.924
package templates
//lint:file-ignore SA4006 This context is only used if a nested component is present.

View File

@@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT.
// templ: version: v0.3.943
// templ: version: v0.3.924
package templates
//lint:file-ignore SA4006 This context is only used if a nested component is present.

View File

@@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT.
// templ: version: v0.3.943
// templ: version: v0.3.924
package templates
//lint:file-ignore SA4006 This context is only used if a nested component is present.

View File

@@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT.
// templ: version: v0.3.943
// templ: version: v0.3.924
package templates
//lint:file-ignore SA4006 This context is only used if a nested component is present.

View File

@@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT.
// templ: version: v0.3.943
// templ: version: v0.3.924
package templates
//lint:file-ignore SA4006 This context is only used if a nested component is present.

View File

@@ -149,6 +149,7 @@ templ defaultDayComponent(day models.IWorkDay) {
}}
@absenceComponent(absentDay, false)
}
<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">

View File

@@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT.
// templ: version: v0.3.943
// templ: version: v0.3.924
package templates
//lint:file-ignore SA4006 This context is only used if a nested component is present.
@@ -463,7 +463,7 @@ func defaultDayComponent(day models.IWorkDay) templ.Component {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, "</form></div><div class=\"grid-cell flex flex-row gap-2 items-end\">")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, "<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
}
@@ -507,7 +507,7 @@ func absentInput(a models.Absence) templ.Component {
var templ_7745c5c3_Var21 string
templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(a.DateFrom.Format("2006-01-02"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 161, Col: 78}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 162, Col: 78}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21))
if templ_7745c5c3_Err != nil {
@@ -520,7 +520,7 @@ func absentInput(a models.Absence) templ.Component {
var templ_7745c5c3_Var22 string
templ_7745c5c3_Var22, templ_7745c5c3_Err = templ.JoinStringErrs(a.DateTo.Format("2006-01-02"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 162, Col: 74}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 163, Col: 74}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var22))
if templ_7745c5c3_Err != nil {
@@ -533,7 +533,7 @@ func absentInput(a models.Absence) templ.Component {
var templ_7745c5c3_Var23 string
templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(a.AbwesenheitTyp.Id)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 163, Col: 64}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 164, Col: 64}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23))
if templ_7745c5c3_Err != nil {
@@ -546,7 +546,7 @@ func absentInput(a models.Absence) templ.Component {
var templ_7745c5c3_Var24 string
templ_7745c5c3_Var24, templ_7745c5c3_Err = templ.JoinStringErrs(a.CounterId)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 164, Col: 54}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 165, Col: 54}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var24))
if templ_7745c5c3_Err != nil {