control

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2019 License: MIT Imports: 25 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 (
	PageClick = iota + 1000
)

Variables

View Source
var DefaultMaxPagintorButtons = 10

DefaultMaxPagintorButtons is the default maximum number of buttons to display on the pager. You can change this in an individual control, too.

View Source
var DefaultPaginatorPageSize = 10

DefaultPaginatorPageSize is the default number of items that a paginated 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 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.Control
}

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 NewButton

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

NewButton creates a new standard html button

func (*Button) Init

func (b *Button) Init(self page.ControlI, 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.EventI, actions ...action.ActionI) page.EventI

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

func (*Button) OnSubmit

func (b *Button) OnSubmit(actions ...action.ActionI) page.EventI

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.

func (*Button) ΩDrawingAttributes added in v0.0.3

func (b *Button) ΩDrawingAttributes() *html.Attributes

ΩDrawingAttributes retrieves the tag's attributes at draw time. You should not normally need to call this, and the attributes are disposed of after drawing, so they are essentially read-only.

type ButtonI

type ButtonI interface {
	page.ControlI
}

type Canvas

type Canvas struct {
	page.Control
}

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 NewCanvas

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

NewCanvas creates a Canvas control

func (*Canvas) Init

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

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

func (*Canvas) ΩDrawingAttributes added in v0.0.3

func (c *Canvas) ΩDrawingAttributes() *html.Attributes

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

type CanvasI

type CanvasI interface {
	page.ControlI
}

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.

type Checkbox

type Checkbox struct {
	CheckboxBase
}

Checkbox is a basic html checkbox input form control.

func NewCheckbox

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

NewCheckbox creates a new checkbox control.

func (*Checkbox) ΩDrawingAttributes added in v0.0.3

func (c *Checkbox) ΩDrawingAttributes() *html.Attributes

ΩDrawingAttributes is called by the framework to set the temporary attributes that the control needs. Checkboxes set the grctl, name, type and value attributes automatically. You do not normally need to call this function.

func (*Checkbox) ΩUpdateFormValues added in v0.0.3

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

	// LabelMode describes where to place the label associating the text with the checkbox
	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, p *page.Page) (err error)

Deserialize is called by the framework during page state serialization.

func (*CheckboxBase) Init

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

Init initializes a checkbox base class. It is called by checkbox implementations.

func (*CheckboxBase) InputLabelAttributes

func (c *CheckboxBase) InputLabelAttributes() *html.Attributes

InputLabelAttributes 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 name wrapper. After setting attributes, be sure to call Refresh on the control if you do this during an Ajax response.

func (*CheckboxBase) Serialize

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

Serialize is called by the framework during pagestate serialization.

func (*CheckboxBase) SetChecked

func (c *CheckboxBase) SetChecked(v bool) CheckboxI

SetChecked sets the value of the checkbox. Returns itself for chaining.

func (*CheckboxBase) SetCheckedNoRefresh

func (c *CheckboxBase) SetCheckedNoRefresh(v interface{})

SetCheckedNoRefresh is used internally to update values without causing a refresh loop.

func (*CheckboxBase) SetLabelDrawingMode

func (c *CheckboxBase) SetLabelDrawingMode(m html.LabelDrawingMode)

SetLabelDrawingMode determines how the label is drawn for the checkbox.

func (*CheckboxBase) SetValue

func (c *CheckboxBase) SetValue(v interface{}) CheckboxI

SetValue sets the checked status of checkbox. The given value can be:

For True "1", "true", "TRUE", "on", "ON", 1(int), true(bool)

For False "0", "false", "FALSE", "off, "OFF", ""(empty string), 0(int), false(bool)

Other values will cause a panic.

func (*CheckboxBase) TextIsLabel

func (c *CheckboxBase) TextIsLabel() bool

TextIsLabel is called by the framework to determine that the Text of the control is used in a label tag. You do not normally need to call this unless you are creating the template for a custom control.

func (*CheckboxBase) UpdateCheckboxFormValues added in v0.0.4

func (c *CheckboxBase) UpdateCheckboxFormValues(ctx *page.Context)

UpdateCheckboxFormValues is used by subclasses of CheckboxBase to update their internal state if they are a checkbox type of control.

func (*CheckboxBase) UpdateRadioFormValues added in v0.0.4

func (c *CheckboxBase) UpdateRadioFormValues(ctx *page.Context, group string)

UpdateRadioFormValues is used by subclasses of CheckboxBase to update their internal state if they are a radioButton type of control.

func (*CheckboxBase) Value

func (c *CheckboxBase) Value() interface{}

Value returns the boolean checked status of the checkbox.

func (*CheckboxBase) ΩDrawTag added in v0.0.3

func (c *CheckboxBase) ΩDrawTag(ctx context.Context) (ctrl string)

ΩDrawTag draws the checkbox tag. This can be quite tricky. Some CSS frameworks are very particular about how checkboxes get associated with labels. The Text value of the control will become the text directly associated with the checkbox, while the Label value is only shown when drawing a checkbox with a wrapper.

func (*CheckboxBase) ΩDrawingAttributes added in v0.0.3

func (c *CheckboxBase) ΩDrawingAttributes() *html.Attributes

ΩDrawingAttributes retrieves the tag's attributes at draw time. You should not normally need to call this, and the attributes are disposed of after drawing, so they are essentially read-only.

func (*CheckboxBase) ΩGetDrawingLabelAttributes added in v0.0.3

func (c *CheckboxBase) ΩGetDrawingLabelAttributes() *html.Attributes

ΩGetDrawingLabelAttributes is called by the framework to temporarily set the attributes of the label associated with the checkbox.

func (*CheckboxBase) ΩMarshalState added in v0.0.3

func (c *CheckboxBase) ΩMarshalState(m maps.Setter)

ΩMarshalState is called by the framework to save the state of the checkbox between form views. Call SetState(true) to enable state saving.

func (*CheckboxBase) ΩUnmarshalState added in v0.0.3

