goffeetabler/controllers/tablertypes.go
2026-05-02 21:38:15 -05:00

93 lines
2.7 KiB
Go

package controllers
// TablerMenuItem represents a single item in the navbar menu
type TablerMenuItem struct {
Title string `json:"title"`
TitleLong string `json:"title-long,omitempty"`
Icon string `json:"icon,omitempty"`
URL string `json:"url,omitempty"`
Badge string `json:"badge,omitempty"`
Color string `json:"color,omitempty"`
Active bool `json:"active,omitempty"`
Disabled bool `json:"disabled,omitempty"`
Columns int `json:"columns,omitempty"`
Children []*TablerMenuItem `json:"children,omitempty"`
}
// TablerMenu is a map of menu sections keyed by identifier
type TablerMenu map[string]*TablerMenuItem
// TableComponent represents a reusable table component with headers and rows.
type TableComponent struct {
ID string
Title string
Headers []TableComponentHeader
Rows []TableComponentRow
EmptyMessage string
PerPageOptions []string
Striped bool
Hover bool
CardClass string
TableClass string
}
// TableComponentHeader defines a single column header.
type TableComponentHeader struct {
Name string
Sort string
Width string
Align string
}
// TableComponentRow represents a single row as a slice of cells.
type TableComponentRow struct {
Cells []TableCell
}
// TableCell represents a single cell in a table row.
// Type controls how the cell is rendered in the template:
// "text" - plain text
// "avatar" - avatar with name/email
// "status" - status dot + text
// "badge" - colored badge
// "tags" - list of tag badges
// "actions" - dropdown action button
// "date" - date display
type TableCell struct {
Type string
Value string
// Used by "avatar" type
AvatarID string
Subtext string
// Used by "status" type
StatusColor string
// Used by "badge" type
BadgeColor string
// Used by "tags" type
Tags []string
}
// TablerPageData holds the common data for all tabler pages.
// It should NOT contain component-specific fields like tables or forms.
// Add those by creating a page-specific struct that embeds TablerPageData
// and defines the component fields, then use hasField in the template.
type TablerPageData struct {
PageTitle string
PageDescription string
BodyClass string
Content interface{}
// Default layout fields
Sidebar bool
ShowTopbar bool
WrapperFull bool
ContainerCentered bool
ContainerClass string
// Page header
PageHeader string
PagePretitle string
// Navbar fields
UserName string
UserRole string
NavbarMenu TablerMenu
CurrentPage string
}