control

package
v0.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2019 License: MIT Imports: 26 Imported by: 0

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

View Source
const (
	ButtonClick = iota + 3000
	DialogClose
)

event codes

View Source
const (
	OrderedListNumberTypeNumber      = "1" // default
	OrderedListNumberTypeUpperLetter = "A"
	OrderedListNumberTypeLowerLetter = "a"
	OrderedListNumberTypeUpperRoman  = "I"
	OrderedListNumberTypeLowerRoman  = "i"
)
View Source
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"
)
View Source
const (
	ColumnAction = iota + 2000
	SortClick
)
View Source
const (
	NotSortable    = SortDirection(0)
	SortAscending  = SortDirection(1)
	SortDescending = SortDirection(-1)
	NotSorted      = SortDirection(-100)
)
View Source
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"
)
View Source
const DialogButtonEvent = "gr-dlgbtn"
View Source
const DialogOverlayID = "gr-dlg-overlay"
View Source
const (
	PageClick = iota + 1000
)

Variables

View Source
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.

View Source
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.

View Source
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

func CalcWrapperID(wrapperId string, childCreator page.Creator, postfix string) string

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

func Children(creators ...page.Creator) []page.Creator

Children is just a helper function for doing declarative control creation for child control creators

func GetCreatorID added in v0.2.0

func GetCreatorID(c page.Creator) string

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 RegisterColumn added in v0.3.0

func RegisterColumn(i interface{})

RegisterColumn registers the column for the serialize/deserialize process. You should call this for each column type in an init() function.

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.

func SortIds

func SortIds(ids []string)

SortIds sorts a list of auto-generated ids in numerical and hierarchical order. This is normally just called by the framework.

Types

type AlertFuncType

type AlertFuncType func(form page.FormI, message string, buttons interface{}) DialogI

type Button

type Button struct {
	page.ControlBase
}

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

func GetButton(c page.ControlI, id string) *Button

GetButton is a convenience method to return the button with the given id from the page.

func NewButton

func NewButton(parent page.ControlI, id string) *Button

NewButton creates a new standard html button

func (*Button) DrawingAttributes

func (b *Button) DrawingAttributes(ctx context.Context) 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 (*Button) Init

func (b *Button) Init(parent page.ControlI, id string)

Init is called by subclasses of Button to initialize the button control structure.

func (*Button) On

func (b *Button) On(e *page.Event, action action.ActionI) page.ControlI

On causes the given actions to execute when the given event is triggered.

func (*Button) OnSubmit

func (b *Button) OnSubmit(action action.ActionI) page.ControlI

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

func (b *Button) SetLabel(label string) page.ControlI

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.

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
	ValidationType page.ValidationType
	page.ControlOptions
}

ButtonCreator is the initialization structure for declarative creation of buttons

func (ButtonCreator) Create added in v0.2.0

func (c ButtonCreator) Create(ctx context.Context, parent page.ControlI) page.ControlI

Create is called by the framework to create a new control from the Creator. You do not normally need to call this.

func (ButtonCreator) Init added in v0.2.0

func (c ButtonCreator) Init(ctx context.Context, ctrl ButtonI)

Init is called by implementations of Buttons to initialize a control with the creator. You do not normally need to call this.

type ButtonI

type ButtonI interface {
	page.ControlI
	SetLabel(label string) page.ControlI
	OnSubmit(action action.ActionI) page.ControlI
}

type Canvas

type Canvas struct {
	page.ControlBase
}

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

func GetCanvas(c page.ControlI, id string) *Canvas

GetCanvas is a convenience method to return the canvas with the given id from the page.

func NewCanvas

func NewCanvas(parent page.ControlI, id string) *Canvas

NewCanvas creates a Canvas control

func (*Canvas) DrawingAttributes

func (c *Canvas) DrawingAttributes(ctx context.Context) html.Attributes

DrawingAttributes is called by the framework to get the temporary attributes that are specifically set by this control just before drawing.

func (*Canvas) Init

func (c *Canvas) Init(parent page.ControlI, id string)

Init is called by subcontrols. You do not normally need to call it.

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

func (CanvasCreator) Create added in v0.2.0

func (c CanvasCreator) Create(ctx context.Context, parent page.ControlI) page.ControlI

Create is called by the framework to create a new control from the Creator. You do not normally need to call this.

type CanvasI

type CanvasI interface {
	page.ControlI
}

type CellStyler added in v0.2.0

type CellStyler interface {
	CellAttributes(ctx context.Context, col ColumnI, row int, colNum int, data interface{}) html.Attributes
}

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

func GetCheckbox(c page.ControlI, id string) *Checkbox

GetCheckbox is a convenience method to return the checkbox with the given id from the page.

func NewCheckbox

func NewCheckbox(parent page.ControlI, id string) *Checkbox

NewCheckbox creates a new checkbox control.

func (*Checkbox) DrawingAttributes

func (c *Checkbox) DrawingAttributes(ctx context.Context) 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

func (c *Checkbox) UpdateFormValues(ctx *page.Context)

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.ControlBase

	// 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

func (c *CheckboxBase) Deserialize(d page.Decoder) (err error)

Deserialize is called by the framework during page state serialization.

func (*CheckboxBase) DrawTag

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

func (c *CheckboxBase) DrawingAttributes(ctx context.Context) 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.4.0

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) Init

func (c *CheckboxBase) Init(parent page.ControlI, id string)

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) MarshalState

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) 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) UnmarshalState

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) 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.

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.Attributes
	// SaveState will save the value of the checkbox and restore it when the page is reentered.
	SaveState bool
	page.ControlOptions
}

func (CheckboxCreator) Create added in v0.2.0

func (c CheckboxCreator) Create(ctx context.Context, parent page.ControlI) page.ControlI

Create is called by the framework to create a new control from the Creator. You do not normally need to call this.

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) Deserialize added in v0.3.0

func (l *CheckboxList) Deserialize(dec page.Decoder) (err error)

func (*CheckboxList) DrawInnerHtml

func (l *CheckboxList) DrawInnerHtml(ctx context.Context, buf *bytes.Buffer) (err error)

DrawInnerHtml is called by the framework to draw the contents of the list.

func (*CheckboxList) DrawingAttributes

func (l *CheckboxList) DrawingAttributes(ctx context.Context) 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) Init

func (l *CheckboxList) Init(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) RenderItem

func (l *CheckboxList) RenderItem(item *ListItem) (h string)

RenderItem is called by the framework to render a single item in the list.

func (*CheckboxList) RenderItems added in v0.4.0

func (l *CheckboxList) RenderItems(items []*ListItem) string

func (*CheckboxList) Serialize added in v0.3.0

func (l *CheckboxList) Serialize(e page.Encoder) (err error)

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) UpdateFormValues

func (l *CheckboxList) UpdateFormValues(ctx *page.Context)

UpdateFormValues is used by the framework to cause the control to retrieve its values from the form

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 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

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 []*ListItem) string
	RenderItem(item *ListItem) 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) ApplyFormat added in v0.3.0

func (c *ColumnBase) ApplyFormat(data interface{}) string

ApplyFormat is used by table columns to apply the given fmt.Sprintf and time.Format strings to the data. It is exported to allow custom cell texters to use it.

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) CellData added in v0.3.0

func (c *ColumnBase) CellData(ctx context.Context, row int, col int, data interface{}) interface{}

func (*ColumnBase) CellText

func (c *ColumnBase) CellText(ctx context.Context, row int, col int, data interface{}) string

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) Deserialize added in v0.3.0