func (c *CheckboxBase) ΩUnmarshalState(m maps.Loader)

ΩUnmarshalState restores the state of the checkbox if coming back to a form in the same session.

func (*CheckboxBase) ΩisSerializer

func (c *CheckboxBase) ΩisSerializer(i page.ControlI) bool

ΩisSerializer is used by the automated control serializer to determine how far down the control chain the control has to go before just calling serialize and deserialize

type 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 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) Direction

func (l *CheckboxList) Direction() LayoutDirection

Direction returns the direction of how items are spread across the columns.

func (*CheckboxList) Init

func (l *CheckboxList) Init(self CheckboxListI, parent page.ControlI, id string)

Init is called by subclasses

func (*CheckboxList) SetColumnCount

func (l *CheckboxList) SetColumnCount(columns int) *CheckboxList

SetColumnCount sets the number of columns to use to display the list. Items will be evenly distributed across the columns.

func (*CheckboxList) SetDirection

func (l *CheckboxList) SetDirection(direction LayoutDirection) *CheckboxList

SetDirection specifies how items are distributed across the columns.

func (*CheckboxList) SetIsScrolling

func (l *CheckboxList) SetIsScrolling(s bool) *CheckboxList

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) *CheckboxList

SetLabelDrawingMode indicates how labels for each of the checkboxes are drawn.

func (*CheckboxList) ΩDrawInnerHtml added in v0.0.3

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

func (l *CheckboxList) ΩDrawingAttributes() *html.Attributes

ΩDrawingAttributes retrieves the tag's attributes at draw time. You should not normally need to call this, and the attributes are disposed of after drawing, so they are essentially read-only.

func (*CheckboxList) ΩRenderItem added in v0.0.3

func (l *CheckboxList) ΩRenderItem(item ListItemI) (h string)

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

func (*CheckboxList) ΩRenderItems added in v0.0.4

func (l *CheckboxList) ΩRenderItems(items []ListItemI) string

func (*CheckboxList) ΩUpdateFormValues added in v0.0.3

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

ΩUpdateFormValues is called by the framework to tell the control to update its internal values based on the form values sent by the browser.

type CheckboxListI

type CheckboxListI interface {
	MultiselectListI
	ΩRenderItems(items []ListItemI) string
}

type ColumnBase

