From 528327f779816b0c2c6517ef0d54836c684df3f0 Mon Sep 17 00:00:00 2001 From: Henrique Miranda Date: Mon, 26 Aug 2024 14:13:34 -0300 Subject: [PATCH] boost daskboard links --- web/handler/employee_handler.go | 6 +- web/view/client/clients.templ | 2 +- web/view/employee/employee_create.templ | 5 +- web/view/employee/employees.templ | 6 +- web/view/home/homepage.templ | 2 +- web/view/layout/base.templ | 2 +- web/view/layout/dashboard.templ | 106 +++++++++++------------- 7 files changed, 61 insertions(+), 68 deletions(-) diff --git a/web/handler/employee_handler.go b/web/handler/employee_handler.go index 52e1645..a0dbce0 100644 --- a/web/handler/employee_handler.go +++ b/web/handler/employee_handler.go @@ -18,11 +18,13 @@ func NewEmployeeHandler(repo database.EmployeeRepository) EmployeeHandler { } func (h EmployeeHandler) EmployeesPage(w http.ResponseWriter, r *http.Request) { - web.Render(w, r, http.StatusOK, employee.EmployeesPage()) + boosted := r.Header.Get("HX-Boosted") == "true" + web.Render(w, r, http.StatusOK, employee.EmployeesPage(boosted)) } func (h EmployeeHandler) EmployeeCreatePage(w http.ResponseWriter, r *http.Request) { - web.Render(w, r, http.StatusOK, employee.EmployeeCreatePage()) + boosted := r.Header.Get("HX-Boosted") == "true" + web.Render(w, r, http.StatusOK, employee.EmployeeCreatePage(boosted)) } func (h EmployeeHandler) EmployeeCreateAction(w http.ResponseWriter, r *http.Request) { diff --git a/web/view/client/clients.templ b/web/view/client/clients.templ index 200e9d4..4d41ae1 100644 --- a/web/view/client/clients.templ +++ b/web/view/client/clients.templ @@ -3,7 +3,7 @@ package client import "github.com/henriquepw/imperium-tattoo/web/view/layout" templ ClientsPage() { - @layout.Dashbaord("Painel", "clients") { + @layout.Dashbaord("Painel", "clients", false) {
MAIN
diff --git a/web/view/employee/employee_create.templ b/web/view/employee/employee_create.templ index ff82f72..011d7cd 100644 --- a/web/view/employee/employee_create.templ +++ b/web/view/employee/employee_create.templ @@ -6,8 +6,8 @@ import ( "github.com/henriquepw/imperium-tattoo/web/view/ui" ) -templ EmployeeCreatePage() { - @layout.Dashbaord("Novo Profissional", "employees") { +templ EmployeeCreatePage(boosted bool) { + @layout.Dashbaord("Novo Profissional", "employees", boosted) {
@layout.PageHeader( "Novo Profissional", @@ -15,7 +15,6 @@ templ EmployeeCreatePage() { {Label: "Profissinais", Href: "/employees"}, {Label: "Novo", Href: "/employees/create"}, }, - "/employees", ) @EmployeeCreateForm(EmployeeCreateFormProps{})
diff --git a/web/view/employee/employees.templ b/web/view/employee/employees.templ index 7a4ad13..9b79619 100644 --- a/web/view/employee/employees.templ +++ b/web/view/employee/employees.templ @@ -5,12 +5,12 @@ import ( "github.com/henriquepw/imperium-tattoo/web/view/ui" ) -templ EmployeesPage() { - @layout.Dashbaord("Profissinais", "employees") { +templ EmployeesPage(boosted bool) { + @layout.Dashbaord("Profissinais", "employees", boosted) {
@layout.PageHeader("Profissinais", []ui.BreadcrumbItem{ {Label: "Profissinais", Href: "/employees"}, - }, "") { + }) { @ui.Link(ui.LinkProps{Href: "employees/create"}) { } diff --git a/web/view/home/homepage.templ b/web/view/home/homepage.templ index 25cc1cf..725d312 100644 --- a/web/view/home/homepage.templ +++ b/web/view/home/homepage.templ @@ -3,7 +3,7 @@ package home import "github.com/henriquepw/imperium-tattoo/web/view/layout" templ HomePage() { - @layout.Dashbaord("Painel", "home") { + @layout.Dashbaord("Painel", "home", false) {
MAIN
diff --git a/web/view/layout/base.templ b/web/view/layout/base.templ index 0427765..39d5335 100644 --- a/web/view/layout/base.templ +++ b/web/view/layout/base.templ @@ -17,6 +17,6 @@ templ Base(title string) { { children... } - + } diff --git a/web/view/layout/dashboard.templ b/web/view/layout/dashboard.templ index 6b7638d..864520e 100644 --- a/web/view/layout/dashboard.templ +++ b/web/view/layout/dashboard.templ @@ -2,80 +2,72 @@ package layout import "github.com/henriquepw/imperium-tattoo/web/view/ui" -templ Dashbaord(title, route string) { - @Base(title) { -
- -
- { children... } -
- -
+ + +
+ } } } templ item(label, icon, href string, active bool) { { label } } -templ PageHeader(title string, breadcrumb []ui.BreadcrumbItem, back string) { +templ PageHeader(title string, breadcrumb []ui.BreadcrumbItem) {
@ui.Breadcrumb(breadcrumb)
- if back != "" { - - } +

{ title }

{ children... }