Documentation
¶
Overview ¶
templ: version: v0.3.857
Package ui holds the admin UI's templ templates and the view-model types they render. The view models are built in the parent admin package (form.go) from registered proto descriptors and handed here for rendering, so the dependency runs admin -> ui only.
templ: version: v0.3.857
Index ¶
- Constants
- func AppPage(nav Nav, appID string) templ.Component
- func AppsPage(nav Nav, apps []AppRow) templ.Component
- func CellView(c Cell) templ.Component
- func DetailPanel(d Detail) templ.Component
- func EntityPage(nav Nav, v EntityView) templ.Component
- func Field(f FieldView) templ.Component
- func FilterBar(v FilterView) templ.Component
- func FilterCond(v FilterView, c FilterCondView) templ.Component
- func Layout(nav Nav, title string) templ.Component
- func PickerResults(rows []PickerRow) templ.Component
- func RefPicker(c RefControl) templ.Component
- func RowsFragment(v EntityView) templ.Component
- func Sidebar(nav Nav) templ.Component
- type AppRow
- type Cell
- type CellKind
- type Column
- type Detail
- type EntityRef
- type EntityView
- type EnumOption
- type FieldKind
- type FieldView
- type FilterCondView
- type FilterFieldOption
- type FilterOpOption
- type FilterView
- type MapItem
- type Nav
- type NavEntity
- type NavOption
- type PickerRow
- type Pill
- type RefControl
- type RefItem
- type Row
- type ValueControl
- type ValueKind
Constants ¶
const ( MatchAll = "all" MatchAny = "any" )
Match values for FilterView.Match: how the conditions combine.
Variables ¶
This section is empty.
Functions ¶
func AppPage ¶
AppPage is shown for an app that has no workspace data yet (otherwise the app route redirects straight to the first entity).
func AppsPage ¶
AppsPage lists every hosted app as a card grid (shown when no app is selected). Each card links into the app.
func DetailPanel ¶
DetailPanel is the slide-over for one row: backdrop + panel + the generic proto editor as a form. Saving redirects (HX-Redirect) so the table reloads; admin.js handles Escape/backdrop close.
func EntityPage ¶
func EntityPage(nav Nav, v EntityView) templ.Component
EntityPage is the browse page for one entity in one workspace: the header, the view toggle, the filter bar and a paginated rich-cell table. Row clicks open the detail slide-over (htmx → #panel-root).
func FilterBar ¶
func FilterBar(v FilterView) templ.Component
FilterBar is the condition builder above the browse table: a row per condition (field · operator · operand), an add control that clones the blank row, and Apply / Clear.
It is a plain GET form, so applying a filter is a navigation and the filter ends up in the URL — shareable, reloadable, and carried by "Load more". Only the per-row refresh (which operators a field admits, which control its operand needs) goes through htmx. The match select and Apply are hidden by CSS until there is something for them to act on, so the bar stays quiet on an unfiltered table without needing a round trip to appear.
func FilterCond ¶
func FilterCond(v FilterView, c FilterCondView) templ.Component
FilterCond is one condition row, and the fragment the row endpoint returns when its field or operator changes. Until a field is chosen there are no operators to offer, so the row is just the field select.
A group row is the same head over a block of element-scoped sub-rows. It stays the single .filter-cond so removing it takes the whole group, while sub-rows carry .filter-sub and remove one at a time; every select inside reloads the WHOLE group, which is what round-trips the sub-rows.
func Layout ¶
Layout is the app shell shared by every full page: a fixed sidebar plus the scrollable main region. It pulls in the vendored htmx and the plain CSS/JS (all served locally — no CDN, local-first). #panel-root is the slide-over mount point htmx swaps detail panels into.
func PickerResults ¶
PickerResults renders the reference picker dropdown: one clickable row per matching target, carrying the target's key-field values as a JSON object the client copies into the hidden ref inputs on selection.
func RefPicker ¶
func RefPicker(c RefControl) templ.Component
RefPicker is the reference picker component: the chosen value(s) as chips beside an inline "+ Add" that opens a combobox popover over the target entity's rows. admin.js drives it entirely through the data- hooks here, so the row editor and the filter bar's reference operand share one behaviour.
func RowsFragment ¶
func RowsFragment(v EntityView) templ.Component
RowsFragment is the htmx-swappable slice of table rows plus, when more rows follow, a self-replacing "Load more" control. Each row opens the detail panel; the delete button consumes its click so it does not also open it.
Types ¶
type Cell ¶
type Cell struct {
Kind CellKind
Text string // CellText
Muted bool // CellText: render dimmed (empty / secondary)
Numeric bool // CellText: right-align (matches the column)
Bool bool // CellBool
Pill Pill // CellPill
Chips []Pill // CellChips
}
Cell is one typed table cell. Only the field matching Kind is populated.
type Detail ¶
type Detail struct {
AppID string
Workspace string
Entity string // wire name
FullName string // descriptor full name, e.g. taskflow.v1.Todo
Title string // row display label
Key string
Version uint64
Fields []FieldView
Edit bool
}
Detail is the slide-over panel state for one row (view/edit).
type EntityView ¶
type EntityView struct {
AppID string
WS string
Entity string // wire name (routes)
Title string // display label, e.g. "Todo"
FullName string // descriptor full name, e.g. taskflow.v1.Todo
PrimaryLabel string // header text for the primary column
Count int
More bool // count is a lower bound
Columns []Column
Rows []Row
PageMore bool // another page of rows follows
NextURL string // browse URL of the next page, carrying the filter
Filter FilterView
Filtered bool // a filter is applied: Count is a match count, not the total
// FilterError, when set, replaces the table: a condition could not be read,
// and showing unfiltered rows under a filter the user wrote would mislead.
FilterError string
}
EntityView is the browse page state: the header, the filter bar, the (non-primary) columns, and one page of rows. The primary column is rendered from Row.Label/Key.
type EnumOption ¶
type EnumOption struct {
Value string // numeric value, submitted
Label string // enum value name
Selected bool
}
EnumOption is one option of an enum <select>.
type FieldKind ¶
type FieldKind int
FieldKind classifies how a field renders.
const ( KindScalar FieldKind = iota // text/number input KindBool // checkbox KindEnum // <select> of enum values KindOpaque // replaced-whole bytes/message (base64 textarea) KindText // collaborative text document (plain textarea) KindMessage // embedded sub-message -> nested fieldset KindRef // typed reference -> key picker KindRepeatedScalar // add/remove scalar rows KindKeyedList // repeated embedded message (keyed list) KindMap // key/value pairs )
type FieldView ¶
type FieldView struct {
Label string
TypeLabel string // type chip text, e.g. "string", "enum Status", "repeated User"
Name string // input-name base (dotted/indexed)
Kind FieldKind
ReadOnly bool
Template []FieldView // keyed list: blank field set cloned for a new item
// Scalar / bool / enum / opaque.
Value string
Numeric bool // render <input type=number>
// Enum.
EnumOptions []EnumOption
// Reference.
Ref RefControl
// Embedded sub-message.
Children []FieldView
// Repeated scalar.
ScalarItems []string
// Keyed message list.
ListItems [][]FieldView
// Map.
MapItems []MapItem
}
FieldView is the rendered model of one field; templates walk it, recursing through Children / ListItems.
type FilterCondView ¶
type FilterCondView struct {
Name string
Path string
Ops []FilterOpOption
Value ValueControl
Error string // why this row's operand could not be read
// Group renders the row as an element-scoped block instead of a pill: the
// field is a repeated message list and the operator asks whether SOME
// element satisfies the sub-conditions in Subs. All of them are asked of
// the same element, which is the whole reason the group exists — see
// ExistsCond in syncplane/v1/query.proto.
Group bool
// Subs are the sub-conditions, whose paths name fields of the ELEMENT.
// They render as ordinary condition rows, one scope down.
Subs []FilterCondView
// SubFields are the element's filterable paths, for a sub-row's field
// select. SubTemplate is the blank sub-row the group's own "+ Condition"
// clones; nil when the group is read-only.
SubFields []FilterFieldOption
SubTemplate *FilterCondView
}
FilterCondView is one condition row: field · operator · operand. Name is the input-name base ("f[0]", or "f[__i__]" in the blank template admin.js clones). Ops is empty until a field is chosen.
func (FilterCondView) SubName ¶
func (c FilterCondView) SubName() string
SubName is the input-name base of this group's sub-conditions, which is also the repeat group admin.js adds a blank row to.
type FilterFieldOption ¶
type FilterFieldOption struct {
Path string // dotted proto path, submitted as f[i].path
Label string
}
FilterFieldOption is one selectable path in a condition's field select.
type FilterOpOption ¶
FilterOpOption is one operator in a condition's operator select.
type FilterView ¶
type FilterView struct {
Action string // form target: the entity's browse URL
RowURL string // single-condition-row endpoint (htmx)
Fields []FilterFieldOption // every filterable path, for the field select
Conds []FilterCondView
Template FilterCondView // blank row cloned by "+ Condition"
Match string // MatchAll / MatchAny
Active bool // at least one condition is complete and applied
}
FilterView is the browse page's filter bar — the condition builder above the table. It submits as a plain GET form to Action, so the filter lives in the URL; RowURL re-renders one condition row when its field or operator changes.
func (FilterView) ReloadAttrs ¶
func (v FilterView) ReloadAttrs() templ.Attributes
ReloadAttrs are the htmx attributes that re-render one condition row from the server. They sit on the field and operator selects only: changing either one changes which operators apply and which operand control is needed, while typing an operand must not disturb the input being typed into.
type NavEntity ¶
type NavEntity struct {
}
NavEntity is one entity row in the sidebar, with its live row count.
type NavOption ¶
type NavOption struct {
}
NavOption is one <select> option in a switcher: its label, the URL to navigate to when chosen, and whether it is the current selection.
type PickerRow ¶
type PickerRow struct {
Label string
Sub string // secondary text (the row key)
Color int
Initials string
KeysJSON string // {"<keyfield>":"<value>", ...}
}
PickerRow is one selectable target row in the reference picker dropdown: its display label, a secondary line (the joined key), and the target key field values as a JSON object (field -> value) the client copies into the hidden ref inputs on selection.
type Pill ¶
Pill is a labelled, color-slotted badge. Color is a palette slot (see slotClass); a negative slot renders neutral/gray. Initials, when set, render a small avatar bubble inside the chip (used for reference chips).
type RefControl ¶
type RefControl struct {
Name string // input-name base the selection binds to
Entity string // target entity wire name (picker route, aria labels)
Keys []string // target key field names, plus Workspace when set
PickerURL string // picker endpoint listing target rows in this workspace
// Workspace names the reference message's workspace field, carried as one
// more hidden input per chip; empty for a same-workspace reference. The
// picker matches chips against rows by the key fields alone, so the
// input is tagged apart from them.
Workspace string
Items []RefItem
// Multi allows several targets to be selected: the chips accumulate and
// the popover stays open, rather than one selection replacing the last.
Multi bool
ReadOnly bool
// Inline is the filter bar's compact form. It also changes what the
// selection submits: one input named Name per chip, carrying the target
// key alone (a filter operand is a literal), rather than the editor's
// Name[.field] / Name[i].field stubs. Only single-key targets use it.
Inline bool
}
RefControl is the reference picker component: the selected value(s) as chips, and a combobox popover listing the target entity's rows. It is shared by the row editor's reference field and the filter bar's reference operand, so both are the same control and admin.js drives them with one set of hooks.
func (RefControl) Key ¶
func (c RefControl) Key(it RefItem) string
Key is the item's value for the target's single key field, which is what an inline (filter-operand) chip submits. Empty when the target has no single key field, in which case Inline does not apply.
type RefItem ¶
type RefItem struct {
Name string // input-name base for this element
Values map[string]string // key field name -> value
Label string // resolved target display label
Color int // chip color slot (from Label)
Initials string // avatar initials (from Label)
}
RefItem is one selected reference value: the target key field values, keyed by field name, rendered as hidden inputs named Name[.field]. Label is the resolved display label of the target row (its key, when unresolved), shown on the chip so the user sees a name rather than an opaque id.
type Row ¶
type Row struct {
Key string
Label string // primary-column display text (a chosen string field, or the key)
Version uint64
Cells []Cell
}
Row is one entity row in the browse table: its key, the display label shown in the primary column, its version, plus ordered typed cells matching the page's Columns.
type ValueControl ¶
type ValueControl struct {
Kind ValueKind
Value string // submitted as f[i].v
Options []EnumOption // ValueEnum
Placeholder string
Ref RefControl // ValueRef
}
ValueControl is the operand control of one condition.
func (ValueControl) InputType ¶
func (v ValueControl) InputType() string
InputType is the HTML input type for a free-text operand. A comma-separated list stays text however numeric its parts are.
type ValueKind ¶
type ValueKind int
ValueKind selects the control rendered for a condition's operand.
const ( ValueNone ValueKind = iota // the presence / emptiness operators take no operand ValueText // free text ValueNumber // free text, numeric input ValueBool // yes / no ValueEnum // one enum value ValueList // comma-separated operands (the multi-value operators) ValueRef // reference picker: the operand is a target row's key )