From 8f2104270d867e210dff9a104e30021f06fbd682 Mon Sep 17 00:00:00 2001 From: Sas Andy Date: Wed, 8 May 2024 09:23:43 +0700 Subject: [PATCH] modal edit user group --- assets/andy/usergroup.html | 274 ++++++++++++++++++ .../asset-corporate-portal/css/sas.bundle.css | 17 +- handlers/mastermenuusergroup.handlers.go | 26 +- handlers/routes.go | 4 + handlers/xsample.handlers.go | 41 +++ models/CustomTextField.models.go | 14 + models/usergroup.models.go | 7 + services/mastermenuusergroup.services.go | 35 +++ .../customtextfield/customtextfield.templ | 2 +- .../customtextfield/customtextfield_templ.go | 2 +- .../customtextfield/customtextfieldv2.templ | 17 ++ .../customtextfieldv2_templ.go | 115 ++++++++ views/component/modal/modal.templ | 30 ++ views/component/modal/modal_templ.go | 85 ++++++ .../mastermenuusergroup.templ | 99 +++++-- .../mastermenuusergroup_templ.go | 123 ++++++-- .../modaladdusergroup.templ | 56 ++++ .../modaladdusergroup_templ.go | 114 ++++++++ .../modaleditusergroup.templ | 79 +++++ .../modaleditusergroup_templ.go | 162 +++++++++++ views/xsample/trycounter.templ | 51 ++++ views/xsample/trycounter_templ.go | 194 +++++++++++++ 22 files changed, 1496 insertions(+), 51 deletions(-) create mode 100644 assets/andy/usergroup.html create mode 100644 models/CustomTextField.models.go create mode 100644 models/usergroup.models.go create mode 100644 views/component/customtextfield/customtextfieldv2.templ create mode 100644 views/component/customtextfield/customtextfieldv2_templ.go create mode 100644 views/component/modal/modal.templ create mode 100644 views/component/modal/modal_templ.go create mode 100644 views/mastermenuusergroup/modaladdusergroup.templ create mode 100644 views/mastermenuusergroup/modaladdusergroup_templ.go create mode 100644 views/mastermenuusergroup/modaleditusergroup.templ create mode 100644 views/mastermenuusergroup/modaleditusergroup_templ.go create mode 100644 views/xsample/trycounter.templ create mode 100644 views/xsample/trycounter_templ.go diff --git a/assets/andy/usergroup.html b/assets/andy/usergroup.html new file mode 100644 index 0000000..39a2d6d --- /dev/null +++ b/assets/andy/usergroup.html @@ -0,0 +1,274 @@ + + + + + + + + Company Portal | { title } + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
KODEUSERGROUPAKSI
001Admin +
+ + +
+
002Tes +
+ + +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + diff --git a/assets/asset-corporate-portal/css/sas.bundle.css b/assets/asset-corporate-portal/css/sas.bundle.css index 8e83486..9d4b59f 100644 --- a/assets/asset-corporate-portal/css/sas.bundle.css +++ b/assets/asset-corporate-portal/css/sas.bundle.css @@ -601,12 +601,12 @@ a.text-white:focus { /* ## BUTTON OUTLINE SECONDARY*/ .btn-outline-secondary { - color: var(--secondary) !important; - border-color: var(--secondary) !important; + color: var(--text-black) !important; + border-color: var(--grey) !important; } .btn-outline-secondary:hover { - color: #181c32; - background-color: var(--secondary) !important; + color: var(--white); + background-color: var(--grey) !important; border-color: var(--secondary) !important; } .btn-outline-secondary:focus, @@ -5168,6 +5168,15 @@ a.text-hover-tosca:hover .svg-icon svg:hover g [fill], transition: fill 0.3s ease; } +.htmx-indicator { + display: none; +} +.htmx-request .htmx-indicator { + display: inline; +} +.htmx-request.htmx-indicator { + display: inline; +} /* ### BUTTON HOVER TEXT */ /* ### */ /* ## PRIMARY */ diff --git a/handlers/mastermenuusergroup.handlers.go b/handlers/mastermenuusergroup.handlers.go index b7babb7..721ce7f 100644 --- a/handlers/mastermenuusergroup.handlers.go +++ b/handlers/mastermenuusergroup.handlers.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/a-h/templ" + "github.com/emarifer/go-templ-project-structure/models" "github.com/emarifer/go-templ-project-structure/services" mastermenuusergroup "github.com/emarifer/go-templ-project-structure/views/mastermenuusergroup" "github.com/labstack/echo/v4" @@ -11,6 +12,8 @@ import ( type MasterMenuUserGroupService interface { GetMasterMenus() ([]services.MasterMenu, error) + GetUserGroup() ([]models.UserGroup, error) + GetUserGroupByID(id string) (models.UserGroup, error) } func NewMasterMenuUserGroupHandler(us MasterMenuUserGroupService) *MasterMenuUserGroupHandler { @@ -38,10 +41,17 @@ func (lh *MasterMenuUserGroupHandler) HandlerShowMasterMenuUserGroup(c echo.Cont fmt.Println(dataUser) return err } + dataUserGroup, err := lh.MasterMenuUserGroupService.GetUserGroup() + fmt.Println(dataUserGroup) + fmt.Println(err) + if err != nil { + fmt.Println(dataUserGroup) + return err + } si := mastermenuusergroup.ShowMasterMenuUserGroup( "Master Menu", - mastermenuusergroup.ContentMasterMenuUserGroup(), + mastermenuusergroup.ContentMasterMenuUserGroup(dataUserGroup), mastermenuusergroup.CssMasterMenuUserGroup(), mastermenuusergroup.JsMasterMenuUserGroup(), dataMenu, @@ -51,6 +61,20 @@ func (lh *MasterMenuUserGroupHandler) HandlerShowMasterMenuUserGroup(c echo.Cont return lh.View(c, si) } +func (lh *MasterMenuUserGroupHandler) ChangeFormEdit(c echo.Context) error { + id := c.QueryParam("id") + dataUserGroup, err := lh.MasterMenuUserGroupService.GetUserGroupByID(id) + fmt.Println(dataUserGroup) + fmt.Println(err) + if err != nil { + fmt.Println(dataUserGroup) + return err + } + vw := mastermenuusergroup.DialogEditForm(dataUserGroup.UserGroupKode, dataUserGroup.UserGroupName) + + return lh.View(c, vw) +} + func (uh *MasterMenuUserGroupHandler) View(c echo.Context, cmp templ.Component) error { c.Response().Header().Set(echo.HeaderContentType, echo.MIMETextHTML) diff --git a/handlers/routes.go b/handlers/routes.go index b30c9db..e2d9099 100644 --- a/handlers/routes.go +++ b/handlers/routes.go @@ -19,6 +19,8 @@ func SetupRoutesXsample(app *echo.Echo, h *XsampleHandler) { xSample := app.Group("/xsample") xSample.GET("/xsample01", h.Hello) xSample.GET("/coba", h.ShowCoba) + xSample.GET("/counter", h.ShowCounter) + xSample.GET("/counterchange", h.ChangeCounter) } func SetupRoutesLandingPage(app *echo.Echo, h *LandingPageHandler, mastermenuusergroupHandler *MasterMenuUserGroupHandler) { Lp := app.Group("/landing_page") @@ -27,6 +29,8 @@ func SetupRoutesLandingPage(app *echo.Echo, h *LandingPageHandler, mastermenuuse // mdgroup := clientgroup.Group("/md") // clientusergroup.GET("/md", mastermenuusergroupHandler.HandlerShowMasterMenuUserGroup) clientgroup.GET("/usergroup", mastermenuusergroupHandler.HandlerShowMasterMenuUserGroup) + clientgroup.GET("/usergroup/edit", mastermenuusergroupHandler.ChangeFormEdit) + } func SetupRoutesPieChart(app *echo.Echo, h *PiechartHandler) { Lp := app.Group("/pie_chart") diff --git a/handlers/xsample.handlers.go b/handlers/xsample.handlers.go index 7d07e58..8292816 100644 --- a/handlers/xsample.handlers.go +++ b/handlers/xsample.handlers.go @@ -2,6 +2,7 @@ package handlers import ( "fmt" + "strconv" "github.com/a-h/templ" "github.com/emarifer/go-templ-project-structure/services" @@ -49,6 +50,46 @@ func (uh *XsampleHandler) ShowCoba(c echo.Context) error { helo := xsample.ShowCoba("Hello World", xsample.Coba("Hello World"), xsample.CssCoba(), xsample.JsCoba(), dataMenu, dataUser) return uh.View(c, helo) } +func (uh *XsampleHandler) ShowCounter(c echo.Context) error { + typectr := c.QueryParam("type") + + counter := c.QueryParam("counter") + if counter == "" { + counter = "0" + } + ctr, err := strconv.Atoi(counter) + if err != nil { + fmt.Println("Error counter parse int") + return err + } + + if typectr == "min" { + ctr = ctr - 1 + } else if typectr == "plus" { + ctr = ctr + 1 + } + helo := xsample.Page(ctr) + return uh.View(c, helo) +} +func (uh *XsampleHandler) ChangeCounter(c echo.Context) error { + + typectr := c.QueryParam("type") + + counter := c.QueryParam("counter") + ctr, err := strconv.Atoi(counter) + if err != nil { + fmt.Println("Error counter parse int") + return err + } + + if typectr == "min" { + ctr = ctr - 1 + } else { + ctr = ctr + 1 + } + helo := xsample.Counts(ctr) + return uh.View(c, helo) +} func (uh *XsampleHandler) View(c echo.Context, cmp templ.Component) error { c.Response().Header().Set(echo.HeaderContentType, echo.MIMETextHTML) diff --git a/models/CustomTextField.models.go b/models/CustomTextField.models.go new file mode 100644 index 0000000..6fc167c --- /dev/null +++ b/models/CustomTextField.models.go @@ -0,0 +1,14 @@ +package models + +// inpLabelText, +// inpName, +// inpPlaceHolder, +// inpType string +// MainCustomTextField +type CustomTextFieldv2Prm struct { + Label string `default:"Label"` + Name string `default:"name"` + Placeholder string `default:"Placeholder"` + Type string `default:"text"` + Value string `default:""` +} diff --git a/models/usergroup.models.go b/models/usergroup.models.go new file mode 100644 index 0000000..1aa130a --- /dev/null +++ b/models/usergroup.models.go @@ -0,0 +1,7 @@ +package models + +type UserGroup struct { + UserGroupID int `json:"user_group_id"` + UserGroupKode string `json:"user_group_kode"` + UserGroupName string `json:"user_group_name"` +} diff --git a/services/mastermenuusergroup.services.go b/services/mastermenuusergroup.services.go index 4b3d65c..81feea9 100644 --- a/services/mastermenuusergroup.services.go +++ b/services/mastermenuusergroup.services.go @@ -1,7 +1,12 @@ package services import ( + "fmt" + "strconv" + "time" + "github.com/emarifer/go-templ-project-structure/db" + "github.com/emarifer/go-templ-project-structure/models" ) func NewServicesMasterMenuUserGroup(u MasterMenu, uStore db.MasterMenuUserGroupStore) *ServicesMasterMenuUserGroup { @@ -543,6 +548,36 @@ func (su *ServicesMasterMenuUserGroup) GetMasterMenus() ([]MasterMenu, error) { return dummyMenu, nil } +func (ug *ServicesMasterMenuUserGroup) GetUserGroup() ([]models.UserGroup, error) { + data := []models.UserGroup{ + {UserGroupID: 1, UserGroupKode: "A", UserGroupName: "UG1"}, + {UserGroupID: 2, UserGroupKode: "B", UserGroupName: "UG2"}, + {UserGroupID: 3, UserGroupKode: "C", UserGroupName: "UG3"}, + } + return data, nil +} + +func (ug *ServicesMasterMenuUserGroup) GetUserGroupByID(id string) (models.UserGroup, error) { + listdata := []models.UserGroup{ + {UserGroupID: 1, UserGroupKode: "A", UserGroupName: "UG1"}, + {UserGroupID: 2, UserGroupKode: "B", UserGroupName: "UG2"}, + {UserGroupID: 3, UserGroupKode: "C", UserGroupName: "UG3"}, + } + var data models.UserGroup + idData, err := strconv.Atoi(id) + if err != nil { + return data, fmt.Errorf("pack %v: %w", "Error", err) + } + for _, v := range listdata { + + if v.UserGroupID == idData { + data = v + } + } + time.Sleep(5 * time.Second) + return data, nil +} + // func (su *ServicesMasterMenuUserGroup) GetAllMasterMenus() ([]MasterMenu, error) { // query := `SELECT id, MasterMenuname, email, created_at FROM MasterMenus ORDER BY created_at DESC` diff --git a/views/component/customtextfield/customtextfield.templ b/views/component/customtextfield/customtextfield.templ index 189b9be..73c5598 100644 --- a/views/component/customtextfield/customtextfield.templ +++ b/views/component/customtextfield/customtextfield.templ @@ -11,7 +11,7 @@ templ MainCustomTextField(inpLabelText, name={ inpName } type={ inpType } placeholder={ inpPlaceHolder } - class="form-control bg-field border-0" + class="form-control bg-field border-0 h-auto py-6 px-6 rounded-lg" /> } diff --git a/views/component/customtextfield/customtextfield_templ.go b/views/component/customtextfield/customtextfield_templ.go index eaa6d1d..52c41ac 100644 --- a/views/component/customtextfield/customtextfield_templ.go +++ b/views/component/customtextfield/customtextfield_templ.go @@ -91,7 +91,7 @@ func MainCustomTextField(inpLabelText, if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" class=\"form-control bg-field border-0\">") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" class=\"form-control bg-field border-0 h-auto py-6 px-6 rounded-lg\">") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/views/component/customtextfield/customtextfieldv2.templ b/views/component/customtextfield/customtextfieldv2.templ new file mode 100644 index 0000000..c24ff90 --- /dev/null +++ b/views/component/customtextfield/customtextfieldv2.templ @@ -0,0 +1,17 @@ +package customtextfield + +import "github.com/emarifer/go-templ-project-structure/models" + +templ CustomTextFieldv2(inp models.CustomTextFieldv2Prm) { +
+ + +
+} diff --git a/views/component/customtextfield/customtextfieldv2_templ.go b/views/component/customtextfield/customtextfieldv2_templ.go new file mode 100644 index 0000000..8b20ddb --- /dev/null +++ b/views/component/customtextfield/customtextfieldv2_templ.go @@ -0,0 +1,115 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.663 +package customtextfield + +//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 "github.com/emarifer/go-templ-project-structure/models" + +func CustomTextFieldv2(inp models.CustomTextFieldv2Prm) 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_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/views/component/modal/modal.templ b/views/component/modal/modal.templ new file mode 100644 index 0000000..9742c2f --- /dev/null +++ b/views/component/modal/modal.templ @@ -0,0 +1,30 @@ +package modalcomponent + +templ Modal(modalID string, modalTitle string, modalBody templ.Component, modalAction templ.Component, btnClose templ.Component) { + +} diff --git a/views/component/modal/modal_templ.go b/views/component/modal/modal_templ.go new file mode 100644 index 0000000..7f79716 --- /dev/null +++ b/views/component/modal/modal_templ.go @@ -0,0 +1,85 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.663 +package modalcomponent + +//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" + +func Modal(modalID string, modalTitle string, modalBody templ.Component, modalAction templ.Component, btnClose templ.Component) 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_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var3 string + templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(modalTitle) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\component\modal\modal.templ`, Line: 17, Col: 18} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) + 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 = btnClose.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 + } + templ_7745c5c3_Err = modalBody.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 + }) +} diff --git a/views/mastermenuusergroup/mastermenuusergroup.templ b/views/mastermenuusergroup/mastermenuusergroup.templ index c7c045f..80a4aad 100644 --- a/views/mastermenuusergroup/mastermenuusergroup.templ +++ b/views/mastermenuusergroup/mastermenuusergroup.templ @@ -6,10 +6,12 @@ import ( "github.com/emarifer/go-templ-project-structure/services" "github.com/emarifer/go-templ-project-structure/models" "github.com/emarifer/go-templ-project-structure/views/component/table" + "github.com/emarifer/go-templ-project-structure/views/component/modal" + "strconv" ) // "github.com/emarifer/go-templ-project-structure/views/component/sidebar_user_profile" -templ ContentMasterMenuUserGroup() { +templ ContentMasterMenuUserGroup(ugData []models.UserGroup) {
@@ -18,7 +20,12 @@ templ ContentMasterMenuUserGroup() {
//
- +
@@ -26,32 +33,76 @@ templ ContentMasterMenuUserGroup() {
- @tablecomponent.Table([]string{"KODE", "USERGROUP", "AKSI"}, []string{"40%", "40%", "20%"}, TableRow(), Pagination()) + @tablecomponent.Table([]string{"KODE", "USERGROUP", "AKSI"}, []string{"40%", "40%", "20%"}, TableRow(ugData), Pagination())
+ @modalcomponent.Modal("dialogNew", "New - User Group", DialogNewBody("", ""), DialogNewAction(), BtnCloseNew()) + @modalcomponent.Modal("dialogEdit", "Edit - User Group", DialogEditBody("", ""), DialogEditAction(), BtnCloseNew()) + @JSku()
} -templ TableRow() { - - 001 - Admin - -
- - -
- - - - 002 - Tes - -
- - -
- - +templ TableRow(data []models.UserGroup) { + // /usergroup/edit + for _, v := range data { + + { v.UserGroupKode } + { v.UserGroupName } + +
+ + Hapus +
+ + + } +} + +templ JSku() { + } templ Pagination() { diff --git a/views/mastermenuusergroup/mastermenuusergroup_templ.go b/views/mastermenuusergroup/mastermenuusergroup_templ.go index c235a4f..bd99e4a 100644 --- a/views/mastermenuusergroup/mastermenuusergroup_templ.go +++ b/views/mastermenuusergroup/mastermenuusergroup_templ.go @@ -14,12 +14,14 @@ import ( "github.com/emarifer/go-templ-project-structure/models" "github.com/emarifer/go-templ-project-structure/services" "github.com/emarifer/go-templ-project-structure/views/component/breadcrumbadmin" + "github.com/emarifer/go-templ-project-structure/views/component/modal" "github.com/emarifer/go-templ-project-structure/views/component/table" "github.com/emarifer/go-templ-project-structure/views/layout" + "strconv" ) // "github.com/emarifer/go-templ-project-structure/views/component/sidebar_user_profile" -func ContentMasterMenuUserGroup() templ.Component { +func ContentMasterMenuUserGroup(ugData []models.UserGroup) 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 { @@ -40,15 +42,31 @@ func ContentMasterMenuUserGroup() templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = tablecomponent.Table([]string{"KODE", "USERGROUP", "AKSI"}, []string{"40%", "40%", "20%"}, TableRow(), Pagination()).Render(ctx, templ_7745c5c3_Buffer) + templ_7745c5c3_Err = tablecomponent.Table([]string{"KODE", "USERGROUP", "AKSI"}, []string{"40%", "40%", "20%"}, TableRow(ugData), Pagination()).Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = modalcomponent.Modal("dialogNew", "New - User Group", DialogNewBody("", ""), DialogNewAction(), BtnCloseNew()).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = modalcomponent.Modal("dialogEdit", "Edit - User Group", DialogEditBody("", ""), DialogEditAction(), BtnCloseNew()).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = JSku().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 } @@ -59,7 +77,7 @@ func ContentMasterMenuUserGroup() templ.Component { }) } -func TableRow() templ.Component { +func TableRow(data []models.UserGroup) 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 { @@ -72,7 +90,72 @@ func TableRow() templ.Component { templ_7745c5c3_Var2 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("001Admin
002Tes
") + for _, v := range data { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var3 string + templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(v.UserGroupKode) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\mastermenuusergroup\mastermenuusergroup.templ`, Line: 48, Col: 24} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) + 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_Var4 string + templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(v.UserGroupName) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\mastermenuusergroup\mastermenuusergroup.templ`, Line: 49, Col: 24} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
Hapus
") + 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 + }) +} + +func JSku() 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_Var6 := templ.GetChildren(ctx) + if templ_7745c5c3_Var6 == nil { + templ_7745c5c3_Var6 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -91,9 +174,9 @@ func Pagination() templ.Component { defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var3 := templ.GetChildren(ctx) - if templ_7745c5c3_Var3 == nil { - templ_7745c5c3_Var3 = templ.NopComponent + templ_7745c5c3_Var7 := templ.GetChildren(ctx) + if templ_7745c5c3_Var7 == nil { + templ_7745c5c3_Var7 = templ.NopComponent } ctx = templ.ClearChildren(ctx) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") @@ -115,9 +198,9 @@ func CssMasterMenuUserGroup() templ.Component { defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var4 := templ.GetChildren(ctx) - if templ_7745c5c3_Var4 == nil { - templ_7745c5c3_Var4 = templ.NopComponent + templ_7745c5c3_Var8 := templ.GetChildren(ctx) + if templ_7745c5c3_Var8 == nil { + templ_7745c5c3_Var8 = templ.NopComponent } ctx = templ.ClearChildren(ctx) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") @@ -139,9 +222,9 @@ func JsMasterMenuUserGroup() templ.Component { defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var5 := templ.GetChildren(ctx) - if templ_7745c5c3_Var5 == nil { - templ_7745c5c3_Var5 = templ.NopComponent + templ_7745c5c3_Var9 := templ.GetChildren(ctx) + if templ_7745c5c3_Var9 == nil { + templ_7745c5c3_Var9 = templ.NopComponent } ctx = templ.ClearChildren(ctx) if !templ_7745c5c3_IsBuffer { @@ -159,12 +242,12 @@ func ShowMasterMenuUserGroup(title string, cmp templ.Component, css templ.Compon defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var6 := templ.GetChildren(ctx) - if templ_7745c5c3_Var6 == nil { - templ_7745c5c3_Var6 = templ.NopComponent + templ_7745c5c3_Var10 := templ.GetChildren(ctx) + if templ_7745c5c3_Var10 == nil { + templ_7745c5c3_Var10 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Var7 := templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { + templ_7745c5c3_Var11 := 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() @@ -179,7 +262,7 @@ func ShowMasterMenuUserGroup(title string, cmp templ.Component, css templ.Compon } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = layout.CorporateLayout(title, css, js, dataMenu, dataUser).Render(templ.WithChildren(ctx, templ_7745c5c3_Var7), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = layout.CorporateLayout(title, css, js, dataMenu, dataUser).Render(templ.WithChildren(ctx, templ_7745c5c3_Var11), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/views/mastermenuusergroup/modaladdusergroup.templ b/views/mastermenuusergroup/modaladdusergroup.templ new file mode 100644 index 0000000..c4303fd --- /dev/null +++ b/views/mastermenuusergroup/modaladdusergroup.templ @@ -0,0 +1,56 @@ +package mastermenuusergroup + +import ( + "github.com/emarifer/go-templ-project-structure/models" + "github.com/emarifer/go-templ-project-structure/views/component/customtextfield" +) + +templ DialogNewBody(code string, name string) { +
+ @customtextfield.CustomTextFieldv2( + models.CustomTextFieldv2Prm{ + Label: "Kode user group", + Name: "usergroupcode", + Placeholder: "Kode user Group", + Type: "text", + Value: code, + }) + @customtextfield.CustomTextFieldv2( + models.CustomTextFieldv2Prm{ + Label: "Nama User Group", + Name: "usergroupname", + Placeholder: "Nama User Group", + Type: "text", + Value: name, + }) +
+} + +templ DialogNewAction() { +
+ + +
+} + +templ BtnCloseNew() { + +} diff --git a/views/mastermenuusergroup/modaladdusergroup_templ.go b/views/mastermenuusergroup/modaladdusergroup_templ.go new file mode 100644 index 0000000..cf7559d --- /dev/null +++ b/views/mastermenuusergroup/modaladdusergroup_templ.go @@ -0,0 +1,114 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.663 +package mastermenuusergroup + +//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 ( + "github.com/emarifer/go-templ-project-structure/models" + "github.com/emarifer/go-templ-project-structure/views/component/customtextfield" +) + +func DialogNewBody(code string, name string) 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_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = customtextfield.CustomTextFieldv2( + models.CustomTextFieldv2Prm{ + Label: "Kode user group", + Name: "usergroupcode", + Placeholder: "Kode user Group", + Type: "text", + Value: code, + }).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = customtextfield.CustomTextFieldv2( + models.CustomTextFieldv2Prm{ + Label: "Nama User Group", + Name: "usergroupname", + Placeholder: "Nama User Group", + Type: "text", + Value: name, + }).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 + }) +} + +func DialogNewAction() 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_Var2 := templ.GetChildren(ctx) + if templ_7745c5c3_Var2 == nil { + templ_7745c5c3_Var2 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, 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 + }) +} + +func BtnCloseNew() 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_Var3 := templ.GetChildren(ctx) + if templ_7745c5c3_Var3 == nil { + templ_7745c5c3_Var3 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, 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/views/mastermenuusergroup/modaleditusergroup.templ b/views/mastermenuusergroup/modaleditusergroup.templ new file mode 100644 index 0000000..a0a61dd --- /dev/null +++ b/views/mastermenuusergroup/modaleditusergroup.templ @@ -0,0 +1,79 @@ +package mastermenuusergroup + +import ( + "github.com/emarifer/go-templ-project-structure/models" + "github.com/emarifer/go-templ-project-structure/views/component/customtextfield" +) + +templ DialogEditForm(code string, name string) { + @customtextfield.CustomTextFieldv2( + models.CustomTextFieldv2Prm{ + Label: "Kode user group", + Name: "usergroupcode", + Placeholder: "Kode user Group", + Type: "text", + Value: code, + }) + @customtextfield.CustomTextFieldv2( + models.CustomTextFieldv2Prm{ + Label: "Nama User Group", + Name: "usergroupname", + Placeholder: "Nama User Group", + Type: "text", + Value: name, + }) +} + +templ DialogEditBody(code string, name string) { +
+ @DialogEditForm(code, name) +
+
+
+
+
+
+} + +templ LoadingSpinner() { +
+
+
+
+
+} + +templ DialogEditAction() { +
+ + +
+} + +templ BtnCloseEdit() { + +} diff --git a/views/mastermenuusergroup/modaleditusergroup_templ.go b/views/mastermenuusergroup/modaleditusergroup_templ.go new file mode 100644 index 0000000..a4192aa --- /dev/null +++ b/views/mastermenuusergroup/modaleditusergroup_templ.go @@ -0,0 +1,162 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.663 +package mastermenuusergroup + +//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 ( + "github.com/emarifer/go-templ-project-structure/models" + "github.com/emarifer/go-templ-project-structure/views/component/customtextfield" +) + +func DialogEditForm(code string, name string) 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 = customtextfield.CustomTextFieldv2( + models.CustomTextFieldv2Prm{ + Label: "Kode user group", + Name: "usergroupcode", + Placeholder: "Kode user Group", + Type: "text", + Value: code, + }).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = customtextfield.CustomTextFieldv2( + models.CustomTextFieldv2Prm{ + Label: "Nama User Group", + Name: "usergroupname", + Placeholder: "Nama User Group", + Type: "text", + Value: name, + }).Render(ctx, templ_7745c5c3_Buffer) + 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 + }) +} + +func DialogEditBody(code string, name string) 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_Var2 := templ.GetChildren(ctx) + if templ_7745c5c3_Var2 == nil { + templ_7745c5c3_Var2 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = DialogEditForm(code, name).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 + }) +} + +func LoadingSpinner() 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_Var3 := templ.GetChildren(ctx) + if templ_7745c5c3_Var3 == nil { + templ_7745c5c3_Var3 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, 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 + }) +} + +func DialogEditAction() 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_Var4 := templ.GetChildren(ctx) + if templ_7745c5c3_Var4 == nil { + templ_7745c5c3_Var4 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, 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 + }) +} + +func BtnCloseEdit() 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_Var5 := templ.GetChildren(ctx) + if templ_7745c5c3_Var5 == nil { + templ_7745c5c3_Var5 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, 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/views/xsample/trycounter.templ b/views/xsample/trycounter.templ new file mode 100644 index 0000000..9f41ba4 --- /dev/null +++ b/views/xsample/trycounter.templ @@ -0,0 +1,51 @@ +package xsample + +import "strconv" +import ( + "github.com/emarifer/go-templ-project-structure/views/layout" +) + +templ Counts(counter int) { +
counter: { strconv.Itoa(counter) }
+} + +templ Form(counter int) { + // /show?team=x-men&member=wolverine + // hx-get="/xsample/counterchange?type=min&counter" + // /xsample/counterchange?type=min&counter= +
+ +1 +
+
+ -1 +
+} + +templ CssCtr() { +} + +templ JsCtr() { +} + +templ Page(counter int) { + @layout.PlaygroundLayout("Coba counter", CssCtr(), JsCtr()) { +
+ @Counts(counter) + @Form(counter) +
+ } +} diff --git a/views/xsample/trycounter_templ.go b/views/xsample/trycounter_templ.go new file mode 100644 index 0000000..0650659 --- /dev/null +++ b/views/xsample/trycounter_templ.go @@ -0,0 +1,194 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.663 +package xsample + +//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 ( + "github.com/emarifer/go-templ-project-structure/views/layout" +) + +func Counts(counter int) 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_7745c5c3_Buffer.WriteString("
counter: ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var2 string + templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(strconv.Itoa(counter)) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\xsample\trycounter.templ`, Line: 9, Col: 48} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2)) + 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 + }) +} + +func Form(counter int) 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_Var3 := templ.GetChildren(ctx) + if templ_7745c5c3_Var3 == nil { + templ_7745c5c3_Var3 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
+1
-1
") + 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 + }) +} + +func CssCtr() 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_Var6 := templ.GetChildren(ctx) + if templ_7745c5c3_Var6 == nil { + templ_7745c5c3_Var6 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) + } + return templ_7745c5c3_Err + }) +} + +func JsCtr() 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_Var7 := templ.GetChildren(ctx) + if templ_7745c5c3_Var7 == nil { + templ_7745c5c3_Var7 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) + } + return templ_7745c5c3_Err + }) +} + +func Page(counter int) 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_Var8 := templ.GetChildren(ctx) + if templ_7745c5c3_Var8 == nil { + templ_7745c5c3_Var8 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Var9 := 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) + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = Counts(counter).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = Form(counter).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 = io.Copy(templ_7745c5c3_W, templ_7745c5c3_Buffer) + } + return templ_7745c5c3_Err + }) + templ_7745c5c3_Err = layout.PlaygroundLayout("Coba counter", CssCtr(), JsCtr()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var9), templ_7745c5c3_Buffer) + 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 + }) +}