From 65f7715b0572447f3473db764ca982fd8782560d Mon Sep 17 00:00:00 2001 From: JACS Date: Fri, 1 May 2026 19:39:45 -0500 Subject: [PATCH] tablas --- controllers/tablerbase.go | 24 +++- controllers/tablerdata.go | 131 ++++++++++++++++++ controllers/tablertypes.go | 27 ++++ routes.go | 1 + storage/templates/tabler/includes/table.html | 55 ++++++++ storage/templates/tabler/layouts/default.html | 6 + storage/templates/tabler_tables.html | 1 + 7 files changed, 242 insertions(+), 3 deletions(-) create mode 100644 storage/templates/tabler/includes/table.html create mode 100644 storage/templates/tabler_tables.html diff --git a/controllers/tablerbase.go b/controllers/tablerbase.go index 257dd1a..22be054 100644 --- a/controllers/tablerbase.go +++ b/controllers/tablerbase.go @@ -10,14 +10,13 @@ import ( "git.smarteching.com/goffee/core" ) - // TablerDemo1 renders a Tabler-themed demo page func TablerDemo1(c *core.Context) *core.Response { // first, include compoment type templateData struct { Content template.HTML - } + } // Build the template data data := templateData{ // The main page content (rendered HTML) @@ -70,6 +69,25 @@ func TablerNavbar(c *core.Context) *core.Response { return c.Response.Template("tabler_default.html", data) } +// TablerTables renders a page with table components +func TablerTables(c *core.Context) *core.Response { + data := TablerPageData{ + PageTitle: "Tables", + PageDescription: "Table demo page", + ShowTopbar: true, + Sidebar: false, + PageHeader: "Tables", + PagePretitle: "Components", + UserName: "Jane Doe", + UserRole: "Administrator", + NavbarMenu: SampleNavbarMenu(), + TableHeaders: SampleTableHeaders(), + TableRows: SampleTableRows(), + Content: template.HTML(""), + } + return c.Response.Template("tabler_tables.html", data) +} + // TablerHome renders the homepage/dashboard layout func TablerHome(c *core.Context) *core.Response { data := TablerPageData{ @@ -83,4 +101,4 @@ func TablerHome(c *core.Context) *core.Response { Sidebar: false, } return c.Response.Template("tabler_homepage.html", data) -} \ No newline at end of file +} diff --git a/controllers/tablerdata.go b/controllers/tablerdata.go index ed6e865..1da3f43 100644 --- a/controllers/tablerdata.go +++ b/controllers/tablerdata.go @@ -43,3 +43,134 @@ func SampleNavbarMenu() TablerMenu { }, } } + +// SampleTableRows returns sample data for table demos +// Migrated from liquid/data/people.json +func SampleTableRows() []TableRow { + return []TableRow{ + { + ID: "1", + Name: "Paweł Kuna", + AvatarID: "000m", + Email: "paweluna@howstuffworks.com", + City: "Peimei", + Country: "China", + Status: "VIP", + JobTitle: "UI Designer", + Department: "Training", + Date: "2025-04-07", + Tags: []string{"High Volume"}, + Category: "Training", + }, + { + ID: "2", + Name: "Jeffie Lewzey", + AvatarID: "052f", + Email: "jlewzey1@seesaa.net", + City: "Indaial", + Country: "Brazil", + Status: "New", + JobTitle: "Chemical Engineer", + Department: "Support", + Date: "2024-12-12", + Tags: []string{"No Refunds"}, + Category: "Support", + }, + { + ID: "3", + Name: "Mallory Hulme", + AvatarID: "002m", + Email: "mhulme2@domainmarket.com", + City: "Cimuncang", + Country: "Indonesia", + Status: "VIP", + JobTitle: "Geologist IV", + Department: "Support", + Date: "2025-01-09", + Tags: []string{"High Value", "No Refunds", "Loyal"}, + Category: "Support", + }, + { + ID: "4", + Name: "Dunn Slane", + AvatarID: "003m", + Email: "dslane3@epa.gov", + City: "Liutang", + Country: "China", + Status: "Regular", + JobTitle: "Research Nurse", + Department: "Sales", + Date: "2022-10-01", + Tags: []string{"No Refunds"}, + Category: "Sales", + }, + { + ID: "5", + Name: "Emmy Levet", + AvatarID: "000f", + Email: "elevet4@senate.gov", + City: "Kaliprak", + Country: "Indonesia", + Status: "Regular", + JobTitle: "VP Product Management", + Department: "Accounting", + Date: "2025-05-18", + Tags: []string{"Standard"}, + Category: "Accounting", + }, + { + ID: "6", + Name: "Maryjo Lebarree", + AvatarID: "001f", + Email: "mlebarree5@unc.edu", + City: "Hantai", + Country: "China", + Status: "Regular", + JobTitle: "Civil Engineer", + Department: "Product Management", + Date: "2025-06-06", + Tags: []string{"No Refunds", "Loyal"}, + Category: "Product Management", + }, + { + ID: "7", + Name: "Egan Poetz", + AvatarID: "004m", + Email: "epoetz6@free.fr", + City: "Villaguay", + Country: "Argentina", + Status: "New", + JobTitle: "Research Nurse", + Department: "Engineering", + Date: "2024-08-21", + Tags: []string{"No Refunds"}, + Category: "Engineering", + }, + { + ID: "8", + Name: "Kellie Skingley", + AvatarID: "002f", + Email: "kskingley7@columbia.edu", + City: "Sidon", + Country: "Lebanon", + Status: "VIP", + JobTitle: "Teacher", + Department: "Services", + Date: "2025-02-23", + Tags: []string{"No Refunds", "Loyal"}, + Category: "Services", + }, + } +} + +// SampleTableHeaders returns headers for the advanced table +func SampleTableHeaders() []TableHeader { + return []TableHeader{ + {Name: "Name", Sort: "sort-name"}, + {Name: "City", Sort: "sort-city"}, + {Name: "Status", Sort: "sort-status"}, + {Name: "Start date", Sort: "sort-date"}, + {Name: "Tags", Sort: "sort-tags"}, + {Name: "Category", Sort: "sort-category"}, + } +} diff --git a/controllers/tablertypes.go b/controllers/tablertypes.go index 8f01d8c..dc9df11 100644 --- a/controllers/tablertypes.go +++ b/controllers/tablertypes.go @@ -17,6 +17,29 @@ type TablerMenuItem struct { // TablerMenu is a map of menu sections keyed by identifier type TablerMenu map[string]*TablerMenuItem +// TableHeader represents a column header +type TableHeader struct { + Name string + Sort string + Width string +} + +// TableRow represents a single row of mock data +type TableRow struct { + ID string + Name string + AvatarID string + Email string + City string + Country string + Status string + JobTitle string + Department string + Date string + Tags []string + Category string +} + // TablerPageData holds the common data for all tabler pages type TablerPageData struct { PageTitle string @@ -37,4 +60,8 @@ type TablerPageData struct { UserRole string NavbarMenu TablerMenu CurrentPage string + // Table data + TableHeaders []TableHeader + TableRows []TableRow + PerPageOptions []string } diff --git a/routes.go b/routes.go index 9409a83..466fa47 100644 --- a/routes.go +++ b/routes.go @@ -69,5 +69,6 @@ func registerRoutes() { controller.Get("/tablerdefault", controllers.TablerDefault) controller.Get("/tablerhome", controllers.TablerHome) controller.Get("/tablernavmenu", controllers.TablerNavbar) + controller.Get("/tablertable", controllers.TablerTables) } diff --git a/storage/templates/tabler/includes/table.html b/storage/templates/tabler/includes/table.html new file mode 100644 index 0000000..bc16b7d --- /dev/null +++ b/storage/templates/tabler/includes/table.html @@ -0,0 +1,55 @@ +{{define "tabler_table"}} +
+ + + + {{range .TableHeaders}} + {{.Name}} + {{end}} + + + + + {{range .TableRows}} + + + + + + + + + + {{end}} + +
+
+ +
+
{{.Name}}
+ +
+
+
+
{{.City}}
+
{{.Country}}
+
+ + {{.Status}} + {{.Date}} +
+ {{range .Tags}} +
+ {{.}} +
+ {{end}} +
+
+ {{.Category}} + + + + +
+
+{{end}} diff --git a/storage/templates/tabler/layouts/default.html b/storage/templates/tabler/layouts/default.html index c8a07a9..279a980 100644 --- a/storage/templates/tabler/layouts/default.html +++ b/storage/templates/tabler/layouts/default.html @@ -24,7 +24,13 @@ {{.Content}} {{else}}
+ {{if .TableRows}} +
+ {{template "tabler_table" .}} +
+ {{else}} {{.Content}} + {{end}}
{{end}} diff --git a/storage/templates/tabler_tables.html b/storage/templates/tabler_tables.html new file mode 100644 index 0000000..05a9bdb --- /dev/null +++ b/storage/templates/tabler_tables.html @@ -0,0 +1 @@ +{{template "default_layout" .}}