func (c *ColumnBase) Deserialize(dec page.Decoder) (err error)

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

func (c *ColumnBase) FooterCellHtml(ctx context.Context, row int, col int) string

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

func (c *ColumnBase) HeaderCellHtml(ctx context.Context, row int, col int) (h string)

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) ID

func (c *ColumnBase) ID() string

ID returns the id of the column

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) Restore added in v0.3.0

func (c *ColumnBase) Restore(parentTable TableI)

func (*ColumnBase) Serialize added in v0.3.0

func (c *ColumnBase) Serialize(e page.Encoder) (err error)

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) SetFormat added in v0.3.0

func (c *ColumnBase) SetFormat(format string) ColumnI

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

SetSortable 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) SetTimeFormat added in v0.3.0

func (c *ColumnBase) SetTimeFormat(timeFormat string) ColumnI

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 ColumnCreator interface {
	Create(context.Context, TableI) ColumnI
}

func Columns added in v0.2.3

func Columns(cols ...ColumnCreator) []ColumnCreator

Columns is a helper to return a group of columns

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)
	DrawFooterCell(ctx context.Context, row int, col int, count int, 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
	CellData(ctx context.Context, row int, col int, data interface{}) interface{}
	HeaderCellHtml(ctx context.Context, row int, col int) string
	FooterCellHtml(ctx context.Context, row int, col int) string
	HeaderAttributes(ctx context.Context, row int, col int) html.Attributes
	FooterAttributes(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
	SetFooterTexter(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)
	Serialize(e page.Encoder) (err error)
	Deserialize(dec page.Decoder) (err error)
	Restore(parentTable TableI)
	// 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.Attributes
	// 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.Attributes
	// FooterAttributes is a slice of attributes to apply to each row of the footer cells in the column.
	// Each item in the slice corresponds to a row of the footer.
	FooterAttributes []html.Attributes
	// 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.Attributes
	// 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{}
	// FooterTexter is an object that will provide the text of the footer cells. This can be either an
	// 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
	// Format is a format string applied to the data using fmt.Sprintf
	Format string
	// TimeFormat is a format string applied specifically to time data using time.Format
	TimeFormat string
}

ColumnOptions are settings you can apply to all types of table columns

type DataBinder added in v0.3.0

type DataBinder interface {
	// A DataBinder must be a control so that we can serialize it
	ID() string
	// BindData is called by the data manager to get the data for the control during draw time
	BindData(ctx context.Context, s DataManagerI)
}

type DataManager added in v0.3.0

type DataManager struct {
	// contains filtered or unexported fields
}

DataManager is an object designed to be embedded in a control that will help manage the data binding process.

func (*DataManager) Deserialize added in v0.3.0

func (d *DataManager) Deserialize(dec page.Decoder) (err error)

func (*DataManager) HasData added in v0.3.0

func (d *DataManager) HasData() bool

func (*DataManager) HasDataProvider added in v0.3.0

func (d *DataManager) HasDataProvider() bool

func (*DataManager) LoadData added in v0.3.0

func (d *DataManager) LoadData(ctx context.Context, owner DataManagerI)

LoadData tells the data binder to load data by calling SetData on the given object. The object should be the embedder of the DataManager

func (*DataManager) RangeData added in v0.3.0

func (d *DataManager) RangeData(f func(int, interface{}) bool)

RangeData will call the given function for each item in the data. The function should return true to continue, and false to end early.

func (*DataManager) ResetData added in v0.3.0

func (d *DataManager) ResetData()

ResetData is called by controls that use a data binder to unload the data after it is used.

func (*DataManager) Serialize added in v0.3.0

func (d *DataManager) Serialize(e page.Encoder) (err error)

func (*DataManager) SetData added in v0.3.0

func (d *DataManager) SetData(data interface{})

Call SetData to set the data of a control that uses a data binder. You MUST call it with a slice of some kind of data.

func (*DataManager) SetDataProvider added in v0.3.0

func (d *DataManager) SetDataProvider(b DataBinder)

type DataManagerEmbedder added in v0.3.0

type DataManagerEmbedder interface {
	SetDataProvider(b DataBinder)
	// SetData should be passed a slice of data items
	SetData(interface{})
	LoadData(ctx context.Context, owner DataManagerI)
	ResetData()
}

DataManagerEmbedder is the interface to include in embedded control interfaces Currently go does not allow interface conflicts, but that is scheduled to change

type DataManagerI added in v0.3.0

type DataManagerI interface {
	page.ControlI
	DataManagerEmbedder
}

A DataManagerI is the interface for the owner (the embedder) of the DataManager

type DataPager

type DataPager struct {
	page.ControlBase

	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 (d *DataPager) ButtonProxy() *Proxy

func (*DataPager) CalcBunch

func (d *DataPager) CalcBunch() (pageStart, pageEnd int)

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 (d *DataPager) Deserialize(dec page.Decoder) (err error)

func (*DataPager) DrawInnerHtml

func (d *DataPager) DrawInnerHtml(ctx context.Context, buf *bytes.Buffer) (err error)

DrawInnerHtml is called by the framework to draw the control's inner html.

func (*DataPager) DrawingAttributes

func (d *DataPager) DrawingAttributes(ctx context.Context) html.Attributes

DrawingAttributes is called by the framework to add temporary attributes to the html.

func (*DataPager) Init

func (d *DataPager) Init(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) MarshalState

func (d *DataPager) MarshalState(m maps.Setter)

MarshalState is an internal function to save the state of the control

func (*DataPager) NextButtonsHtml

func (d *DataPager) NextButtonsHtml() string

NextButtonsHtml returns the html for the next buttons. Subclasses can override this to change how the next buttons are drawn.

func (*DataPager) PageButtonsHtml

func (d *DataPager) PageButtonsHtml(i int) string

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) PreRender

func (d *DataPager) PreRender(ctx context.Context, buf *bytes.Buffer) (err error)

PreRender is called by the framework to load data into the paged control just before drawing.

func (*DataPager) PreviousButtonsHtml

func (d *DataPager) PreviousButtonsHtml() string

PreviousButtonsHtml returns the html to draw the previous buttons. Subclasses can override this to change how the Previous buttons are drawn.

func (*DataPager) Serialize

func (d *DataPager) Serialize(e page.Encoder) (err error)

func (*DataPager) SetLabels

func (d *DataPager) SetLabels(previous string, next string)

SetLabels sets the previous and next labels. Translate these first.

func (*DataPager) SetMaxPageButtons

func (d *DataPager) SetMaxPageButtons(b int)

SetMaxPageButtons sets the maximum number of buttons that will be displayed in the paginator.

func (*DataPager) SetObjectNames

func (d *DataPager) SetObjectNames(singular string, plural string)

SetObjectNames sets the single and plural names of the objects that are represented in the data pager.

func (*DataPager) UnmarshalState

func (d *DataPager) UnmarshalState(m maps.Loader)

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

func (c DataPagerCreator) Create(ctx context.Context, parent page.ControlI) page.ControlI

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) Deserialize added in v0.3.0

func (d *DateTextbox) Deserialize(dec page.Decoder) (err error)

func (*DateTextbox) Format added in v0.3.0

func (d *DateTextbox) Format() string

Format returns the format string specified previously

func (*DateTextbox) Init

func (d *DateTextbox) Init(parent page.ControlI, id string)

func (*DateTextbox) Serialize added in v0.3.0

