Documentation
¶
Index ¶
- Constants
- type Config
- type CrudView
- func (v *CrudView) IconSvg() *sprite.Sprite
- func (v *CrudView) Init(ctx Ctx)
- func (v *CrudView) Reload() error
- func (v *CrudView) Render() *Element
- func (v *CrudView) RenderCSS() *css.Stylesheet
- func (v *CrudView) RenderSheet() *style.Sheet
- func (v *CrudView) WidgetKind() widget.Kind
- func (v *CrudView) WidgetName() widget.Name
- type ListView
Constants ¶
const NameCrudView widget.Name = "crudview"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶ added in v0.0.11
type Config struct {
// ParentID is the DOM id the form mounts under.
ParentID string
// Presenter is built by the module via view.New(...). Required.
Presenter view.Presenter
// IDs supplies new ids for hidden text-PK auto-assignment on submit (the
// form's composition-root injection, see form.New). Required — New fails
// if nil. Pass unixid.NewUnixID() at your composition root.
IDs model.IDGenerator
// Filter is the control that narrows the list. Optional: nil renders no
// controls band. When nil, New installs a searchbar.SearchBar carrying the
// presenter's placeholder — the ergonomic default, not a decision imposed:
// pass any widget.Filterable to replace it.
Filter dom.Component
// List builds the row-rendering widget. Optional: nil installs a
// targetlist.TargetList factory — the ergonomic default, not a decision
// imposed: pass a targethour.TargetHour (or anything satisfying
// ListView) factory instead when the data wants a leading date/time
// badge (view.Item's LeadTop/Main/Bottom) rather than a plain label.
List func(selected *dom.SignalString, onSelect func(view.Item), onDelete func(string)) ListView
}
Config is what a renderer needs to draw a view.Presenter — nothing about ops, transport, or codec: that is ALL inside the Presenter already. The module builds the Presenter via view.New(...) (importing view+model+router, never layout) and hands it here.
type CrudView ¶
type CrudView struct {
Element // value embed — NEVER *dom.Element
Title string
Form Component // what Render paints (may stay nil in standalone mode)
Presenter view.Presenter
// Filter is the control that narrows the list — a searchbar.SearchBar, a
// calendar, a select. nil paints no controls band at all. If it implements
// widget.Filterable, crudview wires it to the list filter in Init.
//
// The type is Component, not widget.Filterable, on purpose: a control with
// no live output (a static legend, a chip strip that navigates elsewhere) is
// a legitimate occupant and must not be forced to implement a callback it
// would never fire.
Filter Component
// List builds the row-rendering widget, given the Selected signal and the
// OnSelect/OnDelete callbacks CrudView owns — Init calls it once. Set by
// New from Config.List; nil there resolves to a targetlist.TargetList
// factory, same "ergonomic default, not a decision imposed" as Filter.
List func(selected *SignalString, onSelect func(view.Item), onDelete func(string)) ListView
// Additive user hooks — called AFTER the built-in behavior. Assigning them
// can never disable list→form fill, save or delete wiring.
OnSelect func(it view.Item)
OnNew func()
OnSaved func(err error)
OnDeleted func(id string, err error)
OnCancel func()
// contains filtered or unexported fields
}
func New ¶ added in v0.0.11
New builds the renderer around an already-constructed Presenter. It generates the form from Presenter.Record().Schema(), and wires save/delete to sync the form INTO Record() before calling Presenter.Save/Delete — crudview never talks to a Caller directly anymore.
func (*CrudView) IconSvg ¶ added in v0.0.19
IconSvg returns the sprite with the captured Pa100T icons. Captured paths from Pa100T v3.0.1 (base64 SVGs in IE_MODULE_CONTENT.md §2). Method receiver (not a free function) so tinywasm/ssr detects a single receiver type for the package and emits RenderCSS + IconSvg together.
func (*CrudView) RenderCSS ¶ added in v0.0.19
func (v *CrudView) RenderCSS() *css.Stylesheet
RenderCSS implements the visual contract for crudview using the style DSL.
func (*CrudView) RenderSheet ¶ added in v0.1.0
RenderSheet returns the style Sheet containing the rules for crudview.
func (*CrudView) WidgetKind ¶ added in v0.0.23
func (*CrudView) WidgetName ¶ added in v0.0.23
type ListView ¶ added in v0.1.13
type ListView interface {
Component
SetItems(items []view.Item)
Items() []view.Item
Count() int
CloseMenus()
}
ListView is the row-rendering half of a CrudView. targetlist.TargetList (plain label rows) and targethour.TargetHour (a leading date/time badge instead of a plain label — see view.Item's LeadTop/Main/Bottom) both satisfy it, so Config.List can swap one for the other without CrudView ever knowing which it got.