type ColumnBase struct {
	base.Base

	*html.Attributes // These are attributes that will appear on the 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) CellAttributes

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

CellAttributes returns the attributes of the cell. Column implementations should call this base version first before customizing more. It will use the CellStyler if one was provided.

func (*ColumnBase) CellText

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) 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(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(row int, col int) *html.Attributes

HeaderAttributes returns the attributes to use on the header cell.

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

func (c *ColumnBase) SetCellStyler(s html.Attributer)

SetCellStyler sets the CellStyler for the body cells.

func (*ColumnBase) SetCellTexter

func (c *ColumnBase) SetCellTexter(s CellTexter) ColumnI

SetCellTexter sets the CellTexter for getting the content of each body cell.

func (*ColumnBase) SetFooterTexter

func (c *ColumnBase) SetFooterTexter(s CellTexter) ColumnI

SetFooterTexter sets the CellTexter that gets the text for footer cells.

func (*ColumnBase) SetHeaderTexter

func (c *ColumnBase) SetHeaderTexter(s CellTexter) ColumnI

SetHeaderTexter sets the CellTexter that gets the text for header cells.

func (*ColumnBase) SetHidden

func (c *ColumnBase) SetHidden(h bool) ColumnI

SetHidden hides the column without removing it completely from the table.

func (*ColumnBase) SetID

func (c *ColumnBase) SetID(id string) ColumnI

SetID sets the id of the column. If you are going to provide your own id, do this as the first thing after you create a table, or the new id might not propagate through the system correctly. Note that the id in html will have the table id prepended to it. This is required so that actions can be routed to a column.

func (*ColumnBase) SetIsHtml

func (c *ColumnBase) SetIsHtml(columnIsHtml bool) ColumnI

SetIsHtml will cause the cell to treat the text it receives as html rather than raw text it should escape. Use this with extreme caution. Do not display unescaped text that might come from user input, as it could open you up to XSS attacks.

func (*ColumnBase) SetRenderAsHeader

func (c *ColumnBase) SetRenderAsHeader(r bool)

SetRenderAsHeader will cause the entire column to be output with th instead of td cells.

func (*ColumnBase) SetSortDirection

func (c *ColumnBase) SetSortDirection(d SortDirection) ColumnI

SetSortDirection is used internally to set the sort direction indicator.

func (*ColumnBase) SetSpan

func (c *ColumnBase) SetSpan(span int) ColumnI

SetSpan sets the span indicated in the column tag of the column. This is used to create colgroup tags.

func (*ColumnBase) SetTitle

func (c *ColumnBase) SetTitle(title string) ColumnI

SetTitle sets the title of the column. It returns a column reference for chaining.

func (*ColumnBase) SortDirection

func (c *ColumnBase) SortDirection() SortDirection

SortDirection returns the current sort direction.

func (*ColumnBase) Sortable

func (c *ColumnBase) Sortable() ColumnI

Sortable indicates that the column should be drawn with sort indicators.

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 ColumnI

type ColumnI interface {
	ID() string
	SetID(string) ColumnI

	ParentTable() TableI
	Title() string
	SetTitle(string) ColumnI
	Span() int
	SetSpan(int) ColumnI
	IsHidden() 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
	HeaderCellHtml(ctx context.Context, row int, col int) string
	FooterCellHtml(ctx context.Context, row int, col int) string
	HeaderAttributes(row int, col int) *html.Attributes
	FooterAttributes(row int, col int) *html.Attributes
	ColTagAttributes() *html.Attributes
	UpdateFormValues(ctx *page.Context)
	AddActions(ctrl page.ControlI)
	Action(ctx context.Context, params page.ActionParams)
	SetHeaderTexter(s CellTexter) ColumnI
	SetCellTexter(s CellTexter) ColumnI
	SetFooterTexter(s CellTexter) ColumnI
	SetCellStyler(s html.Attributer)
	IsSortable() bool
	SortDirection() SortDirection
	SetSortDirection(SortDirection) ColumnI
	Sortable() ColumnI
	SetIsHtml(columnIsHtml bool) ColumnI
	PreRender()
	MarshalState(m maps.Setter)
	UnmarshalState(m maps.Loader)
	// contains filtered or unexported methods
}

ColumnI defines the interface that all columns must support. Most of these functions are provided by the default behavior of the ColumnBase class.

type DataPager

type DataPager struct {
	page.Control

	ObjectName       string
	ObjectPluralName string
	LabelForNext     string
	LabelForPrevious string

	Proxy *Proxy
	// 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, paginatedControl PaginatedControlI) *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) 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, p *page.Page) (err error)

func (*DataPager) Init

func (d *DataPager) Init(self page.ControlI, parent page.ControlI, id string, paginatedControl PaginatedControlI)

Init is called by subclasses of a DataPager to initialize the data pager. You do not normally need to call this.

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

func (d *DataPager) PaginatedControl() PaginatedControlI

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

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

func (d *DataPager) SqlLimits() (maxRowCount, offset int)

SqlLimits returns the limits you would use in a sql database limit clause

func (*DataPager) ΩDrawInnerHtml added in v0.0.3

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

func (d *DataPager) ΩDrawingAttributes() *html.Attributes

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

func (*DataPager) ΩMarshalState added in v0.0.3

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

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

func (*DataPager) ΩPreRender added in v0.0.3

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

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

func (*DataPager) ΩUnmarshalState added in v0.0.3

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

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

func (*DataPager) ΩisSerializer

func (d *DataPager) ΩisSerializer(i page.ControlI) bool

ΩisSerializer is used by the automated control serializer to determine how far down the control chain the control has to go before just calling serialize and deserialize

type DataPagerI

type DataPagerI interface {
	page.ControlI
	PreviousButtonsHtml() string
	NextButtonsHtml() string
	PageButtonsHtml(i int) string
}

DataPagerI is the data pager interface that allows this object to call into subclasses.

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 NewDateTextbox

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

NewDateTextbox creates a new DateTextbox.

func (*DateTextbox) Date

func (d *DateTextbox) Date() datetime.DateTime

Date returns the value as a DateTime value based on the format. If a bad value was entered into the textbox, it will return an empty datetime.

func (*DateTextbox) Init

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

func (*DateTextbox) SetDate

func (d *DateTextbox) SetDate(dt datetime.DateTime)

SetDate will set the textbox to the give datetime value

func (*DateTextbox) SetFormat

func (d *DateTextbox) SetFormat(format string)

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{}) *DateTextbox

SetValue will set the DateTextbox to the given value if possible.

func (*DateTextbox) Value

func (d *DateTextbox) Value() interface{}

Value returns the value as an interface, but the underlying value will be a datetime. If a bad value was entered into the textbox, it will return an empty datetime.

func (*DateTextbox) ΩUpdateFormValues added in v0.0.3

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

type DateTimeSpan

type DateTimeSpan struct {
	Span
	// contains filtered or unexported fields
}

DateTimeSpan is a span that displays a datetime value as static text. This is a typical default control to use for a timestamp in the database.

func NewDateTimeSpan

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

NewDateTimeSpan create a new DateTimeSpan.

func (*DateTimeSpan) Init

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

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

func (*DateTimeSpan) SetDateTime

func (s *DateTimeSpan) SetDateTime(d datetime.DateTime)

SetDateTime sets the value to a datetime.DateTime.

func (*DateTimeSpan) SetFormat

func (s *DateTimeSpan) SetFormat(format string) *DateTimeSpan

SetFormat sets the format string. This should be a time.TimeFormat string described at https://golang.org/pkg/time/#Time.Format

func (*DateTimeSpan) SetValue

func (s *DateTimeSpan) SetValue(v interface{})

SetValue sets the value display. You can set the value to a datetime.DateTime, a time.Time, or a string that can be parsed by the format string.

func (*DateTimeSpan) Value

func (s *DateTimeSpan) Value() datetime.DateTime

Value returns the value as a datetime.DateTime object.

func (*DateTimeSpan) ΩDrawInnerHtml added in v0.0.3

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.

type DateValidator

type DateValidator struct {
	Message string
	// contains filtered or unexported fields
}

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
}

Our own implementation of a dialog. This works cooperatively with javascript in goradd.js to create a minimal implementation of the dialog interface.

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

func (d *Dialog) Close()

Close will hide the dialog.

func (*Dialog) DrawTemplate

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

func (*Dialog) Init

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

Init is called by subclasses of the dialog.

func (*Dialog) Open

func (d *Dialog) Open()

Open will show 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) 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) Title

func (d *Dialog) Title() string

Title returns the title of the dialog

func (*Dialog) ΩDrawingAttributes added in v0.0.3

func (d *Dialog) ΩDrawingAttributes() *html.Attributes

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

type DialogButtonOptions

type DialogButtonOptions struct {
	// Validates indicates that this button will validate the dialog
	Validates bool
	// The ConfirmationMessage string will appear with a yes/no box making sure the user wants the action.
	// This is usually used when the action could be destructive, like a Delete button.
	ConfirmationMessage string
	// PushLeft pushes this button to the left side of the dialog. Buttons are typically aligned right.
	// This is helpful to separate particular buttons from the main grouping of buttons.
	PushLeft bool
	// IsClose will set the button up to automatically close the dialog. Detect closes with the DialogCloseEvent if needed.
	// The button will not send a DialogButton event.
	IsClose bool
	// Options are additional options specific to the dialog implementation you are using.
	Options map[string]interface{}
}

DialogButtonOptions are optional additional items you can add to a dialog button.

type DialogI

type DialogI interface {
	PanelI

	SetTitle(string)
	SetDialogStyle(state DialogStyle)
	Open()
	Close()
}