func (d *DateTextbox) Serialize(e page.Encoder) (err error)

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) UpdateFormValues added in v0.4.0

func (d *DateTextbox) UpdateFormValues(ctx *page.Context)

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.

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) Create added in v0.2.0

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
	Date() datetime.DateTime
	Format() string
}

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) Deserialize added in v0.3.0

func (s *DateTimeSpan) Deserialize(dec page.Decoder) (err error)

func (*DateTimeSpan) DrawInnerHtml

func (s *DateTimeSpan) DrawInnerHtml(ctx context.Context, buf *bytes.Buffer) error

DrawInnerHtml is called by the framework to draw the inner html of the span.

func (*DateTimeSpan) Init

func (s *DateTimeSpan) Init(parent page.ControlI, id string)

Init is called by subclasses to initialize the parent. You do not normally need to call this.

func (*DateTimeSpan) Serialize added in v0.3.0

func (s *DateTimeSpan) Serialize(e page.Encoder) (err error)

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.

type DateTimeSpanCreator added in v0.2.0

type DateTimeSpanCreator struct {
	ID     string
	Format string
	Value  datetime.DateTime
	page.ControlOptions
}

func (DateTimeSpanCreator) Create added in v0.2.0

type DateValidator

type DateValidator struct {
	Message string
}

func (DateValidator) Validate

func (v DateValidator) Validate(c page.ControlI, s string) (msg string)

type Dialog

type Dialog struct {
	Panel
	// contains filtered or unexported fields
}

A Dialog is a control the pops up in front of everything on a page, with an overlay as its background. It usually has a close box or button so that it may be closed. Dialogs start out hidden.

func GetDialog added in v0.5.0

func GetDialog(c page.ControlI, id string) *Dialog

func NewDialog

func NewDialog(parent page.ControlI, id string) *Dialog

NewDialog creates a new dialog.

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

func (d *Dialog) AddCloseButton(label string, id string)

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) ButtonBar added in v0.2.0

func (d *Dialog) ButtonBar() *Panel

func (*Dialog) CloseBox added in v0.2.0

func (d *Dialog) CloseBox() *Button

func (*Dialog) Deserialize added in v0.3.0

func (d *Dialog) Deserialize(dec page.Decoder) (err error)

func (*Dialog) DrawInnerHtml added in v0.5.0

func (d *Dialog) DrawInnerHtml(ctx context.Context, buf *bytes.Buffer) (err error)

func (*Dialog) DrawTemplate

func (d *Dialog) DrawTemplate(ctx context.Context, buf *bytes.Buffer) (err error)

func (*Dialog) DrawingAttributes

func (d *Dialog) DrawingAttributes(ctx context.Context) html.Attributes

DrawingAttributes is called by the framework to set temporary attributes just before drawing.

func (*Dialog) Hide added in v0.5.0

func (d *Dialog) Hide()

Hide will hide the dialog. The dialog will still be part of the form, just in a hidden state.

func (*Dialog) Init

func (d *Dialog) Init(parent page.ControlI, id string)

Init is called by subclasses of the dialog.

func (*Dialog) RemoveAllButtons

func (d *Dialog) RemoveAllButtons()

RemoveAllButtons removes all the buttons from the dialog

func (*Dialog) RemoveButton

func (d *Dialog) RemoveButton(id string)

RemoveButton removes the given button from the dialog

func (*Dialog) Serialize added in v0.3.0

func (d *Dialog) Serialize(e page.Encoder) (err error)

func (*Dialog) SetButtonStyles

func (d *Dialog) SetButtonStyles(id string, a html.Style)

SetButtonStyle sets css styles on a button that is already in the dialog

func (*Dialog) SetButtonVisible

func (d *Dialog) SetButtonVisible(id string, visible bool)

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

func (d *Dialog) SetHasCloseBox(h bool)

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) SetTitle

func (d *Dialog) SetTitle(t string)

SetTitle sets the title of the dialog

func (*Dialog) Show added in v0.5.0

func (d *Dialog) Show()

Show will show the dialog.

func (*Dialog) Title

func (d *Dialog) Title() string

Title returns the title of the dialog

func (*Dialog) TitleBar added in v0.2.0

func (d *Dialog) TitleBar() *Panel

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)
	Show()
	Hide()
}

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

func Alert(form page.FormI, message string, buttons interface{}) DialogI

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) Deserialize added in v0.3.0

func (t *EmailTextbox) Deserialize(dec page.Decoder) (err error)

func (*EmailTextbox) Init

func (t *EmailTextbox) Init(parent page.ControlI, id string)

func (*EmailTextbox) Serialize added in v0.3.0

func (t *EmailTextbox) Serialize(e page.Encoder) (err error)

func (*EmailTextbox) SetMaxItemCount added in v0.2.0

func (t *EmailTextbox) SetMaxItemCount(max int) EmailTextboxI

func (*EmailTextbox) UpdateFormValues

func (t *EmailTextbox) UpdateFormValues(ctx *page.Context)

UpdateFormValues is used by the framework to cause the control to retrieve its values from the form

func (*EmailTextbox) Validate

func (t *EmailTextbox) Validate(ctx context.Context) bool

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) Create added in v0.2.0

func (EmailTextboxCreator) Init added in v0.2.0

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

func GetFieldset(c page.ControlI, id string) *Fieldset

GetFieldset is a convenience method to return the panel with the given id from the page.

func NewFieldset

func NewFieldset(parent page.ControlI, id string) *Fieldset

NewFieldset creates a new Fieldset.

func (*Fieldset) DrawTag

func (c *Fieldset) DrawTag(ctx context.Context) string

DrawTag is called by the framework.

func (*Fieldset) DrawingAttributes

func (c *Fieldset) DrawingAttributes(ctx context.Context) html.Attributes

DrawingAttributes is called by the framework.

func (*Fieldset) Init

func (c *Fieldset) Init(parent page.ControlI, id string)

Init is called by subclasses of Fieldset.

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.

func (FieldsetCreator) Create added in v0.2.0

func (c FieldsetCreator) Create(ctx context.Context, parent page.ControlI) page.ControlI

Create is called by the framework to create the panel. You do not normally need to call this.

type FieldsetI

type FieldsetI interface {
	PanelI
}

type FloatLimit added in v0.2.0

type FloatLimit struct {
	Value          float64
	InvalidMessage string
}

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(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

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
}

func (FloatValidator) Validate

func (v FloatValidator) Validate(c page.ControlI, s string) (msg string)

type FormBase

type FormBase struct {
	page.FormBase
}

The FormBase is the control that all Form objects should include, and is the master container for all other goradd controls.

func (*FormBase) Action

func (f *FormBase) Action(ctx context.Context, a page.ActionParams)

func (*FormBase) Init

func (f *FormBase) Init(ctx context.Context, id string)

Init initializes the FormBase. Call this before adding other controls.

type FormFieldWrapper added in v0.2.0

