From fb91440c81a5d88886b527c5583b4366a97d71f2 Mon Sep 17 00:00:00 2001 From: sindhu Date: Wed, 8 May 2024 13:36:37 +0700 Subject: [PATCH] autocomplete --- handlers/mastermenuusergroup.handlers.go | 172 +++++++++++ handlers/routes.go | 5 + services/mastermenuusergroup.services.go | 198 +++++++++++++ .../customtextfieldautocomplete.templ | 126 ++++++++ .../customtextfieldautocomplete_templ.go | 268 ++++++++++++++++++ .../mastermenuusergroup.templ | 4 +- .../mastermenuusergroup_templ.go | 5 + 7 files changed, 777 insertions(+), 1 deletion(-) create mode 100644 views/component/customtextfieldautocomplete/customtextfieldautocomplete.templ create mode 100644 views/component/customtextfieldautocomplete/customtextfieldautocomplete_templ.go diff --git a/handlers/mastermenuusergroup.handlers.go b/handlers/mastermenuusergroup.handlers.go index 7065a55..ec88c46 100644 --- a/handlers/mastermenuusergroup.handlers.go +++ b/handlers/mastermenuusergroup.handlers.go @@ -2,15 +2,19 @@ package handlers import ( "fmt" + "net/url" + "strconv" "github.com/a-h/templ" "github.com/emarifer/go-templ-project-structure/services" + "github.com/emarifer/go-templ-project-structure/views/component/customtextfieldautocomplete" mastermenuusergroup "github.com/emarifer/go-templ-project-structure/views/mastermenuusergroup" "github.com/labstack/echo/v4" ) type MasterMenuUserGroupService interface { GetMasterMenus() ([]services.MasterMenu, error) + GetAutoComplete(param string, pageOf string, limit string) (string, string, string, []services.AutoComplete, error) } func NewMasterMenuUserGroupHandler(us MasterMenuUserGroupService) *MasterMenuUserGroupHandler { @@ -48,6 +52,174 @@ func (lh *MasterMenuUserGroupHandler) HandlerShowMasterMenuUserGroup(c echo.Cont return lh.View(c, si) } +// initial +func (lh *MasterMenuUserGroupHandler) HandlerListAutoComplete(c echo.Context) error { + // param := c.Param("p") + param := c.QueryParam("searchAutocomplete") + pageOf := "1" + limit := "3" + + pageOfBefore, _ := strconv.Atoi(c.Param("pageOf")) + limitBefore, _ := strconv.Atoi(c.Param("limit")) + + if pageOfBefore > 1 { + pageCurrent := pageOfBefore + 1 + pageOf = strconv.Itoa(pageCurrent) + + limitCurrent := limitBefore + limit = strconv.Itoa(limitCurrent) + } + + // urlCustomAutoComplete := "/client/autoCompleteLoadMore/"+ strconv.Itoa(pageOf) + var si templ.Component + if param != "" { + totalData, foundCount, textFound, dataAutoComplete, err := lh.MasterMenuUserGroupService.GetAutoComplete(param, pageOf, limit) + fmt.Println(param) + // fmt.Println(err) + if err != nil { + fmt.Println(dataAutoComplete) + return err + } + + foundCountInt, err := strconv.Atoi(foundCount) + if err != nil { + return err + } + + totalDataInt, err := strconv.Atoi(totalData) + if err != nil { + return err + } + + // si := customtextfieldautocomplete.ListCustomAutoComplete(dataAutoComplete) + + si = customtextfieldautocomplete.ListCustomAutoComplete(limit, param, totalDataInt, foundCountInt, pageOf, textFound, dataAutoComplete) + } else { + si = customtextfieldautocomplete.ListCustomAutoCompleteHide() + } + + return lh.View(c, si) +} + +// after selected +func (lh *MasterMenuUserGroupHandler) HandlerListAutoCompleteAfterSelected(c echo.Context) error { + // param := c.QueryParam("searchAutocomplete") + + setvalue := c.Param("setvalue") + setvalue, err := url.PathUnescape(setvalue) + if err != nil { + return err + } + + si := customtextfieldautocomplete.MainCustomAutoComplete(setvalue) + + return lh.View(c, si) +} + +// load more autocomplete +func (lh *MasterMenuUserGroupHandler) HandlerListAutoCompleteLoadMore(c echo.Context) error { + // param := c.QueryParam("searchAutocomplete") + + var totalPerPage int = 3 + paramSearch := c.Param("searchParam") + searchParam, err := url.PathUnescape(paramSearch) + if err != nil { + return err + } + + pageOfStr := c.Param("pageOf") + pageOfInt, err := strconv.Atoi(pageOfStr) + if err != nil { + return err + } + + pageOfInt++ + pageOf := strconv.Itoa(pageOfInt) + + limitOfStr := c.Param("limit") + limitOfInt, err := strconv.Atoi(limitOfStr) + if err != nil { + return err + } + + limitOfX := limitOfInt + totalPerPage + limitOf := strconv.Itoa(limitOfX) + + var si templ.Component + + totalData, foundCount, textFound, dataAutoComplete, err := lh.MasterMenuUserGroupService.GetAutoComplete(searchParam, pageOf, limitOf) + + // fmt.Println(param) + // fmt.Println(err) + + if err != nil { + fmt.Println(dataAutoComplete) + return err + } + + foundCountInt, err := strconv.Atoi(foundCount) + if err != nil { + return err + } + + totalDataInt, err := strconv.Atoi(totalData) + if err != nil { + return err + } + + // si := customtextfieldautocomplete.ListCustomAutoComplete(dataAutoComplete) + si = customtextfieldautocomplete.ListCustomAutoComplete(limitOf, searchParam, totalDataInt, foundCountInt, pageOf, textFound, dataAutoComplete) + + // if param != "" { + // textFound, dataAutoComplete, err := lh.MasterMenuUserGroupService.GetAutoComplete(param, pageOf) + // fmt.Println(param) + // // fmt.Println(err) + // if err != nil { + // fmt.Println(dataAutoComplete) + // return err + // } + + // // si := customtextfieldautocomplete.ListCustomAutoComplete(dataAutoComplete) + // si = customtextfieldautocomplete.ListCustomAutoComplete(pageOf, textFound, dataAutoComplete) + + // } else { + // si = customtextfieldautocomplete.ListCustomAutoCompleteHide() + // } + + return lh.View(c, si) +} + +func (lh *MasterMenuUserGroupHandler) HandlerAutoCompleteExample(c echo.Context) error { + // dataAutoComplete, err := lh.MasterMenuUserGroupService.GetAutoCompleteExample() + // fmt.Println(dataAutoComplete) + // fmt.Println(err) + // if err != nil { + // fmt.Println(dataAutoComplete) + // return err + // } + // fmt.Printf("%+v\n", dataMenu) + // si := mastermenu.ShowMasterMenu("Master Menu", + // mastermenu.MainMasterMenu(dataMenu), + // mastermenu.CssMasterMenu(), + // mastermenu.JsMasterMenu(), + // ) + + // si := mastermenuusergroup.ShowMasterMenuUserGroup( + // "Master Menu", + // mastermenuusergroup.MainMasterMenuUserGroup(dataMenu), + // mastermenuusergroup.CssMasterMenuUserGroup(), + // mastermenuusergroup.JsMasterMenuUserGroup(), + // ) + + si := customtextfieldautocomplete.ShowCustomAutoComplete("", + customtextfieldautocomplete.MainCustomAutoComplete(""), + customtextfieldautocomplete.CssCustomAutoComplete(), + customtextfieldautocomplete.JsCustomAutoComplete(), + ) + + return lh.View(c, si) +} + 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 b34dc81..dab2983 100644 --- a/handlers/routes.go +++ b/handlers/routes.go @@ -26,6 +26,11 @@ func SetupRoutesLandingPage(app *echo.Echo, h *LandingPageHandler, mastermenuuse // mdgroup := clientgroup.Group("/md") // clientusergroup.GET("/md", mastermenuusergroupHandler.HandlerShowMasterMenuUserGroup) clientgroup.GET("/usergroup", mastermenuusergroupHandler.HandlerShowMasterMenuUserGroup) + autocomplete := app.Group("/client") + autocomplete.GET("/autocomplete", mastermenuusergroupHandler.HandlerListAutoComplete) + autocomplete.GET("/autoCompleteLoadMore/:pageOf/:searchParam/:limit", mastermenuusergroupHandler.HandlerListAutoCompleteLoadMore) + autocomplete.GET("/autoCompleteSetValue/:setvalue", mastermenuusergroupHandler.HandlerListAutoCompleteAfterSelected) + } func SetupRoutesPieChart(app *echo.Echo, h *PiechartHandler) { Lp := app.Group("/pie_chart") diff --git a/services/mastermenuusergroup.services.go b/services/mastermenuusergroup.services.go index 4b3d65c..711f2bc 100644 --- a/services/mastermenuusergroup.services.go +++ b/services/mastermenuusergroup.services.go @@ -1,6 +1,9 @@ package services import ( + "fmt" + "strconv" + "github.com/emarifer/go-templ-project-structure/db" ) @@ -41,6 +44,10 @@ type ServicesMasterMenuUserGroup struct { MasterMenuUserGroupStore db.MasterMenuUserGroupStore } +type AutoComplete struct { + Name string `json:"name"` +} + func (su *ServicesMasterMenuUserGroup) GetMasterMenus() ([]MasterMenu, error) { // dummyBreadcrumb := []Breadcrumb{ @@ -543,6 +550,197 @@ func (su *ServicesMasterMenuUserGroup) GetMasterMenus() ([]MasterMenu, error) { return dummyMenu, nil } +func contains(s, substr string) bool { + return s != "" && substr != "" && len(s) >= len(substr) && s[:len(substr)] == substr +} + +// example autocomplete +func (su *ServicesMasterMenuUserGroup) GetAutoComplete(param string, pageOfParam string, limitOfStr string) (string, string, string, []AutoComplete, error) { + // fmt.Println("ini param : ", param) + + dummyAutoComplete := []AutoComplete{ + { + Name: "Google", + }, + { + Name: "Google 1", + }, + { + Name: "Google 2", + }, + { + Name: "Google 3", + }, + { + Name: "Google 4", + }, + { + Name: "Google 5", + }, + { + Name: "Google 6", + }, + { + Name: "Gojek", + }, + { + Name: "Mozilla Firefox", + }, + { + Name: "Apple", + }, + { + Name: "Microsoft", + }, + { + Name: "Facebook", + }, + { + Name: "Amazon", + }, + { + Name: "Twitter", + }, + { + Name: "Instagram", + }, + { + Name: "Snapchat", + }, + { + Name: "LinkedIn", + }, + { + Name: "Netflix", + }, + { + Name: "YouTube", + }, + { + Name: "Reddit", + }, + { + Name: "WhatsApp", + }, + { + Name: "Pinterest", + }, + { + Name: "TikTok", + }, + { + Name: "Spotify", + }, + { + Name: "Zoom", + }, + } + + var textFound string + var results []AutoComplete + // var currentRes []AutoComplete + // var oldResults []AutoComplete + // var limit int = 3 + var count int = 0 + var foundCount int = 0 + var totalData int = 0 + var startIndex int = 0 + var endIndex int = 3 + + if len(dummyAutoComplete) > 0 { + totalData = len(dummyAutoComplete) + } + + // pageOf, err := strconv.Atoi(pageOfParam) + // if err != nil { + // return "", "", "", nil, err + // } + + limit, err := strconv.Atoi(limitOfStr) + if err != nil { + return "", "", "", nil, err + } + + // find data search + if pageOfParam == "1" { + count = 0 + // for _, item := range dummyAutoComplete { + // if contains(item.Name, param) { + // results = append(results, item) + // count++ + // if count == limit { + // break + // } + // } + // } + + for _, item := range dummyAutoComplete { + if contains(item.Name, param) { + // Check if the item is already in results + found := false + for _, res := range results { + if res.Name == item.Name { + found = true + break + } + } + // If not found, append it + if !found { + results = append(results, item) + count++ + if count == limit { + break + } + } + } + } + + } else { + // ketika klik load more + // count = 0 + for _, item := range dummyAutoComplete { + if contains(item.Name, param) { + results = append(results, item) + count++ + if count == limit { + break + } + } + } + + startIndex = 0 + endIndex = limit + + if startIndex >= len(dummyAutoComplete) { + return "", "max", "", nil, nil + } + + if endIndex > len(dummyAutoComplete) { + endIndex = len(dummyAutoComplete) + } + + for _, item := range dummyAutoComplete[startIndex:endIndex] { + found := false + for _, res := range results { + if res.Name == item.Name { + found = true + break + } + } + // If not found, append it + if !found { + results = append(results, item) + } + } + } + + foundCount = len(results) + totalCount := len(dummyAutoComplete) + textFound = fmt.Sprintf("Ditemukan %d dari %d", foundCount, totalCount) + + return strconv.Itoa(totalData), strconv.Itoa(foundCount), textFound, results, 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/customtextfieldautocomplete/customtextfieldautocomplete.templ b/views/component/customtextfieldautocomplete/customtextfieldautocomplete.templ new file mode 100644 index 0000000..3fbbe69 --- /dev/null +++ b/views/component/customtextfieldautocomplete/customtextfieldautocomplete.templ @@ -0,0 +1,126 @@ +package customtextfieldautocomplete; + +import ( + "github.com/emarifer/go-templ-project-structure/views/layout" + "github.com/emarifer/go-templ-project-structure/services" +) + +templ MainCustomAutoComplete(value string) { +
+ +
+
+ Loading... +
+
+
+} + +templ ListCustomAutoCompleteHide() { +
+} + +templ ListCustomAutoComplete(limit string, param string, totalDataInt int, foundCount int, pageOf string, textFound string, data []services.AutoComplete) { + +} + +templ JsCustomAutoComplete() { +} + +templ CssCustomAutoComplete() { + +} + +templ ShowCustomAutoComplete(title string, cmp templ.Component, css templ.Component, js templ.Component) { + @layout.PlaygroundLayout(title, css, js) { + @cmp + } +} diff --git a/views/component/customtextfieldautocomplete/customtextfieldautocomplete_templ.go b/views/component/customtextfieldautocomplete/customtextfieldautocomplete_templ.go new file mode 100644 index 0000000..b65d634 --- /dev/null +++ b/views/component/customtextfieldautocomplete/customtextfieldautocomplete_templ.go @@ -0,0 +1,268 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.663 +package customtextfieldautocomplete + +//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/services" + "github.com/emarifer/go-templ-project-structure/views/layout" +) + +func MainCustomAutoComplete(value 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("
Loading...
") + 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 ListCustomAutoCompleteHide() 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 ListCustomAutoComplete(limit string, param string, totalDataInt int, foundCount int, pageOf string, textFound string, data []services.AutoComplete) 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 len(data) == 0 { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("Data Tidak Ditemukan") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } else { + for _, d := range data { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var6 string + templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(d.Name) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\component\customtextfieldautocomplete\customtextfieldautocomplete.templ`, Line: 48, Col: 13} + } + _, 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("") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
Loading...

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var7 string + templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(textFound) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\component\customtextfieldautocomplete\customtextfieldautocomplete.templ`, Line: 59, Col: 76} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) + 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 foundCount == totalDataInt { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("Show More") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } else { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("Show More") + 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 JsCustomAutoComplete() 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_Var9 := templ.GetChildren(ctx) + if templ_7745c5c3_Var9 == nil { + templ_7745c5c3_Var9 = 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 CssCustomAutoComplete() 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_Var10 := templ.GetChildren(ctx) + if templ_7745c5c3_Var10 == nil { + templ_7745c5c3_Var10 = 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 ShowCustomAutoComplete(title string, cmp templ.Component, css templ.Component, js 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_Var11 := templ.GetChildren(ctx) + if templ_7745c5c3_Var11 == nil { + templ_7745c5c3_Var11 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Var12 := 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 = cmp.Render(ctx, templ_7745c5c3_Buffer) + 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(title, css, js).Render(templ.WithChildren(ctx, templ_7745c5c3_Var12), 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 + }) +} diff --git a/views/mastermenuusergroup/mastermenuusergroup.templ b/views/mastermenuusergroup/mastermenuusergroup.templ index 624e94f..5523021 100644 --- a/views/mastermenuusergroup/mastermenuusergroup.templ +++ b/views/mastermenuusergroup/mastermenuusergroup.templ @@ -5,9 +5,9 @@ import ( "github.com/emarifer/go-templ-project-structure/services" "github.com/emarifer/go-templ-project-structure/views/component/sidebarmaster" "github.com/emarifer/go-templ-project-structure/views/component/breadcrumbadmin" + "github.com/emarifer/go-templ-project-structure/views/component/customtextfieldautocomplete" ) - templ MainNavbar(datamenu []services.MasterMenu) {
@@ -190,6 +190,8 @@ templ MainMasterMenuUserGroup(datamenu []services.MasterMenu) {
@breadcrumadmin.MainBreadcrumbAdmin() + // inputan autocomplete + @customtextfieldautocomplete.ShowCustomAutoComplete("", customtextfieldautocomplete.MainCustomAutoComplete(""), customtextfieldautocomplete.CssCustomAutoComplete(), customtextfieldautocomplete.JsCustomAutoComplete())
diff --git a/views/mastermenuusergroup/mastermenuusergroup_templ.go b/views/mastermenuusergroup/mastermenuusergroup_templ.go index eb1a1be..8edb06b 100644 --- a/views/mastermenuusergroup/mastermenuusergroup_templ.go +++ b/views/mastermenuusergroup/mastermenuusergroup_templ.go @@ -13,6 +13,7 @@ import "bytes" import ( "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/customtextfieldautocomplete" "github.com/emarifer/go-templ-project-structure/views/component/sidebarmaster" "github.com/emarifer/go-templ-project-structure/views/layout" ) @@ -104,6 +105,10 @@ func MainMasterMenuUserGroup(datamenu []services.MasterMenu) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } + templ_7745c5c3_Err = customtextfieldautocomplete.ShowCustomAutoComplete("", customtextfieldautocomplete.MainCustomAutoComplete(""), customtextfieldautocomplete.CssCustomAutoComplete(), customtextfieldautocomplete.JsCustomAutoComplete()).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

User Profile\r 12 messages

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err