DialogI defines the publicly consumable api that the goradd framework uses to interact with a dialog.

More and more CSS and javascript frameworks are coming out with their own forms of dialog, which is usually a combination of html, css and a javascript widget. goradd has many ways of potentially interacting with dialogs, but to be able to inject a dialog into the framework, we need a consistent interface for all to use.

This particular interface has been implemented in a simple default dialog and Bootstrap dialogs. As more needs arise, we can modify the interface to accommodate as many frameworks as possible.

Dialog implementations should descend from the Panel control. Dialogs should be able to be a member of a form or control object and appear with an Open call, but they should also be able to be instantiated on the fly. The framework has hooks for both, and if you are creating a dialog implementation, see the current Bootstrap implementation for more direction. Feel free to implement more than just the functions listed. These are the minimal set to allow goradd to use a dialog implementation. When possible, implementations should use the same function signatures found here to do the same work. For example, SetHasCloseBox is defined here, and in the Bootstrap Modal implementation with the same function signature, and other implementations should attempt to do the same, but it is not enforced by an interface.

func Alert

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 Text 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 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() []string

Addresses returns a slice of the individual addresses entered, stripped of any extra text entered.

func (*EmailTextbox) Init

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

func (*EmailTextbox) SetMaxCount

func (t *EmailTextbox) SetMaxCount(max int)

func (*EmailTextbox) Validate

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

func (*EmailTextbox) ΩUpdateFormValues added in v0.0.3

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

type Fieldset

type Fieldset struct {
	Panel
}

Fieldset is a Panel that is drawn with a fieldset tag. The panel's label is used as the legend tag. Fieldset's cannot have wrappers.

func NewFieldset

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

NewFieldset creates a new Fieldset.

func (*Fieldset) Init

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

Init is called by subclasses of Fieldset.

func (*Fieldset) ΩDrawTag added in v0.0.3

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

ΩDrawTag is called by the framework.

func (*Fieldset) ΩDrawingAttributes added in v0.0.3

func (c *Fieldset) ΩDrawingAttributes() *html.Attributes

ΩDrawingAttributes is called by the framework.

type FieldsetI

type FieldsetI interface {
	PanelI
}

type FloatTextbox

type FloatTextbox struct {
	Textbox
}

FloatTextbox is a text control that ensures a valid floating point number is entered in the field.

func NewFloatTextbox

func NewFloatTextbox(parent page.ControlI, id string) *FloatTextbox

func (*FloatTextbox) Float32

func (i *FloatTextbox) Float32() float32

func (*FloatTextbox) Float64

func (i *FloatTextbox) Float64() float64

func (*FloatTextbox) Init

func (i *FloatTextbox) Init(self TextboxI, parent page.ControlI, id string)

func (*FloatTextbox) SetFloat32

func (i *FloatTextbox) SetFloat32(v float32) *FloatTextbox

func (*FloatTextbox) SetFloat64

func (i *FloatTextbox) SetFloat64(v float64) *FloatTextbox

func (*FloatTextbox) SetMaxValue

func (i *FloatTextbox) SetMaxValue(maxValue float64, invalidMessage string)

func (*FloatTextbox) SetMinValue

func (i *FloatTextbox) SetMinValue(minValue float64, invalidMessage string)

func (*FloatTextbox) Value

func (i *FloatTextbox) Value() interface{}

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 NewMockForm added in v0.0.3

func NewMockForm() *FormBase

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

func (*FormBase) Action

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

func (*FormBase) Init

func (f *FormBase) Init(ctx context.Context, self page.FormI, path string, id string)

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

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

Direction 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.Control
	// 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 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) 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(self ImageI, parent page.ControlI, id string)

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

func (*Image) SetAlt

func (i *Image) SetAlt(alt string)

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)

SetData sets the raw data of the image.

func (*Image) SetHeight

func (i *Image) SetHeight(height int)

SetHeight sets the height attribute.

func (*Image) SetMimeType

func (i *Image) SetMimeType(typ string)

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

func (*Image) SetSrc

func (i *Image) SetSrc(src string)

SetSrc sets the src attribute.

func (*Image) SetWidth

func (i *Image) SetWidth(width int)

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

func (*Image) ΩDrawingAttributes added in v0.0.3

func (i *Image) ΩDrawingAttributes() *html.Attributes

ΩDrawingAttributes is called by the framework.

type ImageCapture