type FormFieldWrapper struct {
	page.ControlBase

	// 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) ChildValidationChanged added in v0.2.5

func (c *FormFieldWrapper) ChildValidationChanged()

func (*FormFieldWrapper) Deserialize added in v0.3.0

func (c *FormFieldWrapper) Deserialize(dec page.Decoder) (err error)

func (*FormFieldWrapper) DrawTag added in v0.4.0

func (c *FormFieldWrapper) DrawTag(ctx context.Context) string

func (*FormFieldWrapper) DrawingAttributes added in v0.4.0

func (c *FormFieldWrapper) DrawingAttributes(ctx context.Context) html.Attributes

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(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) Serialize added in v0.3.0

func (c *FormFieldWrapper) Serialize(e page.Encoder) (err error)

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

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.Attributes
	// ErrorAttributes are additional attributes to add to the tag that displays the error.
	ErrorAttributes html.Attributes
	// InstructionAttributes are additional attributes to add to the tag that displays the instructions.
	InstructionAttributes html.Attributes
	// 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

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

type IDSetter

type IDSetter interface {
	SetID(id string)
}

IDSetter is an interface for an item that sets an id.

type IDer

type IDer interface {
	ID() string
}

IDer is an object that can embed a list.

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.

func (IdSlice) Len

func (p IdSlice) Len() int

func (IdSlice) Less

func (p IdSlice) Less(i, j int) bool

func (IdSlice) Swap

func (p IdSlice) Swap(i, j int)

type Image

type Image struct {
	page.ControlBase
	// contains filtered or unexported fields
}

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

func GetImage(c page.ControlI, id string) *Image

GetImage is a convenience method to return the button with the given id from the page.

func NewImage

func NewImage(parent page.ControlI, id string) *Image

NewImage creates a new image.

func (*Image) Alt

func (i *Image) Alt() string

Alt returns the text that will be used for the alt tag.

func (*Image) Data

func (i *Image) Data() []byte

Data returns the data of the image if provided.

func (*Image) Deserialize added in v0.3.0

func (i *Image) Deserialize(dec page.Decoder) (err error)

func (*Image) DrawingAttributes

func (i *Image) DrawingAttributes(ctx context.Context) html.Attributes

DrawingAttributes is called by the framework.

func (*Image) Height

func (i *Image) Height() int

Height returns the number that will be used in the height attribute.

func (*Image) Init

func (i *Image) Init(parent page.ControlI, id string)

Init is called by subclasses. Normally you will not call this directly.

func (*Image) Serialize added in v0.3.0

func (i *Image) Serialize(e page.Encoder) (err error)

func (*Image) SetAlt

func (i *Image) SetAlt(alt string) ImageI

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) SetData

func (i *Image) SetData(data []byte) ImageI

SetData sets the raw data of the image.

func (*Image) SetHeight

func (i *Image) SetHeight(height int) ImageI

SetHeight sets the height attribute.

func (*Image) SetMimeType

func (i *Image) SetMimeType(typ string) ImageI

Set the MIME type for the data, (jpeg, gif, png, etc.)

func (*Image) SetSrc

func (i *Image) SetSrc(src string) ImageI

SetSrc sets the src attribute.

func (*Image) SetWidth

func (i *Image) SetWidth(width int) ImageI

SetWidth sets the width attribute.

func (*Image) Src

func (i *Image) Src() string

Src returns the src attribute

func (*Image) Width

func (i *Image) Width() int

Width returns the number that will be used as the width of the image

type ImageCapture

type ImageCapture struct {
	Panel

	ErrTextID string
	// contains filtered or unexported fields
}

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) Deserialize added in v0.3.0

func (i *ImageCapture) Deserialize(dec page.Decoder) (err error)

func (*ImageCapture) DrawingAttributes

func (i *ImageCapture) DrawingAttributes(ctx context.Context) html.Attributes

DrawingAttributes is called by the framework.

func (*ImageCapture) Init

func (i *ImageCapture) Init(parent page.ControlI, id string)

Init is called by subclasses.

func (*ImageCapture) PutCustomScript

func (i *ImageCapture) PutCustomScript(ctx context.Context, response *page.Response)

PutCustomScript is called by the framework.

func (*ImageCapture) Serialize added in v0.3.0

func (i *ImageCapture) Serialize(e page.Encoder) (err error)

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. ControlBase 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) UpdateFormValues

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

func (ImageCaptureCreator) 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.

type ImageCaptureI

type ImageCaptureI interface {
	page.ControlI
}

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

func (ImageCreator) Create added in v0.2.0

func (c ImageCreator) Create(ctx context.Context, parent page.ControlI) page.ControlI

Create is called by the framework to create a new control from the Creator. You do not normally need to call this.

func (ImageCreator) Init added in v0.2.0

func (c ImageCreator) Init(ctx context.Context, ctrl ImageI)

Init is called by implementations of Images to initialize a control with the creator. You do not normally need to call this.

type ImageI

type ImageI interface {
	page.ControlI
	SetSrc(src string) ImageI
	SetAlt(alt string) ImageI
	SetWidth(width int) ImageI
	SetHeight(height int) ImageI
	SetMimeType(typ string) ImageI
	SetData(data []byte) ImageI
}

type IntValidator

type IntValidator struct {
	Message string
}

func (IntValidator) Validate

func (v IntValidator) Validate(c page.ControlI, s string) (msg string)

type IntegerLimit added in v0.2.0

type IntegerLimit struct {
	Value          int
	InvalidMessage string
}

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(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

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 ItemIDer

type ItemIDer interface {
	ID() string
	String() string
}

ItemIDer is an interface to a listable object that matches orm objects

type ItemList

type ItemList struct {
	// contains filtered or unexported fields
}

ItemList manages a list of *ListItem 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.

Controls that embed this must implement the Serialize and Deserialize methods to call both the base ControlBase's Serialize and Deserialize methods, and the ones here.

func NewItemList

func NewItemList(owner IDer) ItemList

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

func (l *ItemList) AddItem(label string, value ...string) *ListItem

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

func (l *ItemList) AddItemAt(index int, label string, value ...string)

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

func (l *ItemList) AddListItemAt(index int, item *ListItem)

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 *ListItem, ItemLister, ItemIDer, Labeler or Stringer types. This function can accept one or more lists of items, or single items

func (*ItemList) Clear

func (l *ItemList) Clear()

Clear removes all the items from the list.

func (*ItemList) Deserialize added in v0.3.0

func (l *ItemList) Deserialize(dec page.Decoder) (err error)

func (*ItemList) GetItem

func (l *ItemList) GetItem(id string) (foundItem *ListItem)

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) GetItemAt

func (l *ItemList) GetItemAt(index int) *ListItem

GetItemAt retrieves an item by index.

func (*ItemList) GetItemByValue

func (l *ItemList) GetItemByValue(value string) (id string, foundItem *ListItem)

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

func (l *ItemList) Len() int

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

func (l *ItemList) ListItems() []*ListItem

ListItems returns a slice of the *ListItem items, in the order they were added or arranged.

func (*ItemList) RemoveItemAt added in v0.0.3

func (l *ItemList) RemoveItemAt(index int)

RemoveItemAt removes an item at the given index.

func (*ItemList) Serialize added in v0.3.0

func (l *ItemList) Serialize(e page.Encoder) (err error)

type ItemListI

type ItemListI interface {
	AddItem(label string, value ...string) *ListItem
	AddItemAt(index int, label string, value ...string)
	AddListItemAt(index int, item *ListItem)
	AddListItems(items ...interface{})
	GetItemAt(index int) *ListItem
	ListItems() []*ListItem
	Clear()
	RemoveItemAt(index int)
	Len() int
	GetItem(id string) (foundItem *ListItem)
	GetItemByValue(value string) (id string, foundItem *ListItem)
	// 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 Labeler

type Labeler 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

func NewItemFromItemIDer(i ItemIDer) *ListItem

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

func NewItemFromLabeler(i Labeler) *ListItem

NewItemFromLabeler creates a new item from any object that has just a Label method.

func NewItemFromStringer

func NewItemFromStringer(i fmt.Stringer) *ListItem

NewItemFromStringer creates a new item from any object that has just a String method. The label and value will be the same.

func NewListItem

func NewListItem(label string, value ...string) *ListItem

NewListItem creates a new item for a list. Specify an empty string for an item that represents no selection.

func (*ListItem) Anchor

func (i *ListItem) Anchor() string

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) Deserialize added in v0.3.0

