diff --git a/handlers/dev/masterkelainan.handlers.go b/handlers/dev/masterkelainan.handlers.go index b6b6aff..ec47fd7 100644 --- a/handlers/dev/masterkelainan.handlers.go +++ b/handlers/dev/masterkelainan.handlers.go @@ -910,7 +910,7 @@ func (lh *MasterKelainanHandler) HandleSelected(c echo.Context) error { id := c.QueryParam("id") search := c.QueryParam("search") searchID := c.QueryParam("searchID") - tableID := c.QueryParam("tableID") + tableID := c.QueryParam("tableID") + "1ppp" paginationID := c.QueryParam("paginationID") dialogEditBodyID := c.QueryParam("dialogEditBodyID") dialogDeleteBodyID := c.QueryParam("dialogDeleteBodyID") diff --git a/views/dev/masterkelainan/mdkelainantable.templ b/views/dev/masterkelainan/mdkelainantable.templ index b585be4..c031a19 100644 --- a/views/dev/masterkelainan/mdkelainantable.templ +++ b/views/dev/masterkelainan/mdkelainantable.templ @@ -38,22 +38,17 @@ templ TableKelainan(data []models.Kelainan, } -// func concatIDx(id string) string { -// return "changeColor(" + id + ")" -// } +script clickHandler(id string) { + document.getElementById("sas"+id).classList.add("selected"); + // console.log(id); +} -// templ component(contact model.Contact) { -//
-// { contact.Name } -//
-// } -// templ buttonTempl(id int) { -// -// } - -script clickHandler(id int) { - // document.getElementById(id).classList.add("selected"); - console.log(id); +script HandleAfterRequesX(idx string) { + document.querySelectorAll("tr.selected").forEach(function(row) { + row.classList.remove("selected"); + }); + document.getElementById("sas"+idx).classList.add("selected"); + console.log('handle after',idx); } templ TableRow(data []models.Kelainan, @@ -74,11 +69,13 @@ templ TableRow(data []models.Kelainan, } for _, v := range data { { v.Nomor } { v.Mcu_KelainanGroupName } diff --git a/views/dev/masterkelainan/mdkelainantable_templ.go b/views/dev/masterkelainan/mdkelainantable_templ.go index c6ea323..b80c251 100644 --- a/views/dev/masterkelainan/mdkelainantable_templ.go +++ b/views/dev/masterkelainan/mdkelainantable_templ.go @@ -84,27 +84,28 @@ func TableKelainan(data []models.Kelainan, }) } -// func concatIDx(id string) string { -// return "changeColor(" + id + ")" -// } - -// templ component(contact model.Contact) { -//
-// { contact.Name } -//
-// } -// -// templ buttonTempl(id int) { -// -// } -func clickHandler(id int) templ.ComponentScript { +func clickHandler(id string) templ.ComponentScript { return templ.ComponentScript{ - Name: `__templ_clickHandler_4d2c`, - Function: `function __templ_clickHandler_4d2c(id){// document.getElementById(id).classList.add("selected"); - console.log(id); + Name: `__templ_clickHandler_c9e6`, + Function: `function __templ_clickHandler_c9e6(id){document.getElementById("sas"+id).classList.add("selected"); + // console.log(id); }`, - Call: templ.SafeScript(`__templ_clickHandler_4d2c`, id), - CallInline: templ.SafeScriptInline(`__templ_clickHandler_4d2c`, id), + Call: templ.SafeScript(`__templ_clickHandler_c9e6`, id), + CallInline: templ.SafeScriptInline(`__templ_clickHandler_c9e6`, id), + } +} + +func HandleAfterRequesX(idx string) templ.ComponentScript { + return templ.ComponentScript{ + Name: `__templ_HandleAfterRequesX_ef3a`, + Function: `function __templ_HandleAfterRequesX_ef3a(idx){document.querySelectorAll("tr.selected").forEach(function(row) { + row.classList.remove("selected"); + }); + document.getElementById("sas"+idx).classList.add("selected"); + console.log('handle after',idx); +}`, + Call: templ.SafeScript(`__templ_HandleAfterRequesX_ef3a`, idx), + CallInline: templ.SafeScriptInline(`__templ_HandleAfterRequesX_ef3a`, idx), } } @@ -138,55 +139,90 @@ func TableRow(data []models.Kelainan, } } for _, v := range data { - templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, clickHandler(v.Mcu_KelainanGroupID)) + templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, clickHandler(strconv.Itoa(v.Mcu_KelainanGroupID)), HandleAfterRequesX(strconv.Itoa(v.Mcu_KelainanGroupID))) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-trigger=\"click\" hx-include=\"") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var6 string - templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(v.Nomor) + templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs("#paginationID, #dialogEditBodyID, #dialogEditID, #dialogDeleteBodyID, #dialogDeleteID,#tableID, #sas" + strconv.Itoa(v.Mcu_KelainanGroupID)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\masterkelainan\mdkelainantable.templ`, Line: 83, Col: 16} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\masterkelainan\mdkelainantable.templ`, Line: 75, Col: 156} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" onclick=\"") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var7 templ.ComponentScript = clickHandler(strconv.Itoa(v.Mcu_KelainanGroupID)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var7.Call) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-on::after-request=\"") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var8 templ.ComponentScript = HandleAfterRequesX(strconv.Itoa(v.Mcu_KelainanGroupID)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var8.Call) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-swap=\"none\">") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var9 string + templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(v.Nomor) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\masterkelainan\mdkelainantable.templ`, Line: 80, Col: 16} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var7 string - templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(v.Mcu_KelainanGroupName) + var templ_7745c5c3_Var10 string + templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(v.Mcu_KelainanGroupName) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\masterkelainan\mdkelainantable.templ`, Line: 84, Col: 32} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\masterkelainan\mdkelainantable.templ`, Line: 81, Col: 32} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -237,21 +273,21 @@ func TableAction( defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var8 := templ.GetChildren(ctx) - if templ_7745c5c3_Var8 == nil { - templ_7745c5c3_Var8 = templ.NopComponent + templ_7745c5c3_Var11 := templ.GetChildren(ctx) + if templ_7745c5c3_Var11 == nil { + templ_7745c5c3_Var11 = templ.NopComponent } ctx = templ.ClearChildren(ctx) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("