type ImageCapture struct {
	Panel
	Canvas             *Canvas
	CaptureButton      *Button
	SwitchCameraButton *Button

	ErrText *Panel
	// 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 NewImageCapture

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

NewImageCapture creates a new image capture panel.

func (*ImageCapture) Data

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

func (*ImageCapture) Init

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

Init is called by subclasses.

func (*ImageCapture) SetData

func (i *ImageCapture) SetData(data []byte)

SetData sets the binary picture data. The data must be in the mime type format.

func (*ImageCapture) SetMaskShape

func (i *ImageCapture) SetMaskShape(shape ImageCaptureShape)

SetMaskShape sets the masking shape for the image

func (*ImageCapture) SetMimeType

func (i *ImageCapture) SetMimeType(typ string)

func (*ImageCapture) SetPixelSize

func (i *ImageCapture) SetPixelSize(width int, height int)

SetPixelSize sets the pixel size of the image that will be returned. Control the visible size of the canvas through setting css sizes.

func (*ImageCapture) SetQuality

func (i *ImageCapture) SetQuality(quality float32)

SetQuality specifies a number between 0 and 1 used as the quality value for capturing jpegs or webp images.

func (*ImageCapture) SetZoom

func (i *ImageCapture) SetZoom(zoom int)

SetZoom zooms the camera by the given percent, i.e. 50 is 50% closer and 100 would be a 2x zoom.

func (*ImageCapture) TurnOff

func (i *ImageCapture) TurnOff()

TurnOff will turn off the camera and the image displayed in the control

func (*ImageCapture) ΩDrawingAttributes added in v0.0.3

func (i *ImageCapture) ΩDrawingAttributes() *html.Attributes

ΩDrawingAttributes is called by the framework.

func (*ImageCapture) ΩPutCustomScript added in v0.0.3

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

ΩPutCustomScript is called by the framework.

func (*ImageCapture) ΩUpdateFormValues added in v0.0.3

func (i *ImageCapture) ΩUpdateFormValues(ctx *page.Context)

ΩUpdateFormValues is called by the framework.

type ImageCaptureI

type ImageCaptureI interface {
	page.ControlI
}

type ImageCaptureShape

type ImageCaptureShape string
const (
	ImageCaptureShapeRect   ImageCaptureShape = "rect"
	ImageCaptureShapeCircle ImageCaptureShape = "circle"
)

type ImageI

type ImageI interface {
	page.ControlI
}

type IntValidator

type IntValidator struct {
	Message string
}

func (IntValidator) Validate

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

type IntegerTextbox

type IntegerTextbox struct {
	Textbox
	// contains filtered or unexported fields
}

func NewIntegerTextbox

func NewIntegerTextbox(parent page.ControlI, id string) *IntegerTextbox

func (*IntegerTextbox) Init

func (i *IntegerTextbox) Init(self TextboxI, parent page.ControlI, id string)

func (*IntegerTextbox) Int

func (i *IntegerTextbox) Int() int

func (*IntegerTextbox) Int64

func (i *IntegerTextbox) Int64() int64

func (*IntegerTextbox) SetInt

func (i *IntegerTextbox) SetInt(v int) *IntegerTextbox

func (*IntegerTextbox) SetMaxValue

func (i *IntegerTextbox) SetMaxValue(maxValue int, invalidMessage string)

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 (i *IntegerTextbox) SetMinValue(minValue int, invalidMessage string)

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 (i *IntegerTextbox) SetValue(v interface{}) *IntegerTextbox

func (*IntegerTextbox) Value

func (i *IntegerTextbox) Value() interface{}

type ItemIDer

type ItemIDer interface {
	ID() interface{}
	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 ListItemI list items. ItemList is designed to be embedded in another structure, and will turn that object into a manager of list items. ItemList will manage the id's of the items in its list, you do not have control of that, and it needs to manage those ids in order to efficiently manage the selection process.

func NewItemList

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 ...interface{}) ListItemI

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 ...interface{})

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

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

AddItemAt adds the item at the given index. If the index is negative, it counts from the end. If the index is -1 or bigger than the number of items, it adds it to the end. If the index is zero, or is negative and smaller than the negative value of the number of items, it adds to the beginning. This can be an expensive operation in a long hierarchical list, so use sparingly.

func (*ItemList) AddListItems

func (l *ItemList) AddListItems(items ...interface{})

AddListItems adds one or more objects to the end of the list. items should be a list of ListItemI, ItemLister, ItemIDer, Labeler or Stringer types. This function can accept one or more lists of items, or single items

func (*ItemList) Clear

func (l *ItemList) Clear()

Clear removes all the items from the list.

func (*ItemList) GetItem

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

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

GetItemAt retrieves an item by index.

func (*ItemList) GetItemByValue

func (l *ItemList) GetItemByValue(value interface{}) (id string, foundItem ListItemI)

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

ListItems returns a slice of the ListItemI 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.

type ItemListI

type ItemListI interface {
	AddItem(label string, value ...interface{}) ListItemI
	AddItemAt(index int, label string, value ...interface{})
	AddListItemAt(index int, item ListItemI)
	AddListItems(items ...interface{})
	GetItemAt(index int) ListItemI
	ListItems() []ListItemI
	Clear()
	RemoveItemAt(index int)
	Len() int
	GetItem(id string) (foundItem ListItemI)
	GetItemByValue(value interface{}) (id string, foundItem ListItemI)
	// contains filtered or unexported methods
}

ItemListI is the interface for all controls that display a list of ListItems.

type ItemLister

type ItemLister interface {
	Value() interface{}
	Label() string
}

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

func NewListItem

func NewListItem(label string, value ...interface{}) *ListItem

NewListItem creates a new item for a list. Specify an empty value 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) 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) 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 interface{}) *ListItem

func (*ListItem) StringValue

func (i *ListItem) StringValue() string

func (*ListItem) Value

func (i *ListItem) Value() interface{}

type ListItemI

type ListItemI interface {
	ItemListI
	Value() interface{}
	ID() string
	SetID(string)
	Label() string
	SetLabel(string)
	SetDisabled(bool)
	Disabled() bool
	SetIsDivider(bool)
	IsDivider() bool
	IntValue() int
	StringValue() string
	HasChildItems() bool
	Attributes() *html.Attributes
	Anchor() string
	SetAnchor(string)
	AnchorAttributes() *html.Attributes
	RenderLabel() string
	IsEmptyValue() bool
}

ListItemI is the interface for list items in one of the various list controls that embed the ItemList structure. It is generally used by implementations of list controls.

type ListValue added in v0.0.3