func (i *ListItem) Deserialize(dec page.Decoder) (err error)

func (*ListItem) Disabled

func (i *ListItem) Disabled() bool

func (*ListItem) HasChildItems

func (i *ListItem) HasChildItems() bool

func (*ListItem) ID

func (i *ListItem) ID() string

func (*ListItem) IntValue

func (i *ListItem) IntValue() int

func (*ListItem) IsDivider

func (i *ListItem) IsDivider() bool

func (*ListItem) IsEmptyValue added in v0.0.3

func (i *ListItem) IsEmptyValue() bool

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) Label

func (i *ListItem) Label() string

func (*ListItem) RenderLabel

func (i *ListItem) RenderLabel() (h string)

func (*ListItem) Serialize added in v0.3.0

func (i *ListItem) Serialize(e page.Encoder) (err error)

func (*ListItem) SetAnchor

func (i *ListItem) SetAnchor(a string)

func (*ListItem) SetDisabled

func (i *ListItem) SetDisabled(d bool)

func (*ListItem) SetID

func (i *ListItem) SetID(id string)

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 (i *ListItem) SetIsDivider(d bool)

func (*ListItem) SetLabel

func (i *ListItem) SetLabel(l string)

func (*ListItem) SetShouldEscapeLabel

func (i *ListItem) SetShouldEscapeLabel(e bool) *ListItem

func (*ListItem) SetValue

func (i *ListItem) SetValue(v string) *ListItem

func (*ListItem) Value

func (i *ListItem) Value() string

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.

func (ListValue) Label added in v0.0.3

func (l ListValue) Label() string

func (ListValue) Value added in v0.0.3

func (l ListValue) Value() interface{}

type MaxFloatValidator

type MaxFloatValidator struct {
	MaxValue float64
	Message  string
}

func (MaxFloatValidator) Validate

func (v MaxFloatValidator) Validate(c page.ControlI, s string) (msg string)

type MaxIntValidator

type MaxIntValidator struct {
	MaxValue int
	Message  string
}

func (MaxIntValidator) Validate

func (v MaxIntValidator) Validate(c page.ControlI, s string) (msg string)

type MaxLengthValidator

type MaxLengthValidator struct {
	Length  int
	Message string
}

MaxLengthValidator is a Validater to test that the user did not enter too many characters.

func (MaxLengthValidator) Validate

func (v MaxLengthValidator) Validate(c page.ControlI, s string) (msg string)

Validate runs the Validate logic to validate the control value.

type MinFloatValidator

type MinFloatValidator struct {
	MinValue float64
	Message  string
}

func (MinFloatValidator) Validate

func (v MinFloatValidator) Validate(c page.ControlI, s string) (msg string)

type MinIntValidator

type MinIntValidator struct {
	MinValue int
	Message  string
}

func (MinIntValidator) Validate

func (v MinIntValidator) Validate(c page.ControlI, s string) (msg string)

type MinLengthValidator

type MinLengthValidator struct {
	Length  int
	Message string
}

MinLenghtValidator is a validator that checks that the user has entered a minimum length. It is set up automatically by calling SetMinValue.

func (MinLengthValidator) Validate

func (v MinLengthValidator) Validate(c page.ControlI, s string) (msg string)

Validate runs the Validate logic to validate the control value.

type MockForm added in v0.3.0

type MockForm struct {
	FormBase
}

func NewMockForm added in v0.0.3

func NewMockForm() *MockForm

NewMockForm creates a form that should be used as a parent of a control when unit testing the control.

type MultiselectList

type MultiselectList struct {
	page.ControlBase
	ItemList
	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) Deserialize added in v0.3.0

func (l *MultiselectList) Deserialize(dec page.Decoder) (err error)

func (*MultiselectList) DrawInnerHtml

func (l *MultiselectList) DrawInnerHtml(ctx context.Context, buf *bytes.Buffer) (err error)

func (*MultiselectList) DrawTag added in v0.4.0

func (l *MultiselectList) DrawTag(ctx context.Context) string

func (*MultiselectList) DrawingAttributes

func (l *MultiselectList) DrawingAttributes(ctx context.Context) 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) Init

func (l *MultiselectList) Init(parent page.ControlI, id string)

func (*MultiselectList) IsValueSelected added in v0.5.0

func (l *MultiselectList) IsValueSelected(v string) bool

func (*MultiselectList) MarshalState

func (l *MultiselectList) MarshalState(m maps.Setter)

MarshalState is an internal function to save the state of the control

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() []*ListItem

func (*MultiselectList) SelectedLabels

func (l *MultiselectList) SelectedLabels() []string

func (*MultiselectList) SelectedValues

func (l *MultiselectList) SelectedValues() []string

func (*MultiselectList) Serialize added in v0.3.0

func (l *MultiselectList) Serialize(e page.Encoder) (err error)

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) SetSelectedValueNoRefresh added in v0.5.0

func (l *MultiselectList) SetSelectedValueNoRefresh(value string, on bool)

func (*MultiselectList) SetSelectedValues added in v0.5.0

func (l *MultiselectList) SetSelectedValues(ids []string)

SetSelectedValues 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) SetSelectedValuesNoRefresh added in v0.5.0

func (l *MultiselectList) SetSelectedValuesNoRefresh(values []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) UnmarshalState

func (l *MultiselectList) UnmarshalState(m maps.Loader)

UnmarshalState is an internal function to restore the state of the control

func (*MultiselectList) UpdateFormValues

func (l *MultiselectList) UpdateFormValues(ctx *page.Context)

UpdateFormValues is used by the framework to cause the control to retrieve its values from the form

func (*MultiselectList) Validate

func (l *MultiselectList) Validate(ctx context.Context) bool

func (*MultiselectList) Value

func (l *MultiselectList) Value() interface{}

Value implements the Valuer interface for general purpose value getting and setting

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 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
}

func (MultiselectListCreator) Create added in v0.2.0

type MultiselectListI

type MultiselectListI interface {
	page.ControlI
	ItemListI
	DataManagerEmbedder
}

type On added in v0.2.0

type On struct {
	Event  *page.Event
	Action action.ActionI
}

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) DrawInnerHtml

func (l *OrderedList) DrawInnerHtml(ctx context.Context, buf *bytes.Buffer) (err error)

func (*OrderedList) Init

func (l *OrderedList) Init(parent page.ControlI, id string)

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.

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 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 ControlBase controllable by a data pager. All embedders of a PagedControl MUST implement the Serialize and Deserialize methods so that the base ControlBase versions of these functions will get called.

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) Deserialize added in v0.3.0

func (c *PagedControl) Deserialize(dec page.Decoder) (err error)

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) Serialize added in v0.3.0

func (c *PagedControl) Serialize(e page.Encoder) (err error)

