360 lines
9.6 KiB
Go
360 lines
9.6 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
|
|
}
|
|
|
|
// FormtablerTextInput renders a basic text/static/password/textarea input.
|
|
type FormtablerTextInput struct {
|
|
Label string
|
|
Placeholder string
|
|
Value string
|
|
Type string // "text", "static", "password", "textarea"
|
|
Name string
|
|
}
|
|
|
|
// FormtablerIconInput renders an input with an icon or loader.
|
|
type FormtablerIconInput struct {
|
|
Label string
|
|
Placeholder string
|
|
Icon string // icon name, empty = search icon
|
|
Prepend bool
|
|
Loader bool
|
|
}
|
|
|
|
// FormtablerIconSeparated renders a search input with a separate button.
|
|
type FormtablerIconSeparated struct {
|
|
Label string
|
|
Placeholder string
|
|
ButtonIcon string
|
|
}
|
|
|
|
// FormtablerInputSizing renders three inputs of different sizes.
|
|
type FormtablerInputSizing struct{}
|
|
|
|
// FormtablerFileInput renders a file input.
|
|
type FormtablerFileInput struct {
|
|
Label string
|
|
}
|
|
|
|
// FormtablerColorInput renders a color swatch picker (radio or checkbox).
|
|
type FormtablerColorInput struct {
|
|
Label string
|
|
Name string
|
|
Type string // "radio" or "checkbox"
|
|
Colors []FormtablerSwatch
|
|
HideBW bool
|
|
Rounded bool
|
|
}
|
|
|
|
// FormtablerSwatch is a single color swatch in a color input.
|
|
type FormtablerSwatch struct {
|
|
Color string
|
|
Checked bool
|
|
}
|
|
|
|
// FormtablerColorPicker renders a native HTML5 color picker.
|
|
type FormtablerColorPicker struct {
|
|
Label string
|
|
Color string
|
|
}
|
|
|
|
// FormtablerRangeInput renders range sliders.
|
|
type FormtablerRangeInput struct {
|
|
Label string
|
|
}
|
|
|
|
// FormtablerDatalist renders an input with a datalist.
|
|
type FormtablerDatalist struct {
|
|
Label string
|
|
Placeholder string
|
|
Options []string
|
|
}
|
|
|
|
// FormtablerImageCheck renders image checkboxes.
|
|
type FormtablerImageCheck struct {
|
|
Label string
|
|
Images []FormtablerImageItem
|
|
}
|
|
|
|
// FormtablerImageItem is a single image in an image check group.
|
|
type FormtablerImageItem struct {
|
|
Src string
|
|
Alt string
|
|
Checked bool
|
|
}
|
|
|
|
// FormtablerImageRadio renders image radio buttons.
|
|
type FormtablerImageRadio struct {
|
|
Label string
|
|
Images []FormtablerImageItem
|
|
}
|
|
|
|
// FormtablerImagePerson renders person avatar checkboxes.
|
|
type FormtablerImagePerson struct {
|
|
Label string
|
|
People []FormtablerPersonItem
|
|
AvatarSize string
|
|
}
|
|
|
|
// FormtablerPersonItem is a single person in a person check group.
|
|
type FormtablerPersonItem struct {
|
|
Name string
|
|
Src string
|
|
Checked bool
|
|
}
|
|
|
|
// FormtablerCheckboxes renders a group of checkboxes.
|
|
type FormtablerCheckboxes struct {
|
|
Label string
|
|
Checkboxes []FormtablerCheckItem
|
|
}
|
|
|
|
// FormtablerCheckItem is a single checkbox/radio/switch item.
|
|
type FormtablerCheckItem struct {
|
|
Title string
|
|
Checked bool
|
|
Disabled bool
|
|
}
|
|
|
|
// FormtablerCheckboxesInline renders inline checkboxes.
|
|
type FormtablerCheckboxesInline struct {
|
|
Label string
|
|
Checkboxes []FormtablerCheckItem
|
|
}
|
|
|
|
// FormtablerRadios renders a group of radio buttons.
|
|
type FormtablerRadios struct {
|
|
Label string
|
|
Name string
|
|
Radios []FormtablerCheckItem
|
|
}
|
|
|
|
// FormtablerRadiosInline renders inline radio buttons.
|
|
type FormtablerRadiosInline struct {
|
|
Label string
|
|
Name string
|
|
Radios []FormtablerCheckItem
|
|
}
|
|
|
|
// FormtablerToggle renders toggle switch checkboxes.
|
|
type FormtablerToggle struct {
|
|
Label string
|
|
Toggles []FormtablerCheckItem
|
|
}
|
|
|
|
// FormtablerToggleSingle renders a single toggle switch.
|
|
type FormtablerToggleSingle struct {
|
|
Label string
|
|
Title string
|
|
}
|
|
|
|
// FormtablerSelect renders a select dropdown.
|
|
type FormtablerSelect struct {
|
|
Label string
|
|
Options []string
|
|
Multiple bool
|
|
}
|
|
|
|
// FormtablerSelectgroup renders a selectgroup (pill-style toggle buttons).
|
|
type FormtablerSelectgroup struct {
|
|
Label string
|
|
Groups []FormtablerSelectGroup
|
|
Pills bool
|
|
}
|
|
|
|
// FormtablerSelectGroup is a single selectgroup set.
|
|
type FormtablerSelectGroup struct {
|
|
Title string
|
|
Values []FormtablerSelectGroupValue
|
|
Type string // "radio" or "checkbox"
|
|
Name string
|
|
Pills bool
|
|
WithText bool
|
|
}
|
|
|
|
// FormtablerSelectGroupValue is a single option in a selectgroup.
|
|
type FormtablerSelectGroupValue struct {
|
|
Label string
|
|
Value string
|
|
Icon string // icon name like "home", "user"
|
|
Checked bool
|
|
WithText bool
|
|
}
|
|
|
|
// FormtablerSelectgroupPayments renders payment method selectgroups.
|
|
type FormtablerSelectgroupPayments struct {
|
|
Label string
|
|
Items []FormtablerPaymentItem
|
|
}
|
|
|
|
// FormtablerPaymentItem is a single payment option.
|
|
type FormtablerPaymentItem struct {
|
|
Provider string // "visa", "mastercard", "paypal"
|
|
Ending string // last 4 digits (optional)
|
|
Checked bool
|
|
}
|
|
|
|
// FormtablerSelectgroupProjectManager renders a project manager selectgroup.
|
|
type FormtablerSelectgroupProjectManager struct {
|
|
Label string
|
|
Managers []FormtablerPersonItemWithJob
|
|
}
|
|
|
|
// FormtablerPersonItemWithJob extends FormtablerPersonItem with a job title.
|
|
type FormtablerPersonItemWithJob struct {
|
|
Name string
|
|
Src string
|
|
JobTitle string
|
|
Checked bool
|
|
}
|
|
|
|
// FormtablerFieldset renders a fieldset with inputs.
|
|
type FormtablerFieldset struct {
|
|
Label string
|
|
Inputs []FormtablerFieldsetInput
|
|
}
|
|
|
|
// FormtablerFieldsetInput is a single input inside a fieldset.
|
|
type FormtablerFieldsetInput struct {
|
|
Label string
|
|
Type string // "text", "email", "tel"
|
|
Required bool
|
|
Placeholder string
|
|
}
|
|
|
|
// FormtablerCheckboxesList renders a list of toggle switches with labels.
|
|
type FormtablerCheckboxesList struct {
|
|
Label string
|
|
Items []FormtablerCheckListItem
|
|
}
|
|
|
|
// FormtablerCheckListItem is a single item in a checkboxes list.
|
|
type FormtablerCheckListItem struct {
|
|
Title string
|
|
Checked bool
|
|
}
|
|
|
|
// FormtablerValidationStates renders validation state inputs.
|
|
type FormtablerValidationStates struct {
|
|
Label string
|
|
Lite bool
|
|
}
|
|
|
|
// FormtablerFormElementsPage is the page-specific struct for the form elements demo.
|
|
// Each field is one of the 25 form element groups.
|
|
type FormtablerFormElementsPage struct {
|
|
TextInputs []FormtablerTextInput
|
|
IconInputs []FormtablerIconInput
|
|
IconSeparated FormtablerIconSeparated
|
|
InputSizing FormtablerInputSizing
|
|
FileInput FormtablerFileInput
|
|
ColorInput FormtablerColorInput
|
|
ColorPicker FormtablerColorPicker
|
|
RangeInput FormtablerRangeInput
|
|
Datalist FormtablerDatalist
|
|
ImageCheck FormtablerImageCheck
|
|
ImageRadio FormtablerImageRadio
|
|
ImagePerson FormtablerImagePerson
|
|
Checkboxes FormtablerCheckboxes
|
|
CheckboxesInline FormtablerCheckboxesInline
|
|
Radios FormtablerRadios
|
|
RadiosInline FormtablerRadiosInline
|
|
Toggles FormtablerToggle
|
|
ToggleSingle FormtablerToggleSingle
|
|
Select FormtablerSelect
|
|
Selectgroups []FormtablerSelectGroup
|
|
SelectgroupPayments FormtablerSelectgroupPayments
|
|
SelectgroupProjectManager FormtablerSelectgroupProjectManager
|
|
Fieldset FormtablerFieldset
|
|
CheckboxesList FormtablerCheckboxesList
|
|
ValidationStates FormtablerValidationStates
|
|
}
|
|
|
|
// 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
|
|
}
|