type ListValue struct {
	// L is the label
	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 MultiselectList

type MultiselectList struct {
	page.Control
	ItemList
	// 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 NewMultiselectList

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

func (*MultiselectList) Init

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

func (*MultiselectList) IsIdSelected

func (l *MultiselectList) IsIdSelected(id string) bool

func (*MultiselectList) SelectedIds

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

SelectedIds returns a list of ids sorted by id number that correspond to the selection

func (*MultiselectList) SelectedItems

func (l *MultiselectList) SelectedItems() []ListItemI

func (*MultiselectList) SelectedLabels

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

func (*MultiselectList) SelectedValues

func (l *MultiselectList) SelectedValues() []interface{}

func (*MultiselectList) SetSelectedIdNoRefresh added in v0.0.3

func (l *MultiselectList) SetSelectedIdNoRefresh(id string, value bool)

func (*MultiselectList) SetSelectedIds

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

SetSelectedIds sets the current selection to the given ids. You must ensure that the items with the ids exist, it will not attempt to make sure the items exist.

func (*MultiselectList) SetSelectedIdsNoRefresh

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

func (*MultiselectList) SetSize

func (l *MultiselectList) SetSize(size int) MultiselectListI

func (*MultiselectList) SetValue

func (l *MultiselectList) SetValue(v interface{})

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

func (*MultiselectList) Size

func (l *MultiselectList) Size() int

func (*MultiselectList) 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

func (*MultiselectList) ΩDrawInnerHtml added in v0.0.3

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

func (*MultiselectList) ΩDrawingAttributes added in v0.0.3

func (l *MultiselectList) ΩDrawingAttributes() *html.Attributes

ΩDrawingAttributes retrieves the tag's attributes at draw time. You should not normally need to call this, and the attributes are disposed of after drawing, so they are essentially read-only.

func (*MultiselectList) ΩMarshalState added in v0.0.3

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

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

func (*MultiselectList) ΩUnmarshalState added in v0.0.3

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

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

func (*MultiselectList) ΩUpdateFormValues added in v0.0.3

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

ΩUpdateFormValues is an internal function that lets us reflect the value of the selection on the web override

type MultiselectListI

type MultiselectListI interface {
	page.ControlI
	ItemListI
}

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 GetData function.

func NewOrderedList

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

NewOrderedList creates a new ordered list (ol tag).

func (*OrderedList) Init

func (l *OrderedList) Init(self page.ControlI, 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) *OrderedList

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) *OrderedList

SetStart sets the starting number for the numbers in the top level list. To set the start of a sub-list, set the "start" attribute on the list item that is the parent of the sub-list.

func (*OrderedList) ΩDrawInnerHtml added in v0.0.3

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

type PaginatedControl

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

PaginatedControl is a mixin that makes a Control controllable by a data pager

func (*PaginatedControl) AddDataPager

func (c *PaginatedControl) AddDataPager(d DataPagerI)

AddDataPager adds a data pager to the PaginatedControl. A PaginatedControl can have multiple data pagers.

func (*PaginatedControl) CalcPageCount

func (c *PaginatedControl) CalcPageCount() int

CalcPageCount will return the number of pages based on the page size and total items.

func (*PaginatedControl) PageNum

func (c *PaginatedControl) PageNum() int

PageNum returns the current page number.

func (*PaginatedControl) PageSize

func (c *PaginatedControl) PageSize() int

PageSize returns the maximum number of items that will be allowed in a page.

func (*PaginatedControl) SetPageNum

func (c *PaginatedControl) 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 (*PaginatedControl) SetPageSize

func (c *PaginatedControl) 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 (*PaginatedControl) SetTotalItems

func (c *PaginatedControl) 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 (*PaginatedControl) TotalItems

func (c *PaginatedControl) TotalItems() int

TotalItems returns the number of items that the paginator is aware of in the list it is managing.

type PaginatedControlI

type PaginatedControlI interface {
	data.DataManagerI
	SetTotalItems(uint)
	TotalItems() int
	SetPageSize(size int)
	PageSize() int
	PageNum() int
	SetPageNum(n int)
	AddDataPager(DataPagerI)
	CalcPageCount() int
	// contains filtered or unexported methods
}

PaginatedControlI is the interface that paginated controls must implement

type PaginatedTable

type PaginatedTable struct {
	Table
	PaginatedControl
}

func NewPaginatedTable

func NewPaginatedTable(parent page.ControlI, id string) *PaginatedTable

func (*PaginatedTable) Init

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

type Panel

type Panel struct {
	page.Control
}

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 NewPanel

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

func (*Panel) Init

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

func (*Panel) Value

func (c *Panel) Value() interface{}

func (*Panel) ΩDrawingAttributes added in v0.0.3

func (c *Panel) ΩDrawingAttributes() *html.Attributes

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

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 NewProxy

func NewProxy(parent page.ControlI) *Proxy

NewProxy creates a new proxy. The parent should 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,
	eventActionValue string,
	attributes *html.Attributes,
	rawHtml bool,
) string

ButtonHtml outputs the proxy as a button tag. eventActionValue 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)

func (*Proxy) LinkHtml

func (p *Proxy) LinkHtml(label string,
	actionValue string,
	attributes *html.Attributes,
) string

LinkHtml renders the proxy as a link. Generally, only do this if you are actually linking to a page. If not, use a button.

func (*Proxy) OnSubmit

func (p *Proxy) OnSubmit(actions ...action.ActionI) page.EventI

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

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

type ProxyI

type ProxyI interface {
	page.ControlI
	LinkHtml(label string,
		actionValue string,
		attributes *html.Attributes,
	) string
	TagHtml(label string,
		actionValue string,
		attributes *html.Attributes,
		tag string,
		rawHtml bool,
	) string
	ButtonHtml(label string,
		eventActionValue string,
		attributes *html.Attributes,
		rawHtml bool,
	) string
	OnSubmit(actions ...action.ActionI) page.EventI
}

type RadioButton

type RadioButton struct {
	CheckboxBase
	// contains filtered or unexported fields
}

RadioButton is a standard html radio button. You can optionally specify a group name for the radiobutton to belong to and the browser will make sure only one item in the group is selected.

func NewRadioButton

func NewRadioButton(parent page.ControlI, id string) *RadioButton

NewRadioButton creates a new radio button

func (*RadioButton) Group

func (c *RadioButton) Group() string

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

func (*RadioButton) SetChecked

func (c *RadioButton) SetChecked(v bool) RadioButtonI

SetChecked will set the checked status of this radio button to the given value.

func (*RadioButton) SetGroup

func (c *RadioButton) SetGroup(g string) RadioButtonI

SetGroup sets the name of the group that the control will belong to. Set all the radio buttons that represent a selection from a group to this same group name.

func (*RadioButton) ΩDrawingAttributes added in v0.0.3

func (c *RadioButton) ΩDrawingAttributes() *html.Attributes

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

