Documentation ¶
Overview ¶
Package control contains the implementations of the standard controls in goradd. These controls generally fall under the following categories: - Standard html tags. For example, div, input, select, table, img - Controls specifically designed to edit database data, like INT, FLOAT or DATE fields - Controls that we need to support the manipulation of database relationships, like one-to-many links - Useful utility controls
Controls in this package should function and be usable even if javascript is turned off.
Index ¶
- Constants
- Variables
- func CalcWrapperID(wrapperId string, childCreator page.Creator, postfix string) string
- func Children(creators ...page.Creator) []page.Creator
- func GetCreatorID(c page.Creator) string
- func NoSelectionItemList() []interface{}
- func SelectOneItemList() []interface{}
- func SetAlertFunction(f AlertFuncType)
- func SortIds(ids []string)
- type AlertFuncType
- type Button
- func (b *Button) Init(self page.ControlI, parent page.ControlI, id string)
- func (b *Button) On(e page.EventI, actions ...action.ActionI) page.ControlI
- func (b *Button) OnSubmit(actions ...action.ActionI) page.ControlI
- func (b *Button) SetLabel(label string) page.ControlI
- func (b *Button) ΩDrawingAttributes() html.Attributes
- type ButtonCreator
- type ButtonI
- type Canvas
- type CanvasCreator
- type CanvasI
- type CellStyler
- type CellTexter
- type Checkbox
- type CheckboxBase
- func (c *CheckboxBase) Checked() bool
- func (c *CheckboxBase) Deserialize(d page.Decoder, p *page.Page) (err error)
- func (c *CheckboxBase) Init(self page.ControlI, parent page.ControlI, id string)
- func (c *CheckboxBase) LabelAttributes() html.Attributes
- func (c *CheckboxBase) Serialize(e page.Encoder) (err error)
- func (c *CheckboxBase) SetChecked(v bool) CheckboxI
- func (c *CheckboxBase) SetCheckedNoRefresh(v interface{})
- func (c *CheckboxBase) SetLabelDrawingMode(m html.LabelDrawingMode)
- func (c *CheckboxBase) SetValue(v interface{}) CheckboxI
- func (c *CheckboxBase) TextIsLabel() bool
- func (c *CheckboxBase) UpdateCheckboxFormValues(ctx *page.Context)
- func (c *CheckboxBase) UpdateRadioFormValues(ctx *page.Context, group string)
- func (c *CheckboxBase) Value() interface{}
- func (c *CheckboxBase) ΩDrawTag(ctx context.Context) (ctrl string)
- func (c *CheckboxBase) ΩDrawingAttributes() html.Attributes
- func (c *CheckboxBase) ΩGetDrawingLabelAttributes() html.Attributes
- func (c *CheckboxBase) ΩMarshalState(m maps.Setter)
- func (c *CheckboxBase) ΩUnmarshalState(m maps.Loader)
- func (c *CheckboxBase) ΩisSerializer(i page.ControlI) bool
- type CheckboxCreator
- type CheckboxI
- type CheckboxList
- func (l *CheckboxList) ColumnCount() int
- func (l *CheckboxList) Init(self CheckboxListI, parent page.ControlI, id string)
- func (l *CheckboxList) LayoutDirection() LayoutDirection
- func (l *CheckboxList) SetColumnCount(columns int) CheckboxListI
- func (l *CheckboxList) SetIsScrolling(s bool) CheckboxListI
- func (l *CheckboxList) SetLabelDrawingMode(mode html.LabelDrawingMode) CheckboxListI
- func (l *CheckboxList) SetLayoutDirection(direction LayoutDirection) CheckboxListI
- func (l *CheckboxList) SetRowClass(c string) CheckboxListI
- func (l *CheckboxList) ΩDrawInnerHtml(ctx context.Context, buf *bytes.Buffer) (err error)
- func (l *CheckboxList) ΩDrawingAttributes() html.Attributes
- func (l *CheckboxList) ΩRenderItem(item ListItemI) (h string)
- func (l *CheckboxList) ΩRenderItems(items []ListItemI) string
- func (l *CheckboxList) ΩUpdateFormValues(ctx *page.Context)
- type CheckboxListCreator
- type CheckboxListI
- type ColumnBase
- func (c *ColumnBase) Action(ctx context.Context, params page.ActionParams)
- func (c *ColumnBase) AddActions(ctrl page.ControlI)
- func (c *ColumnBase) ApplyOptions(ctx context.Context, parent TableI, opt ColumnOptions)
- func (c *ColumnBase) AsHeader() bool
- func (c *ColumnBase) CellAttributes(ctx context.Context, row int, col int, data interface{}) html.Attributes
- func (c *ColumnBase) CellText(ctx context.Context, row int, col int, data interface{}) string
- func (c *ColumnBase) CellTexter() CellTexter
- func (c *ColumnBase) ColTagAttributes() html.Attributes
- func (c *ColumnBase) DrawCell(ctx context.Context, row int, col int, data interface{}, buf *bytes.Buffer)
- func (c *ColumnBase) DrawColumnTag(ctx context.Context, buf *bytes.Buffer)
- func (c *ColumnBase) DrawFooterCell(ctx context.Context, row int, col int, count int, buf *bytes.Buffer)
- func (c *ColumnBase) FooterAttributes(ctx context.Context, row int, col int) html.Attributes
- func (c *ColumnBase) FooterCellHtml(ctx context.Context, row int, col int) string
- func (c *ColumnBase) HeaderAttributes(ctx context.Context, row int, col int) html.Attributes
- func (c *ColumnBase) HeaderCellHtml(ctx context.Context, row int, col int) (h string)
- func (c *ColumnBase) ID() string
- func (c *ColumnBase) Init(self ColumnI)
- func (c *ColumnBase) IsHidden() bool
- func (c *ColumnBase) IsSortable() bool
- func (c *ColumnBase) MarshalState(m maps.Setter)
- func (c *ColumnBase) ParentTable() TableI
- func (c *ColumnBase) PreRender()
- func (c *ColumnBase) RenderSortButton(labelHtml string) string
- func (c *ColumnBase) SetAsHeader(r bool)
- func (c *ColumnBase) SetCellStyler(s CellStyler)
- func (c *ColumnBase) SetCellTexter(s CellTexter) ColumnI
- func (c *ColumnBase) SetFooterTexter(s CellTexter) ColumnI
- func (c *ColumnBase) SetHeaderTexter(s CellTexter) ColumnI
- func (c *ColumnBase) SetHidden(h bool) ColumnI
- func (c *ColumnBase) SetID(id string) ColumnI
- func (c *ColumnBase) SetIsHtml(columnIsHtml bool) ColumnI
- func (c *ColumnBase) SetSortDirection(d SortDirection) ColumnI
- func (c *ColumnBase) SetSortable() ColumnI
- func (c *ColumnBase) SetSpan(span int) ColumnI
- func (c *ColumnBase) SetTitle(title string) ColumnI
- func (c *ColumnBase) SortDirection() SortDirection
- func (c *ColumnBase) Span() int
- func (c *ColumnBase) Title() string
- func (c *ColumnBase) UnmarshalState(m maps.Loader)
- func (c *ColumnBase) UpdateFormValues(ctx *page.Context)
- type ColumnCreator
- type ColumnI
- type ColumnOptions
- type DataPager
- func (d *DataPager) Action(ctx context.Context, params page.ActionParams)
- func (d *DataPager) ButtonProxy() *Proxy
- func (d *DataPager) CalcBunch() (pageStart, pageEnd int)
- func (d *DataPager) Deserialize(dec page.Decoder, p *page.Page) (err error)
- func (d *DataPager) Init(self page.ControlI, parent page.ControlI, id string, ...)
- func (d *DataPager) NextButtonsHtml() string
- func (d *DataPager) PageButtonsHtml(i int) string
- func (d *DataPager) PagedControl() PagedControlI
- func (d *DataPager) PreviousButtonsHtml() string
- func (d *DataPager) Serialize(e page.Encoder) (err error)
- func (d *DataPager) SetLabels(previous string, next string)
- func (d *DataPager) SetMaxPageButtons(b int)
- func (d *DataPager) SetObjectNames(singular string, plural string)
- func (d *DataPager) ΩDrawInnerHtml(ctx context.Context, buf *bytes.Buffer) (err error)
- func (d *DataPager) ΩDrawingAttributes() html.Attributes
- func (d *DataPager) ΩMarshalState(m maps.Setter)
- func (d *DataPager) ΩPreRender(ctx context.Context, buf *bytes.Buffer) (err error)
- func (d *DataPager) ΩUnmarshalState(m maps.Loader)
- func (d *DataPager) ΩisSerializer(i page.ControlI) bool
- type DataPagerCreator
- type DataPagerI
- type DateTextbox
- func (d *DateTextbox) Date() datetime.DateTime
- func (d *DateTextbox) Init(self TextboxI, parent page.ControlI, id string)
- func (d *DateTextbox) SetDate(dt datetime.DateTime)
- func (d *DateTextbox) SetFormat(format string) DateTextboxI
- func (d *DateTextbox) SetText(s string) page.ControlI
- func (d *DateTextbox) SetValue(val interface{}) page.ControlI
- func (d *DateTextbox) Value() interface{}
- func (d *DateTextbox) ΩUpdateFormValues(ctx *page.Context)
- type DateTextboxCreator
- type DateTextboxI
- type DateTimeSpan
- func (s *DateTimeSpan) Init(self page.ControlI, parent page.ControlI, id string)
- func (s *DateTimeSpan) SetDateTime(d datetime.DateTime)
- func (s *DateTimeSpan) SetFormat(format string) *DateTimeSpan
- func (s *DateTimeSpan) SetValue(v interface{})
- func (s *DateTimeSpan) Value() datetime.DateTime
- func (s *DateTimeSpan) ΩDrawInnerHtml(ctx context.Context, buf *bytes.Buffer) error
- type DateTimeSpanCreator
- type DateValidator
- type Dialog
- func (d *Dialog) Action(ctx context.Context, a page.ActionParams)
- func (d *Dialog) AddButton(label string, id string, options *DialogButtonOptions)
- func (d *Dialog) AddCloseButton(label string, id string)
- func (d *Dialog) ButtonBar() *Panel
- func (d *Dialog) Close()
- func (d *Dialog) CloseBox() *Button
- func (d *Dialog) DrawTemplate(ctx context.Context, buf *bytes.Buffer) (err error)
- func (d *Dialog) Init(self DialogI, parent page.ControlI, id string)
- func (d *Dialog) Open()
- func (d *Dialog) RemoveAllButtons()
- func (d *Dialog) RemoveButton(id string)
- func (d *Dialog) SetButtonStyles(id string, a html.Style)
- func (d *Dialog) SetButtonVisible(id string, visible bool)
- func (d *Dialog) SetDialogStyle(s DialogStyle)
- func (d *Dialog) SetHasCloseBox(h bool)
- func (d *Dialog) SetTitle(t string)
- func (d *Dialog) Title() string
- func (d *Dialog) TitleBar() *Panel
- func (d *Dialog) ΩDrawingAttributes() html.Attributes
- type DialogButtonOptions
- type DialogI
- type DialogStyle
- type EmailTextbox
- func (t *EmailTextbox) Addresses() (ret []string)
- func (t *EmailTextbox) Init(self TextboxI, parent page.ControlI, id string)
- func (t *EmailTextbox) SetMaxItemCount(max int) EmailTextboxI
- func (t *EmailTextbox) Validate(ctx context.Context) bool
- func (t *EmailTextbox) ΩUpdateFormValues(ctx *page.Context)
- type EmailTextboxCreator
- type EmailTextboxI
- type Fieldset
- type FieldsetCreator
- type FieldsetI
- type FloatLimit
- type FloatTextbox
- func (t *FloatTextbox) Float32() float32
- func (t *FloatTextbox) Float64() float64
- func (t *FloatTextbox) Init(self TextboxI, parent page.ControlI, id string)
- func (t *FloatTextbox) SetFloat32(v float32) *FloatTextbox
- func (t *FloatTextbox) SetFloat64(v float64) *FloatTextbox
- func (t *FloatTextbox) SetMaxValue(maxValue float64, invalidMessage string) FloatTextboxI
- func (t *FloatTextbox) SetMinValue(minValue float64, invalidMessage string) FloatTextboxI
- func (t *FloatTextbox) SetValue(v interface{}) page.ControlI
- func (t *FloatTextbox) Value() interface{}
- type FloatTextboxCreator
- type FloatTextboxI
- type FloatValidator
- type FormBase
- type FormFieldWrapper
- func (c *FormFieldWrapper) ErrorAttributes() html.Attributes
- func (c *FormFieldWrapper) For() string
- func (c *FormFieldWrapper) Init(self PanelI, parent page.ControlI, id string)
- func (c *FormFieldWrapper) InstructionAttributes() html.Attributes
- func (c *FormFieldWrapper) Instructions() string
- func (c *FormFieldWrapper) LabelAttributes() html.Attributes
- func (c *FormFieldWrapper) SetErrorAttributes(a html.Attributes) FormFieldWrapperI
- func (c *FormFieldWrapper) SetFor(relatedId string) FormFieldWrapperI
- func (c *FormFieldWrapper) SetInstructionAttributes(a html.Attributes) FormFieldWrapperI
- func (c *FormFieldWrapper) SetInstructions(i string) FormFieldWrapperI
- func (c *FormFieldWrapper) SetLabelAttributes(a html.Attributes) FormFieldWrapperI
- func (c *FormFieldWrapper) Validate(ctx context.Context) bool
- func (c *FormFieldWrapper) ΩDrawTag(ctx context.Context) string
- func (c *FormFieldWrapper) ΩDrawingAttributes() html.Attributes
- type FormFieldWrapperCreator
- type FormFieldWrapperI
- type GridLayoutBuilder
- func (g *GridLayoutBuilder) Build() string
- func (g *GridLayoutBuilder) ColumnCount(count int) *GridLayoutBuilder
- func (g *GridLayoutBuilder) Direction(placement LayoutDirection) *GridLayoutBuilder
- func (g *GridLayoutBuilder) Items(items []string) *GridLayoutBuilder
- func (g *GridLayoutBuilder) RowClass(t string) *GridLayoutBuilder
- func (g *GridLayoutBuilder) RowTag(t string) *GridLayoutBuilder
- type IDSetter
- type IDer
- type IdSlice
- type Image
- func (i *Image) Alt() string
- func (i *Image) Data() []byte
- func (i *Image) Height() int
- func (i *Image) Init(self ImageI, parent page.ControlI, id string)
- func (i *Image) SetAlt(alt string) ImageI
- func (i *Image) SetData(data []byte) ImageI
- func (i *Image) SetHeight(height int) ImageI
- func (i *Image) SetMimeType(typ string) ImageI
- func (i *Image) SetSrc(src string) ImageI
- func (i *Image) SetWidth(width int) ImageI
- func (i *Image) Src() string
- func (i *Image) Width() int
- func (i *Image) ΩDrawingAttributes() html.Attributes
- type ImageCapture
- func (i *ImageCapture) Data() []byte
- func (i *ImageCapture) Init(self ImageCaptureI, parent page.ControlI, id string)
- func (i *ImageCapture) SetData(data []byte)
- func (i *ImageCapture) SetMaskShape(shape ImageCaptureShape)
- func (i *ImageCapture) SetMimeType(typ string)
- func (i *ImageCapture) SetPixelSize(width int, height int)
- func (i *ImageCapture) SetQuality(quality float32)
- func (i *ImageCapture) SetZoom(zoom int)
- func (i *ImageCapture) TurnOff()
- func (i *ImageCapture) ΩDrawingAttributes() html.Attributes
- func (i *ImageCapture) ΩPutCustomScript(ctx context.Context, response *page.Response)
- func (i *ImageCapture) ΩUpdateFormValues(ctx *page.Context)
- type ImageCaptureCreator
- type ImageCaptureI
- type ImageCaptureShape
- type ImageCreator
- type ImageI
- type IntValidator
- type IntegerLimit
- type IntegerTextbox
- func (t *IntegerTextbox) Init(self TextboxI, parent page.ControlI, id string)
- func (t *IntegerTextbox) Int() int
- func (t *IntegerTextbox) Int64() int64
- func (t *IntegerTextbox) SetInt(v int) IntegerTextboxI
- func (t *IntegerTextbox) SetMaxValue(maxValue int, invalidMessage string) IntegerTextboxI
- func (t *IntegerTextbox) SetMinValue(minValue int, invalidMessage string) IntegerTextboxI
- func (t *IntegerTextbox) SetValue(v interface{}) page.ControlI
- func (t *IntegerTextbox) Value() interface{}
- type IntegerTextboxCreator
- type IntegerTextboxI
- type ItemIDer
- type ItemList
- func (l *ItemList) AddItem(label string, value ...interface{}) ListItemI
- func (l *ItemList) AddItemAt(index int, label string, value ...interface{})
- func (l *ItemList) AddListItemAt(index int, item ListItemI)
- func (l *ItemList) AddListItems(items ...interface{})
- func (l *ItemList) Clear()
- func (l *ItemList) GetItem(id string) (foundItem ListItemI)
- func (l *ItemList) GetItemAt(index int) ListItemI
- func (l *ItemList) GetItemByValue(value interface{}) (id string, foundItem ListItemI)
- func (l *ItemList) Len() int
- func (l *ItemList) ListItems() []ListItemI
- func (l *ItemList) RemoveItemAt(index int)
- type ItemListI
- type ItemLister
- type Labeler
- type LayoutDirection
- type ListItem
- func (i *ListItem) Anchor() string
- func (i *ListItem) AnchorAttributes() html.Attributes
- func (i *ListItem) Attributes() html.Attributes
- func (i *ListItem) Disabled() bool
- func (i *ListItem) HasChildItems() bool
- func (i *ListItem) ID() string
- func (i *ListItem) IntValue() int
- func (i *ListItem) IsDivider() bool
- func (i *ListItem) IsEmptyValue() bool
- func (i *ListItem) Label() string
- func (i *ListItem) RenderLabel() (h string)
- func (i *ListItem) SetAnchor(a string)
- func (i *ListItem) SetDisabled(d bool)
- func (i *ListItem) SetID(id string)
- func (i *ListItem) SetIsDivider(d bool)
- func (i *ListItem) SetLabel(l string)
- func (i *ListItem) SetShouldEscapeLabel(e bool) *ListItem
- func (i *ListItem) SetValue(v interface{}) *ListItem
- func (i *ListItem) StringValue() string
- func (i *ListItem) Value() interface{}
- type ListItemI
- type ListValue
- type MaxFloatValidator
- type MaxIntValidator
- type MaxLengthValidator
- type MinFloatValidator
- type MinIntValidator
- type MinLengthValidator
- type MultiselectList
- func (l *MultiselectList) Init(self MultiselectListI, parent page.ControlI, id string)
- func (l *MultiselectList) IsIdSelected(id string) bool
- func (l *MultiselectList) SelectedIds() []string
- func (l *MultiselectList) SelectedItems() []ListItemI
- func (l *MultiselectList) SelectedLabels() []string
- func (l *MultiselectList) SelectedValues() []interface{}
- func (l *MultiselectList) SetData(data interface{})
- func (l *MultiselectList) SetSelectedIdNoRefresh(id string, value bool)
- func (l *MultiselectList) SetSelectedIds(ids []string)
- func (l *MultiselectList) SetSelectedIdsNoRefresh(ids []string)
- func (l *MultiselectList) SetSize(size int) MultiselectListI
- func (l *MultiselectList) SetValue(v interface{})
- func (l *MultiselectList) Size() int
- func (l *MultiselectList) Validate(ctx context.Context) bool
- func (l *MultiselectList) Value() interface{}
- func (l *MultiselectList) ΩDrawInnerHtml(ctx context.Context, buf *bytes.Buffer) (err error)
- func (l *MultiselectList) ΩDrawingAttributes() html.Attributes
- func (l *MultiselectList) ΩMarshalState(m maps.Setter)
- func (l *MultiselectList) ΩUnmarshalState(m maps.Loader)
- func (l *MultiselectList) ΩUpdateFormValues(ctx *page.Context)
- type MultiselectListCreator
- type MultiselectListI
- type On
- type OrderedList
- func (l *OrderedList) Init(self page.ControlI, parent page.ControlI, id string)
- func (l *OrderedList) NumberType() string
- func (l *OrderedList) SetNumberType(t string) OrderedListI
- func (l *OrderedList) SetStart(start int) OrderedListI
- func (l *OrderedList) ΩDrawInnerHtml(ctx context.Context, buf *bytes.Buffer) (err error)
- type OrderedListCreator
- type OrderedListI
- type PagedControl
- func (c *PagedControl) AddDataPager(d DataPagerI)
- func (c *PagedControl) CalcPageCount() int
- func (c *PagedControl) GetDataPagerIDs() []string
- func (c *PagedControl) HasDataPagers() bool
- func (c *PagedControl) PageNum() int
- func (c *PagedControl) PageSize() int
- func (c *PagedControl) SetPageNum(n int)
- func (c *PagedControl) SetPageSize(size int)
- func (c *PagedControl) SetTotalItems(count uint)
- func (c *PagedControl) SliceOffsets() (start, end int)
- func (c *PagedControl) SqlLimits() (maxRowCount, offset int)
- func (c *PagedControl) TotalItems() int
- type PagedControlI
- type PagedTable
- type PagedTableCreator
- type PagedTableI
- type Panel
- type PanelCreator
- type PanelI
- type PrimaryKeyer
- type Proxy
- func (p *Proxy) ActionAttributes(actionValue string) html.Attributes
- func (p *Proxy) ButtonHtml(label string, actionValue string, attributes html.Attributes, rawHtml bool) string
- func (p *Proxy) Draw(ctx context.Context, buf *bytes.Buffer) (err error)
- func (p *Proxy) Init(parent page.ControlI, id string)
- func (p *Proxy) LinkHtml(ctx context.Context, label string, actionValue string, ...) string
- func (p *Proxy) OnSubmit(actions ...action.ActionI) page.ControlI
- func (p *Proxy) TagHtml(label string, actionValue string, attributes html.Attributes, tag string, ...) string
- func (p *Proxy) WrapEvent(eventName string, selector string, eventJs string, ...) string
- type ProxyCreator
- type ProxyI
- type RadioButton
- type RadioButtonCreator
- type RadioButtonI
- type RadioList
- func (l *RadioList) ColumnCount() int
- func (l *RadioList) Init(self RadioListI, parent page.ControlI, id string)
- func (l *RadioList) LayoutDirection() LayoutDirection
- func (l *RadioList) SetColumnCount(columns int) RadioListI
- func (l *RadioList) SetIsScrolling(s bool) RadioListI
- func (l *RadioList) SetLabelDrawingMode(mode html.LabelDrawingMode) RadioListI
- func (l *RadioList) SetLayoutDirection(direction LayoutDirection) RadioListI
- func (l *RadioList) SetRowClass(c string) RadioListI
- func (l *RadioList) ΩDrawInnerHtml(ctx context.Context, buf *bytes.Buffer) (err error)
- func (l *RadioList) ΩDrawingAttributes() html.Attributes
- func (l *RadioList) ΩRenderItem(item ListItemI) (h string)
- func (l *RadioList) ΩRenderItems(items []ListItemI) string
- func (l *RadioList) ΩUpdateFormValues(ctx *page.Context)
- type RadioListCreator
- type RadioListI
- type SelectList
- func (l *SelectList) Init(self page.ControlI, parent page.ControlI, id string)
- func (l *SelectList) IntValue() int
- func (l *SelectList) SelectedItem() ListItemI
- func (l *SelectList) SelectedLabel() string
- func (l *SelectList) SetData(data interface{})
- func (l *SelectList) SetSelectedID(id string)
- func (l *SelectList) SetValue(v interface{})
- func (l *SelectList) StringValue() string
- func (l *SelectList) Validate(ctx context.Context) bool
- func (l *SelectList) Value() interface{}
- func (l *SelectList) ΩDrawInnerHtml(ctx context.Context, buf *bytes.Buffer) (err error)
- func (l *SelectList) ΩDrawingAttributes() html.Attributes
- func (l *SelectList) ΩMarshalState(m maps.Setter)
- func (l *SelectList) ΩUnmarshalState(m maps.Loader)
- func (l *SelectList) ΩUpdateFormValues(ctx *page.Context)
- type SelectListCreator
- type SelectListI
- type SelectTable
- func (t *SelectTable) GetRowAttributes(row int, data interface{}) (a html.Attributes)
- func (t *SelectTable) Init(self page.ControlI, parent page.ControlI, id string)
- func (t *SelectTable) SelectedID() string
- func (t *SelectTable) SetSelectedID(id string) SelectTableI
- func (t *SelectTable) ΩDrawingAttributes() html.Attributes
- func (t *SelectTable) ΩMarshalState(m maps.Setter)
- func (t *SelectTable) ΩUnmarshalState(m maps.Loader)
- func (t *SelectTable) ΩUpdateFormValues(ctx *page.Context)
- type SelectTableCreator
- type SelectTableI
- type SortDirection
- type Span
- type SpanCreator
- type SpanI
- type Table
- func (t *Table) AddColumn(column ColumnI) ColumnI
- func (t *Table) AddColumnAt(column ColumnI, loc int)
- func (t *Table) ClearColumns()
- func (t *Table) DrawCaption(ctx context.Context, buf *bytes.Buffer) (err error)
- func (t *Table) FooterCellDrawingInfo(ctx context.Context, col ColumnI, rowNum int, colNum int) (cellHtml string, cellAttributes html.Attributes)
- func (t *Table) GetColumn(loc int) ColumnI
- func (t *Table) GetColumnByID(id string) ColumnI
- func (t *Table) GetColumnByTitle(title string) ColumnI
- func (t *Table) GetFooterRowAttributes(row int) html.Attributes
- func (t *Table) GetHeaderRowAttributes(row int) html.Attributes
- func (t *Table) GetRowAttributes(row int, data interface{}) html.Attributes
- func (t *Table) HeaderCellDrawingInfo(ctx context.Context, col ColumnI, rowNum int, colNum int) (cellHtml string, cellAttributes html.Attributes)
- func (t *Table) HideColumns()
- func (t *Table) Init(self page.ControlI, parent page.ControlI, id string)
- func (t *Table) MakeSortable() TableI
- func (t *Table) PrivateAction(ctx context.Context, p page.ActionParams)
- func (t *Table) RemoveColumn(loc int)
- func (t *Table) RemoveColumnByID(id string)
- func (t *Table) RemoveColumnByTitle(title string)
- func (t *Table) RowStyler() TableRowAttributer
- func (t *Table) SetCaption(caption interface{}) TableI
- func (t *Table) SetFooterRowCount(count int) TableI
- func (t *Table) SetFooterRowStyler(a TableFooterRowAttributer) TableI
- func (t *Table) SetHeaderRowCount(count int) TableI
- func (t *Table) SetHeaderRowStyler(a TableHeaderRowAttributer) TableI
- func (t *Table) SetHideIfEmpty(h bool) TableI
- func (t *Table) SetRenderColumnTags(r bool) TableI
- func (t *Table) SetRowStyler(a TableRowAttributer) TableI
- func (t *Table) SetSortHistoryLimit(n int) TableI
- func (t *Table) ShowColumns()
- func (t *Table) SortColumns() (ret []ColumnI)
- func (t *Table) ΩDrawInnerHtml(ctx context.Context, buf *bytes.Buffer) (err error)
- func (t *Table) ΩDrawTag(ctx context.Context) string
- func (t *Table) ΩDrawingAttributes() html.Attributes
- func (t *Table) ΩMarshalState(m maps.Setter)
- func (t *Table) ΩUnmarshalState(m maps.Loader)
- func (t *Table) ΩUpdateFormValues(ctx *page.Context)
- type TableCreator
- type TableEmbedder
- type TableFooterRowAttributer
- type TableHeaderRowAttributer
- type TableI
- type TableRowAttributer
- type Textbox
- func (t *Textbox) Deserialize(d page.Decoder, p *page.Page) (err error)
- func (t *Textbox) Init(self TextboxI, parent page.ControlI, id string)
- func (t *Textbox) MaxLength() int
- func (t *Textbox) MinLength() int
- func (t *Textbox) Placeholder() string
- func (t *Textbox) ResetValidators()
- func (t *Textbox) Serialize(e page.Encoder) (err error)
- func (t *Textbox) SetColumnCount(columns int) TextboxI
- func (t *Textbox) SetMaxLength(len int) *MaxLengthValidator
- func (t *Textbox) SetMinLength(len int) *MinLengthValidator
- func (t *Textbox) SetPlaceholder(s string) TextboxI
- func (t *Textbox) SetReadOnly(r bool) TextboxI
- func (t *Textbox) SetRowCount(rows int) TextboxI
- func (t *Textbox) SetText(s string) page.ControlI
- func (t *Textbox) SetType(typ string) TextboxI
- func (t *Textbox) SetValue(v interface{}) page.ControlI
- func (t *Textbox) Text() string
- func (t *Textbox) Validate(ctx context.Context) bool
- func (t *Textbox) ValidateWith(v Validater)
- func (t *Textbox) Value() interface{}
- func (t *Textbox) ΩDrawInnerHtml(ctx context.Context, buf *bytes.Buffer) (err error)
- func (t *Textbox) ΩDrawingAttributes() html.Attributes
- func (t *Textbox) ΩMarshalState(m maps.Setter)
- func (t *Textbox) ΩSanitize(s string) string
- func (t *Textbox) ΩUnmarshalState(m maps.Loader)
- func (t *Textbox) ΩUpdateFormValues(ctx *page.Context)
- func (t *Textbox) ΩisSerializer(i page.ControlI) bool
- type TextboxCreator
- type TextboxI
- type UnorderedList
- func (l *UnorderedList) GetItemsHtml(items []ListItemI) string
- func (l *UnorderedList) Init(self page.ControlI, parent page.ControlI, id string)
- func (l *UnorderedList) SetBulletStyle(s string) UnorderedListI
- func (l *UnorderedList) SetData(data interface{})
- func (l *UnorderedList) SetItemTag(s string) UnorderedListI
- func (l *UnorderedList) ΩDrawInnerHtml(ctx context.Context, buf *bytes.Buffer) (err error)
- func (l *UnorderedList) ΩDrawTag(ctx context.Context) string
- func (l *UnorderedList) ΩDrawingAttributes() html.Attributes
- type UnorderedListCreator
- type UnorderedListI
- type Validater
Constants ¶
const ( ButtonClick = iota + 3000 DialogClose )
event codes
const ( OrderedListNumberTypeNumber = "1" // default OrderedListNumberTypeUpperLetter = "A" OrderedListNumberTypeLowerLetter = "a" OrderedListNumberTypeUpperRoman = "I" OrderedListNumberTypeLowerRoman = "i" )
const ( // UnoderedListStyleDisc is the default list style for main items and is a bullet UnorderedListStyleDisc = "disc" // default // UnorderedListStyleCircle is the default list style for 2nd level items and is an open circle UnorderedListStyleCircle = "circle" // UnorderedListStyleSquare sets a square as the bullet UnorderedListStyleSquare = "square" // UnorderedListStyleNone removes the bullet from the list UnorderedListStyleNone = "none" )
const ( ColumnAction = iota + 2000 SortClick )
const ( NotSortable = SortDirection(0) SortAscending = SortDirection(1) SortDescending = SortDirection(-1) NotSorted = SortDirection(-100) )
const ( TextboxTypeDefault = "text" TextboxTypePassword = "password" TextboxTypeSearch = "search" TextboxTypeNumber = "number" // Puts little arrows in box, will need to widen it. TextboxTypeEmail = "email" // see TextEmail. Prevents submission of RFC5322 email addresses (Gogh Fir <gf@example.com>) TextboxTypeTel = "tel" // not well supported TextboxTypeUrl = "url" )
const DialogButtonEvent = "gr-dlgbtn"
const (
PageClick = iota + 1000
)
Variables ¶
var DefaultMaxPagerButtons = 10
DefaultMaxPagerButtons is the default maximum number of buttons to display on the pager. You can change this in an individual control, too.
var DefaultPagerPageSize = 10
DefaultPagerPageSize is the default number of items that a paged control will show. You can change this in an individual control, too.
var SortButtonHtmlGetter func(SortDirection) string
SortButtonHtmlGetter is the injected function for getting the html for sort buttons in the column header. The default uses FontAwesome to draw the buttons, which means the css for FontAwesome must be loaded into the web page. You can change what html is loaded by setting this function.
Functions ¶
func CalcWrapperID ¶ added in v0.2.0
CalcWrapperID returns the computed id of a control that wraps another control This would be the id of the child control followed by the postfix
func Children ¶ added in v0.2.0
Children is just a helper function for doing declarative control creation for child control creators
func GetCreatorID ¶ added in v0.2.0
GetCreatorID uses reflection to get the id of the given creator
func NoSelectionItemList ¶ added in v0.2.0
func NoSelectionItemList() []interface{}
NoSelectionItemList returns a default item list to start a selection list that allows no selection
func SelectOneItemList ¶ added in v0.2.0
func SelectOneItemList() []interface{}
SelectOneItemList returns a default item list to start a selection list that asks the user to select an item
func SetAlertFunction ¶
func SetAlertFunction(f AlertFuncType)
SetAlertFunction will set the entire framework's alert function to this function. The alert function is called whenever the framework needs to display an alert. Currently, this is done only from the code generated forms. Css/js frameworks that want to work with goradd should call this from an init() function to enable goradd to use it to display its alerts.
Types ¶
type AlertFuncType ¶
type Button ¶
Button is a standard html form submit button. It corresponds to a <button> tag in html.
The default behavior of a submit button is to submit a form. If you have text boxes on your form, pressing enter will submit the FIRST button in the form, and so this essentially becomes your default button. If you have more than one button, and you want the default button to NOT be the first button on the screen, you can handle this in one of two ways: - Make sure your default button comes out first in the html, but then use css to change the visible order of the buttons. Be sure to also set the tab order if you do this to reflect the visible arrangement of the buttons. Or, - Create another button as the first button, and give it a display attribute of none so that it is not visible. Set its action to be the default action you want.
If you want the button to display an image, simple create an Image control as a child of the button.
func GetButton ¶ added in v0.2.0
GetButton is a convenience method to return the button with the given id from the page.
func (*Button) Init ¶
Init is called by subclasses of Button to initialize the button control structure.
func (*Button) OnSubmit ¶
OnSubmit is a shortcut for adding a click event handler that is particular to buttons and button like objects. It debounces the click, so that all other events are lost until this event processes. It should generally be used for operations that will eventually redirect to a different page. If coupling this with an ajax response, you should probably also make the response priority PriorityFinal.
func (*Button) SetLabel ¶
SetLabel is an alias for SetText on buttons. Standard buttons do not normally have separate labels. Subclasses can redefine this if they use separate labels.
func (*Button) ΩDrawingAttributes ¶ added in v0.0.3
func (b *Button) ΩDrawingAttributes() html.Attributes
ΩDrawingAttributes retrieves the tag's attributes at draw time. You should not normally need to call this, and the attributes are disposed of after drawing, so they are essentially read-only.
type ButtonCreator ¶ added in v0.2.0
type ButtonCreator struct { // ID is the control id ID string // Text is the text displayed in the button Text string // OnSubmit is the action to take when the button is submitted. Use this specifically // for buttons that move to other pages or processes transactions, as it debounces the button // and waits until all other actions complete OnSubmit action.ActionI // OnClick is an action to take when the button is pressed. Do not specify both // a OnClick and OnSubmit. OnClick action.ActionI page.ControlOptions }
ButtonCreator is the initialization structure for declarative creation of buttons
type Canvas ¶
Canvas is a Goradd control that is an html canvas control. It currently does not have any primitives to draw on the canvas, and is here primarily to create a canvas that you would draw on using JavaScript.
func GetCanvas ¶ added in v0.2.0
GetCanvas is a convenience method to return the canvas with the given id from the page.
func (*Canvas) ΩDrawingAttributes ¶ added in v0.0.3
func (c *Canvas) ΩDrawingAttributes() html.Attributes
ΩDrawingAttributes is called by the framework to get the temporary attributes that are specifically set by this control just before drawing.
type CanvasCreator ¶ added in v0.2.0
type CanvasCreator struct { // ID is the control id ID string page.ControlOptions }
CanvasCreator is the initialization structure for declarative creation of buttons
type CellStyler ¶ added in v0.2.0
type CellTexter ¶
type CellTexter interface {
CellText(ctx context.Context, col ColumnI, rowNum int, colNum int, data interface{}) string
}
CellTexter defines the interface for a structure that provides the content of a table cell. If your CellTexter is not a control, you should register it with gob.
type Checkbox ¶
type Checkbox struct {
CheckboxBase
}
Checkbox is a basic html checkbox input form control.
func GetCheckbox ¶ added in v0.2.0
GetCheckbox is a convenience method to return the checkbox with the given id from the page.
func NewCheckbox ¶
NewCheckbox creates a new checkbox control.
func (*Checkbox) ΩDrawingAttributes ¶ added in v0.0.3
func (c *Checkbox) ΩDrawingAttributes() html.Attributes
ΩDrawingAttributes is called by the framework to set the temporary attributes that the control needs. Checkboxes set the grctl, name, type and value attributes automatically. You do not normally need to call this function.
func (*Checkbox) ΩUpdateFormValues ¶ added in v0.0.3
ΩUpdateFormValues is an internal call that lets us reflect the value of the checkbox on the form. You do not normally need to call this function.
type CheckboxBase ¶
type CheckboxBase struct { page.Control // LabelMode describes where to place the label associating the text with the checkbox. The default is the // global page.DefaultCheckboxLabelDrawingMode, and you would normally set that instead so that all your checkboxes draw // the same way. LabelMode html.LabelDrawingMode // contains filtered or unexported fields }
CheckboxBase is a base class for checkbox-like objects, including html checkboxes and radio buttons.
func (*CheckboxBase) Checked ¶
func (c *CheckboxBase) Checked() bool
Checked returns true if the checkbox is checked.
func (*CheckboxBase) Deserialize ¶
Deserialize is called by the framework during page state serialization.
func (*CheckboxBase) Init ¶
Init initializes a checkbox base class. It is called by checkbox implementations.
func (*CheckboxBase) LabelAttributes ¶ added in v0.2.0
func (c *CheckboxBase) LabelAttributes() html.Attributes
LabelAttributes returns a pointer to the input label attributes. Feel free to set the attributes directly on the returned object. The input label attributes are the attributes for the label tag that associates the Text with the checkbox. This is specific to checkbox style controls and is not the same as the label tag that appears when using a FormFieldWrapper wrapper. After setting attributes, be sure to call Refresh on the control if you do this during an Ajax response.
func (*CheckboxBase) Serialize ¶
func (c *CheckboxBase) Serialize(e page.Encoder) (err error)
Serialize is called by the framework during pagestate serialization.
func (*CheckboxBase) SetChecked ¶
func (c *CheckboxBase) SetChecked(v bool) CheckboxI
SetChecked sets the value of the checkbox. Returns itself for chaining.
func (*CheckboxBase) SetCheckedNoRefresh ¶
func (c *CheckboxBase) SetCheckedNoRefresh(v interface{})
SetCheckedNoRefresh is used internally to update values without causing a refresh loop.
func (*CheckboxBase) SetLabelDrawingMode ¶
func (c *CheckboxBase) SetLabelDrawingMode(m html.LabelDrawingMode)
SetLabelDrawingMode determines how the label is drawn for the checkbox.
func (*CheckboxBase) SetValue ¶
func (c *CheckboxBase) SetValue(v interface{}) CheckboxI
SetValue sets the checked status of checkbox. The given value can be:
For True "1", "true", "TRUE", "on", "ON", 1(int), true(bool)
For False "0", "false", "FALSE", "off, "OFF", ""(empty string), 0(int), false(bool)
Other values will cause a panic.
func (*CheckboxBase) TextIsLabel ¶
func (c *CheckboxBase) TextIsLabel() bool
TextIsLabel is called by the framework to determine that the Text of the control is used in a label tag. You do not normally need to call this unless you are creating the template for a custom control.
func (*CheckboxBase) UpdateCheckboxFormValues ¶ added in v0.0.4
func (c *CheckboxBase) UpdateCheckboxFormValues(ctx *page.Context)
UpdateCheckboxFormValues is used by subclasses of CheckboxBase to update their internal state if they are a checkbox type of control.
func (*CheckboxBase) UpdateRadioFormValues ¶ added in v0.0.4
func (c *CheckboxBase) UpdateRadioFormValues(ctx *page.Context, group string)
UpdateRadioFormValues is used by subclasses of CheckboxBase to update their internal state if they are a radioButton type of control.
func (*CheckboxBase) Value ¶
func (c *CheckboxBase) Value() interface{}
Value returns the boolean checked status of the checkbox.
func (*CheckboxBase) ΩDrawTag ¶ added in v0.0.3
func (c *CheckboxBase) ΩDrawTag(ctx context.Context) (ctrl string)
ΩDrawTag draws the checkbox tag. This can be quite tricky. Some CSS frameworks are very particular about how checkboxes get associated with labels. The Text value of the control will become the text directly associated with the checkbox, while the Label value is only shown when drawing a checkbox with a wrapper.
func (*CheckboxBase) ΩDrawingAttributes ¶ added in v0.0.3
func (c *CheckboxBase) ΩDrawingAttributes() html.Attributes
ΩDrawingAttributes retrieves the tag's attributes at draw time. You should not normally need to call this, and the attributes are disposed of after drawing, so they are essentially read-only.
func (*CheckboxBase) ΩGetDrawingLabelAttributes ¶ added in v0.0.3
func (c *CheckboxBase) ΩGetDrawingLabelAttributes() html.Attributes
ΩGetDrawingLabelAttributes is called by the framework to temporarily set the attributes of the label associated with the checkbox.
func (*CheckboxBase) ΩMarshalState ¶ added in v0.0.3
func (c *CheckboxBase) ΩMarshalState(m maps.Setter)
ΩMarshalState is called by the framework to save the state of the checkbox between form views. Call SetState(true) to enable state saving.
func (*CheckboxBase) ΩUnmarshalState ¶ added in v0.0.3
func (c *CheckboxBase) ΩUnmarshalState(m maps.Loader)
ΩUnmarshalState restores the state of the checkbox if coming back to a form in the same session.
func (*CheckboxBase) ΩisSerializer ¶
func (c *CheckboxBase) ΩisSerializer(i page.ControlI) bool
ΩisSerializer is used by the automated control serializer to determine how far down the control chain the control has to go before just calling serialize and deserialize
type CheckboxCreator ¶ added in v0.2.0
type CheckboxCreator struct { // ID is the id of the control ID string // Text is the text of the label displayed right next to the checkbox. Text string // Checked will initialize the checkbox in its checked state. Checked bool // LabelMode specifies how the label is drawn with the checkbox. LabelMode html.LabelDrawingMode // LabelAttributes are additional attributes placed on the label tag. LabelAttributes html.AttributeCreator // SaveState will save the value of the checkbox and restore it when the page is reentered. SaveState bool page.ControlOptions }
type CheckboxI ¶
type CheckboxI interface { page.ControlI ΩGetDrawingLabelAttributes() html.Attributes }
type CheckboxList ¶
type CheckboxList struct { MultiselectList // contains filtered or unexported fields }
CheckboxList is a multi-select control that presents its choices as a list of checkboxes. Styling is provided by divs and spans that you can provide css for in your style sheets. The goradd.css file has default styling to handle the basics. It wraps the whole thing in a div that can be set to scroll as well, so that the final structure can be styled like a multi-column table, or a single-column scrolling list much like a standard html select list.
func GetCheckboxList ¶ added in v0.2.0
func GetCheckboxList(c page.ControlI, id string) *CheckboxList
GetRadioList is a convenience method to return the control with the given id from the page.
func NewCheckboxList ¶
func NewCheckboxList(parent page.ControlI, id string) *CheckboxList
NewCheckboxList creates a new CheckboxList
func (*CheckboxList) ColumnCount ¶
func (l *CheckboxList) ColumnCount() int
ColumnCount returns the current column count.
func (*CheckboxList) Init ¶
func (l *CheckboxList) Init(self CheckboxListI, parent page.ControlI, id string)
Init is called by subclasses
func (*CheckboxList) LayoutDirection ¶ added in v0.2.0
func (l *CheckboxList) LayoutDirection() LayoutDirection
LayoutDirection returns the direction of how items are spread across the columns.
func (*CheckboxList) SetColumnCount ¶
func (l *CheckboxList) SetColumnCount(columns int) CheckboxListI
SetColumnCount sets the number of columns to use to display the list. Items will be evenly distributed across the columns.
func (*CheckboxList) SetIsScrolling ¶
func (l *CheckboxList) SetIsScrolling(s bool) CheckboxListI
SetIsScrolling sets whether the list will scroll if it gets bigger than its bounding box. You will need to style the bounding box to give it limits, or else it will simply grow as big as the list.
func (*CheckboxList) SetLabelDrawingMode ¶
func (l *CheckboxList) SetLabelDrawingMode(mode html.LabelDrawingMode) CheckboxListI
SetLabelDrawingMode indicates how labels for each of the checkboxes are drawn.
func (*CheckboxList) SetLayoutDirection ¶ added in v0.2.0
func (l *CheckboxList) SetLayoutDirection(direction LayoutDirection) CheckboxListI
SetLayoutDirection specifies how items are distributed across the columns.
func (*CheckboxList) SetRowClass ¶ added in v0.2.0
func (l *CheckboxList) SetRowClass(c string) CheckboxListI
SetRowClass sets the class to the div wrapper around each row. If blank, will be given a default.
func (*CheckboxList) ΩDrawInnerHtml ¶ added in v0.0.3
ΩDrawInnerHtml is called by the framework to draw the contents of the list.
func (*CheckboxList) ΩDrawingAttributes ¶ added in v0.0.3
func (l *CheckboxList) ΩDrawingAttributes() html.Attributes
ΩDrawingAttributes retrieves the tag's attributes at draw time. You should not normally need to call this, and the attributes are disposed of after drawing, so they are essentially read-only.
func (*CheckboxList) ΩRenderItem ¶ added in v0.0.3
func (l *CheckboxList) ΩRenderItem(item ListItemI) (h string)
ΩRenderItem is called by the framework to render a single item in the list.
func (*CheckboxList) ΩRenderItems ¶ added in v0.0.4
func (l *CheckboxList) ΩRenderItems(items []ListItemI) string
func (*CheckboxList) ΩUpdateFormValues ¶ added in v0.0.3
func (l *CheckboxList) ΩUpdateFormValues(ctx *page.Context)
ΩUpdateFormValues is called by the framework to tell the control to update its internal values based on the form values sent by the browser.
type CheckboxListCreator ¶ added in v0.2.0
type CheckboxListCreator struct { ID string // Items is a static list of labels and values that will be in the list. Or, use a DataProvider to dynamically generate the items. Items []ListValue // DataProvider is the control that will dynamically provide the data for the list and that implements the DataBinder interface. DataProvider data.DataBinder // DataProviderID is the id of a control that will dynamically provide the data for the list and that implements the DataBinder interface. DataProviderID string // ColumnCount specifies how many columns to show ColumnCount int // LayoutDirection determines how the items are arranged in the columns LayoutDirection LayoutDirection // LabelDrawingMode specifies how the labels on the radio buttons will be associated with the buttons LabelDrawingMode html.LabelDrawingMode // IsScrolling will give the inner div a vertical scroll style. You will need to style the height of the outer control to have a fixed style as well. IsScrolling bool // RowClass is the class assigned to each row RowClass string // Value is the initial value of the textbox. Often its best to load the value in a separate Load step after creating the control. Value string // SaveState saves the selected value so that it is restored if the form is returned to. SaveState bool page.ControlOptions }
func (CheckboxListCreator) Create ¶ added in v0.2.0
Create is called by the framework to create a new control from the Creator. You do not normally need to call this.
func (CheckboxListCreator) Init ¶ added in v0.2.0
func (c CheckboxListCreator) Init(ctx context.Context, ctrl CheckboxListI)
type CheckboxListI ¶
type CheckboxListI interface { MultiselectListI SetColumnCount(int) CheckboxListI SetLayoutDirection(direction LayoutDirection) CheckboxListI SetLabelDrawingMode(mode html.LabelDrawingMode) CheckboxListI SetIsScrolling(s bool) CheckboxListI SetRowClass(c string) CheckboxListI ΩRenderItems(items []ListItemI) string ΩRenderItem(item ListItemI) string }
type ColumnBase ¶
type ColumnBase struct { base.Base html.Attributes // These are static attributes that will appear on each cell // contains filtered or unexported fields }
ColumnBase is the base implementation of all table columns
func (*ColumnBase) Action ¶
func (c *ColumnBase) Action(ctx context.Context, params page.ActionParams)
Do a table action that is directed at this table Column implementations can implement this method to receive private actions that they have added using AddActions
func (*ColumnBase) AddActions ¶
func (c *ColumnBase) AddActions(ctrl page.ControlI)
func (*ColumnBase) ApplyOptions ¶ added in v0.2.0
func (c *ColumnBase) ApplyOptions(ctx context.Context, parent TableI, opt ColumnOptions)
func (*ColumnBase) AsHeader ¶ added in v0.2.0
func (c *ColumnBase) AsHeader() bool
func (*ColumnBase) CellAttributes ¶
func (c *ColumnBase) CellAttributes(ctx context.Context, row int, col int, data interface{}) html.Attributes
CellAttributes returns the attributes of the cell. Column implementations should call this base version first before customizing more. It will use the CellStyler if one was provided.
func (*ColumnBase) CellText ¶
CellText returns the text in the cell. It will use the CellTexter if one was provided.
func (*ColumnBase) CellTexter ¶
func (c *ColumnBase) CellTexter() CellTexter
CellTexter returns the cell texter.
func (*ColumnBase) ColTagAttributes ¶
func (c *ColumnBase) ColTagAttributes() html.Attributes
ColTagAttributes specifies attributes that will appear in the table tag. Note that you have to turn on table tags in the table object as well for these to appear.
func (*ColumnBase) DrawCell ¶
func (c *ColumnBase) DrawCell(ctx context.Context, row int, col int, data interface{}, buf *bytes.Buffer)
DrawCell is the default cell drawing function.
func (*ColumnBase) DrawColumnTag ¶
func (c *ColumnBase) DrawColumnTag(ctx context.Context, buf *bytes.Buffer)
DrawColumnTag draws the column tag if one was requested.
func (*ColumnBase) DrawFooterCell ¶
func (c *ColumnBase) DrawFooterCell(ctx context.Context, row int, col int, count int, buf *bytes.Buffer)
DrawFooterCell will draw the footer cells html into the given buffer.
func (*ColumnBase) FooterAttributes ¶
func (c *ColumnBase) FooterAttributes(ctx context.Context, row int, col int) html.Attributes
FooterAttributes returns the attributes to use for the footer cell.
func (*ColumnBase) FooterCellHtml ¶
FooterCellHtml returns the html to use in the given footer cell.
func (*ColumnBase) HeaderAttributes ¶
func (c *ColumnBase) HeaderAttributes(ctx context.Context, row int, col int) html.Attributes
HeaderAttributes returns the attributes to use on the header cell. The default version will return an attribute structure which you can use to directly manipulate the attributes. If you want something more customized, create your own column and implement this function. row and col are zero based.
func (*ColumnBase) HeaderCellHtml ¶
HeaderCellHtml returns the text of the indicated header cell. The default will call into the headerTexter if it is provided, or just return the Label value. This function can also be overridden by embedding the ColumnBase object into another object.
func (*ColumnBase) Init ¶
func (c *ColumnBase) Init(self ColumnI)
func (*ColumnBase) IsHidden ¶
func (c *ColumnBase) IsHidden() bool
IsHidden returns true if the column is hidden.
func (*ColumnBase) IsSortable ¶
func (c *ColumnBase) IsSortable() bool
IsSortable indicates whether the column is sortable, and has a sort indicator in the head.
func (*ColumnBase) MarshalState ¶ added in v0.0.4
func (c *ColumnBase) MarshalState(m maps.Setter)
MarshalState is an internal function to save the state of the control.
func (*ColumnBase) ParentTable ¶
func (c *ColumnBase) ParentTable() TableI
ParentTable returns the table that is the parent of the column
func (*ColumnBase) PreRender ¶ added in v0.0.4
func (c *ColumnBase) PreRender()
PreRender is called just before the table is redrawn.
func (*ColumnBase) RenderSortButton ¶
func (c *ColumnBase) RenderSortButton(labelHtml string) string
func (*ColumnBase) SetAsHeader ¶ added in v0.2.0
func (c *ColumnBase) SetAsHeader(r bool)
SetAsHeader will cause the entire column to be output with th instead of td cells.
func (*ColumnBase) SetCellStyler ¶
func (c *ColumnBase) SetCellStyler(s CellStyler)
SetCellStyler sets the CellStyler for the body cells.
func (*ColumnBase) SetCellTexter ¶
func (c *ColumnBase) SetCellTexter(s CellTexter) ColumnI
SetCellTexter sets the CellTexter for getting the content of each body cell.
func (*ColumnBase) SetFooterTexter ¶
func (c *ColumnBase) SetFooterTexter(s CellTexter) ColumnI
SetFooterTexter sets the CellTexter that gets the text for footer cells.
func (*ColumnBase) SetHeaderTexter ¶
func (c *ColumnBase) SetHeaderTexter(s CellTexter) ColumnI
SetHeaderTexter sets the CellTexter that gets the text for header cells.
func (*ColumnBase) SetHidden ¶
func (c *ColumnBase) SetHidden(h bool) ColumnI
SetHidden hides the column without removing it completely from the table.
func (*ColumnBase) SetID ¶
func (c *ColumnBase) SetID(id string) ColumnI
SetID sets the id of the column. If you are going to provide your own id, do this as the first thing after you create a table, or the new id might not propagate through the system correctly. Note that the id in html will have the table id prepended to it. This is required so that actions can be routed to a column.
func (*ColumnBase) SetIsHtml ¶
func (c *ColumnBase) SetIsHtml(columnIsHtml bool) ColumnI
SetIsHtml will cause the cell to treat the text it receives as html rather than raw text it should escape. Use this with extreme caution. Do not display unescaped text that might come from user input, as it could open you up to XSS attacks.
func (*ColumnBase) SetSortDirection ¶
func (c *ColumnBase) SetSortDirection(d SortDirection) ColumnI
SetSortDirection is used internally to set the sort direction indicator.
func (*ColumnBase) SetSortable ¶ added in v0.0.7
func (c *ColumnBase) SetSortable() ColumnI
MakeSortable indicates that the column should be drawn with sort indicators.
func (*ColumnBase) SetSpan ¶
func (c *ColumnBase) SetSpan(span int) ColumnI
SetSpan sets the span indicated in the column tag of the column. This is used to create colgroup tags.
func (*ColumnBase) SetTitle ¶
func (c *ColumnBase) SetTitle(title string) ColumnI
SetTitle sets the title of the column. It returns a column reference for chaining.
func (*ColumnBase) SortDirection ¶
func (c *ColumnBase) SortDirection() SortDirection
SortDirection returns the current sort direction.
func (*ColumnBase) Span ¶
func (c *ColumnBase) Span() int
Span returns the number of columns this column will span.
func (*ColumnBase) Title ¶
func (c *ColumnBase) Title() string
Title returns the title text that will appear in the header of the column
func (*ColumnBase) UnmarshalState ¶ added in v0.0.4
func (c *ColumnBase) UnmarshalState(m maps.Loader)
UnmarshalState is an internal function to restore the state of the control.
func (*ColumnBase) UpdateFormValues ¶
func (c *ColumnBase) UpdateFormValues(ctx *page.Context)
UpdateFormValues is called by the system whenever values are sent by client controls. This default version does nothing. Columns that need to record information (checkbox columns for example), should implement this.
type ColumnCreator ¶ added in v0.2.0
type ColumnI ¶
type ColumnI interface { ID() string SetID(string) ColumnI ParentTable() TableI Title() string SetTitle(string) ColumnI Span() int SetSpan(int) ColumnI IsHidden() bool AsHeader() bool SetHidden(bool) ColumnI DrawColumnTag(ctx context.Context, buf *bytes.Buffer) DrawCell(ctx context.Context, row int, col int, data interface{}, buf *bytes.Buffer) CellText(ctx context.Context, row int, col int, data interface{}) string HeaderCellHtml(ctx context.Context, row int, col int) string HeaderAttributes(ctx context.Context, row int, col int) html.Attributes ColTagAttributes() html.Attributes UpdateFormValues(ctx *page.Context) AddActions(ctrl page.ControlI) Action(ctx context.Context, params page.ActionParams) SetCellTexter(s CellTexter) ColumnI SetHeaderTexter(s CellTexter) ColumnI SetCellStyler(s CellStyler) IsSortable() bool SortDirection() SortDirection SetSortDirection(SortDirection) ColumnI SetSortable() ColumnI SetIsHtml(columnIsHtml bool) ColumnI PreRender() MarshalState(m maps.Setter) UnmarshalState(m maps.Loader) // contains filtered or unexported methods }
ColumnI defines the interface that all columns must support. Most of these functions are provided by the default behavior of the ColumnBase class.
type ColumnOptions ¶ added in v0.2.0
type ColumnOptions struct { // CellAttributes is a static map of attributes to apply to every cell in the column CellAttributes html.AttributeCreator // HeaderAttributes is a slice of attributes to apply to each row of the header cells in the column. // Each item in the slice corresponds to a row of the header. HeaderAttributes []html.AttributeCreator // Each item in the slice corresponds to a row of the footer. FooterAttributes []html.AttributeCreator // ColTagAttributes applies attributes to the col tag if col tags are on in the table. There are limited uses for // this, but in particular, you can style a column and give it an id. Use Span to set the span attribute. ColTagAttributes html.AttributeCreator // Span is specifically for col tags to specify the width of the styling in the col tag. Span int // AsHeader will cause the entire column to output header tags (th) instead of standard cell tags (td). // This is useful for columns on the left or right that contain labels for the rows. AsHeader bool // IsHtml will cause the text of the cells to NOT be escaped IsHtml bool // HeaderTexter is an object that will provide the text of the header cells. This can be either an // object that you have set up prior, or a string id of a control HeaderTexter interface{} // object that you have set up prior, or a string id of a control FooterTexter interface{} // IsHidden will start the column out in a hidden state so that it will not initially be drawn IsHidden bool }
ColumnOptions are settings you can apply to all types of table columns
type DataPager ¶
type DataPager struct { page.Control ObjectName string ObjectPluralName string LabelForNext string LabelForPrevious string // contains filtered or unexported fields }
DataPager is a toolbar designed to aid scrolling a large set of data. It is implemented using Aria design best practices. It is designed to be paired with a Table or DataRepeater to aid in navigating through the data. It is similar to a Paginator, but a paginator is for navigating through a series of related web pages and not just for data on one form.
func NewDataPager ¶
func NewDataPager(parent page.ControlI, id string, pagedControl PagedControlI) *DataPager
NewDataPager creates a new DataPager
func (*DataPager) Action ¶
func (d *DataPager) Action(ctx context.Context, params page.ActionParams)
Action is called by the framework to respond to actions.
func (*DataPager) ButtonProxy ¶ added in v0.2.0
func (*DataPager) CalcBunch ¶
CalcBunch is called by the framework to lay out the data pager based on the number of pages in the pager. It should try to represent an easy to navigate interface that can manage 2 or 2000 pages.
A "Bunch" is defined as the collection of numbers that lies in between the pair of Ellipsis ("...")
Layout ¶
For an IndexCount of 10 2 213 2 (two items to the left of the bunch, and then 2 indexes, selected index, 3 indexes, and then two items to the right of the bunch) e.g. 1 ... 5 6 *7* 8 9 10 ... 100
For IndexCount of 11 2 313 2
For IndexCount of 12 2 314 2
For IndexCount of 13 2 414 2
For IndexCount of 14 2 415 2
Start/end page numbers for the bunch
For IndexCount of 10 1 2 3 4 5 6 7 8 .. 100 1 .. 4 5 *6* 7 8 9 .. 100 1 .. 92 93 *94* 95 96 97 .. 100 1 .. 93 94 95 96 97 98 99 100
For IndexCount of 11 1 2 3 4 5 6 7 8 9 .. 100 1 .. 4 5 6 *7* 8 9 10 .. 100 1 .. 91 92 93 *94* 95 96 97 .. 100 1 .. 92 93 94 95 96 97 98 99 100
For IndexCount of 12 1 2 3 4 5 6 7 8 9 10 .. 100 1 .. 4 5 6 *7* 8 9 10 11 .. 100 1 .. 90 91 92 *93* 94 95 96 97 .. 100 1 .. 91 92 93 94 95 96 97 98 99 100
For IndexCount of 13 1 2 3 4 5 6 7 8 9 11 .. 100 1 .. 4 5 6 7 *8* 9 10 11 12 .. 100 1 .. 89 90 91 92 *93* 94 95 96 97 .. 100 1 .. 90 91 92 93 94 95 96 97 98 99 100
Note: there are likely better ways to do this. Some innovative ones are to have groups of 10s, and then 100s etc. Or, use the ellipsis as a dropdown menu for more selections
func (*DataPager) Deserialize ¶
func (*DataPager) Init ¶
func (d *DataPager) Init(self page.ControlI, parent page.ControlI, id string, pagedControl PagedControlI)
Init is called by subclasses of a DataPager to initialize the data pager. You do not normally need to call this.
func (*DataPager) NextButtonsHtml ¶
NextButtonsHtml returns the html for the next buttons. Subclasses can override this to change how the next buttons are drawn.
func (*DataPager) PageButtonsHtml ¶
PageButtonsHtml returns the html for the page buttons. Subclasses can override this to change how the page buttons are drawn.
func (*DataPager) PagedControl ¶ added in v0.2.0
func (d *DataPager) PagedControl() PagedControlI
func (*DataPager) PreviousButtonsHtml ¶
PreviousButtonsHtml returns the html to draw the previous buttons. Subclasses can override this to change how the Previous buttons are drawn.
func (*DataPager) SetMaxPageButtons ¶
SetMaxPageButtons sets the maximum number of buttons that will be displayed in the paginator.
func (*DataPager) SetObjectNames ¶
SetObjectNames sets the single and plural names of the objects that are represented in the data pager.
func (*DataPager) ΩDrawInnerHtml ¶ added in v0.0.3
ΩDrawInnerHtml is called by the framework to draw the control's inner html.
func (*DataPager) ΩDrawingAttributes ¶ added in v0.0.3
func (d *DataPager) ΩDrawingAttributes() html.Attributes
ΩDrawingAttributes is called by the framework to add temporary attributes to the html.
func (*DataPager) ΩMarshalState ¶ added in v0.0.3
ΩMarshalState is an internal function to save the state of the control
func (*DataPager) ΩPreRender ¶ added in v0.0.3
ΩPreRender is called by the framework to load data into the paged control just before drawing.
func (*DataPager) ΩUnmarshalState ¶ added in v0.0.3
ΩUnmarshalState is an internal function to restore the state of the control
type DataPagerCreator ¶ added in v0.2.0
type DataPagerCreator struct { // ID is the control id ID string // MaxPageButtons is the maximum number of page buttons to display in the pager MaxPageButtons int // ObjectName is the name of the object being displayed in the table ObjectName string // ObjectPluralName is the plural name of the object being displayed ObjectPluralName string // LabelForNext is the text to use in the Next button LabelForNext string // LabelForPrevious is the text to use in the Previous button LabelForPrevious string // PagedControl is the id of the control that will be paged by the pager PagedControl string page.ControlOptions }
DataPagerCreator is the initialization structure for declarative creation of data pagers
func (DataPagerCreator) Create ¶ added in v0.2.0
Create is called by the framework to create a new control from the Creator. You do not normally need to call this.
func (DataPagerCreator) Init ¶ added in v0.2.0
func (c DataPagerCreator) Init(ctx context.Context, ctrl DataPagerI)
Init is called by implementations of Buttons to initialize a control with the creator. You do not normally need to call this.
type DataPagerI ¶
type DataPagerI interface { page.ControlI PreviousButtonsHtml() string NextButtonsHtml() string PageButtonsHtml(i int) string SetMaxPageButtons(b int) SetObjectNames(singular string, plural string) SetLabels(previous string, next string) }
DataPagerI is the data pager interface that allows this object to call into subclasses.
func GetDataPager ¶ added in v0.2.0
func GetDataPager(c page.ControlI, id string) DataPagerI
type DateTextbox ¶
type DateTextbox struct { Textbox // contains filtered or unexported fields }
DateTextbox is a textbox that only permits dates and/or times to be entered into it.
func GetDateTextbox ¶ added in v0.2.0
func GetDateTextbox(c page.ControlI, id string) *DateTextbox
GetEmailTextbox is a convenience method to return the control with the given id from the page.
func NewDateTextbox ¶
func NewDateTextbox(parent page.ControlI, id string) *DateTextbox
NewDateTextbox creates a new DateTextbox.
func (*DateTextbox) Date ¶
func (d *DateTextbox) Date() datetime.DateTime
Date returns the value as a DateTime value based on the format. If a bad value was entered into the textbox, it will return an empty datetime.
func (*DateTextbox) Init ¶
func (d *DateTextbox) Init(self TextboxI, parent page.ControlI, id string)
func (*DateTextbox) SetDate ¶
func (d *DateTextbox) SetDate(dt datetime.DateTime)
SetDate will set the textbox to the give datetime value
func (*DateTextbox) SetFormat ¶
func (d *DateTextbox) SetFormat(format string) DateTextboxI
SetFormat sets the format of the text allowed. The format is any allowable format that datetime or time can convert.
func (*DateTextbox) SetText ¶
func (d *DateTextbox) SetText(s string) page.ControlI
SetText sets the DateTime to the given text. If you attempt set the text to something that is not convertible to a date, an empty string will be entered.
func (*DateTextbox) SetValue ¶
func (d *DateTextbox) SetValue(val interface{}) page.ControlI
SetValue will set the DateTextbox to the given value if possible.
func (*DateTextbox) Value ¶
func (d *DateTextbox) Value() interface{}
Value returns the value as an interface, but the underlying value will be a datetime. If a bad value was entered into the textbox, it will return an empty datetime.
func (*DateTextbox) ΩUpdateFormValues ¶ added in v0.0.3
func (d *DateTextbox) ΩUpdateFormValues(ctx *page.Context)
type DateTextboxCreator ¶ added in v0.2.0
type DateTextboxCreator struct { // ID is the control id of the html widget and must be unique to the page ID string // Placeholder is the placeholder attribute of the textbox and shows as help text inside the field Placeholder string // Type is the type attribute of the textbox Type string // MinLength is the minimum number of characters that the user is required to enter. If the // length is less than this number, a validation error will be shown. MinLength int // MaxLength is the maximum number of characters that the user is required to enter. If the // length is more than this number, a validation error will be shown. MaxLength int // ColumnCount is the number of characters wide the textbox will be, and becomes the width attribute in the tag. // The actual width is browser dependent. For better control, use a width style property. ColumnCount int // ReadOnly sets the readonly attribute of the textbox, which prevents it from being changed by the user. ReadOnly bool // SaveState will save the text in the textbox, to be restored if the user comes back to the page. // It is particularly helpful when the textbox is being used to filter the results of a query, so that // when the user comes back to the page, he does not have to type the filter text again. SaveState bool // Text is the initial value of the textbox. Often its best to load the value in a separate Load step after creating the control. Text string // Format is the time.format string to use to decode the text into a date. Format string page.ControlOptions }
Use DateTextboxCreator to create an email textbox. Pass it to AddControls of a control, or as a Child of a FormFieldWrapper.
func (DateTextboxCreator) Init ¶ added in v0.2.0
func (c DateTextboxCreator) Init(ctx context.Context, ctrl DateTextboxI)
type DateTextboxI ¶ added in v0.2.0
type DateTextboxI interface { TextboxI SetFormat(format string) DateTextboxI }
type DateTimeSpan ¶
type DateTimeSpan struct { Span // contains filtered or unexported fields }
DateTimeSpan is a span that displays a datetime value as static text. This is a typical default control to use for a timestamp in the database.
func NewDateTimeSpan ¶
func NewDateTimeSpan(parent page.ControlI, id string) *DateTimeSpan
NewDateTimeSpan create a new DateTimeSpan.
func (*DateTimeSpan) Init ¶
Init is called by subclasses to initialize the parent. You do not normally need to call this.
func (*DateTimeSpan) SetDateTime ¶
func (s *DateTimeSpan) SetDateTime(d datetime.DateTime)
SetDateTime sets the value to a datetime.DateTime.
func (*DateTimeSpan) SetFormat ¶
func (s *DateTimeSpan) SetFormat(format string) *DateTimeSpan
SetFormat sets the format string. This should be a time.TimeFormat string described at https://golang.org/pkg/time/#Time.Format
func (*DateTimeSpan) SetValue ¶
func (s *DateTimeSpan) SetValue(v interface{})
SetValue sets the value display. You can set the value to a datetime.DateTime, a time.Time, or a string that can be parsed by the format string.
func (*DateTimeSpan) Value ¶
func (s *DateTimeSpan) Value() datetime.DateTime
Value returns the value as a datetime.DateTime object.
func (*DateTimeSpan) ΩDrawInnerHtml ¶ added in v0.0.3
ΩDrawInnerHtml is called by the framework to draw the inner html of the span.
type DateTimeSpanCreator ¶ added in v0.2.0
type DateValidator ¶
type DateValidator struct { Message string // contains filtered or unexported fields }
type Dialog ¶
type Dialog struct { Panel // contains filtered or unexported fields }
Our own implementation of a dialog. This works cooperatively with javascript in goradd.js to create a minimal implementation of the dialog interface.
func (*Dialog) Action ¶
func (d *Dialog) Action(ctx context.Context, a page.ActionParams)
Action is called by the framework and will respond to the DialogClose action sent by any close buttons on the page to close the dialog. You do not normally need to call this.
func (*Dialog) AddButton ¶
func (d *Dialog) AddButton( label string, id string, options *DialogButtonOptions, )
AddButton adds the given button to the dialog. The first button added is the default button that gets submitted when an enter key is pressed in a textbox.
func (*Dialog) AddCloseButton ¶
AddCloseButton adds a button to the list of buttons with the given label, but this button will trigger the DialogCloseEvent instead of the DialogButtonEvent. The button will also close the dialog.
func (*Dialog) DrawTemplate ¶
func (*Dialog) RemoveAllButtons ¶
func (d *Dialog) RemoveAllButtons()
RemoveAllButtons removes all the buttons from the dialog
func (*Dialog) RemoveButton ¶
RemoveButton removes the given button from the dialog
func (*Dialog) SetButtonStyles ¶
SetButtonStyle sets css styles on a button that is already in the dialog
func (*Dialog) SetButtonVisible ¶
SetButtonVisible sets the visible state of the button. Hidden buttons are still rendered, but are styled so that they are not shown.
func (*Dialog) SetDialogStyle ¶ added in v0.0.3
func (d *Dialog) SetDialogStyle(s DialogStyle)
SetDialogStyle sets the style of the dialog.
func (*Dialog) SetHasCloseBox ¶ added in v0.0.3
SetHasCloseBox adds a close box so that the dialog can be closed in a way that is independent of buttons. Often this is an X button in the upper right corner of the dialog.
func (*Dialog) ΩDrawingAttributes ¶ added in v0.0.3
func (d *Dialog) ΩDrawingAttributes() html.Attributes
ΩDrawingAttributes is called by the framework to set temporary attributes just before drawing.
type DialogButtonOptions ¶
type DialogButtonOptions struct { // Validates indicates that this button will validate the dialog Validates bool // The ConfirmationMessage string will appear with a yes/no box making sure the user wants the action. // This is usually used when the action could be destructive, like a Delete button. ConfirmationMessage string // PushLeft pushes this button to the left side of the dialog. Buttons are typically aligned right. // This is helpful to separate particular buttons from the main grouping of buttons. PushLeft bool // IsClose will set the button up to automatically close the dialog. Detect closes with the DialogCloseEvent if needed. // The button will not send a DialogButton event. IsClose bool // Options are additional options specific to the dialog implementation you are using. Options map[string]interface{} }
DialogButtonOptions are optional additional items you can add to a dialog button.
type DialogI ¶
type DialogI interface { PanelI SetTitle(string) SetDialogStyle(state DialogStyle) Open() Close() }
DialogI defines the publicly consumable api that the goradd framework uses to interact with a dialog.
More and more CSS and javascript frameworks are coming out with their own forms of dialog, which is usually a combination of html, css and a javascript widget. goradd has many ways of potentially interacting with dialogs, but to be able to inject a dialog into the framework, we need a consistent interface for all to use.
This particular interface has been implemented in a simple default dialog and Bootstrap dialogs. As more needs arise, we can modify the interface to accommodate as many frameworks as possible.
Dialog implementations should descend from the Panel control. Dialogs should be able to be a member of a form or control object and appear with an Open call, but they should also be able to be instantiated on the fly. The framework has hooks for both, and if you are creating a dialog implementation, see the current Bootstrap implementation for more direction. Feel free to implement more than just the functions listed. These are the minimal set to allow goradd to use a dialog implementation. When possible, implementations should use the same function signatures found here to do the same work. For example, SetHasCloseBox is defined here, and in the Bootstrap Modal implementation with the same function signature, and other implementations should attempt to do the same, but it is not enforced by an interface.
func Alert ¶
Alert is used by the framework to create an alert type message dialog.
If you specify no buttons, a close box in the corner will be created that will just close the dialog. If you specify just a string in buttons, or just one string as a slice of strings, one button will be shown that will just close the message.
If you specify more than one button, the first button will be the default button (the one pressed if the user presses the return key). In this case, you will need to detect the button by adding a On(event.DialogButton(), action) to the dialog returned. You will also be responsible for calling "Close()" on the dialog after detecting a button in this case.
Call SetAlertFunction to register a different alert function for the framework to use.
type DialogStyle ¶ added in v0.0.3
type DialogStyle int
DialogStyle represents the style of the dialog, whether its a plain dialog (the default), or whether it should display additional indicators showing that its indicating an error, warning, information, or success. Not all css frameworks support all of these styles.
const ( DialogStyleDefault DialogStyle = iota DialogStyleError DialogStyleWarning DialogStyleInfo DialogStyleSuccess )
type EmailTextbox ¶
type EmailTextbox struct { Textbox // contains filtered or unexported fields }
EmailTextbox is a Textbox control that validates for email addresses. EmailTextbox can accept multiple addresses separated by commas, and can accept any address in RFC5322 format (Barry Gibbs <bg@example.com>) making it useful for people copying addresses out of an email client and pasting into the field.
func GetEmailTextbox ¶ added in v0.2.0
func GetEmailTextbox(c page.ControlI, id string) *EmailTextbox
GetEmailTextbox is a convenience method to return the control with the given id from the page.
func NewEmailTextbox ¶
func NewEmailTextbox(parent page.ControlI, id string) *EmailTextbox
NewEmailTextbox creates a new textbox that validates its input as an email address. multi will allow the textbox to accept multiple email addresses separated by a comma.
func (*EmailTextbox) Addresses ¶
func (t *EmailTextbox) Addresses() (ret []string)
Addresses returns a slice of the individual addresses entered, stripped of any extra text entered.
func (*EmailTextbox) Init ¶
func (t *EmailTextbox) Init(self TextboxI, parent page.ControlI, id string)
func (*EmailTextbox) SetMaxItemCount ¶ added in v0.2.0
func (t *EmailTextbox) SetMaxItemCount(max int) EmailTextboxI
func (*EmailTextbox) ΩUpdateFormValues ¶ added in v0.0.3
func (t *EmailTextbox) ΩUpdateFormValues(ctx *page.Context)
type EmailTextboxCreator ¶ added in v0.2.0
type EmailTextboxCreator struct { // ID is the control id of the html widget and must be unique to the page ID string // Placeholder is the placeholder attribute of the textbox and shows as help text inside the field Placeholder string // Type is the type attribute of the textbox Type string // MinLength is the minimum number of characters that the user is required to enter. If the // length is less than this number, a validation error will be shown. MinLength int // MaxLength is the maximum number of characters that the user is required to enter. If the // length is more than this number, a validation error will be shown. MaxLength int // ColumnCount is the number of characters wide the textbox will be, and becomes the width attribute in the tag. // The actual width is browser dependent. For better control, use a width style property. ColumnCount int // ReadOnly sets the readonly attribute of the textbox, which prevents it from being changed by the user. ReadOnly bool // SaveState will save the text in the textbox, to be restored if the user comes back to the page. // It is particularly helpful when the textbox is being used to filter the results of a query, so that // when the user comes back to the page, he does not have to type the filter text again. SaveState bool // Text is the initial value of the textbox. Often its best to load the value in a separate Load step after creating the control. Text string // MaxItemCount is the maximum number of email addresses allowed to be entered, separated by commas // By default it allows only 1. MaxItemCount int page.ControlOptions }
Use EmailTextboxCreator to create an email textbox. Pass it to AddControls of a control, or as a Child of a FormFieldWrapper.
func (EmailTextboxCreator) Init ¶ added in v0.2.0
func (c EmailTextboxCreator) Init(ctx context.Context, ctrl EmailTextboxI)
type EmailTextboxI ¶ added in v0.2.0
type EmailTextboxI interface { TextboxI SetMaxItemCount(count int) EmailTextboxI }
type Fieldset ¶
type Fieldset struct {
Panel
}
Fieldset is a Panel that is drawn with a fieldset tag. The panel's text is used as the legend tag. Fieldset's cannot have wrappers.
func GetFieldset ¶ added in v0.2.0
GetFieldset is a convenience method to return the panel with the given id from the page.
func NewFieldset ¶
NewFieldset creates a new Fieldset.
func (*Fieldset) ΩDrawingAttributes ¶ added in v0.0.3
func (c *Fieldset) ΩDrawingAttributes() html.Attributes
ΩDrawingAttributes is called by the framework.
type FieldsetCreator ¶ added in v0.2.0
type FieldsetCreator struct { // ID is the id the tag will have on the page and must be unique on the page ID string // Legend is the text to use in the legend tag of the fieldset Legend string // Children are the child creators declaring the controls wrapped by the fieldset Children []page.Creator page.ControlOptions }
FieldsetCreator declares a Fieldset control. Pass it to AddControls or as a child of other creators.
type FloatLimit ¶ added in v0.2.0
type FloatTextbox ¶
type FloatTextbox struct {
Textbox
}
FloatTextbox is a text control that ensures a valid floating point number is entered in the field.
func GetFloatTextbox ¶ added in v0.2.0
func GetFloatTextbox(c page.ControlI, id string) *FloatTextbox
GetFloatTextbox is a convenience method to return the control with the given id from the page.
func NewFloatTextbox ¶
func NewFloatTextbox(parent page.ControlI, id string) *FloatTextbox
func (*FloatTextbox) Float32 ¶
func (t *FloatTextbox) Float32() float32
func (*FloatTextbox) Float64 ¶
func (t *FloatTextbox) Float64() float64
func (*FloatTextbox) Init ¶
func (t *FloatTextbox) Init(self TextboxI, parent page.ControlI, id string)
func (*FloatTextbox) SetFloat32 ¶
func (t *FloatTextbox) SetFloat32(v float32) *FloatTextbox
func (*FloatTextbox) SetFloat64 ¶
func (t *FloatTextbox) SetFloat64(v float64) *FloatTextbox
func (*FloatTextbox) SetMaxValue ¶
func (t *FloatTextbox) SetMaxValue(maxValue float64, invalidMessage string) FloatTextboxI
func (*FloatTextbox) SetMinValue ¶
func (t *FloatTextbox) SetMinValue(minValue float64, invalidMessage string) FloatTextboxI
func (*FloatTextbox) SetValue ¶ added in v0.2.0
func (t *FloatTextbox) SetValue(v interface{}) page.ControlI
func (*FloatTextbox) Value ¶
func (t *FloatTextbox) Value() interface{}
type FloatTextboxCreator ¶ added in v0.2.0
type FloatTextboxCreator struct { // ID is the control id of the html widget and must be unique to the page ID string // Placeholder is the placeholder attribute of the textbox and shows as help text inside the field Placeholder string // Type is the type attribute of the textbox Type string // MinLength is the minimum number of characters that the user is required to enter. If the // length is less than this number, a validation error will be shown. MinLength int // MaxLength is the maximum number of characters that the user is required to enter. If the // length is more than this number, a validation error will be shown. MaxLength int // ColumnCount is the number of characters wide the textbox will be, and becomes the width attribute in the tag. // The actual width is browser dependent. For better control, use a width style property. ColumnCount int // RowCount creates a multi-line textarea with the given number of rows. By default the // textbox will expand vertically by this number of lines. Use a height style property for // better control of the height of a textbox. RowCount int // ReadOnly sets the readonly attribute of the textbox, which prevents it from being changed by the user. ReadOnly bool // SaveState will save the text in the textbox, to be restored if the user comes back to the page. // It is particularly helpful when the textbox is being used to filter the results of a query, so that // when the user comes back to the page, he does not have to type the filter text again. SaveState bool // MinValue is the minimum value the user can enter. If the user does not // enter at least this amount, or enters something that is not an integer, it will fail validation // and the FormFieldWrapper will show an error. MinValue *FloatLimit // MaxValue is the maximum value the user can enter. If the user enter more // than this amount, or enters something that is not an integer, it will fail validation // and the FormFieldWrapper will show an error. MaxValue *FloatLimit // Value is the initial value of the textbox. Often its best to load the value in a separate Load step after creating the control. Value interface{} page.ControlOptions }
Use FloatTextboxCreator to create a textbox that only accepts numbers. Pass it to AddControls of a control, or as a Child of a FormFieldWrapper.
func (FloatTextboxCreator) Create ¶ added in v0.2.0
Create is called by the framework to create a new control from the Creator. You do not normally need to call this.
func (FloatTextboxCreator) Init ¶ added in v0.2.0
func (c FloatTextboxCreator) Init(ctx context.Context, ctrl FloatTextboxI)
Init is called by implementations of Textboxes to initialize a control with the creator. You do not normally need to call this.
type FloatTextboxI ¶ added in v0.2.0
type FloatTextboxI interface { TextboxI SetMinValue(minValue float64, invalidMessage string) FloatTextboxI SetMaxValue(maxValue float64, invalidMessage string) FloatTextboxI }
type FloatValidator ¶
type FloatValidator struct {
Message string
}
type FormBase ¶
The FormBase is the control that all Form objects should include, and is the master container for all other goradd controls.
func NewMockForm ¶ added in v0.0.3
func NewMockForm() *FormBase
NewMockForm creates a form that should be used as a parent of a control when unit testing the control.
type FormFieldWrapper ¶ added in v0.2.0
type FormFieldWrapper struct { page.Control // subtag is the tag to use for instructions and error Subtag string // contains filtered or unexported fields }
FormFieldWrapper is a Goradd control that wraps other controls, and provides common companion functionality like a form label, validation state display, and help text.
func GetFormFieldWrapper ¶ added in v0.2.0
func GetFormFieldWrapper(c page.ControlI, id string) *FormFieldWrapper
GetFormFieldWrapper is a convenience method to return the form field with the given id from the page.
func NewFormField ¶ added in v0.2.0
func NewFormField(parent page.ControlI, id string) *FormFieldWrapper
func (*FormFieldWrapper) ErrorAttributes ¶ added in v0.2.0
func (c *FormFieldWrapper) ErrorAttributes() html.Attributes
func (*FormFieldWrapper) For ¶ added in v0.2.0
func (c *FormFieldWrapper) For() string
func (*FormFieldWrapper) Init ¶ added in v0.2.0
func (c *FormFieldWrapper) Init(self PanelI, parent page.ControlI, id string)
func (*FormFieldWrapper) InstructionAttributes ¶ added in v0.2.0
func (c *FormFieldWrapper) InstructionAttributes() html.Attributes
func (*FormFieldWrapper) Instructions ¶ added in v0.2.0
func (c *FormFieldWrapper) Instructions() string
Instructions returns the instructions to be printed with the control
func (*FormFieldWrapper) LabelAttributes ¶ added in v0.2.0
func (c *FormFieldWrapper) LabelAttributes() html.Attributes
func (*FormFieldWrapper) SetErrorAttributes ¶ added in v0.2.0
func (c *FormFieldWrapper) SetErrorAttributes(a html.Attributes) FormFieldWrapperI
func (*FormFieldWrapper) SetFor ¶ added in v0.2.0
func (c *FormFieldWrapper) SetFor(relatedId string) FormFieldWrapperI
SetFor associates the form field with a sub control. The relatedId is the ID that the form field is associated with. Most browsers allow you to click on the label in order to give focus to the related control
func (*FormFieldWrapper) SetInstructionAttributes ¶ added in v0.2.0
func (c *FormFieldWrapper) SetInstructionAttributes(a html.Attributes) FormFieldWrapperI
func (*FormFieldWrapper) SetInstructions ¶ added in v0.2.0
func (c *FormFieldWrapper) SetInstructions(i string) FormFieldWrapperI
SetInstructions sets the instructions that will be printed with the control. Instructions only get rendered by wrappers, so if there is no wrapper, or the wrapper does not render the instructions, this will not appear.
func (*FormFieldWrapper) SetLabelAttributes ¶ added in v0.2.0
func (c *FormFieldWrapper) SetLabelAttributes(a html.Attributes) FormFieldWrapperI
func (*FormFieldWrapper) Validate ¶ added in v0.2.0
func (c *FormFieldWrapper) Validate(ctx context.Context) bool
func (*FormFieldWrapper) ΩDrawTag ¶ added in v0.2.0
func (c *FormFieldWrapper) ΩDrawTag(ctx context.Context) string
func (*FormFieldWrapper) ΩDrawingAttributes ¶ added in v0.2.0
func (c *FormFieldWrapper) ΩDrawingAttributes() html.Attributes
type FormFieldWrapperCreator ¶ added in v0.2.0
type FormFieldWrapperCreator struct { // ID is the optional control id on the html form. If you do not specify this, it // will create on for you that is the ID of the child control + "-ff" ID string // Label is the text that will be in the html label tag associated with the Child control. Label string // Child is the creator of the child control you want to wrap Child page.Creator // Instructions is help text that will follow the control and that further describes its purpose or use. Instructions string // For specifies the id of the control that the label is for, and that is the control that we are wrapping. // You normally do not need this, as it will simply look at the first child control, but if for some reason // that control is wrapped, you should explicitly sepecify the For control id here. For string // LabelAttributes are additional attributes to add to the label tag. LabelAttributes html.AttributeCreator // ErrorAttributes are additional attributes to add to the tag that displays the error. ErrorAttributes html.AttributeCreator // InstructionAttributes are additional attributes to add to the tag that displays the instructions. InstructionAttributes html.AttributeCreator // Set IsInline to true to use a "span" instead of a "div" in the wrapping tag. IsInline bool // ControlOptions are additional options for the wrapper tag ControlOptions page.ControlOptions }
Use FormFieldWrapperCreator to create a FormFieldWrapper, which wraps a control with a div or span that also has a label, validation error text and optional instructions. Pass the creator of the control you are wrapping as the Child item.
func (FormFieldWrapperCreator) Create ¶ added in v0.2.0
Create is called by the framework to create the control. You do not normally need to call it directly. Instead either pass this creator to AddControls for the parent control you want to add this to, or add this to the Children of the parent control's creator.
func (FormFieldWrapperCreator) Init ¶ added in v0.2.0
func (f FormFieldWrapperCreator) Init(ctx context.Context, c FormFieldWrapperI)
Init is called by implementations of a FormFieldWrapper to initialize the creator. You do not normally need to call this.
type FormFieldWrapperI ¶ added in v0.2.0
type FormFieldWrapperI interface { page.ControlI SetFor(relatedId string) FormFieldWrapperI For() string Instructions() string SetInstructions(string) FormFieldWrapperI LabelAttributes() html.Attributes ErrorAttributes() html.Attributes InstructionAttributes() html.Attributes }
type GridLayoutBuilder ¶ added in v0.0.3
type GridLayoutBuilder struct {
// contains filtered or unexported fields
}
GridLayoutBuilder is a helper that will allow a slice of items to be layed out in a table like pattern. It will compute the number of rows required, and then wrap the rows in row html, and the cells in cell html. You can have the items flow with the rows, or flow across the row axis. You can use this to build a table or a table-like structure.
func (*GridLayoutBuilder) Build ¶ added in v0.0.3
func (g *GridLayoutBuilder) Build() string
func (*GridLayoutBuilder) ColumnCount ¶ added in v0.0.3
func (g *GridLayoutBuilder) ColumnCount(count int) *GridLayoutBuilder
ColumnCount sets the number of columns.
func (*GridLayoutBuilder) Direction ¶ added in v0.0.3
func (g *GridLayoutBuilder) Direction(placement LayoutDirection) *GridLayoutBuilder
LayoutDirection indicates how items are placed, whether they should fill up rows first, or fill up columns.
func (*GridLayoutBuilder) Items ¶ added in v0.0.3
func (g *GridLayoutBuilder) Items(items []string) *GridLayoutBuilder
Items sets the html for each item to display.
func (*GridLayoutBuilder) RowClass ¶ added in v0.0.3
func (g *GridLayoutBuilder) RowClass(t string) *GridLayoutBuilder
func (*GridLayoutBuilder) RowTag ¶ added in v0.0.3
func (g *GridLayoutBuilder) RowTag(t string) *GridLayoutBuilder
type IDSetter ¶
type IDSetter interface {
SetID(id string)
}
IDSetter is an interface for an item that sets an id.
type IdSlice ¶
type IdSlice []string
IdSlice is a slice of string ids, and is used to sort a list of ids that the item list uses.
type Image ¶
Image is an img tag. You can display either a URL, or direct image information by setting the Src or the Data values.
func GetImage ¶ added in v0.2.0
GetImage is a convenience method to return the button with the given id from the page.
func (*Image) SetAlt ¶
SetAlt will set the alt tag. The html standard requires the alt tag. Alt tags are used to display a descirption of an image when the browser cannot display an image, and is very important for assistive technologies.
func (*Image) SetMimeType ¶
Set the MIME type for the data, (jpeg, gif, png, etc.)
func (*Image) ΩDrawingAttributes ¶ added in v0.0.3
func (i *Image) ΩDrawingAttributes() html.Attributes
ΩDrawingAttributes is called by the framework.
type ImageCapture ¶
ImageCapture is a panel that has both an image and button to help you capture images from the user's camera. It is a kind of composite control that exports the image so that you can further manipulate it after creation. It also has javascript to manage the actual image capture process. It does not currently allow the user to upload an image in place of capturing an image from the camera. It only captures images from devices and browsers that support image capture.
func GetImageCapture ¶ added in v0.2.0
func GetImageCapture(c page.ControlI, id string) *ImageCapture
GetImageCapture is a convenience method to return the button with the given id from the page.
func NewImageCapture ¶
func NewImageCapture(parent page.ControlI, id string) *ImageCapture
NewImageCapture creates a new image capture panel.
func (*ImageCapture) Data ¶
func (i *ImageCapture) Data() []byte
func (*ImageCapture) Init ¶
func (i *ImageCapture) Init(self ImageCaptureI, parent page.ControlI, id string)
Init is called by subclasses.
func (*ImageCapture) SetData ¶
func (i *ImageCapture) SetData(data []byte)
SetData sets the binary picture data. The data must be in the mime type format.
func (*ImageCapture) SetMaskShape ¶
func (i *ImageCapture) SetMaskShape(shape ImageCaptureShape)
SetMaskShape sets the masking shape for the image
func (*ImageCapture) SetMimeType ¶
func (i *ImageCapture) SetMimeType(typ string)
func (*ImageCapture) SetPixelSize ¶
func (i *ImageCapture) SetPixelSize(width int, height int)
SetPixelSize sets the pixel size of the image that will be returned. Control the visible size of the canvas through setting css sizes.
func (*ImageCapture) SetQuality ¶
func (i *ImageCapture) SetQuality(quality float32)
SetQuality specifies a number between 0 and 1 used as the quality value for capturing jpegs or webp images.
func (*ImageCapture) SetZoom ¶
func (i *ImageCapture) SetZoom(zoom int)
SetZoom zooms the camera by the given percent, i.e. 50 is 50% closer and 100 would be a 2x zoom.
func (*ImageCapture) TurnOff ¶
func (i *ImageCapture) TurnOff()
TurnOff will turn off the camera and the image displayed in the control
func (*ImageCapture) ΩDrawingAttributes ¶ added in v0.0.3
func (i *ImageCapture) ΩDrawingAttributes() html.Attributes
ΩDrawingAttributes is called by the framework.
func (*ImageCapture) ΩPutCustomScript ¶ added in v0.0.3
func (i *ImageCapture) ΩPutCustomScript(ctx context.Context, response *page.Response)
ΩPutCustomScript is called by the framework.
func (*ImageCapture) ΩUpdateFormValues ¶ added in v0.0.3
func (i *ImageCapture) ΩUpdateFormValues(ctx *page.Context)
ΩUpdateFormValues is called by the framework.
type ImageCaptureCreator ¶ added in v0.2.0
type ImageCaptureCreator struct { // ID is the control id ID string MaskShape ImageCaptureShape MimeType string Zoom int Quality float32 page.ControlOptions }
ImageCaptureCreator is the initialization structure for declarative creation of buttons
type ImageCaptureI ¶
type ImageCaptureShape ¶
type ImageCaptureShape string
const ( ImageCaptureShapeRect ImageCaptureShape = "rect" ImageCaptureShapeCircle ImageCaptureShape = "circle" )
type ImageCreator ¶ added in v0.2.0
type ImageCreator struct { // ID is the control id ID string // Src is the content of the source attribute, usually a url Src string // Alt is the text displayed for screen readers Alt string MimeType string Width int Height int Data []byte page.ControlOptions }
ImageCreator is the initialization structure for declarative creation of buttons
type IntValidator ¶
type IntValidator struct {
Message string
}
type IntegerLimit ¶ added in v0.2.0
type IntegerTextbox ¶
type IntegerTextbox struct { Textbox // contains filtered or unexported fields }
func GetIntegerTextbox ¶ added in v0.2.0
func GetIntegerTextbox(c page.ControlI, id string) *IntegerTextbox
GetIntegerTextbox is a convenience method to return the control with the given id from the page.
func NewIntegerTextbox ¶
func NewIntegerTextbox(parent page.ControlI, id string) *IntegerTextbox
func (*IntegerTextbox) Init ¶
func (t *IntegerTextbox) Init(self TextboxI, parent page.ControlI, id string)
func (*IntegerTextbox) Int ¶
func (t *IntegerTextbox) Int() int
func (*IntegerTextbox) Int64 ¶
func (t *IntegerTextbox) Int64() int64
func (*IntegerTextbox) SetInt ¶
func (t *IntegerTextbox) SetInt(v int) IntegerTextboxI
func (*IntegerTextbox) SetMaxValue ¶
func (t *IntegerTextbox) SetMaxValue(maxValue int, invalidMessage string) IntegerTextboxI
SetMaxValue creates a validator that makes sure the value of the text box is at most the given value. Specify your own error message, or leave the error message blank and a standard error message will be presented if the value is not valid.
func (*IntegerTextbox) SetMinValue ¶
func (t *IntegerTextbox) SetMinValue(minValue int, invalidMessage string) IntegerTextboxI
SetMinValue creates a validator that makes sure the value of the text box is at least the given value. Specify your own error message, or leave the error message blank and a standard error message will be presented if the value is not valid.
func (*IntegerTextbox) SetValue ¶
func (t *IntegerTextbox) SetValue(v interface{}) page.ControlI
func (*IntegerTextbox) Value ¶
func (t *IntegerTextbox) Value() interface{}
type IntegerTextboxCreator ¶ added in v0.2.0
type IntegerTextboxCreator struct { // ID is the control id of the html widget and must be unique to the page ID string // Placeholder is the placeholder attribute of the textbox and shows as help text inside the field Placeholder string // Type is the type attribute of the textbox Type string // MinLength is the minimum number of characters that the user is required to enter. If the // length is less than this number, a validation error will be shown. MinLength int // MaxLength is the maximum number of characters that the user is required to enter. If the // length is more than this number, a validation error will be shown. MaxLength int // ColumnCount is the number of characters wide the textbox will be, and becomes the width attribute in the tag. // The actual width is browser dependent. For better control, use a width style property. ColumnCount int // RowCount creates a multi-line textarea with the given number of rows. By default the // textbox will expand vertically by this number of lines. Use a height style property for // better control of the height of a textbox. RowCount int // ReadOnly sets the readonly attribute of the textbox, which prevents it from being changed by the user. ReadOnly bool // SaveState will save the text in the textbox, to be restored if the user comes back to the page. // It is particularly helpful when the textbox is being used to filter the results of a query, so that // when the user comes back to the page, he does not have to type the filter text again. SaveState bool // MinValue is the minimum value the user can enter. If the user does not // enter at least this amount, or enters something that is not an integer, it will fail validation // and the FormFieldWrapper will show an error. MinValue *IntegerLimit // MaxValue is the maximum value the user can enter. If the user enter more // than this amount, or enters something that is not an integer, it will fail validation // and the FormFieldWrapper will show an error. MaxValue *IntegerLimit // Value is the initial value of the textbox. Often its best to load the value in a separate Load step after creating the control. Value interface{} page.ControlOptions }
Use IntegerTextboxCreator to create an integer textbox. Pass it to AddControls of a control, or as a Child of a FormFieldWrapper.
func (IntegerTextboxCreator) Create ¶ added in v0.2.0
Create is called by the framework to create a new control from the Creator. You do not normally need to call this.
func (IntegerTextboxCreator) Init ¶ added in v0.2.0
func (c IntegerTextboxCreator) Init(ctx context.Context, ctrl IntegerTextboxI)
Init is called by implementations of Textboxes to initialize a control with the creator. You do not normally need to call this.
type IntegerTextboxI ¶ added in v0.2.0
type IntegerTextboxI interface { TextboxI SetMinValue(minValue int, invalidMessage string) IntegerTextboxI SetMaxValue(maxValue int, invalidMessage string) IntegerTextboxI }
type ItemList ¶
type ItemList struct {
// contains filtered or unexported fields
}
ItemList manages a list of ListItemI list items. ItemList is designed to be embedded in another structure, and will turn that object into a manager of list items. ItemList will manage the id's of the items in its list, you do not have control of that, and it needs to manage those ids in order to efficiently manage the selection process.
func NewItemList ¶
NewItemList creates a new item list. "owner" is the object that has the list embedded in it, and must be an IDer.
func (*ItemList) AddItem ¶
AddItem adds the given item to the end of the list. The value is optional, but should only be one or zero values.
func (*ItemList) AddItemAt ¶
AddItemAt adds the item at the given index. If the index is negative, it counts from the end. -1 would therefore put the item before the last item. If the index is bigger or equal to the number of items, it adds it to the end. If the index is zero, or is negative and smaller than the negative value of the number of items, it adds to the beginning. This can be an expensive operation in a long hierarchical list, so use sparingly.
func (*ItemList) AddListItemAt ¶
AddItemAt adds the item at the given index. If the index is negative, it counts from the end. If the index is -1 or bigger than the number of items, it adds it to the end. If the index is zero, or is negative and smaller than the negative value of the number of items, it adds to the beginning. This can be an expensive operation in a long hierarchical list, so use sparingly.
func (*ItemList) AddListItems ¶
func (l *ItemList) AddListItems(items ...interface{})
AddListItems adds one or more objects to the end of the list. items should be a list of ListItemI, ItemLister, ItemIDer, Labeler or Stringer types. This function can accept one or more lists of items, or single items
func (*ItemList) GetItem ¶
GetItem recursively searches for and returns the item corresponding to the given id. Since we are managing the id numbers, we can efficiently find the item. Note that if you add items to the list, the ids may change.
func (*ItemList) GetItemByValue ¶
GetItemByValue recursively searches the list to find the item with the given value. It starts with the current list, and if not found, will search in sublists.
func (*ItemList) Len ¶
Len returns the length of the item list at the current level. In other words, it does not count items in sublists.
func (*ItemList) ListItems ¶
ListItems returns a slice of the ListItemI items, in the order they were added or arranged.
func (*ItemList) RemoveItemAt ¶ added in v0.0.3
RemoveItemAt removes an item at the given index.
type ItemListI ¶
type ItemListI interface { AddItem(label string, value ...interface{}) ListItemI AddItemAt(index int, label string, value ...interface{}) AddListItemAt(index int, item ListItemI) AddListItems(items ...interface{}) GetItemAt(index int) ListItemI ListItems() []ListItemI Clear() RemoveItemAt(index int) Len() int GetItem(id string) (foundItem ListItemI) GetItemByValue(value interface{}) (id string, foundItem ListItemI) // contains filtered or unexported methods }
ItemListI is the interface for all controls that display a list of ListItems.
type ItemLister ¶
type ItemLister interface { Value() interface{} Label() string }
type LayoutDirection ¶ added in v0.0.4
type LayoutDirection int
LayoutDirection controls whether items are layed out in rows or columns.
const ( // LayoutRow lays out items in rows LayoutRow LayoutDirection = iota // LayoutColumn lays out items in columns, computing the number of rows required to make the specified number of columns. LayoutColumn )
type ListItem ¶
type ListItem struct { ItemList // contains filtered or unexported fields }
A ListItem is an object that is a member of a list. HTML has a few different kinds of lists, and this can be a member of a select list (<select>), or an ordered or unordered list (<ul> or <ol>). It is up to the manager of the list to render the item, but this serves as a place to store options about the item. Not all options are pertinent to all lists.
A list item generally has a value, and a label. Often, lists will have ids too, that will appear in the html output, but the id values are managed by the list manager and generally should not be set by you. In situations where the user selects a list item, you would use the id to retrieve the ListItem selected.
func NewItemFromItemIDer ¶
NewItemFromItemIDer creates a new item from any object that has an ID and String method. Note that the ID() of the ItemIDer will become the value of the select item, and the String() will become the label
func NewItemFromItemLister ¶
func NewItemFromItemLister(i ItemLister) *ListItem
NewItemFromItemLister creates a new item from any object that has a Value and Label method.
func NewItemFromLabeler ¶
NewItemFromLabeler creates a new item from any object that has just a Label method.
func NewItemFromStringer ¶
NewItemFromStringer creates a new item from any object that has just a String method. The label and value will be the same.
func NewListItem ¶
NewListItem creates a new item for a list. Specify an empty value for an item that represents no selection.
func (*ListItem) AnchorAttributes ¶
func (i *ListItem) AnchorAttributes() html.Attributes
func (*ListItem) Attributes ¶
func (i *ListItem) Attributes() html.Attributes
Attributes returns a pointer to the attributes of the item for customization. You can directly set the attributes on the returned object.
func (*ListItem) HasChildItems ¶
func (*ListItem) IsEmptyValue ¶ added in v0.0.3
IsEmptyValue returns true if the value is empty, meaning it does not satisfy a selection being made if the list has IsRequired turned on.
func (*ListItem) RenderLabel ¶
func (*ListItem) SetDisabled ¶
func (*ListItem) SetID ¶
SetID should not be called by your code typically. It is exported for implementations of item lists. The IDs of an item list are completely managed by the list, you cannot have custom ids.
func (*ListItem) SetIsDivider ¶
func (*ListItem) SetShouldEscapeLabel ¶
func (*ListItem) StringValue ¶
type ListItemI ¶
type ListItemI interface { ItemListI Value() interface{} ID() string SetID(string) Label() string SetLabel(string) SetDisabled(bool) Disabled() bool SetIsDivider(bool) IsDivider() bool IntValue() int StringValue() string HasChildItems() bool Attributes() html.Attributes Anchor() string SetAnchor(string) AnchorAttributes() html.Attributes RenderLabel() string IsEmptyValue() bool }
ListItemI is the interface for list items in one of the various list controls that embed the ItemList structure. It is generally used by implementations of list controls.
type ListValue ¶ added in v0.0.3
type ListValue struct { L string // V is the value V interface{} }
ListValue is a helper for initializing a control based on ItemList. It satisfies the ItemLister interface. To use it, create a slice of ListValue's and pass the list to AddListItems or SetData.
type MaxFloatValidator ¶
type MaxIntValidator ¶
type MaxLengthValidator ¶
MaxLengthValidator is a Validater to test that the user did not enter too many characters.
type MinFloatValidator ¶
type MinIntValidator ¶
type MinLengthValidator ¶
MinLenghtValidator is a validator that checks that the user has entered a minimum length. It is set up automatically by calling SetMinValue.
type MultiselectList ¶
type MultiselectList struct { page.Control ItemList data.DataManager // contains filtered or unexported fields }
MultiselectList is a generic list box which allows multiple selections. It is here for completeness, but is not used very often since it doesn't present an intuitive interface and is very browser dependent on what is presented. A CheckboxList is better.
func GetMultiselectList ¶ added in v0.2.0
func GetMultiselectList(c page.ControlI, id string) *MultiselectList
GetSelectList is a convenience method to return the control with the given id from the page.
func NewMultiselectList ¶
func NewMultiselectList(parent page.ControlI, id string) *MultiselectList
func (*MultiselectList) Init ¶
func (l *MultiselectList) Init(self MultiselectListI, parent page.ControlI, id string)
func (*MultiselectList) IsIdSelected ¶
func (l *MultiselectList) IsIdSelected(id string) bool
func (*MultiselectList) SelectedIds ¶
func (l *MultiselectList) SelectedIds() []string
SelectedIds returns a list of ids sorted by id number that correspond to the selection
func (*MultiselectList) SelectedItems ¶
func (l *MultiselectList) SelectedItems() []ListItemI
func (*MultiselectList) SelectedLabels ¶
func (l *MultiselectList) SelectedLabels() []string
func (*MultiselectList) SelectedValues ¶
func (l *MultiselectList) SelectedValues() []interface{}
func (*MultiselectList) SetData ¶ added in v0.2.0
func (l *MultiselectList) SetData(data interface{})
SetData overrides the default data setter to add objects to the item list. The result is kept in memory currently. ItemLister, ItemIDer, Labeler or Stringer types. This function can accept one or more lists of items, or single items.
func (*MultiselectList) SetSelectedIdNoRefresh ¶ added in v0.0.3
func (l *MultiselectList) SetSelectedIdNoRefresh(id string, value bool)
func (*MultiselectList) SetSelectedIds ¶
func (l *MultiselectList) SetSelectedIds(ids []string)
SetSelectedIds sets the current selection to the given ids. You must ensure that the items with the ids exist, it will not attempt to make sure the items exist.
func (*MultiselectList) SetSelectedIdsNoRefresh ¶
func (l *MultiselectList) SetSelectedIdsNoRefresh(ids []string)
func (*MultiselectList) SetSize ¶
func (l *MultiselectList) SetSize(size int) MultiselectListI
func (*MultiselectList) SetValue ¶
func (l *MultiselectList) SetValue(v interface{})
SetValue implements the Valuer interface for general purpose value getting and setting
func (*MultiselectList) Size ¶
func (l *MultiselectList) Size() int
func (*MultiselectList) Value ¶
func (l *MultiselectList) Value() interface{}
Value implements the Valuer interface for general purpose value getting and setting
func (*MultiselectList) ΩDrawInnerHtml ¶ added in v0.0.3
func (*MultiselectList) ΩDrawingAttributes ¶ added in v0.0.3
func (l *MultiselectList) ΩDrawingAttributes() html.Attributes
ΩDrawingAttributes retrieves the tag's attributes at draw time. You should not normally need to call this, and the attributes are disposed of after drawing, so they are essentially read-only.
func (*MultiselectList) ΩMarshalState ¶ added in v0.0.3
func (l *MultiselectList) ΩMarshalState(m maps.Setter)
ΩMarshalState is an internal function to save the state of the control
func (*MultiselectList) ΩUnmarshalState ¶ added in v0.0.3
func (l *MultiselectList) ΩUnmarshalState(m maps.Loader)
ΩUnmarshalState is an internal function to restore the state of the control
func (*MultiselectList) ΩUpdateFormValues ¶ added in v0.0.3
func (l *MultiselectList) ΩUpdateFormValues(ctx *page.Context)
ΩUpdateFormValues is an internal function that lets us reflect the value of the selection on the web override
type MultiselectListCreator ¶ added in v0.2.0
type MultiselectListCreator struct { ID string // Items is a static list of labels and values that will be in the list. Or, use a DataProvider to dynamically generate the items. Items []ListValue // DataProvider is the control that will dynamically provide the data for the list and that implements the DataBinder interface. DataProvider data.DataBinder // DataProviderID is the id of a control that will dynamically provide the data for the list and that implements the DataBinder interface. DataProviderID string // Size specifies how many items to show, and turns the list into a scrolling list Size int // SaveState saves the selected value so that it is restored if the form is returned to. SaveState bool page.ControlOptions }
type MultiselectListI ¶
type MultiselectListI interface { page.ControlI ItemListI data.DataManagerEmbedder }
type OrderedList ¶
type OrderedList struct {
UnorderedList
}
OrderedList is a dynamically generated html ordered list (ol). Such lists are often used as the basis for javascript and css widgets. If you use a data provider to set the data, you should call AddItems to the list in your LoadData function.
func GetOrderedList ¶ added in v0.2.0
func GetOrderedList(c page.ControlI, id string) *OrderedList
GetOrderedList is a convenience method to return the control with the given id from the page.
func NewOrderedList ¶
func NewOrderedList(parent page.ControlI, id string) *OrderedList
NewOrderedList creates a new ordered list (ol tag).
func (*OrderedList) NumberType ¶
func (l *OrderedList) NumberType() string
NumberType returns the string used for the type attribute.
func (*OrderedList) SetNumberType ¶
func (l *OrderedList) SetNumberType(t string) OrderedListI
SetNumberType sets the top level number style for the list. Choose from the OrderedListNumberType* constants. To set a number type for a sublevel, set the "type" attribute on the list item that is the parent of the sub list.
func (*OrderedList) SetStart ¶
func (l *OrderedList) SetStart(start int) OrderedListI
SetStart sets the starting number for the numbers in the top level list. To set the start of a sub-list, set the "start" attribute on the list item that is the parent of the sub-list.
func (*OrderedList) ΩDrawInnerHtml ¶ added in v0.0.3
type OrderedListCreator ¶ added in v0.2.0
type OrderedListCreator struct { ID string // Items is a static list of labels and values that will be in the list. Or, use a DataProvider to dynamically generate the items. Items []ListValue // DataProvider is the control that will dynamically provide the data for the list and that implements the DataBinder interface. DataProvider data.DataBinder // DataProviderID is the id of a control that will dynamically provide the data for the list and that implements the DataBinder interface. DataProviderID string // NumberType is the type attribute and defaults to OrderedListNumberTypeNumber. NumberType string // StartAt sets the number to start counting from. The default is 1. StartAt int page.ControlOptions }
func (OrderedListCreator) Create ¶ added in v0.2.0
Create is called by the framework to create a new control from the Creator. You do not normally need to call this.
func (OrderedListCreator) Init ¶ added in v0.2.0
func (c OrderedListCreator) Init(ctx context.Context, ctrl OrderedListI)
type OrderedListI ¶ added in v0.2.0
type OrderedListI interface { UnorderedListI SetNumberType(t string) OrderedListI SetStart(start int) OrderedListI }
type PagedControl ¶ added in v0.2.0
type PagedControl struct {
// contains filtered or unexported fields
}
PagedControl is a mixin that makes a Control controllable by a data pager
func (*PagedControl) AddDataPager ¶ added in v0.2.0
func (c *PagedControl) AddDataPager(d DataPagerI)
AddDataPager adds a data pager to the PagedControl. A PagedControl can have multiple data pagers.
func (*PagedControl) CalcPageCount ¶ added in v0.2.0
func (c *PagedControl) CalcPageCount() int
CalcPageCount will return the number of pages based on the page size and total items.
func (*PagedControl) GetDataPagerIDs ¶ added in v0.2.0
func (c *PagedControl) GetDataPagerIDs() []string
func (*PagedControl) HasDataPagers ¶ added in v0.2.0
func (c *PagedControl) HasDataPagers() bool
func (*PagedControl) PageNum ¶ added in v0.2.0
func (c *PagedControl) PageNum() int
PageNum returns the current page number.
func (*PagedControl) PageSize ¶ added in v0.2.0
func (c *PagedControl) PageSize() int
PageSize returns the maximum number of items that will be allowed in a page.
func (*PagedControl) SetPageNum ¶ added in v0.2.0
func (c *PagedControl) SetPageNum(n int)
SetPageNum sets the current page number. It does not redraw anything, nor does it determine if the page is actually visible.
func (*PagedControl) SetPageSize ¶ added in v0.2.0
func (c *PagedControl) SetPageSize(size int)
SetPageSize sets the maximum number of items that will be displayed at one time. If more than this number of items is being displayed, the pager will allow paging to other items.
func (*PagedControl) SetTotalItems ¶ added in v0.2.0
func (c *PagedControl) SetTotalItems(count uint)
SetTotalItems sets the total number of items that the paginator keeps track of. This will be divided by the PageSize to determine the number of pages presented. You must call this each time the data size might change.
func (*PagedControl) SliceOffsets ¶ added in v0.2.0
func (c *PagedControl) SliceOffsets() (start, end int)
SliceOffsets returns the start and end values to use to specify a portion of a slice corresponding to the data the pager refers to
func (*PagedControl) SqlLimits ¶ added in v0.2.0
func (c *PagedControl) SqlLimits() (maxRowCount, offset int)
SqlLimits returns the limits you would use in a sql database limit clause
func (*PagedControl) TotalItems ¶ added in v0.2.0
func (c *PagedControl) TotalItems() int
TotalItems returns the number of items that the paginator is aware of in the list it is managing.
type PagedControlI ¶ added in v0.2.0
type PagedControlI interface { data.DataManagerI SetTotalItems(uint) TotalItems() int SetPageSize(size int) PageSize() int PageNum() int SetPageNum(n int) AddDataPager(DataPagerI) CalcPageCount() int HasDataPagers() bool GetDataPagerIDs() []string SliceOffsets() (start, end int) }
PagedControlI is the interface that paged controls must implement
type PagedTable ¶ added in v0.2.0
type PagedTable struct { Table PagedControl }
func GetPagedTable ¶ added in v0.2.0
func GetPagedTable(c page.ControlI, id string) *PagedTable
GetPagedTable is a convenience method to return the table with the given id from the page.
func NewPagedTable ¶ added in v0.2.0
func NewPagedTable(parent page.ControlI, id string) *PagedTable
type PagedTableCreator ¶ added in v0.2.0
type PagedTableCreator struct { // ID is the control id ID string // HasColTags will make the table render <col> tags HasColTags bool // Caption is the content of the caption tag, and can either be a string, or a data pager Caption interface{} // HideIfEmpty will hide the table completely if it has no data. Otherwise, the table and headers will be shown, but no data rows HideIfEmpty bool // HeaderRowCount is the number of header rows. You must set this to at least 1 to show header rows. HeaderRowCount int FooterRowCount int // RowStyler returns the attributes to be used in a cell. RowStyler TableRowAttributer // RowStylerID is a control id for the control that will be the RowStyler of the table. RowStylerID string // HeaderRowStyler returns the attributes to be used in a header cell. HeaderRowStyler TableHeaderRowAttributer // HeaderRowStylerID is a control id for the control that will be the HeaderRowStyler of the table. HeaderRowStylerID string FooterRowStyler TableFooterRowAttributer FooterRowStylerID string // Columns are the column creators that will add columns to the table Columns []ColumnCreator // DataProvider is the data binder for the table. It can be either a control id or a DataBinder DataProvider data.DataBinder // DataProviderID is the control id of the data binder for the table. DataProviderID string // Data is the actual data for the table, and should be a slice of objects Data interface{} // Sortable will make the table sortable Sortable bool // SortHistoryLimit will set how many columns deep we will remember the sorting for multi-level sorts SortHistoryLimit int page.ControlOptions // PageSize is the number of rows to include in a page PageSize int // SaveState will cause the table to remember what page it was on SaveState bool }
PagedTableCreator creates a table that can be paged
func (PagedTableCreator) Create ¶ added in v0.2.0
Create is called by the framework to create a new control from the Creator. You do not normally need to call this.
func (PagedTableCreator) Init ¶ added in v0.2.0
func (c PagedTableCreator) Init(ctx context.Context, ctrl PagedTableI)
Init is called by implementations of Buttons to initialize a control with the creator. You do not normally need to call this.
type PagedTableI ¶ added in v0.2.0
type PagedTableI interface { TableEmbedder PagedControlI }
type Panel ¶
Panel is a Goradd control that is a basic "div" wrapper. Use it to style and listen to events on a div. It can also be used as the basis for more advanced javascript controls.
func GetPanel ¶ added in v0.2.0
GetPanel is a convenience method to return the panel with the given id from the page.
func (*Panel) SetValue ¶ added in v0.2.0
SetValue satisfies the Valuer interface and sets the text of the panel.
func (*Panel) Value ¶
func (c *Panel) Value() interface{}
Value satisfies the Valuer interface and returns the text of the panel.
func (*Panel) ΩDrawingAttributes ¶ added in v0.0.3
func (c *Panel) ΩDrawingAttributes() html.Attributes
type PanelCreator ¶ added in v0.2.0
type PanelCreator struct { // ID is the id the tag will have on the page and must be unique on the page ID string // Text is text that will become the innerhtml part of the tag Text string // If you set TextIsHtml, the Text will not be escaped prior to drawing TextIsHtml bool // Children is a list of creators to use to create the child controls of the panel. // You can wrap your child creators with the Children() function as a helper. Children []page.Creator page.ControlOptions }
PanelCreator creates a div control with child controls. Pass it to AddControls or as a child of a parent control.
type PrimaryKeyer ¶
type PrimaryKeyer interface {
PrimaryKey() string
}
PrimaryKeyer is an interface that is often implemented by model objects.
type Proxy ¶
Proxy is a control that attaches events to controls. It is useful for attaching similar events to a series of controls, like all the links in a table, or all the buttons in button bar. You can also use it to draw a series of links or buttons. The proxy differentiates between the different objects that are sending it events by the ActionValue that you given the proxy when it draws.
To use a Proxy, create it in the control that wraps the controls the proxy will manage. Attach an event to the proxy control, and in the action handler, look for the ControlValue in the Action Value to know which of the controls sent the event. Draw the proxy with one of the following:
LinkHtml() - Output the proxy as a link ButtonHtml() - Output the proxy as a button TagHtml() - Output the proxy in any tag ActionAttributes() - Returns attributes you can use in any custom control to attach a proxy
The ProxyColumn of the Table object will use a proxy to draw items in a table column.
func GetProxy ¶ added in v0.2.0
GetProxy is a convenience method to return the button with the given id from the page.
func NewProxy ¶
NewProxy creates a new proxy. The parent must be the wrapping control of the objects that the proxy will manage.
func (*Proxy) ActionAttributes ¶
func (p *Proxy) ActionAttributes(actionValue string) html.Attributes
ActionAttributes returns attributes that can be included in any tag to attach a proxy to the tag.
func (*Proxy) ButtonHtml ¶
func (p *Proxy) ButtonHtml(label string, actionValue string, attributes html.Attributes, rawHtml bool, ) string
ButtonHtml outputs the proxy as a button tag. actionValue becomes the event's ControlValue parameter
func (*Proxy) Draw ¶
Draw is used by the form engine to draw the control. As a proxy, there is no html to draw, but this is where the scripts attached to the proxy get sent to the response. This should get drawn by the auto-drawing routine, since proxies are not rendered in templates.
func (*Proxy) LinkHtml ¶
func (p *Proxy) LinkHtml(ctx context.Context, label string, actionValue string, attributes html.Attributes, ) string
LinkHtml renders the proxy as a link. To conform to the html standard and accessibility guidelines, links should only be used to navigate away from the page, so the action of your proxy should lead to that kind of behavior. Otherwise, use ButtonHtml.
func (*Proxy) OnSubmit ¶
OnSubmit is a shortcut for adding a click event handler that is particular to buttons. It debounces the click, to prevent potential accidental multiple form submissions. All events fired after this event fires will be lost. It is intended to be used when the action will result in navigating to a new page.
type ProxyCreator ¶ added in v0.2.0
type ProxyCreator struct { // ID is the id of the proxy. Proxies do not draw, so this id will not show up in the html, but you can // use it to get the proxy from the page. ID string // On is a shortcut to assign a single action to an event. If you want a proxy that responds to more than // one event or action, use On in the ControlOptions struct On On page.ControlOptions }
type ProxyI ¶
type ProxyI interface { page.ControlI LinkHtml(label string, actionValue string, attributes html.Attributes, ) string TagHtml(label string, actionValue string, attributes html.Attributes, tag string, rawHtml bool, ) string ButtonHtml(label string, eventActionValue string, attributes html.Attributes, rawHtml bool, ) string OnSubmit(actions ...action.ActionI) page.EventI }
type RadioButton ¶
type RadioButton struct { CheckboxBase // contains filtered or unexported fields }
RadioButton is a standard html radio button. You can optionally specify a group name for the radiobutton to belong to and the browser will make sure only one item in the group is selected.
func GetRadioButton ¶ added in v0.2.0
func GetRadioButton(c page.ControlI, id string) *RadioButton
GetRadioButton is a convenience method to return the radio button with the given id from the page.
func NewRadioButton ¶
func NewRadioButton(parent page.ControlI, id string) *RadioButton
NewRadioButton creates a new radio button
func (*RadioButton) Group ¶
func (c *RadioButton) Group() string
Group returns the name of the group that the control belongs to.
func (*RadioButton) SetChecked ¶
func (c *RadioButton) SetChecked(v bool) RadioButtonI
SetChecked will set the checked status of this radio button to the given value.
func (*RadioButton) SetGroup ¶
func (c *RadioButton) SetGroup(g string) RadioButtonI
SetGroup sets the name of the group that the control will belong to. Set all the radio buttons that represent a selection from a group to this same group name.
func (*RadioButton) ΩDrawingAttributes ¶ added in v0.0.3
func (c *RadioButton) ΩDrawingAttributes() html.Attributes
ΩDrawingAttributes is called by the framework to create temporary attributes for the input tag.
func (*RadioButton) ΩUpdateFormValues ¶ added in v0.0.3
func (c *RadioButton) ΩUpdateFormValues(ctx *page.Context)
ΩUpdateFormValues is called by the framework to update the value of the control based on values sent by the browser.
type RadioButtonCreator ¶ added in v0.2.0
type RadioButtonCreator struct { // ID is the id of the control ID string // Text is the text of the label displayed right next to the checkbox. Text string // Checked will initialize the checkbox in its checked state. Checked bool // LabelMode specifies how the label is drawn with the checkbox. LabelMode html.LabelDrawingMode // LabelAttributes are additional attributes placed on the label tag. LabelAttributes html.AttributeCreator // SaveState will save the value of the checkbox and restore it when the page is reentered. SaveState bool // Group is the name of the group that the button belongs to Group string page.ControlOptions }
type RadioButtonI ¶
type RadioButtonI interface { CheckboxI }
type RadioList ¶
type RadioList struct { SelectList // contains filtered or unexported fields }
RadioList is a multi-select control that presents its choices as a list of checkboxes. Styling is provided by divs and spans that you can provide css for in your style sheets. The goradd.css file has default styling to handle the basics. It wraps the whole thing in a div that can be set to scroll as well, so that the final structure can be styled like a multi-table table, or a single-table scrolling list much like a standard html select list.
func GetRadioList ¶ added in v0.2.0
GetRadioList is a convenience method to return the control with the given id from the page.
func NewRadioList ¶
NewRadioList creates a new RadioList control.
func (*RadioList) ColumnCount ¶ added in v0.0.3
ColumnCount returns the current column count.
func (*RadioList) Init ¶
func (l *RadioList) Init(self RadioListI, parent page.ControlI, id string)
Init is called by subclasses.
func (*RadioList) LayoutDirection ¶ added in v0.2.0
func (l *RadioList) LayoutDirection() LayoutDirection
LayoutDirection returns the direction of how items are spread across the columns.
func (*RadioList) SetColumnCount ¶ added in v0.0.4
func (l *RadioList) SetColumnCount(columns int) RadioListI
SetColumnCount sets the number of columns to use to display the list. Items will be evenly distributed across the columns.
func (*RadioList) SetIsScrolling ¶ added in v0.0.4
func (l *RadioList) SetIsScrolling(s bool) RadioListI
SetIsScrolling sets whether the list will scroll if it gets bigger than its bounding box. You will need to style the bounding box to give it limits, or else it will simply grow as big as the list.
func (*RadioList) SetLabelDrawingMode ¶ added in v0.0.4
func (l *RadioList) SetLabelDrawingMode(mode html.LabelDrawingMode) RadioListI
SetLabelDrawingMode indicates how labels for each of the checkboxes are drawn.
func (*RadioList) SetLayoutDirection ¶ added in v0.2.0
func (l *RadioList) SetLayoutDirection(direction LayoutDirection) RadioListI
SetLayoutDirection specifies how items are distributed across the columns.
func (*RadioList) SetRowClass ¶ added in v0.2.0
func (l *RadioList) SetRowClass(c string) RadioListI
SetRowClass sets the class to the div wrapper around each row. If blank, will be given a default.
func (*RadioList) ΩDrawInnerHtml ¶ added in v0.0.3
ΩDrawInnerHtml is called by the framework to draw the contents of the list.
func (*RadioList) ΩDrawingAttributes ¶ added in v0.0.3
func (l *RadioList) ΩDrawingAttributes() html.Attributes
ΩDrawingAttributes retrieves the tag's attributes at draw time. You should not normally need to call this, and the attributes are disposed of after drawing, so they are essentially read-only.
func (*RadioList) ΩRenderItem ¶ added in v0.0.3
ΩRenderItem is called by the framework to render a single item in the list.
func (*RadioList) ΩRenderItems ¶ added in v0.0.3
func (*RadioList) ΩUpdateFormValues ¶ added in v0.0.3
ΩUpdateFormValues is called by the framework to tell the control to update its internal values based on the form values sent by the browser.
type RadioListCreator ¶ added in v0.2.0
type RadioListCreator struct { ID string // Items is a static list of labels and values that will be in the list. Or, use a DataProvider to dynamically generate the items. Items []ListValue // DataProvider is the control that will dynamically provide the data for the list and that implements the DataBinder interface. DataProvider data.DataBinder // DataProviderID is the id of a control that will dynamically provide the data for the list and that implements the DataBinder interface. DataProviderID string // ColumnCount specifies how many columns to show ColumnCount int // LayoutDirection determines how the items are arranged in the columns LayoutDirection LayoutDirection // LabelDrawingMode specifies how the labels on the radio buttons will be associated with the buttons LabelDrawingMode html.LabelDrawingMode // IsScrolling will give the inner div a vertical scroll style. You will need to style the height of the outer control to have a fixed style as well. IsScrolling bool // RowClass is the class assigned to each row RowClass string // Value is the initial value of the textbox. Often its best to load the value in a separate Load step after creating the control. Value string // SaveState saves the selected value so that it is restored if the form is returned to. SaveState bool page.ControlOptions }
func (RadioListCreator) Create ¶ added in v0.2.0
Create is called by the framework to create a new control from the Creator. You do not normally need to call this.
func (RadioListCreator) Init ¶ added in v0.2.0
func (c RadioListCreator) Init(ctx context.Context, ctrl RadioListI)
type RadioListI ¶
type RadioListI interface { SelectListI SetColumnCount(int) RadioListI SetLayoutDirection(direction LayoutDirection) RadioListI SetLabelDrawingMode(mode html.LabelDrawingMode) RadioListI SetIsScrolling(s bool) RadioListI SetRowClass(c string) RadioListI ΩRenderItems(items []ListItemI) string ΩRenderItem(item ListItemI) string }
type SelectList ¶
type SelectList struct { page.Control ItemList data.DataManager // contains filtered or unexported fields }
SelectList is typically a dropdown list with a single selection. Items are selected by id number, and the SelectList completely controls the ids in the list. Create the list by calling AddItem or AddItems to add ListItemI objects. Or, use the embedded DataManager to load items. Set the size attribute if you want to display it as a scrolling list rather than a dropdown list.
func GetSelectList ¶ added in v0.2.0
func GetSelectList(c page.ControlI, id string) *SelectList
GetSelectList is a convenience method to return the control with the given id from the page.
func NewSelectList ¶
func NewSelectList(parent page.ControlI, id string) *SelectList
NewSelectList creates a new select list
func (*SelectList) IntValue ¶
func (l *SelectList) IntValue() int
IntValue returns the select value as an integer.
func (*SelectList) SelectedItem ¶
func (l *SelectList) SelectedItem() ListItemI
SelectedItem will return the currently selected item. If no item has been selected, it will return the first item in the list, since that is what will be showing in the selection list, and will update its internal pointer to make the first item the current selection.
func (*SelectList) SelectedLabel ¶
func (l *SelectList) SelectedLabel() string
SelectedLabel returns the label of the selected item
func (*SelectList) SetData ¶
func (l *SelectList) SetData(data interface{})
SetData overrides the default data setter to add objects to the item list. The result is kept in memory currently. ItemLister, ItemIDer, Labeler or Stringer types. This function can accept one or more lists of items, or single items.
func (*SelectList) SetSelectedID ¶
func (l *SelectList) SetSelectedID(id string)
SetSelectedId sets the current selection to the given id. You must ensure that the item with the id exists, it will not attempt to make sure the item exists.
func (*SelectList) SetValue ¶
func (l *SelectList) SetValue(v interface{})
SetValue implements the Valuer interface for general purpose value getting and setting
func (*SelectList) StringValue ¶
func (l *SelectList) StringValue() string
StringValue returns the selected value as a string
func (*SelectList) Validate ¶
func (l *SelectList) Validate(ctx context.Context) bool
Validate is called by the framework to validate the contents of the control. For a SelectList, this is typically just checking to see if something was selected if a selection is required.
func (*SelectList) Value ¶
func (l *SelectList) Value() interface{}
Value implements the Valuer interface for general purpose value getting and setting
func (*SelectList) ΩDrawInnerHtml ¶ added in v0.0.3
ΩDrawInnerHtml is called by the framework during drawing of the control to draw the inner html of the control
func (*SelectList) ΩDrawingAttributes ¶ added in v0.0.3
func (l *SelectList) ΩDrawingAttributes() html.Attributes
ΩDrawingAttributes retrieves the tag's attributes at draw time. You should not normally need to call this, and the attributes are disposed of after drawing, so they are essentially read-only.
func (*SelectList) ΩMarshalState ¶ added in v0.0.3
func (l *SelectList) ΩMarshalState(m maps.Setter)
ΩMarshalState is an internal function to save the state of the control
func (*SelectList) ΩUnmarshalState ¶ added in v0.0.3
func (l *SelectList) ΩUnmarshalState(m maps.Loader)
ΩUnmarshalState is an internal function to restore the state of the control
func (*SelectList) ΩUpdateFormValues ¶ added in v0.0.3
func (l *SelectList) ΩUpdateFormValues(ctx *page.Context)
ΩUpdateFormValues is an internal function that lets us reflect the value of the selection that is currently on the browser
type SelectListCreator ¶ added in v0.2.0
type SelectListCreator struct { ID string // Items is a static list of labels and values that will be in the list. Or, use a DataProvider to dynamically generate the items. Items []ListValue // NilItem is a helper to add an item at the top of the list with a nil value. This is often // used to specify no selection, or a message that a selection is required. NilItem string // DataProvider is the control that will dynamically provide the data for the list and that implements the DataBinder interface. DataProvider data.DataBinder // DataProviderID is the id of a control that will dynamically provide the data for the list and that implements the DataBinder interface. DataProviderID string // Size specifies how many items to show, and turns the list into a scrolling list Size int // Value is the initial value of the textbox. Often its best to load the value in a separate Load step after creating the control. Value string // SaveState saves the selected value so that it is restored if the form is returned to. SaveState bool page.ControlOptions }
func (SelectListCreator) Init ¶ added in v0.2.0
func (c SelectListCreator) Init(ctx context.Context, ctrl SelectListI)
type SelectListI ¶ added in v0.0.4
type SelectListI interface { page.ControlI ItemListI data.DataManagerEmbedder SetValue(v interface{}) }
type SelectTable ¶
type SelectTable struct { Table // contains filtered or unexported fields }
SelectTable is a table that is row selectable. To detect a row selection, trigger on event.RowSelected
func GetSelectTable ¶ added in v0.2.0
func GetSelectTable(c page.ControlI, id string) *SelectTable
GetSelectTable is a convenience method to return the button with the given id from the page.
func NewSelectTable ¶
func NewSelectTable(parent page.ControlI, id string) *SelectTable
func (*SelectTable) GetRowAttributes ¶
func (t *SelectTable) GetRowAttributes(row int, data interface{}) (a html.Attributes)
func (*SelectTable) SelectedID ¶
func (t *SelectTable) SelectedID() string
func (*SelectTable) SetSelectedID ¶
func (t *SelectTable) SetSelectedID(id string) SelectTableI
func (*SelectTable) ΩDrawingAttributes ¶ added in v0.0.3
func (t *SelectTable) ΩDrawingAttributes() html.Attributes
func (*SelectTable) ΩMarshalState ¶ added in v0.0.3
func (t *SelectTable) ΩMarshalState(m maps.Setter)
func (*SelectTable) ΩUnmarshalState ¶ added in v0.0.3
func (t *SelectTable) ΩUnmarshalState(m maps.Loader)
func (*SelectTable) ΩUpdateFormValues ¶ added in v0.0.3
func (t *SelectTable) ΩUpdateFormValues(ctx *page.Context)
type SelectTableCreator ¶ added in v0.2.0
type SelectTableCreator struct { // ID is the control id ID string // HasColTags will make the table render <col> tags HasColTags bool // Caption is the content of the caption tag, and can either be a string, or a data pager Caption interface{} // HideIfEmpty will hide the table completely if it has no data. Otherwise, the table and headers will be shown, but no data rows HideIfEmpty bool // HeaderRowCount is the number of header rows. You must set this to at least 1 to show header rows. HeaderRowCount int FooterRowCount int // RowStyler returns the attributes to be used in a cell. RowStyler TableRowAttributer // RowStylerID is a control id for the control that will be the RowStyler of the table. RowStylerID string // HeaderRowStyler returns the attributes to be used in a header cell. HeaderRowStyler TableHeaderRowAttributer // HeaderRowStylerID is a control id for the control that will be the HeaderRowStyler of the table. HeaderRowStylerID string FooterRowStyler TableFooterRowAttributer FooterRowStylerID string // Columns are the column creators that will add columns to the table Columns []ColumnCreator // DataProvider is the control that will dynamically provide the data for the list and that implements the DataBinder interface. DataProvider data.DataBinder // DataProviderID is the id of a control that will dynamically provide the data for the list and that implements the DataBinder interface. DataProviderID string // Data is the actual data for the table, and should be a slice of objects Data interface{} // Sortable will make the table sortable Sortable bool // SortHistoryLimit will set how many columns deep we will remember the sorting for multi-level sorts SortHistoryLimit int page.ControlOptions // OnRowSelected is the action to take when the row is selected OnRowSelected action.ActionI // SelectedID is the row id that will start as the selection SelectedID string // SaveState will cause the table to remember the selection SaveState bool }
SelectTableCreator is the initialization structure for declarative creation of tables
func (SelectTableCreator) Create ¶ added in v0.2.0
Create is called by the framework to create a new control from the Creator. You do not normally need to call this.
func (SelectTableCreator) Init ¶ added in v0.2.0
func (c SelectTableCreator) Init(ctx context.Context, ctrl SelectTableI)
Init is called by implementations of Buttons to initialize a control with the creator. You do not normally need to call this.
type SelectTableI ¶
type SelectTableI interface { TableI SetSelectedID(id string) SelectTableI }
type SortDirection ¶
type SortDirection int
type Span ¶
type Span struct {
Panel
}
Span is a Goradd control that is a basic "span" wrapper. Use it to style and listen to events on a span. It can also be used as the basis for more advanced javascript controls.
func GetSpan ¶ added in v0.2.1
GetSpan is a convenience method to return the button with the given id from the page.
func (*Span) ΩDrawingAttributes ¶ added in v0.0.3
func (c *Span) ΩDrawingAttributes() html.Attributes
type SpanCreator ¶ added in v0.2.0
type Table ¶
type Table struct { page.Control data.DataManager // contains filtered or unexported fields }
Table is a goradd control that outputs a dynamic HTML table object, with table, tr, th and td tags, as well as optional col, thead, and tfoot tags.
To use a Table, call NewTable and then add column objects to it. The columns use a CellTexter to draw the contents of a cell in the table. There are a number of predefined columns to draw text coming from slices of maps, slices, database objects, as well as custom functions you define. See the examples directory for examples of using a Table object. See also the PagedTable for a table that works with a Pager object to page through a large data set.
Call MakeSortable() to make a table sortable, in which case the user can click in the header of a column to sort by that column. The Table maintains a history of what columns have been sorted by what row, so that you can implement multi-level sorting if you so desire. This is particularly helpful when some columns have duplicate data, that then get further identified by another column.
You can provide data to the table when it is first created by calling SetData, or you can provide the data just before drawing by calling SetDataProvider at initialization of the table, and then providing the table data in response to the BindData function. The advantage of this approach is that if you are showing a lot of data, the data is only loaded in memory during drawing, and not kept in the pagestate after drawing.
func GetTable ¶ added in v0.2.0
GetTable is a convenience method to return the button with the given id from the page.
func (*Table) AddColumnAt ¶
AddColumnAt adds the given column at the column offset given. 0 is the first column location. Pass a negative number or a number bigger than the current number of columns to put it at the end.
func (*Table) ClearColumns ¶
func (t *Table) ClearColumns()
ClearColumns removes all of the columns.
func (*Table) DrawCaption ¶
DrawCaption is called internally to draw the caption. Subclasses can override this to draw a custom caption.
func (*Table) FooterCellDrawingInfo ¶ added in v0.2.0
func (t *Table) FooterCellDrawingInfo(ctx context.Context, col ColumnI, rowNum int, colNum int) (cellHtml string, cellAttributes html.Attributes)
FooterCellDrawingInfo is called internally to provide the info for each header cell drawn. Subclasses can override this.
func (*Table) GetColumnByID ¶
GetColumnByID returns the column with the given id.
func (*Table) GetColumnByTitle ¶
GetColumnByTitle returns the column with the given title.
func (*Table) GetFooterRowAttributes ¶
func (t *Table) GetFooterRowAttributes(row int) html.Attributes
GetFooterRowAttributes is called internally to get the attributes for the tr tags in footer rows.
func (*Table) GetHeaderRowAttributes ¶
func (t *Table) GetHeaderRowAttributes(row int) html.Attributes
GetHeaderRowAttributes is called internally to get the attributes for the tr tags in header rows.
func (*Table) GetRowAttributes ¶
func (t *Table) GetRowAttributes(row int, data interface{}) html.Attributes
GetRowAttributes is used internally to return the attributes for the tr tag of a data row.
func (*Table) HeaderCellDrawingInfo ¶
func (t *Table) HeaderCellDrawingInfo(ctx context.Context, col ColumnI, rowNum int, colNum int) (cellHtml string, cellAttributes html.Attributes)
HeaderCellDrawingInfo is called internally to provide the info for each header cell drawn. Subclasses can override this.
func (*Table) HideColumns ¶
func (t *Table) HideColumns()
HideColumns hides all of the columns, keeping them in the column list, but causing them not to draw.
func (*Table) Init ¶
Init is an internal function that enables the object-oriented pattern of calling virtual functions used by the goradd controls. You would only call this if you were implementing a "subclass" of the Table. Call it immediately after creating your Table structure, passing the newly created table as "self".
func (*Table) MakeSortable ¶ added in v0.2.0
MakeSortable makes a table sortable. It will attach sortable events and show the header if its not shown.
func (*Table) PrivateAction ¶
func (t *Table) PrivateAction(ctx context.Context, p page.ActionParams)
PrivateAction is called by the framework to allow controls to process actions internal to themselves.
func (*Table) RemoveColumn ¶
RemoveColumn removes the column at the given location. If you attempt to remove a column that does not exist, it will panic.
func (*Table) RemoveColumnByID ¶
RemoveColumnByID removes the column with the given id. If the column does not exist, nothing will change.
func (*Table) RemoveColumnByTitle ¶
RemoveColumnByTitle removes the given column with the given title. If the column does not exist, nothing will change.
func (*Table) RowStyler ¶
func (t *Table) RowStyler() TableRowAttributer
func (*Table) SetCaption ¶
SetCaption sets the caption of the table. The default Table permits a caption to be either a string, or a goradd control.
func (*Table) SetFooterRowCount ¶
SetFooterRowCount sets the number of footer rows shown. Each column will be asked to draw this number of footer rows.
func (*Table) SetFooterRowStyler ¶
func (t *Table) SetFooterRowStyler(a TableFooterRowAttributer) TableI
SetFooterRowStyler sets a styler that returns attributes to be used on a particular footer row.
func (*Table) SetHeaderRowCount ¶
SetHeaderRowCount sets the number of header rows shown. Each column will be asked to draw this number of header rows.
func (*Table) SetHeaderRowStyler ¶
func (t *Table) SetHeaderRowStyler(a TableHeaderRowAttributer) TableI
SetHeaderRowStyler sets a styler that returns attributes to be used on a particular header row.
func (*Table) SetHideIfEmpty ¶ added in v0.2.0
func (*Table) SetRenderColumnTags ¶ added in v0.2.0
func (*Table) SetRowStyler ¶
func (t *Table) SetRowStyler(a TableRowAttributer) TableI
SetRowStyler sets a styler that returns attributes to be used on a particular row.
func (*Table) SetSortHistoryLimit ¶
SetSortHistoryLimit sets the number of columns that the table will remember for the sort history. It defaults to 1, meaning it will remember only the current column. Setting it more than 1 will let the system report back on secondary sort columns that the user chose. For example, if the user clicks to sort a first name column, and then a last name column, it will let you know to sort by last name, and then first name.
func (*Table) ShowColumns ¶
func (t *Table) ShowColumns()
ShowColumns sets all of the columns to be shown.
func (*Table) SortColumns ¶
SortColumns returns a slice of columns in sort order
func (*Table) ΩDrawInnerHtml ¶ added in v0.0.3
ΩDrawInnerHtml is an override to draw the meat of the table.
func (*Table) ΩDrawTag ¶ added in v0.0.3
ΩDrawTag is called by the framework to draw the table. The Table overrides this to call into the DataProvider to load the table's data into memory just before drawing. The data will be unloaded after drawing.
func (*Table) ΩDrawingAttributes ¶ added in v0.0.3
func (t *Table) ΩDrawingAttributes() html.Attributes
ΩDrawingAttributes is an override to add attributes to the table, including not showing the table at all if there is no data to show. This will hide header and footer cells and potentially the outline of the table when there is no data in the table.
func (*Table) ΩMarshalState ¶ added in v0.0.4
ΩMarshalState is an internal function to save the state of the control
func (*Table) ΩUnmarshalState ¶ added in v0.0.4
ΩUnmarshalState is an internal function to restore the state of the control
func (*Table) ΩUpdateFormValues ¶ added in v0.0.3
ΩUpdateFormValues is called by the system whenever values are sent by client controls. We forward that to the columns.
type TableCreator ¶ added in v0.2.0
type TableCreator struct { // ID is the control id ID string // HasColTags will make the table render <col> tags HasColTags bool // Caption is the content of the caption tag, and can either be a string, or a data pager Caption interface{} // HideIfEmpty will hide the table completely if it has no data. Otherwise, the table and headers will be shown, but no data rows HideIfEmpty bool // HeaderRowCount is the number of header rows. You must set this to at least 1 to show header rows. HeaderRowCount int FooterRowCount int // RowStyler returns the attributes to be used in a cell. RowStyler TableRowAttributer // RowStylerID is a control id for the control that will be the RowStyler of the table. RowStylerID string // HeaderRowStyler returns the attributes to be used in a header cell. HeaderRowStyler TableHeaderRowAttributer // HeaderRowStylerID is a control id for the control that will be the HeaderRowStyler of the table. HeaderRowStylerID string FooterRowStyler TableFooterRowAttributer FooterRowStylerID string // Columns are the column creators that will add columns to the table Columns []ColumnCreator // DataProvider is the control that will dynamically provide the data for the list and that implements the DataBinder interface. DataProvider data.DataBinder // DataProviderID is the id of a control that will dynamically provide the data for the list and that implements the DataBinder interface. DataProviderID string // Data is the actual data for the table, and should be a slice of objects Data interface{} // Sortable will make the table sortable Sortable bool // SortHistoryLimit will set how many columns deep we will remember the sorting for multi-level sorts SortHistoryLimit int page.ControlOptions }
TableCreator is the initialization structure for declarative creation of tables
type TableEmbedder ¶ added in v0.2.0
type TableEmbedder interface { SetCaption(interface{}) TableI DrawCaption(context.Context, *bytes.Buffer) error GetHeaderRowAttributes(row int) html.Attributes GetRowAttributes(row int, data interface{}) html.Attributes HeaderCellDrawingInfo(ctx context.Context, col ColumnI, rowNum int, colNum int) (cellHtml string, cellAttributes html.Attributes) SetRenderColumnTags(r bool) TableI SetHideIfEmpty(h bool) TableI SetHeaderRowCount(count int) TableI SetRowStyler(a TableRowAttributer) TableI SetHeaderRowStyler(a TableHeaderRowAttributer) TableI AddColumnAt(column ColumnI, loc int) AddColumn(column ColumnI) ColumnI GetColumn(loc int) ColumnI GetColumnByID(id string) ColumnI GetColumnByTitle(title string) ColumnI RemoveColumn(loc int) RemoveColumnByID(id string) RemoveColumnByTitle(title string) ClearColumns() HideColumns() ShowColumns() MakeSortable() TableI SetSortHistoryLimit(n int) TableI }
TableEmbedder is a workaround for a problem in GO interfaces. See https://github.com/golang/go/issues/6977
type TableFooterRowAttributer ¶ added in v0.0.7
type TableFooterRowAttributer interface { int) html.Attributes }TableFooterRowAttributes(row
type TableHeaderRowAttributer ¶ added in v0.0.7
type TableHeaderRowAttributer interface { // TableHeaderRowAttributes returns attributes to use for the particular header row indicated TableHeaderRowAttributes(row int) html.Attributes }
type TableI ¶
type TableI interface { page.ControlI TableEmbedder data.DataManagerEmbedder }
TableI is the table interface that lets you create a "subclass" of the Table object. The functions defined here are hooks that you can implement in your subclass.
type TableRowAttributer ¶ added in v0.0.7
type TableRowAttributer interface { // TableRowAttributes returns attributes that should be used on the particular row indicated. // Data is the data for that row. TableRowAttributes(row int, data interface{}) html.Attributes }
TableRowAttributer is used to style particular table rows.
type Textbox ¶
Textbox is a goradd control that outputs an "input" html tag with a "type" attribute of "text", or one of the text-like types, like "password", "search", etc.
func GetTextbox ¶ added in v0.2.0
GetTextbox is a convenience method to return the control with the given id from the page.
func NewTextbox ¶
NewTextbox creates a new goradd textbox html widget.
func (*Textbox) Deserialize ¶
Deserialize is used by the pagestate serializer.
func (*Textbox) Placeholder ¶
Placeholder returns the value of the placeholder.
func (*Textbox) ResetValidators ¶
func (t *Textbox) ResetValidators()
ResetValidators removes all validators
func (*Textbox) Serialize ¶
Serialize is used by the framework to serialize the textbox into the pagestate.
func (*Textbox) SetColumnCount ¶
SetColumnCount sets the visible width of the text control. Each table is an approximate with of a character, and is browser dependent, so its not a very good way of setting the width. The css width property is more accurate. Also, this is only the visible width, not the maximum number of characters.
func (*Textbox) SetMaxLength ¶
func (t *Textbox) SetMaxLength(len int) *MaxLengthValidator
SetMaxLength sets the maximum length allowed in the textbox. The text will be limited by the browser, but the server side will also make sure that the text is not too big.
func (*Textbox) SetMinLength ¶
func (t *Textbox) SetMinLength(len int) *MinLengthValidator
SetMinLength will set the minimum length permitted. If the user does not enter enough text, an error message will be displayed upon submission of the form.
func (*Textbox) SetPlaceholder ¶
SetPlaceholder will set the html placeholder attribute, which puts text in the textbox when the textbox is empty as a hint to the user of what to enter.
func (*Textbox) SetReadOnly ¶
SetReadOnly will disable editing by setting a browser attribute.
func (*Textbox) SetRowCount ¶
SetRowCount sets the number of rowCount the Textbox will have. A value of 0 produces an input tag, and a value of 1 or greater produces a textarea tag.
func (*Textbox) SetType ¶
SetType sets the type of textbox this is. Pass it a TextboxType* constant normally, though you can pass any string and it will become the input type
func (*Textbox) SetValue ¶
SetValue sets the text in the textbox. This satisfies the Valuer interface.
func (*Textbox) Validate ¶
Validate will first check for the IsRequired attribute, and if set, will make sure a value is in the text field. It will then check the validators in the order assigned. The first invalid value found will return false.
func (*Textbox) ValidateWith ¶
ValidateWith adds a Validater to the validator list.
func (*Textbox) Value ¶
func (t *Textbox) Value() interface{}
Value returns the user entered text in the textbox.
func (*Textbox) ΩDrawInnerHtml ¶ added in v0.0.3
ΩDrawInnerHtml is an internal function that renders the inner html of a tag. In this case, it is rendering the inner text of a textarea
func (*Textbox) ΩDrawingAttributes ¶ added in v0.0.3
func (t *Textbox) ΩDrawingAttributes() html.Attributes
ΩDrawingAttributes is called by the framework to retrieve the tag's private attributes at draw time.
func (*Textbox) ΩMarshalState ¶ added in v0.0.3
ΩMarshalState is an internal function to save the state of the control
func (*Textbox) ΩSanitize ¶ added in v0.0.3
Sanitize is called by the framework when taking in user input and strips it of potential malicious XSS scripts. The default uses a global sanitizer created at bootup. Override Sanitize in a subclass if you want a per-textbox sanitizer. This is a very difficult thing to get right, and depends a bit on your application on just how much you want to remove.
func (*Textbox) ΩUnmarshalState ¶ added in v0.0.3
ΩUnmarshalState is an internal function to restore the state of the control
func (*Textbox) ΩUpdateFormValues ¶ added in v0.0.3
ΩUpdateFormValues is an internal function that lets us reflect the value of the textbox on the web override
type TextboxCreator ¶ added in v0.2.0
type TextboxCreator struct { // ID is the control id of the html widget and must be unique to the page ID string // Placeholder is the placeholder attribute of the textbox and shows as help text inside the field Placeholder string // Type is the type attribute of the textbox Type string // MinLength is the minimum number of characters that the user is required to enter. If the // length is less than this number, a validation error will be shown. MinLength int // MaxLength is the maximum number of characters that the user is required to enter. If the // length is more than this number, a validation error will be shown. MaxLength int // ColumnCount is the number of characters wide the textbox will be, and becomes the width attribute in the tag. // The actual width is browser dependent. For better control, use a width style property. ColumnCount int // RowCount creates a multi-line textarea with the given number of rows. By default the // textbox will expand vertically by this number of lines. Use a height style property for // better control of the height of a textbox. RowCount int // ReadOnly sets the readonly attribute of the textbox, which prevents it from being changed by the user. ReadOnly bool // SaveState will save the text in the textbox, to be restored if the user comes back to the page. // It is particularly helpful when the textbox is being used to filter the results of a query, so that // when the user comes back to the page, he does not have to type the filter text again. SaveState bool // Text is the initial value of the textbox. Generally you would not use this, but rather load the value in a separate Load step after creating the control. Text string page.ControlOptions }
Use TextboxCreator to create a textbox. Pass it to AddControls of a control, or as a Child of a FormFieldWrapper.
type TextboxI ¶
type TextboxI interface { page.ControlI SetType(typ string) TextboxI ΩSanitize(string) string SetPlaceholder(s string) TextboxI SetMaxLength(len int) *MaxLengthValidator SetMinLength(len int) *MinLengthValidator SetRowCount(rows int) TextboxI SetColumnCount(columns int) TextboxI SetReadOnly(r bool) TextboxI SetValue(interface{}) page.ControlI }
type UnorderedList ¶
type UnorderedList struct { page.Control ItemList data.DataManager // contains filtered or unexported fields }
UnorderedList is a dynamically generated html unordered list (ul). Such lists are often used as the basis for javascript and css widgets. If you use a data provider to set the data, you should call AddItems to the list in your LoadData function.
func GetUnorderedList ¶ added in v0.2.0
func GetUnorderedList(c page.ControlI, id string) *UnorderedList
GetUnorderedList is a convenience method to return the control with the given id from the page.
func NewUnorderedList ¶
func NewUnorderedList(parent page.ControlI, id string) *UnorderedList
NewUnorderedList creates a new ul type list.
func (*UnorderedList) GetItemsHtml ¶
func (l *UnorderedList) GetItemsHtml(items []ListItemI) string
GetItemsHtml is used by the framework to get the items for the html. It is exported so that it can be overridden by other implementations of an UnorderedList.
func (*UnorderedList) SetBulletStyle ¶
func (l *UnorderedList) SetBulletStyle(s string) UnorderedListI
SetBulletType sets the list-style-type attribute of the list. Choose from the UnorderedListStyle* constants.
func (*UnorderedList) SetData ¶ added in v0.0.4
func (l *UnorderedList) SetData(data interface{})
SetData replaces the current list with the given data. The result is kept in memory currently. ItemLister, ItemIDer, Labeler or Stringer types. This function can accept one or more lists of items, or single items. They will all get added to the top level of the list. To add sub items, get a list item and add items to it.
func (*UnorderedList) SetItemTag ¶ added in v0.0.4
func (l *UnorderedList) SetItemTag(s string) UnorderedListI
SetItemTag sets the tag that will be used for items in the list. By default this is "li".
func (*UnorderedList) ΩDrawInnerHtml ¶ added in v0.0.3
func (*UnorderedList) ΩDrawTag ¶ added in v0.0.3
func (l *UnorderedList) ΩDrawTag(ctx context.Context) string
func (*UnorderedList) ΩDrawingAttributes ¶ added in v0.0.3
func (l *UnorderedList) ΩDrawingAttributes() html.Attributes
ΩDrawingAttributes retrieves the tag's attributes at draw time. You should not normally need to call this, and the attributes are disposed of after drawing, so they are essentially read-only.
type UnorderedListCreator ¶ added in v0.2.0
type UnorderedListCreator struct { ID string // Items is a static list of labels and values that will be in the list. Or, use a DataProvider to dynamically generate the items. Items []ListValue // DataProvider is the control that will dynamically provide the data for the list and that implements the DataBinder interface. DataProvider data.DataBinder // DataProviderID is the id of a control that will dynamically provide the data for the list and that implements the DataBinder interface. DataProviderID string // BulletStyle is the list-style-type property. BulletStyle string page.ControlOptions }
func (UnorderedListCreator) Create ¶ added in v0.2.0
Create is called by the framework to create a new control from the Creator. You do not normally need to call this.
func (UnorderedListCreator) Init ¶ added in v0.2.0
func (c UnorderedListCreator) Init(ctx context.Context, ctrl UnorderedListI)
type UnorderedListI ¶
type UnorderedListI interface { page.ControlI ItemListI GetItemsHtml(items []ListItemI) string data.DataManagerEmbedder SetBulletStyle(s string) UnorderedListI SetItemTag(s string) UnorderedListI }
type Validater ¶
type Validater interface { // Validate evaluates the input, and returns an empty string if the input is valid, and an error string to display // to the user if the input does not pass the validator. Validate(page.ControlI, string) string }
A Validater can be added to a textbox to validate its input on the server side. A textbox can have more than one validater. A number of built-in validators are provided.
Source Files ¶
- button.go
- canvas.go
- checkbox.go
- checkbox_base.go
- data_pager.go
- datetime_span.go
- dialog.go
- dialog.tpl.go
- doc.go
- fieldset.go
- form_base.go
- form_field_wrapper.go
- grid_layout.go
- image.go
- image_capture.go
- item_list.go
- list_checkbox.go
- list_item.go
- list_multiselect.go
- list_ordered.go
- list_radio.go
- list_select.go
- list_unordered.go
- panel.go
- proxy.go
- radioButton.go
- span.go
- table.go
- table_column_base.go
- table_paged.go
- table_select.go
- textbox.go
- textbox_date.go
- textbox_email.go
- textbox_float.go
- textbox_integer.go