Serialize encodes the PagedControl data for serialization. Note that all control implementations that use a PagedControl MUST create their own Serialize method, call the base ControlBase's version first, and then call this Serialize method.

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 {
	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

func (*PagedTable) Deserialize added in v0.3.0

func (t *PagedTable) Deserialize(dec page.Decoder) (err error)

func (*PagedTable) Init added in v0.2.0

func (t *PagedTable) Init(parent page.ControlI, id string)

func (*PagedTable) Serialize added in v0.3.0

func (t *PagedTable) Serialize(e page.Encoder) (err error)

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 is the number of footer rows.
	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 returns the attributes to be used in a footer cell. It can be either a control id or a TableFooterRowAttributer.
	FooterRowStyler TableFooterRowAttributer
	// FooterRowStylerID is a control id for the control that will be the FooterRowStyler of the table.
	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 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
	OnCellClick      action.CallbackActionI
	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

func (c PagedTableCreator) Create(ctx context.Context, parent page.ControlI) page.ControlI

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

type Panel struct {
	page.ControlBase
}

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

func GetPanel(c page.ControlI, id string) *Panel

GetPanel is a convenience method to return the panel with the given id from the page.

func NewPanel

func NewPanel(parent page.ControlI, id string) *Panel

func (*Panel) DrawingAttributes

func (c *Panel) DrawingAttributes(ctx context.Context) html.Attributes

func (*Panel) Init

func (c *Panel) Init(parent page.ControlI, id string)

func (*Panel) SetValue added in v0.2.0

func (c *Panel) SetValue(v interface{}) page.ControlI

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.

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.

func (PanelCreator) Create added in v0.2.0

func (c PanelCreator) Create(ctx context.Context, parent page.ControlI) page.ControlI

Create is called by the framework to create the panel. You do not normally need to call this.

type PanelI

type PanelI interface {
	page.ControlI
}

type PrimaryKeyer

type PrimaryKeyer interface {
	PrimaryKey() string
}

PrimaryKeyer is an interface that is often implemented by model objects.

type Proxy

type Proxy struct {
	page.ControlBase
}

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

func GetProxy(c page.ControlI, id string) *Proxy

GetProxy is a convenience method to return the button with the given id from the page.

func NewProxy

func NewProxy(parent page.ControlI, id string) *Proxy

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

func (p *Proxy) Draw(ctx context.Context, buf *bytes.Buffer) (err error)

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) Init

func (p *Proxy) Init(parent page.ControlI, id string)

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

func (p *Proxy) OnSubmit(action action.ActionI) page.ControlI

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.

func (*Proxy) TagHtml

func (p *Proxy) TagHtml(label string,
	actionValue string,
	attributes html.Attributes,
	tag string,
	rawHtml bool,
) string

TagHtml lets you customize the tag that will be used to embed the proxy.

func (*Proxy) WrapEvent

func (p *Proxy) WrapEvent(eventName string, selector string, eventJs string, options map[string]interface{}) string

WrapEvent is an internal function to allow the control to customize its treatment of event processing.

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
}

func (ProxyCreator) Create added in v0.2.0

func (c ProxyCreator) Create(ctx context.Context, parent page.ControlI) page.ControlI

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(action action.ActionI) *page.Event
}

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) Deserialize added in v0.3.0

func (l *RadioButton) Deserialize(dec page.Decoder) (err error)

func (*RadioButton) DrawingAttributes

func (c *RadioButton) DrawingAttributes(ctx context.Context) html.Attributes

DrawingAttributes is called by the framework to create temporary attributes for the input tag.

func (*RadioButton) Group

func (c *RadioButton) Group() string

Group returns the name of the group that the control belongs to.

func (*RadioButton) Serialize added in v0.3.0

func (l *RadioButton) Serialize(e page.Encoder) (err error)

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) UpdateFormValues

func (c *RadioButton) UpdateFormValues(ctx *page.Context)

UpdateFormValues is used by the framework to cause the control to retrieve its values from the form

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.Attributes
	// 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
}

func (RadioButtonCreator) 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.

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

func GetRadioList(c page.ControlI, id string) *RadioList

GetRadioList is a convenience method to return the control with the given id from the page.

func NewRadioList

func NewRadioList(parent page.ControlI, id string) *RadioList

NewRadioList creates a new RadioList control.

func (*RadioList) ColumnCount added in v0.0.3

func (l *RadioList) ColumnCount() int

ColumnCount returns the current column count.

func (*RadioList) Deserialize added in v0.3.0

func (l *RadioList) Deserialize(dec page.Decoder) (err error)

func (*RadioList) DrawInnerHtml added in v0.4.0

func (l *RadioList) DrawInnerHtml(ctx context.Context, buf *bytes.Buffer) (err error)

DrawInnerHtml is called by the framework to draw the contents of the list.

func (*RadioList) DrawingAttributes

func (l *RadioList) DrawingAttributes(ctx context.Context) 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) Init

func (l *RadioList) Init(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) RenderItem

func (l *RadioList) RenderItem(item *ListItem) (h string)

RenderItem is called by the framework to render a single item in the list.

func (*RadioList) RenderItems added in v0.4.0

func (l *RadioList) RenderItems(items []*ListItem) string

func (*RadioList) Serialize added in v0.3.0

func (l *RadioList) Serialize(e page.Encoder) (err error)

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) UpdateFormValues

func (l *RadioList) UpdateFormValues(ctx *page.Context)

UpdateFormValues is used by the framework to cause the control to retrieve its values from the form

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 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

func (c RadioListCreator) Create(ctx context.Context, parent page.ControlI) page.ControlI

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 []*ListItem) string
	RenderItem(item *ListItem) string
}

type Repeater added in v0.2.3

type Repeater struct {
	page.ControlBase
	PagedControl
	DataManager
	// contains filtered or unexported fields
}

func GetRepeater added in v0.2.3

func GetRepeater(c page.ControlI, id string) *Repeater

GetRepeater is a convenience method to return the repeater with the given id from the page.

func NewRepeater added in v0.2.3

func NewRepeater(parent page.ControlI, id string) *Repeater

NewTable creates a new table

func (*Repeater) Deserialize added in v0.3.0

func (r *Repeater) Deserialize(dec page.Decoder) (err error)

func (*Repeater) DrawInnerHtml added in v0.4.0

func (r *Repeater) DrawInnerHtml(ctx context.Context, buf *bytes.Buffer) (err error)

DrawInnerHtml is an override to draw the individual items of the repeater.

func (*Repeater) DrawItem added in v0.2.3

func (r *Repeater) DrawItem(ctx context.Context, i int, data interface{}, buf *bytes.Buffer) (err error)

func (*Repeater) DrawTag added in v0.4.0

func (r *Repeater) DrawTag(ctx context.Context) string

DrawTag is called by the framework to draw the tag. The Repeater 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 (*Repeater) DrawingAttributes added in v0.4.0

func (r *Repeater) DrawingAttributes(ctx context.Context) 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 (*Repeater) Init added in v0.2.3

func (r *Repeater) Init(parent page.ControlI, id string)

Init is an internal function that enables the object-oriented pattern of calling virtual functions used by the goradd controls.

func (*Repeater) Restore added in v0.3.0

func (r *Repeater) Restore()

func (*Repeater) Serialize added in v0.3.0

func (r *Repeater) Serialize(e page.Encoder) (err error)

func (*Repeater) SetItemHtmler added in v0.2.3

func (r *Repeater) SetItemHtmler(h RepeaterHtmler) RepeaterI

SetItemHtmler sets the htmler that provides the html for each item in the repeater.

type RepeaterCreator added in v0.2.3