func (*RadioButton) ΩUpdateFormValues added in v0.0.3

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

ΩUpdateFormValues is called by the framework to update the value of the control based on values sent by the browser.

type 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 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) Direction added in v0.0.4

func (l *RadioList) Direction() LayoutDirection

Direction returns the direction of how items are spread across the columns.

func (*RadioList) Init

func (l *RadioList) Init(self RadioListI, parent page.ControlI, id string)

Init is called by subclasses.

func (*RadioList) SetColumnCount added in v0.0.4

func (l *RadioList) SetColumnCount(columns int) *RadioList

SetColumnCount sets the number of columns to use to display the list. Items will be evenly distributed across the columns.

func (*RadioList) SetDirection added in v0.0.4

func (l *RadioList) SetDirection(direction LayoutDirection) *RadioList

SetDirection specifies how items are distributed across the columns.

func (*RadioList) SetIsScrolling added in v0.0.4

func (l *RadioList) SetIsScrolling(s bool) *RadioList

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) *RadioList

SetLabelDrawingMode indicates how labels for each of the checkboxes are drawn.

func (*RadioList) ΩDrawInnerHtml added in v0.0.3

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

func (l *RadioList) ΩDrawingAttributes() *html.Attributes

ΩDrawingAttributes retrieves the tag's attributes at draw time. You should not normally need to call this, and the attributes are disposed of after drawing, so they are essentially read-only.

func (*RadioList) ΩRenderItem added in v0.0.3

func (l *RadioList) ΩRenderItem(item ListItemI) (h string)

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

func (*RadioList) ΩRenderItems added in v0.0.3

func (l *RadioList) ΩRenderItems(items []ListItemI) string

func (*RadioList) ΩUpdateFormValues added in v0.0.3

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

ΩUpdateFormValues is called by the framework to tell the control to update its internal values based on the form values sent by the browser.

type RadioListI

type RadioListI interface {
	SelectListI
	ΩRenderItems(items []ListItemI) string
}

type SelectList

type SelectList struct {
	page.Control
	ItemList
	data.DataManager
	// contains filtered or unexported fields
}

SelectList is typically a dropdown list with a single selection. Items are selected by id number, and the SelectList completely controls the ids in the list. Create the list by calling AddItem or AddItems to add ListItemI objects. Or, use the embedded DataManager to load items. Set the size attribute if you want to display it as a scrolling list rather than a dropdown list.

func NewSelectList

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

NewSelectList creates a new select list

func (*SelectList) Init

func (l *SelectList) Init(self page.ControlI, 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) SelectedItem

func (l *SelectList) SelectedItem() ListItemI

SelectedItem will return the currently selected item. If no item has been selected, it will return the first item in the list, since that is what will be showing in the selection list, and will update its internal pointer to make the first item the current selection.

func (*SelectList) SelectedLabel

func (l *SelectList) SelectedLabel() string

SelectedLabel returns the label of the selected item

func (*SelectList) SetData

func (l *SelectList) SetData(data interface{})

SetData overrides the default data setter to add objects to the item list. The result is kept in memory currently. ItemLister, ItemIDer, Labeler or Stringer types. This function can accept one or more lists of items, or single items.

func (*SelectList) SetSelectedID

func (l *SelectList) SetSelectedID(id string)

SetSelectedId sets the current selection to the given id. You must ensure that the item with the id exists, it will not attempt to make sure the item exists.

func (*SelectList) SetValue

func (l *SelectList) SetValue(v interface{})

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

func (*SelectList) StringValue

func (l *SelectList) StringValue() string

StringValue returns the selected value as a string

func (*SelectList) Validate

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

Validate is called by the framework to validate the contents of the control. For a SelectList, this is typically just checking to see if something was selected if a selection is required.

func (*SelectList) Value

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

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

func (*SelectList) ΩDrawInnerHtml added in v0.0.3

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) ΩDrawingAttributes added in v0.0.3

func (l *SelectList) ΩDrawingAttributes() *html.Attributes

ΩDrawingAttributes retrieves the tag's attributes at draw time. You should not normally need to call this, and the attributes are disposed of after drawing, so they are essentially read-only.

func (*SelectList) ΩMarshalState added in v0.0.3

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

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

func (*SelectList) ΩUnmarshalState added in v0.0.3

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

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

func (*SelectList) ΩUpdateFormValues added in v0.0.3

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

ΩUpdateFormValues is an internal function that lets us reflect the value of the selection that is currently on the browser

type SelectListI added in v0.0.4

type SelectListI interface {
	page.ControlI
	ItemListI
}

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 NewSelectTable

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

func (*SelectTable) GetRowAttributes

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

func (*SelectTable) Init

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

func (*SelectTable) SelectedID

func (t *SelectTable) SelectedID() string

func (*SelectTable) SetSelectedID

func (t *SelectTable) SetSelectedID(id string)

func (*SelectTable) ΩDrawingAttributes added in v0.0.3

func (t *SelectTable) ΩDrawingAttributes() *html.Attributes

func (*SelectTable) ΩMarshalState added in v0.0.3

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

func (*SelectTable) ΩPutCustomScript added in v0.0.3

func (t *SelectTable) ΩPutCustomScript(ctx context.Context, response *page.Response)

func (*SelectTable) ΩUnmarshalState added in v0.0.3

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

func (*SelectTable) ΩUpdateFormValues added in v0.0.3

func (t *SelectTable) ΩUpdateFormValues(ctx *page.Context)

type SelectTableI

type SelectTableI interface {
	TableI
}

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 NewSpan

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

func (*Span) Init

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

func (*Span) ΩDrawingAttributes added in v0.0.3

func (c *Span) ΩDrawingAttributes() *html.Attributes

type SpanI

type SpanI interface {
	PanelI
}

type Table

type Table struct {
	page.Control
	data.DataManager
	// contains filtered or unexported fields
}

func NewTable

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

func (*Table) AddColumn

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

func (*Table) AddColumnAt

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

func (*Table) ClearColumns

