From af1c16f8f926b05068d1a0a78f1ff1f578f62991 Mon Sep 17 00:00:00 2001 From: Sas Andy Date: Sat, 25 May 2024 20:10:12 +0700 Subject: [PATCH] up versi --- .../customtextfieldsearch.templ | 39 +++ .../customtextfieldsearch_templ.go | 202 ++++++++++++ component/pagination/paginationv2.templ | 4 +- component/pagination/paginationv2_templ.go | 20 +- component/pagination/paginationv3.templ | 60 ++++ component/pagination/paginationv3_templ.go | 300 ++++++++++++++++++ 6 files changed, 612 insertions(+), 13 deletions(-) create mode 100644 component/pagination/paginationv3.templ create mode 100644 component/pagination/paginationv3_templ.go diff --git a/component/customtextfieldsearch/customtextfieldsearch.templ b/component/customtextfieldsearch/customtextfieldsearch.templ index dec85a3..78cea41 100644 --- a/component/customtextfieldsearch/customtextfieldsearch.templ +++ b/component/customtextfieldsearch/customtextfieldsearch.templ @@ -83,3 +83,42 @@ templ MainCustomTextFieldSearchV2( }); } + +templ MainCustomTextFieldSearchV3( + inpId, + inpName, + inpPlaceHolder, + inpType, + hxGet, + hxTrigger, + hxTarget, + hxIndicator, + value, + hxSwap string, + hxInclude string, + hxBeforeRequest templ.ComponentScript, + hxAfterRequest templ.ComponentScript) { + + +} diff --git a/component/customtextfieldsearch/customtextfieldsearch_templ.go b/component/customtextfieldsearch/customtextfieldsearch_templ.go index 1faf702..c6d210a 100644 --- a/component/customtextfieldsearch/customtextfieldsearch_templ.go +++ b/component/customtextfieldsearch/customtextfieldsearch_templ.go @@ -486,3 +486,205 @@ func MainCustomTextFieldSearchV2( return templ_7745c5c3_Err }) } + +func MainCustomTextFieldSearchV3( + inpId, + inpName, + inpPlaceHolder, + inpType, + hxGet, + hxTrigger, + hxTarget, + hxIndicator, + value, + hxSwap string, + hxInclude string, + hxBeforeRequest templ.ComponentScript, + hxAfterRequest templ.ComponentScript) templ.Component { + return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) + if !templ_7745c5c3_IsBuffer { + templ_7745c5c3_Buffer = templ.GetBuffer() + defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var33 := templ.GetChildren(ctx) + if templ_7745c5c3_Var33 == nil { + templ_7745c5c3_Var33 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, hxBeforeRequest, hxAfterRequest) + 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 + } + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) + } + return templ_7745c5c3_Err + }) +} diff --git a/component/pagination/paginationv2.templ b/component/pagination/paginationv2.templ index 926256b..d692942 100644 --- a/component/pagination/paginationv2.templ +++ b/component/pagination/paginationv2.templ @@ -27,18 +27,16 @@ templ PaginationV2(length int, hx-trigger="click" hx-target={ hxTarget } hx-include={ hxInclude } - hx-disabled-elt=".btneditug, .btndeleteug" >{ strconv.Itoa(i+1) } } else { { strconv.Itoa(i+1) } } } diff --git a/component/pagination/paginationv2_templ.go b/component/pagination/paginationv2_templ.go index c7d92ce..67a51ba 100644 --- a/component/pagination/paginationv2_templ.go +++ b/component/pagination/paginationv2_templ.go @@ -132,14 +132,14 @@ func PaginationV2(length int, if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-disabled-elt=\".btneditug, .btndeleteug\">") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\">") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var9 string templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(strconv.Itoa(i + 1)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `component\pagination\paginationv2.templ`, Line: 31, Col: 25} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `component\pagination\paginationv2.templ`, Line: 30, Col: 25} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9)) if templ_7745c5c3_Err != nil { @@ -157,20 +157,20 @@ func PaginationV2(length int, var templ_7745c5c3_Var10 string templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(link + "?" + "page=" + strconv.Itoa(i+1)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `component\pagination\paginationv2.templ`, Line: 34, Col: 55} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `component\pagination\paginationv2.templ`, Line: 33, Col: 55} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" class=\"btn btn-icon btn-sm border-0 btn-light mr-2 my-1\" hx-swap=\"") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" class=\"btn btn-icon btn-sm border-0 btn-light mr-2 my-1 btneditug\" hx-swap=\"") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var11 string templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(hxSwap) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `component\pagination\paginationv2.templ`, Line: 36, Col: 22} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `component\pagination\paginationv2.templ`, Line: 35, Col: 22} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11)) if templ_7745c5c3_Err != nil { @@ -183,7 +183,7 @@ func PaginationV2(length int, var templ_7745c5c3_Var12 string templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(hxIndicator) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `component\pagination\paginationv2.templ`, Line: 37, Col: 32} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `component\pagination\paginationv2.templ`, Line: 36, Col: 32} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12)) if templ_7745c5c3_Err != nil { @@ -196,7 +196,7 @@ func PaginationV2(length int, var templ_7745c5c3_Var13 string templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(hxTarget) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `component\pagination\paginationv2.templ`, Line: 39, Col: 26} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `component\pagination\paginationv2.templ`, Line: 38, Col: 26} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13)) if templ_7745c5c3_Err != nil { @@ -209,20 +209,20 @@ func PaginationV2(length int, var templ_7745c5c3_Var14 string templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(hxInclude) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `component\pagination\paginationv2.templ`, Line: 40, Col: 28} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `component\pagination\paginationv2.templ`, Line: 39, Col: 28} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-disabled-elt=\".btneditug, .btndeleteug\">") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\">") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var15 string templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(strconv.Itoa(i + 1)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `component\pagination\paginationv2.templ`, Line: 42, Col: 25} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `component\pagination\paginationv2.templ`, Line: 40, Col: 25} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15)) if templ_7745c5c3_Err != nil { diff --git a/component/pagination/paginationv3.templ b/component/pagination/paginationv3.templ new file mode 100644 index 0000000..8f5507e --- /dev/null +++ b/component/pagination/paginationv3.templ @@ -0,0 +1,60 @@ +package pagination + +import "strconv" +import "cpone/component/customtextfield" +import "cpone/models" + +templ PaginationV3(length int, + currentPage int, + link string, + paginationID string, + hxInclude string, + hxTarget string, + hxSwap string, + hxIndicator string, + hxSwapOob string, + hxBeforeRequest templ.ComponentScript, + hxAfterRequest templ.ComponentScript, +) { + // hx-on::before-request={ HideContent(contentID) } + // hx-on::after-request="alert('Done making a request!')" +
+
+ for i:=0; i{ strconv.Itoa(i+1) } + } else { + { strconv.Itoa(i+1) } + } + } +
+ @customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ + ID: "currpage" + paginationID, + Name: "currpage" + paginationID, + Type: "hidden", + Value: strconv.Itoa(currentPage)}) +
+} diff --git a/component/pagination/paginationv3_templ.go b/component/pagination/paginationv3_templ.go new file mode 100644 index 0000000..67929bf --- /dev/null +++ b/component/pagination/paginationv3_templ.go @@ -0,0 +1,300 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.663 +package pagination + +//lint:file-ignore SA4006 This context is only used if a nested component is present. + +import "github.com/a-h/templ" +import "context" +import "io" +import "bytes" + +import "strconv" +import "cpone/component/customtextfield" +import "cpone/models" + +func PaginationV3(length int, + currentPage int, + link string, + paginationID string, + hxInclude string, + hxTarget string, + hxSwap string, + hxIndicator string, + hxSwapOob string, + hxBeforeRequest templ.ComponentScript, + hxAfterRequest templ.ComponentScript, +) templ.Component { + return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) + if !templ_7745c5c3_IsBuffer { + templ_7745c5c3_Buffer = templ.GetBuffer() + defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var1 := templ.GetChildren(ctx) + if templ_7745c5c3_Var1 == nil { + templ_7745c5c3_Var1 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, hxAfterRequest) + 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 + } + for i := 0; i < length; i++ { + if (i + 1) == currentPage { + templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, hxBeforeRequest) + 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_Var11 string + templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(strconv.Itoa(i + 1)) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `component\pagination\paginationv3.templ`, Line: 39, Col: 25} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11)) + 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 + } + } else { + templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, hxBeforeRequest) + 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_Var18 string + templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(strconv.Itoa(i + 1)) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `component\pagination\paginationv3.templ`, Line: 50, Col: 25} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18)) + 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 + } + } + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ + ID: "currpage" + paginationID, + Name: "currpage" + paginationID, + Type: "hidden", + Value: strconv.Itoa(currentPage)}).Render(ctx, templ_7745c5c3_Buffer) + 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 + } + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) + } + return templ_7745c5c3_Err + }) +}