type RepeaterCreator struct {
	// ID is the control id
	ID string
	// ItemHtmler is the object that provides the html for each item
	ItemHtmler RepeaterHtmler
	// DataProvider is the data binder for the table. It can be either a control id or a DataBinder
	DataProvider 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{}
	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 (RepeaterCreator) Create added in v0.2.3

func (c RepeaterCreator) Create(ctx context.Context, parent page.ControlI) page.ControlI

Create is called by the framework to create a new control from the Creator. You do not normally need to call this.

func (RepeaterCreator) Init added in v0.2.3

func (c RepeaterCreator) Init(ctx context.Context, ctrl RepeaterI)

type RepeaterHtmler added in v0.2.3

type RepeaterHtmler interface {
	RepeaterHtml(ctx context.Context, r RepeaterI, i int, data interface{}, buf *bytes.Buffer) error
}

type RepeaterI added in v0.2.3

type RepeaterI interface {
	PagedControlI
	DrawItem(ctx context.Context, i int, data interface{}, buf *bytes.Buffer) (err error)
	SetItemHtmler(h RepeaterHtmler) RepeaterI
}

type SelectList

type SelectList struct {
	page.ControlBase
	ItemList
	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 *ListItem 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) Deserialize added in v0.3.0

func (l *SelectList) Deserialize(dec page.Decoder) (err error)

func (*SelectList) DrawInnerHtml

func (l *SelectList) DrawInnerHtml(ctx context.Context, buf *bytes.Buffer) (err error)

DrawInnerHtml is called by the framework during drawing of the control to draw the inner html of the control

func (*SelectList) DrawTag added in v0.4.0

func (l *SelectList) DrawTag(ctx context.Context) string

func (*SelectList) DrawingAttributes

func (l *SelectList) DrawingAttributes(ctx context.Context) 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) Init

func (l *SelectList) Init(parent page.ControlI, id string)

Init is called by subclasses.

func (*SelectList) IntValue

func (l *SelectList) IntValue() int

IntValue returns the select value as an integer.

func (*SelectList) MarshalState

func (l *SelectList) MarshalState(m maps.Setter)

MarshalState is an internal function to save the state of the control

func (*SelectList) SelectedItem

func (l *SelectList) SelectedItem() *ListItem

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) Serialize added in v0.3.0

func (l *SelectList) Serialize(e page.Encoder) (err error)

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) SetSelectedValue added in v0.5.0

func (l *SelectList) SetSelectedValue(v string)

SetSelectedValue 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) UnmarshalState

func (l *SelectList) UnmarshalState(m maps.Loader)

UnmarshalState is an internal function to restore the state of the control

func (*SelectList) UpdateFormValues

func (l *SelectList) UpdateFormValues(ctx *page.Context)

UpdateFormValues is used by the framework to cause the control to retrieve its values from the form

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

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 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 list. Often its best to load the value in a separate Load step after creating the control.
	Value string
	// OnChange is an action to take when the user changes what is selected (as in, when the javascript change event fires).
	OnChange action.ActionI
	// SaveState saves the selected value so that it is restored if the form is returned to.
	SaveState bool
	page.ControlOptions
}

func (SelectListCreator) Create added in v0.2.0

func (c SelectListCreator) Create(ctx context.Context, parent page.ControlI) page.ControlI

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
	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) Deserialize added in v0.3.0

func (t *SelectTable) Deserialize(dec page.Decoder) (err error)

func (*SelectTable) DrawingAttributes

func (t *SelectTable) DrawingAttributes(ctx context.Context) html.Attributes

func (*SelectTable) GetRowAttributes

func (t *SelectTable) GetRowAttributes(row int, data interface{}) (a html.Attributes)

func (*SelectTable) Init

func (t *SelectTable) Init(parent page.ControlI, id string)

func (*SelectTable) MarshalState

func (t *SelectTable) MarshalState(m maps.Setter)

func (*SelectTable) SelectedID

func (t *SelectTable) SelectedID() string

func (*SelectTable) Serialize added in v0.3.0

func (t *SelectTable) Serialize(e page.Encoder) (err error)

func (*SelectTable) SetSelectedID

func (t *SelectTable) SetSelectedID(id string) SelectTableI

func (*SelectTable) UnmarshalState

func (t *SelectTable) UnmarshalState(m maps.Loader)

func (*SelectTable) UpdateFormValues

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 is the number of footer rows.
	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 returns the attributes to be used in a footer cell. It can be either a control id or a TableFooterRowAttributer.
	FooterRowStyler TableFooterRowAttributer
	// FooterRowStylerID is a control id for the control that will be the FooterRowStyler of the table.
	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 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

func GetSpan(c page.ControlI, id string) *Span

GetSpan is a convenience method to return the button with the given id from the page.

func NewSpan

func NewSpan(parent page.ControlI, id string) *Span

func (*Span) DrawingAttributes

func (c *Span) DrawingAttributes(ctx context.Context) html.Attributes

func (*Span) Init

func (c *Span) Init(parent page.ControlI, id string)

type SpanCreator added in v0.2.0

type SpanCreator struct {
	ID         string
	Text       string
	TextIsHtml bool
	Children   []page.Creator
	page.ControlOptions
}

func (SpanCreator) Create added in v0.2.0

func (c SpanCreator) Create(ctx context.Context, parent page.ControlI) page.ControlI

type SpanI

type SpanI interface {
	PanelI
}

type Table

type Table struct {
	page.ControlBase
	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

func GetTable(c page.ControlI, id string) *Table

GetTable is a convenience method to return the table with the given id from the page.

func NewTable

func NewTable(parent page.ControlI, id string) *Table

NewTable creates a new table

func (*Table) AddColumn

func (t *Table) AddColumn(column ColumnI) ColumnI

AddColumn adds the given column to the end of the column list.

func (*Table) AddColumnAt

func (t *Table) AddColumnAt(column ColumnI, loc int)

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) Deserialize added in v0.3.0

func (t *Table) Deserialize(dec page.Decoder) (err error)

func (*Table) DrawCaption

func (t *Table) DrawCaption(ctx context.Context, buf *bytes.Buffer) (err error)

DrawCaption is called internally to draw the caption. Subclasses can override this to draw a custom caption.

func (*Table) DrawInnerHtml

func (t *Table) DrawInnerHtml(ctx context.Context, buf *bytes.Buffer) (err error)

DrawInnerHtml is an override to draw the meat of the table.

func (*Table) DrawTag

func (t *Table) DrawTag(ctx context.Context) string

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

func (t *Table) DrawingAttributes(ctx context.Context) 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) 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) GetColumn

func (t *Table) GetColumn(loc int) ColumnI

GetColumn returns the column at the given location

func (*Table) GetColumnByID

func (t *Table) GetColumnByID(id string) ColumnI

GetColumnByID returns the column with the given id.

func (*Table) GetColumnByTitle

func (t *Table) GetColumnByTitle(title string) ColumnI

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

func (t *Table) Init(parent page.ControlI, id string)

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

func (t *Table) MakeSortable() TableI

MakeSortable makes a table sortable. It will attach sortable events and show the header if its not shown.

func (*Table) MarshalState added in v0.4.0

func (t *Table) MarshalState(m maps.Setter)

MarshalState is an internal function to save the state of the control

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

func (t *Table) RemoveColumn(loc int)

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

func (t *Table) RemoveColumnByID(id string)

RemoveColumnByID removes the column with the given id. If the column does not exist, nothing will change.

func (*Table) RemoveColumnByTitle

func (t *Table) RemoveColumnByTitle(title string)

RemoveColumnByTitle removes the given column with the given title. If the column does not exist, nothing will change.