func (t *Table) ClearColumns()

func (*Table) DrawCaption

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

func (*Table) GetColumn

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

func (*Table) GetColumnByID

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

func (*Table) GetColumnByTitle

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

func (*Table) GetFooterRowAttributes

func (t *Table) GetFooterRowAttributes(row int) *html.Attributes

func (*Table) GetHeaderRowAttributes

func (t *Table) GetHeaderRowAttributes(row int) *html.Attributes

func (*Table) GetRowAttributes

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

func (*Table) HeaderCellDrawingInfo

func (t *Table) HeaderCellDrawingInfo(ctx context.Context, col ColumnI, rowNum int, colNum int) (cellHtml string, cellAttributes *html.Attributes)

func (*Table) HideColumns

func (t *Table) HideColumns()

func (*Table) Init

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

func (*Table) PrivateAction

func (t *Table) PrivateAction(ctx context.Context, p page.ActionParams)

func (*Table) RemoveColumn

func (t *Table) RemoveColumn(loc int)

func (*Table) RemoveColumnByID

func (t *Table) RemoveColumnByID(id string)

func (*Table) RemoveColumnByTitle

func (t *Table) RemoveColumnByTitle(title string)

func (*Table) RowStyler

func (t *Table) RowStyler() html.Attributer

func (*Table) SetCaption

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

func (*Table) SetFooterRowCount

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

func (*Table) SetFooterRowStyler

func (t *Table) SetFooterRowStyler(a html.Attributer)

func (*Table) SetHeaderRowCount

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

func (*Table) SetHeaderRowStyler

func (t *Table) SetHeaderRowStyler(a html.Attributer)

func (*Table) SetRowStyler

func (t *Table) SetRowStyler(a html.Attributer)

func (*Table) SetSortHistoryLimit

func (t *Table) SetSortHistoryLimit(n int)

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

func (*Table) SortColumns

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

SortColumns returns a slice of columns in sort order

func (*Table) Sortable

func (t *Table) Sortable() TableI

Call Sortable to make a table sortable. It will attach sortable events and show the header if its not shown.

func (*Table) ΩDrawInnerHtml added in v0.0.3

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

func (*Table) ΩDrawTag added in v0.0.3

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

func (*Table) ΩDrawingAttributes added in v0.0.3

func (t *Table) ΩDrawingAttributes() *html.Attributes

func (*Table) ΩMarshalState added in v0.0.4

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

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

func (*Table) ΩUnmarshalState added in v0.0.4

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

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

func (*Table) ΩUpdateFormValues added in v0.0.3

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

ΩUpdateFormValues is called by the system whenever values are sent by client controls. We forward that to the columns.

type TableI

type TableI interface {
	page.ControlI
	SetCaption(interface{})
	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)
}

type Textbox

type Textbox struct {
	page.Control
	// 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 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, p *page.Page) (err error)

Deserialize is used by the pagestate serializer.

func (*Textbox) Init

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

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

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

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)

SetReadOnly will disable editing by setting a browser attribute.

func (*Textbox) SetRowCount

func (t *Textbox) SetRowCount(rows int)

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

func (*Textbox) ΩDrawInnerHtml added in v0.0.3

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

func (t *Textbox) ΩDrawingAttributes() *html.Attributes

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

func (*Textbox) ΩMarshalState added in v0.0.3

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

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

func (*Textbox) ΩSanitize added in v0.0.3

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) ΩUnmarshalState added in v0.0.3

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

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

func (*Textbox) ΩUpdateFormValues added in v0.0.3

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

ΩUpdateFormValues is an internal function that lets us reflect the value of the textbox on the web override

func (*Textbox) ΩisSerializer

func (t *Textbox) ΩisSerializer(i page.ControlI) bool

ΩisSerializer is used by the automated control serializer to determine how far down the control chain the control has to go before just calling serialize and deserialize.

type TextboxI

type TextboxI interface {
	page.ControlI
	SetType(typ string) TextboxI
	ΩSanitize(string) string
}

type UnorderedList

type UnorderedList struct {
	page.Control
	ItemList

	data.DataManager
	// contains filtered or unexported fields
}

UnorderedList is a dynamically generated html unordered list (ul). Such lists are often used as the basis for javascript and css widgets. If you use a data provider to set the data, you should call AddItems to the list in your GetData function.

func NewUnorderedList

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

NewUnorderedList creates a new ul type list.

func (*UnorderedList) GetItemsHtml

func (l *UnorderedList) GetItemsHtml(items []ListItemI) string

GetItemsHtml is used by the framework to get the items for the html. It is exported so that it can be overridden by other implementations of an UnorderedList.

func (*UnorderedList) Init

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

func (*UnorderedList) SetBulletStyle

func (l *UnorderedList) SetBulletStyle(s string)

SetBulletType sets the list-style-type attribute of the list. Choose from the UnorderedListStyle* constants.

func (*UnorderedList) SetData added in v0.0.4

func (l *UnorderedList) SetData(data interface{})

SetData replaces the current list with the given data. The result is kept in memory currently. ItemLister, ItemIDer, Labeler or Stringer types. This function can accept one or more lists of items, or single items. They will all get added to the top level of the list. To add sub items, get a list item and add items to it.

func (*UnorderedList) SetItemTag added in v0.0.4

func (l *UnorderedList) SetItemTag(s string)

SetItemTag sets the tag that will be used for items in the list. By default this is "li".

func (*UnorderedList) ΩDrawInnerHtml added in v0.0.3

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

func (*UnorderedList) ΩDrawTag added in v0.0.3

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

func (*UnorderedList) ΩDrawingAttributes added in v0.0.3

func (l *UnorderedList) ΩDrawingAttributes() *html.Attributes

ΩDrawingAttributes retrieves the tag's attributes at draw time. You should not normally need to call this, and the attributes are disposed of after drawing, so they are essentially read-only.

type UnorderedListI

type UnorderedListI interface {
	page.ControlI
	GetItemsHtml(items []ListItemI) string
}

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