From 329db2e2ac6ab7bad0a0525cca56425755d1680f Mon Sep 17 00:00:00 2001 From: Sas Andy Date: Mon, 6 May 2024 13:27:28 +0700 Subject: [PATCH] layout corporate, navbar & side bar templ --- handlers/mastermenuusergroup.handlers.go | 17 +- handlers/routes.go | 1 + handlers/xsample.handlers.go | 25 + models/table.models.go | 1 - models/user.models.go | 8 + services/user.services.go | 11 + services/xsample.services.go | 502 ++++++++++++++ utils/generaterandomid.utils.go | 16 + views/component/navbar/navbar.templ | 74 ++ views/component/navbar/navbar_templ.go | 112 +++ .../component/navbarmaster/navbarmaster.templ | 655 ------------------ .../navbarmaster/navbarmaster_templ.go | 138 ---- .../sidebar_user_profile.templ | 82 +++ .../sidebar_user_profile_templ.go | 127 ++++ views/layout/layout_corporate.templ | 133 +++- views/layout/layout_corporate_templ.go | 39 +- .../mastermenuusergroup.templ | 43 +- .../mastermenuusergroup_templ.go | 69 +- views/xsample/coba.templ | 23 + views/xsample/coba_templ.go | 133 ++++ 20 files changed, 1306 insertions(+), 903 deletions(-) delete mode 100644 models/table.models.go create mode 100644 models/user.models.go create mode 100644 utils/generaterandomid.utils.go create mode 100644 views/component/navbar/navbar.templ create mode 100644 views/component/navbar/navbar_templ.go delete mode 100644 views/component/navbarmaster/navbarmaster.templ delete mode 100644 views/component/navbarmaster/navbarmaster_templ.go create mode 100644 views/component/sidebar_user_profile/sidebar_user_profile.templ create mode 100644 views/component/sidebar_user_profile/sidebar_user_profile_templ.go create mode 100644 views/xsample/coba.templ create mode 100644 views/xsample/coba_templ.go diff --git a/handlers/mastermenuusergroup.handlers.go b/handlers/mastermenuusergroup.handlers.go index 7065a55..b7babb7 100644 --- a/handlers/mastermenuusergroup.handlers.go +++ b/handlers/mastermenuusergroup.handlers.go @@ -31,18 +31,21 @@ func (lh *MasterMenuUserGroupHandler) HandlerShowMasterMenuUserGroup(c echo.Cont fmt.Println(dataMenu) return err } - // fmt.Printf("%+v\n", dataMenu) - // si := mastermenu.ShowMasterMenu("Master Menu", - // mastermenu.MainMasterMenu(dataMenu), - // mastermenu.CssMasterMenu(), - // mastermenu.JsMasterMenu(), - // ) + dataUser, err := services.GetUser() + fmt.Println(dataUser) + fmt.Println(err) + if err != nil { + fmt.Println(dataUser) + return err + } si := mastermenuusergroup.ShowMasterMenuUserGroup( "Master Menu", - mastermenuusergroup.MainMasterMenuUserGroup(dataMenu), + mastermenuusergroup.ContentMasterMenuUserGroup(), mastermenuusergroup.CssMasterMenuUserGroup(), mastermenuusergroup.JsMasterMenuUserGroup(), + dataMenu, + dataUser, ) return lh.View(c, si) diff --git a/handlers/routes.go b/handlers/routes.go index b34dc81..b30c9db 100644 --- a/handlers/routes.go +++ b/handlers/routes.go @@ -18,6 +18,7 @@ func SetupRoutesLogin(app *echo.Echo, h *LoginHandler) { func SetupRoutesXsample(app *echo.Echo, h *XsampleHandler) { xSample := app.Group("/xsample") xSample.GET("/xsample01", h.Hello) + xSample.GET("/coba", h.ShowCoba) } func SetupRoutesLandingPage(app *echo.Echo, h *LandingPageHandler, mastermenuusergroupHandler *MasterMenuUserGroupHandler) { Lp := app.Group("/landing_page") diff --git a/handlers/xsample.handlers.go b/handlers/xsample.handlers.go index 9253c6b..7d07e58 100644 --- a/handlers/xsample.handlers.go +++ b/handlers/xsample.handlers.go @@ -1,13 +1,18 @@ package handlers import ( + "fmt" + "github.com/a-h/templ" + "github.com/emarifer/go-templ-project-structure/services" + "github.com/emarifer/go-templ-project-structure/utils" "github.com/emarifer/go-templ-project-structure/views/xsample" "github.com/labstack/echo/v4" ) type XsampleService interface { + GetListMenus() ([]services.MasterMenu, error) } func NewXsampleHandler(us XsampleService) *XsampleHandler { @@ -24,6 +29,26 @@ func (uh *XsampleHandler) Hello(c echo.Context) error { helo := xsample.ShowHelo("Hello World", xsample.HelloWorld("Hello World"), xsample.CssHelo(), xsample.JsHelo()) return uh.View(c, helo) } +func (uh *XsampleHandler) ShowCoba(c echo.Context) error { + dataMenu, err := uh.XsampleService.GetListMenus() + fmt.Println(dataMenu) + fmt.Println(err) + if err != nil { + fmt.Println(dataMenu) + return err + } + randomID := utils.GenerateRandomID("coba") + fmt.Println(randomID) + dataUser, err := services.GetUser() + fmt.Println(dataUser) + fmt.Println(err) + if err != nil { + fmt.Println(dataUser) + return err + } + helo := xsample.ShowCoba("Hello World", xsample.Coba("Hello World"), xsample.CssCoba(), xsample.JsCoba(), dataMenu, dataUser) + 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/table.models.go b/models/table.models.go deleted file mode 100644 index 2640e7f..0000000 --- a/models/table.models.go +++ /dev/null @@ -1 +0,0 @@ -package models diff --git a/models/user.models.go b/models/user.models.go new file mode 100644 index 0000000..bb118c8 --- /dev/null +++ b/models/user.models.go @@ -0,0 +1,8 @@ +package models + +type User struct { + UserID int `json:"userID"` + Username string `json:"username"` + UserFullName string `json:"userFullName"` + UserPosition string `json:"userPosition"` +} diff --git a/services/user.services.go b/services/user.services.go index 37e071b..63f63f8 100644 --- a/services/user.services.go +++ b/services/user.services.go @@ -4,6 +4,7 @@ import ( "time" "github.com/emarifer/go-templ-project-structure/db" + "github.com/emarifer/go-templ-project-structure/models" ) func NewServicesUser(u User, uStore db.UserStore) *ServicesUser { @@ -84,3 +85,13 @@ func ConverDateTime(tz string, dt time.Time) string { return dt.In(loc).Format(time.RFC822Z) } + +func GetUser() (models.User, error) { + a := models.User{ + UserID: 1, + Username: "andy", + UserFullName: "Alfianto Andy P", + UserPosition: "Software Developer", + } + return a, nil +} diff --git a/services/xsample.services.go b/services/xsample.services.go index fc24081..517f131 100644 --- a/services/xsample.services.go +++ b/services/xsample.services.go @@ -78,3 +78,505 @@ func (su *ServicesXsample) GetXsampleById(id int) (Xsample, error) { return su.Xsample, nil } + +func (su *ServicesXsample) GetListMenus() ([]MasterMenu, error) { + + // dummyBreadcrumb := []Breadcrumb{ + // { + // Name: "Dashboard", + // Url: "/client/dashboard", + // }, + // { + // Name: "Front Office", + // Url: "/client/usermanagement", + // }, + // } + + dummyMenu := []MasterMenu{ + // 1. Dashboard + { + ID: "1", + ParentMenuID: "0", + ParentMenuName: "Dashboard", + ParentUrl: "/client/md/dashboard", + ParentIcon: "", + Children: []ChildrenMenu{ + { + ChildrenParentID: "1", + ChildrenMenuID: "1", + ChildrenMenuName: "Master User", + ChildrenMenuURL: "/client/md/user", + // Breadcrumb: []Breadcrumb{ + // { + // IDBreadcrumb: "1", + // Title: "Dashboard", + // IsActive: "Y", + // }, + // }, + }, + }, + }, + + // 2. Front Office + { + ID: "2", + ParentMenuID: "1", + ParentMenuName: "Front Office", + ParentUrl: "#", + ParentIcon: "", + Children: []ChildrenMenu{ + { + ChildrenParentID: "1", + ChildrenMenuID: "1", + ChildrenMenuName: "Registrasi", + ChildrenMenuURL: "/fo/registrasi", + // Breadcrumb: []Breadcrumb{ + // { + // IDBreadcrumb: "1", + // Title: "Dashboard", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "2", + // Title: "Master", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "3", + // Title: "User", + // IsActive: "Y", + // }, + // }, + }, + }, + }, + + // 3. Station + { + ID: "3", + ParentMenuID: "2", + ParentMenuName: "Station", + ParentUrl: "#", + ParentIcon: "", + Children: []ChildrenMenu{ + { + ChildrenParentID: "2", + ChildrenMenuID: "1", + ChildrenMenuName: "Sample Station", + ChildrenMenuURL: "/station/sample", + // Breadcrumb: []Breadcrumb{ + // { + // IDBreadcrumb: "1", + // Title: "Dashboard", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "2", + // Title: "Master", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "3", + // Title: "User", + // IsActive: "Y", + // }, + // }, + }, + }, + }, + + // 4. Management MCU + { + ID: "4", + ParentMenuID: "3", + ParentMenuName: "Management MCU", + ParentUrl: "#", + ParentIcon: "", + Children: []ChildrenMenu{ + { + ChildrenParentID: "3", + ChildrenMenuID: "1", + ChildrenMenuName: "Setup MCU", + ChildrenMenuURL: "/mcu/setup", + // Breadcrumb: []Breadcrumb{ + // { + // IDBreadcrumb: "1", + // Title: "Dashboard", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "2", + // Title: "Master", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "3", + // Title: "User", + // IsActive: "Y", + // }, + // }, + }, + { + ChildrenParentID: "3", + ChildrenMenuID: "2", + ChildrenMenuName: "Pre-Registrasi", + ChildrenMenuURL: "/mcu/preregister", + // Breadcrumb: []Breadcrumb{ + // { + // IDBreadcrumb: "1", + // Title: "Dashboard", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "2", + // Title: "Master", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "3", + // Title: "User", + // IsActive: "Y", + // }, + // }, + }, + }, + }, + + // 5. Master Data + { + ID: "5", + ParentMenuID: "4", + ParentMenuName: "Master Data", + ParentUrl: "#", + ParentIcon: "", + Children: []ChildrenMenu{ + // * Master User + { + ChildrenParentID: "4", + ChildrenMenuID: "1", + ChildrenMenuName: "Master User", + ChildrenMenuURL: "/client/md/user", + // Breadcrumb: []Breadcrumb{ + // { + // IDBreadcrumb: "1", + // Title: "Dashboard", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "2", + // Title: "Master", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "3", + // Title: "User", + // IsActive: "Y", + // }, + // }, + }, + + // * Master User Group + { + ChildrenParentID: "4", + ChildrenMenuID: "2", + ChildrenMenuName: "Master User Group", + ChildrenMenuURL: "/client/md/usergroup", + // Breadcrumb: []Breadcrumb{ + // { + // IDBreadcrumb: "1", + // Title: "Dashboard", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "2", + // Title: "Master", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "3", + // Title: "User Group", + // IsActive: "Y", + // }, + // }, + }, + + // * Master Corporate + { + ChildrenParentID: "4", + ChildrenMenuID: "3", + ChildrenMenuName: "Corporate", + ChildrenMenuURL: "/client/md/corp", + // Breadcrumb: []Breadcrumb{ + // { + // IDBreadcrumb: "1", + // Title: "Dashboard", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "2", + // Title: "Master", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "3", + // Title: "User Group", + // IsActive: "Y", + // }, + // }, + }, + + // * Test + { + ChildrenParentID: "4", + ChildrenMenuID: "4", + ChildrenMenuName: "Test", + ChildrenMenuURL: "/client/md/test", + // Breadcrumb: []Breadcrumb{ + // { + // IDBreadcrumb: "1", + // Title: "Dashboard", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "2", + // Title: "Master", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "3", + // Title: "User Group", + // IsActive: "Y", + // }, + // }, + }, + + // * Bahan + { + ChildrenParentID: "4", + ChildrenMenuID: "5", + ChildrenMenuName: "Bahan", + ChildrenMenuURL: "/client/md/bahan", + // Breadcrumb: []Breadcrumb{ + // { + // IDBreadcrumb: "1", + // Title: "Dashboard", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "2", + // Title: "Master", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "3", + // Title: "User Group", + // IsActive: "Y", + // }, + // }, + }, + + // * Sample Type + { + ChildrenParentID: "4", + ChildrenMenuID: "6", + ChildrenMenuName: "Sample Type", + ChildrenMenuURL: "/client/sample/type", + // Breadcrumb: []Breadcrumb{ + // { + // IDBreadcrumb: "1", + // Title: "Dashboard", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "2", + // Title: "Master", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "3", + // Title: "User Group", + // IsActive: "Y", + // }, + // }, + }, + + // * Sample Station + { + ChildrenParentID: "4", + ChildrenMenuID: "7", + ChildrenMenuName: "Sample Station", + ChildrenMenuURL: "/station/sample", + // Breadcrumb: []Breadcrumb{ + // { + // IDBreadcrumb: "1", + // Title: "Dashboard", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "2", + // Title: "Master", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "3", + // Title: "User Group", + // IsActive: "Y", + // }, + // }, + }, + + // * Result Non Lab + { + ChildrenParentID: "4", + ChildrenMenuID: "8", + ChildrenMenuName: "Result Non Lab", + ChildrenMenuURL: "/client/md/resultnonlab", + // Breadcrumb: []Breadcrumb{ + // { + // IDBreadcrumb: "1", + // Title: "Dashboard", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "2", + // Title: "Master", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "3", + // Title: "User Group", + // IsActive: "Y", + // }, + // }, + }, + + // * Template Fisik + { + ChildrenParentID: "4", + ChildrenMenuID: "9", + ChildrenMenuName: "Template Fisik", + ChildrenMenuURL: "/client/md/template-fisik", + // Breadcrumb: []Breadcrumb{ + // { + // IDBreadcrumb: "1", + // Title: "Dashboard", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "2", + // Title: "Master", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "3", + // Title: "User Group", + // IsActive: "Y", + // }, + // }, + }, + + // * Pasien + { + ChildrenParentID: "4", + ChildrenMenuID: "10", + ChildrenMenuName: "Pasien", + ChildrenMenuURL: "/client/md/pasien", + // Breadcrumb: []Breadcrumb{ + // { + // IDBreadcrumb: "1", + // Title: "Dashboard", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "2", + // Title: "Master", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "3", + // Title: "User Group", + // IsActive: "Y", + // }, + // }, + }, + + // * Dokter + { + ChildrenParentID: "4", + ChildrenMenuID: "11", + ChildrenMenuName: "Dokter", + ChildrenMenuURL: "/client/md/dokter", + // Breadcrumb: []Breadcrumb{ + // { + // IDBreadcrumb: "1", + // Title: "Dashboard", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "2", + // Title: "Master", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "3", + // Title: "User Group", + // IsActive: "Y", + // }, + // }, + }, + + // * Paket + { + ChildrenParentID: "4", + ChildrenMenuID: "12", + ChildrenMenuName: "Paket", + ChildrenMenuURL: "/client/md/paket", + // Breadcrumb: []Breadcrumb{ + // { + // IDBreadcrumb: "1", + // Title: "Dashboard", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "2", + // Title: "Master", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "3", + // Title: "User Group", + // IsActive: "Y", + // }, + // }, + }, + + // * Harga Single + { + ChildrenParentID: "4", + ChildrenMenuID: "13", + ChildrenMenuName: "Harga Single", + ChildrenMenuURL: "/client/md/hargasingle", + // Breadcrumb: []Breadcrumb{ + // { + // IDBreadcrumb: "1", + // Title: "Dashboard", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "2", + // Title: "Master", + // IsActive: "N", + // }, + // { + // IDBreadcrumb: "3", + // Title: "User Group", + // IsActive: "Y", + // }, + // }, + }, + }, + }, + } + + return dummyMenu, nil +} diff --git a/utils/generaterandomid.utils.go b/utils/generaterandomid.utils.go new file mode 100644 index 0000000..5b69c70 --- /dev/null +++ b/utils/generaterandomid.utils.go @@ -0,0 +1,16 @@ +package utils + +import ( + "crypto/md5" + "encoding/hex" + "strings" + "time" +) + +func GenerateRandomID(text string) string { + seed := text + time.Now().String() + hash := md5.Sum([]byte(seed)) + randomID := hex.EncodeToString(hash[:]) + randomID = strings.ReplaceAll(randomID, "-", "") + return randomID +} diff --git a/views/component/navbar/navbar.templ b/views/component/navbar/navbar.templ new file mode 100644 index 0000000..c892f01 --- /dev/null +++ b/views/component/navbar/navbar.templ @@ -0,0 +1,74 @@ +package navbar + +import ( + "github.com/emarifer/go-templ-project-structure/views/component/sidebarmaster" + "github.com/emarifer/go-templ-project-structure/services" + "github.com/emarifer/go-templ-project-structure/models" +) + +templ Navbar(dataUser models.User) { +
+ +
+ +
+ + +
+ +
+
+ Hi, + { dataUser.Username } + + + +
+
+ +
+ +
+ +
+} + +templ NavbarMenu(datamenu []services.MasterMenu) { +
+ +
+ + + +
+ +
+} diff --git a/views/component/navbar/navbar_templ.go b/views/component/navbar/navbar_templ.go new file mode 100644 index 0000000..4b166a5 --- /dev/null +++ b/views/component/navbar/navbar_templ.go @@ -0,0 +1,112 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.663 +package navbar + +//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/services" + "github.com/emarifer/go-templ-project-structure/views/component/sidebarmaster" +) + +func Navbar(dataUser models.User) 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("
Hi, ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var2 string + templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(dataUser.Username) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\component\navbar\navbar.templ`, Line: 29, Col: 26} + } + _, 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 NavbarMenu(datamenu []services.MasterMenu) 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 + } + for index, d := range datamenu { + if index == 0 { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = sidebarmaster.MenuDashboard(d.ParentMenuName, d.ParentUrl).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
  • Menu

  • ") + 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 index+1 < len(datamenu) { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = sidebarmaster.ListMenuNavbar(datamenu[index+1].ParentMenuName, datamenu[index+1].Children).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/component/navbarmaster/navbarmaster.templ b/views/component/navbarmaster/navbarmaster.templ deleted file mode 100644 index e501b68..0000000 --- a/views/component/navbarmaster/navbarmaster.templ +++ /dev/null @@ -1,655 +0,0 @@ -package navbarmaster - -import ( - "github.com/emarifer/go-templ-project-structure/views/component/sidebarmaster" - "github.com/emarifer/go-templ-project-structure/services" -) - -templ MainNavbar(datamenu []services.MasterMenu) { -
- -
- - - -
- -
-} - -templ Navbarmaster(datamenu []services.MasterMenu, content templ.Component) { - -
- - - Logo - - - -
- - - - - - -
- -
- - -
- -
- -
- -
- - - - - - -
- - - @MainNavbar(datamenu) - -
- - -
- -
- -
- -
- - -
- -
-
- Hi, - Sean - - S - -
-
- -
- -
- -
- - - @content - -
- -
- -
- -} - -templ Navbaruserprofile() { -
- -
-

- User Profile - 12 messages -

- - - -
- - -
- -
-
-
- -
- -
- - -
- - - - - -
- - -
- -
- Recent Notifications -
- - -
- - - - - - - - - - - - - - +28% -
- - -
- - - - - - - - - - - - -
- - Would - be to people - - Due in 2 Days -
- +50% -
- - -
- - - - - - - - - - - - - - -27% -
- - -
- - - - - - - - - - - - - - -
- - The - best product - - Due in 2 Days -
- +8% -
- -
- -
- -
-} diff --git a/views/component/navbarmaster/navbarmaster_templ.go b/views/component/navbarmaster/navbarmaster_templ.go deleted file mode 100644 index 7fb123b..0000000 --- a/views/component/navbarmaster/navbarmaster_templ.go +++ /dev/null @@ -1,138 +0,0 @@ -// Code generated by templ - DO NOT EDIT. - -// templ: version: v0.2.663 -package navbarmaster - -//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/component/sidebarmaster" -) - -func MainNavbar(datamenu []services.MasterMenu) 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 - } - for index, d := range datamenu { - if index == 0 { - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = sidebarmaster.MenuDashboard(d.ParentMenuName, d.ParentUrl).Render(ctx, templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
  • Menu

  • ") - 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 index+1 < len(datamenu) { - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = sidebarmaster.ListMenuNavbar(datamenu[index+1].ParentMenuName, datamenu[index+1].Children).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 Navbarmaster(datamenu []services.MasterMenu, content 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_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("
\"Logo\"
\"Logo\"
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = MainNavbar(datamenu).Render(ctx, templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
Hi, Sean S
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = content.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 Navbaruserprofile() 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("

User Profile\r 12 messages

") - 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/sidebar_user_profile/sidebar_user_profile.templ b/views/component/sidebar_user_profile/sidebar_user_profile.templ new file mode 100644 index 0000000..7e2242c --- /dev/null +++ b/views/component/sidebar_user_profile/sidebar_user_profile.templ @@ -0,0 +1,82 @@ +package sidebaruserprofile + +import "github.com/emarifer/go-templ-project-structure/models" + +templ Navbaruserprofile(dataUser models.User) { +
+ +
+

+ User Profile + // 12 messages +

+ + + +
+ + +
+ + @ProfileHeader(dataUser) + + +
+ + +
+ +
+ Recent Notifications +
+ + + @NotificationCard() + +
+ +
+ +
+} + +templ ProfileHeader(dataUser models.User) { +
+
+ //
+ // + +
+
+ + { dataUser.UserFullName } + +
+ { dataUser.UserPosition } +
+ +
+
+} + +templ NotificationCard() { +
+ + + + + + + +
+} diff --git a/views/component/sidebar_user_profile/sidebar_user_profile_templ.go b/views/component/sidebar_user_profile/sidebar_user_profile_templ.go new file mode 100644 index 0000000..779eb04 --- /dev/null +++ b/views/component/sidebar_user_profile/sidebar_user_profile_templ.go @@ -0,0 +1,127 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.663 +package sidebaruserprofile + +//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 Navbaruserprofile(dataUser models.User) 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("

User Profile\r

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = ProfileHeader(dataUser).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
Recent Notifications\r
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = NotificationCard().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 ProfileHeader(dataUser models.User) 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 + } + var templ_7745c5c3_Var3 string + templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(dataUser.UserFullName) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\component\sidebar_user_profile\sidebar_user_profile.templ`, Line: 52, Col: 27} + } + _, 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(dataUser.UserPosition) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\component\sidebar_user_profile\sidebar_user_profile.templ`, Line: 55, Col: 27} + } + _, 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("
") + 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 NotificationCard() 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/layout/layout_corporate.templ b/views/layout/layout_corporate.templ index 84e01e0..2c74e19 100644 --- a/views/layout/layout_corporate.templ +++ b/views/layout/layout_corporate.templ @@ -1,7 +1,14 @@ package layout +import ( + "github.com/emarifer/go-templ-project-structure/services" + "github.com/emarifer/go-templ-project-structure/views/component/navbar" + "github.com/emarifer/go-templ-project-structure/views/component/sidebar_user_profile" + "github.com/emarifer/go-templ-project-structure/models" +) + // LAYOUT PLAYGROUND -templ CorporateLayout(title string, css templ.Component, js templ.Component) { +templ CorporateLayout(title string, css templ.Component, js templ.Component, datamenu []services.MasterMenu, dataUser models.User) { // htmx - - { children... } - + +
+ + + Logo + + + +
+ + + + + + +
+ +
+ + +
+ +
+ +
+ +
+ + + + + + +
+ + + @navbar.NavbarMenu(datamenu) + +
+ + +
+ + @navbar.Navbar(dataUser) + + +
+ { children... } +
+ +
+ +
+ +
+ + @sidebaruserprofile.Navbaruserprofile(dataUser) ") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
\"Logo\"
\"Logo\"
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = navbar.NavbarMenu(datamenu).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 = navbar.Navbar(dataUser).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 } @@ -53,7 +76,15 @@ func CorporateLayout(title string, css templ.Component, js templ.Component) temp 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 = sidebaruserprofile.Navbaruserprofile(dataUser).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 } diff --git a/views/mastermenuusergroup/mastermenuusergroup.templ b/views/mastermenuusergroup/mastermenuusergroup.templ index 8d2baf0..9db78ae 100644 --- a/views/mastermenuusergroup/mastermenuusergroup.templ +++ b/views/mastermenuusergroup/mastermenuusergroup.templ @@ -4,45 +4,10 @@ import ( "github.com/emarifer/go-templ-project-structure/views/component/breadcrumbadmin" "github.com/emarifer/go-templ-project-structure/views/layout" "github.com/emarifer/go-templ-project-structure/services" - "github.com/emarifer/go-templ-project-structure/views/component/navbarmaster" + "github.com/emarifer/go-templ-project-structure/models" ) -templ MainMasterMenuUserGroup(datamenu []services.MasterMenu) { - - - @navbarmaster.Navbarmaster(datamenu, ContentMasterMenuUserGroup()) - - - - @navbarmaster.Navbaruserprofile() - - -
- - - - - - - - - - -
- -} - +// "github.com/emarifer/go-templ-project-structure/views/component/sidebar_user_profile" templ ContentMasterMenuUserGroup() {
@@ -152,8 +117,8 @@ templ CssMasterMenuUserGroup() { templ JsMasterMenuUserGroup() { } -templ ShowMasterMenuUserGroup(title string, cmp templ.Component, css templ.Component, js templ.Component) { - @layout.PlaygroundLayout(title, css, js) { +templ ShowMasterMenuUserGroup(title string, cmp templ.Component, css templ.Component, js templ.Component, dataMenu []services.MasterMenu, dataUser models.User) { + @layout.CorporateLayout(title, css, js, dataMenu, dataUser) { @cmp } } diff --git a/views/mastermenuusergroup/mastermenuusergroup_templ.go b/views/mastermenuusergroup/mastermenuusergroup_templ.go index fb038ea..bd87efb 100644 --- a/views/mastermenuusergroup/mastermenuusergroup_templ.go +++ b/views/mastermenuusergroup/mastermenuusergroup_templ.go @@ -11,13 +11,14 @@ import "io" import "bytes" 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/navbarmaster" "github.com/emarifer/go-templ-project-structure/views/layout" ) -func MainMasterMenuUserGroup(datamenu []services.MasterMenu) templ.Component { +// "github.com/emarifer/go-templ-project-structure/views/component/sidebar_user_profile" +func ContentMasterMenuUserGroup() 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 { @@ -30,46 +31,6 @@ func MainMasterMenuUserGroup(datamenu []services.MasterMenu) templ.Component { 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 = navbarmaster.Navbarmaster(datamenu, ContentMasterMenuUserGroup()).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 = navbarmaster.Navbaruserprofile().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 ContentMasterMenuUserGroup() 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 @@ -97,9 +58,9 @@ func CssMasterMenuUserGroup() 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_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("") @@ -121,9 +82,9 @@ func JsMasterMenuUserGroup() 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_Var3 := templ.GetChildren(ctx) + if templ_7745c5c3_Var3 == nil { + templ_7745c5c3_Var3 = templ.NopComponent } ctx = templ.ClearChildren(ctx) if !templ_7745c5c3_IsBuffer { @@ -133,7 +94,7 @@ func JsMasterMenuUserGroup() templ.Component { }) } -func ShowMasterMenuUserGroup(title string, cmp templ.Component, css templ.Component, js templ.Component) templ.Component { +func ShowMasterMenuUserGroup(title string, cmp templ.Component, css templ.Component, js templ.Component, dataMenu []services.MasterMenu, dataUser models.User) 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 { @@ -141,12 +102,12 @@ func ShowMasterMenuUserGroup(title string, cmp templ.Component, css templ.Compon 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_Var4 := templ.GetChildren(ctx) + if templ_7745c5c3_Var4 == nil { + templ_7745c5c3_Var4 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Var6 := templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { + templ_7745c5c3_Var5 := 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() @@ -161,7 +122,7 @@ func ShowMasterMenuUserGroup(title string, cmp templ.Component, css templ.Compon } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = layout.PlaygroundLayout(title, css, js).Render(templ.WithChildren(ctx, templ_7745c5c3_Var6), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = layout.CorporateLayout(title, css, js, dataMenu, dataUser).Render(templ.WithChildren(ctx, templ_7745c5c3_Var5), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/views/xsample/coba.templ b/views/xsample/coba.templ new file mode 100644 index 0000000..08351fa --- /dev/null +++ b/views/xsample/coba.templ @@ -0,0 +1,23 @@ +package xsample + +import ( + "github.com/emarifer/go-templ-project-structure/views/layout" + "github.com/emarifer/go-templ-project-structure/services" + "github.com/emarifer/go-templ-project-structure/models" +) + +templ Coba(title string) { +
{ title }
+} + +templ CssCoba() { +} + +templ JsCoba() { +} + +templ ShowCoba(title string, cmp templ.Component, css templ.Component, js templ.Component, dataMenu []services.MasterMenu, dataUser models.User) { + @layout.CorporateLayout(title, css, js, dataMenu, dataUser) { + @cmp + } +} diff --git a/views/xsample/coba_templ.go b/views/xsample/coba_templ.go new file mode 100644 index 0000000..932685b --- /dev/null +++ b/views/xsample/coba_templ.go @@ -0,0 +1,133 @@ +// 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 ( + "github.com/emarifer/go-templ-project-structure/models" + "github.com/emarifer/go-templ-project-structure/services" + "github.com/emarifer/go-templ-project-structure/views/layout" +) + +func Coba(title 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 + } + var templ_7745c5c3_Var2 string + templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(title) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\xsample\coba.templ`, Line: 10, Col: 13} + } + _, 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 CssCoba() 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) + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) + } + return templ_7745c5c3_Err + }) +} + +func JsCoba() 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) + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) + } + return templ_7745c5c3_Err + }) +} + +func ShowCoba(title string, cmp templ.Component, css templ.Component, js templ.Component, dataMenu []services.MasterMenu, dataUser models.User) 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_Var6 := 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.CorporateLayout(title, css, js, dataMenu, dataUser).Render(templ.WithChildren(ctx, templ_7745c5c3_Var6), 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 + }) +}