func (*Table) Restore added in v0.3.0

func (t *Table) Restore()

func (*Table) RowStyler

func (t *Table) RowStyler() TableRowAttributer

func (*Table) Serialize added in v0.3.0

func (t *Table) Serialize(e page.Encoder) (err error)

func (*Table) SetCaption

func (t *Table) SetCaption(caption interface{}) TableI

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

func (t *Table) SetFooterRowCount(count int) TableI

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

func (t *Table) SetHeaderRowCount(count int) TableI

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 (t *Table) SetHideIfEmpty(h bool) TableI

func (*Table) SetRenderColumnTags added in v0.2.0

func (t *Table) SetRenderColumnTags(r bool) TableI

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

func (t *Table) SetSortHistoryLimit(n int) TableI

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

func (t *Table) SortColumns() (ret []ColumnI)

SortColumns returns a slice of columns in sort order

func (*Table) UnmarshalState added in v0.4.0

func (t *Table) UnmarshalState(m maps.Loader)

UnmarshalState is an internal function to restore the state of the control

func (*Table) UpdateFormValues

func (t *Table) UpdateFormValues(ctx *page.Context)

UpdateFormValues is used by the framework to cause the control to retrieve its values from the form

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 is the number of footer rows.
	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 returns the attributes to be used in a footer cell. It can be either a control id or a TableFooterRowAttributer.
	FooterRowStyler TableFooterRowAttributer
	// FooterRowStylerID is a control id for the control that will be the FooterRowStyler of the table.
	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 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
	OnCellClick      action.ActionI
	ControlOptions   page.ControlOptions
}

TableCreator is the initialization structure for declarative creation of tables

func (TableCreator) Create added in v0.2.0

func (c TableCreator) Create(ctx context.Context, parent page.ControlI) page.ControlI

Create is called by the framework to create a new control from the Creator. You do not normally need to call this.

func (TableCreator) Init added in v0.2.0

func (c TableCreator) Init(ctx context.Context, ctrl TableI)

Init is called by implementations of Tables to initialize a base control. You do not normally need to call this.

type TableEmbedder added in v0.2.0

type TableEmbedder interface {
	SetCaption(interface{}) TableI
	DrawCaption(context.Context, *bytes.Buffer) error
	GetHeaderRowAttributes(row int) html.Attributes
	GetFooterRowAttributes(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)
	FooterCellDrawingInfo(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
	SetFooterRowCount(count int) TableI
	SetRowStyler(a TableRowAttributer) TableI
	SetHeaderRowStyler(a TableHeaderRowAttributer) TableI
	SetFooterRowStyler(a TableFooterRowAttributer) 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 {
	// TableFooterRowAttributes returns attributes to use for the particular footer row indicated
	TableFooterRowAttributes(row int) html.Attributes
}

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
	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

type Textbox struct {
	page.ControlBase
	// contains filtered or unexported fields
}

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

func GetTextbox(c page.ControlI, id string) *Textbox

GetTextbox is a convenience method to return the control with the given id from the page.

func NewTextbox

func NewTextbox(parent page.ControlI, id string) *Textbox

NewTextbox creates a new goradd textbox html widget.

func (*Textbox) Deserialize

func (t *Textbox) Deserialize(d page.Decoder) (err error)

Deserialize is used by the pagestate serializer.

func (*Textbox) DrawInnerHtml

func (t *Textbox) DrawInnerHtml(ctx context.Context, buf *bytes.Buffer) (err error)

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

func (t *Textbox) DrawingAttributes(ctx context.Context) html.Attributes

DrawingAttributes is called by the framework to retrieve the tag's private attributes at draw time.

func (*Textbox) Init

func (t *Textbox) Init(parent page.ControlI, id string)

Initializes a textbox. Normally you will not call this directly.

func (*Textbox) MarshalState

func (t *Textbox) MarshalState(m maps.Setter)

MarshalState is an internal function to save the state of the control

func (*Textbox) MaxLength

func (t *Textbox) MaxLength() int

MaxLength returns the current maximum length setting.

func (*Textbox) MinLength

func (t *Textbox) MinLength() int

MinLength returns the minimum length setting.

func (*Textbox) Placeholder

func (t *Textbox) Placeholder() string

Placeholder returns the value of the placeholder.

func (*Textbox) ResetValidators

func (t *Textbox) ResetValidators()

ResetValidators removes all validators

func (*Textbox) Sanitize

func (t *Textbox) Sanitize(s string) string

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) Serialize

func (t *Textbox) Serialize(e page.Encoder) (err error)

Serialize is used by the framework to serialize the textbox into the pagestate.

func (*Textbox) SetColumnCount

func (t *Textbox) SetColumnCount(columns int) TextboxI

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

func (t *Textbox) SetPlaceholder(s string) TextboxI

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

func (t *Textbox) SetReadOnly(r bool) TextboxI

SetReadOnly will disable editing by setting a browser attribute.

func (*Textbox) SetRowCount

func (t *Textbox) SetRowCount(rows int) TextboxI

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) SetText

func (t *Textbox) SetText(s string) page.ControlI

Set the value of the text. Returns itself for chaining.

func (*Textbox) SetType

func (t *Textbox) SetType(typ string) TextboxI

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

func (t *Textbox) SetValue(v interface{}) page.ControlI

SetValue sets the text in the textbox. This satisfies the Valuer interface.

func (*Textbox) Text

func (t *Textbox) Text() string

Text returns the text entered by the user.

func (*Textbox) UnmarshalState

func (t *Textbox) UnmarshalState(m maps.Loader)

UnmarshalState is an internal function to restore the state of the control

func (*Textbox) UpdateFormValues

func (t *Textbox) UpdateFormValues(ctx *page.Context)

UpdateFormValues is used by the framework to cause the control to retrieve its values from the form

func (*Textbox) Validate

func (t *Textbox) Validate(ctx context.Context) bool

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

func (t *Textbox) ValidateWith(v Validater)

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.

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.

func (TextboxCreator) Create added in v0.2.0

func (c TextboxCreator) Create(ctx context.Context, parent page.ControlI) page.ControlI

Create is called by the framework to create a new control from the Creator. You do not normally need to call this.

func (TextboxCreator) Init added in v0.2.0

func (c TextboxCreator) Init(ctx context.Context, ctrl TextboxI)

Init is called by implementations of Textboxes to initialize a control with the creator. You do not normally need to call this.

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.ControlBase
	ItemList
	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) Deserialize added in v0.3.0

func (l *UnorderedList) Deserialize(dec page.Decoder) (err error)

func (*UnorderedList) DrawInnerHtml

func (l *UnorderedList) DrawInnerHtml(ctx context.Context, buf *bytes.Buffer) (err error)

func (*UnorderedList) DrawTag

func (l *UnorderedList) DrawTag(ctx context.Context) string

func (*UnorderedList) DrawingAttributes

func (l *UnorderedList) DrawingAttributes(ctx context.Context) 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 (*UnorderedList) GetItemsHtml

func (l *UnorderedList) GetItemsHtml(items []*ListItem) 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) Init

func (l *UnorderedList) Init(parent page.ControlI, id string)

func (*UnorderedList) Serialize added in v0.3.0

func (l *UnorderedList) Serialize(e page.Encoder) (err error)

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. ItemLister, ItemIDer, Labeler or Stringer types are accepted. 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".

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 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

type UnorderedListI

type UnorderedListI interface {
	page.ControlI
	ItemListI
	GetItemsHtml(items []*ListItem) string
	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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL