control

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2019 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ButtonClick = iota + 3000
	DialogClose
)

event codes

View Source
const (
	DialogStateDefault = iota
	DialogStateError
	DialogStateWarning
	DialogStateInfo
	DialogStateSuccess
)
View Source
const (
	OrderedListNumberTypeNumber      = "1" // default
	OrderedListNumberTypeUpperLetter = "A"
	OrderedListNumberTypeLowerLetter = "a"
	OrderedListNumberTypeUpperRoman  = "I"
	OrderedListNumberTypeLowerRoman  = "i"
)
View Source
const (
	UnorderedListStyleDisc   = "disc" // default
	UnorderedListStyleCircle = "circle"
	UnorderedListStyleSquare = "square"
	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)

func SortIds

func SortIds(ids []string)

SortIds sorts a list of auto-generated ids in numerical and hierarchical order

Types

type AlertFuncType

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

type Button

type Button struct {
	page.Control
	// contains filtered or unexported fields
}

Button is a standard html button. It derives from the button in the override class, allowing you to customize the behavior of all buttons in your application.

func NewButton

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

Creates a new standard html button

func (*Button) Deserialize

func (b *Button) Deserialize(d page.Decoder, p *page.Page) (err error)

func (*Button) DrawingAttributes

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.

func (*Button) Init

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

func (*Button) IsPrimary

func (b *Button) IsPrimary() bool

func (*Button) On

func (b *Button) On(e page.EventI, actions ...action.ActionI) page.EventI

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

func (b *Button) Serialize(e page.Encoder) (err error)

func (*Button) SetIsPrimary

func (b *Button) SetIsPrimary(isPrimary bool)

func (*Button) SetLabel

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

SetLabel is an alias for SetText on buttons. Buttons do not normally have separate labels.

func (*Button) ΩisSerializer

func (b *Button) Ω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 ButtonI

type ButtonI interface {
	page.ControlI
}

type Canvas

type Canvas struct {
	page.Control
}

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

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

func (*Canvas) DrawingAttributes

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

func (*Canvas) Init

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

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
}

type Checkbox

type Checkbox struct {
	CheckboxBase
}

func NewCheckbox

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

func (*Checkbox) DrawingAttributes

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

func (*Checkbox) UpdateFormValues

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

UpdateFormValues is an internal call that lets us reflect the value of the checkbox on the web override

type CheckboxBase

type CheckboxBase struct {
	page.Control

	LabelMode html.LabelDrawingMode // how to draw the label associating the text with the checkbox
	// contains filtered or unexported fields
}

Checkbox is a base class for checkbox-like objects, including html checkboxes and radio buttons.

func (*CheckboxBase) Checked

func (c *CheckboxBase) Checked() bool

func (*CheckboxBase) Deserialize

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

func (*CheckboxBase) DrawTag

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

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

func (*CheckboxBase) DrawingAttributes

func (c *CheckboxBase) DrawingAttributes() *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) GetDrawingInputLabelAttributes

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

func (*CheckboxBase) Init

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

Init initializes a checbox base class. Normally you will not call this directly. However, sub controls should call this after creation to get the enclosed control initialized.

func (*CheckboxBase) InputLabelAttributes

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

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

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

*

  • Puts the current state of the control to be able to restore it later.

func (*CheckboxBase) Serialize

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

func (*CheckboxBase) SetChecked

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

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

func (*CheckboxBase) SetValue

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

func (*CheckboxBase) TextIsLabel

func (c *CheckboxBase) TextIsLabel() bool

func (*CheckboxBase) UnmarshalState

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

*

  • Restore the state of the control.
  • @param mixed $state Previously saved state as returned by GetState above.

func (*CheckboxBase) Value

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

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
	GetDrawingInputLabelAttributes() *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-table table, or a single-table scrolling list much like a standard html select list.

func NewCheckboxList

func NewCheckboxList(parent page.ControlI, id string) *CheckboxList

func (*CheckboxList) ColumnCount

func (l *CheckboxList) ColumnCount() int

func (*CheckboxList) Direction

func (l *CheckboxList) Direction() ItemDirection

func (*CheckboxList) DrawInnerHtml

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

func (*CheckboxList) DrawingAttributes

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

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

func (*CheckboxList) RenderItem

func (l *CheckboxList) RenderItem(tag string, item ListItemI) (h string)

func (*CheckboxList) SetColumnCount

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

func (*CheckboxList) SetDirection

func (l *CheckboxList) SetDirection(direction ItemDirection) CheckboxListI

func (*CheckboxList) SetIsScrolling

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

func (*CheckboxList) SetLabelDrawingMode

func (l *CheckboxList) SetLabelDrawingMode(mode html.LabelDrawingMode) CheckboxListI

func (*CheckboxList) UpdateFormValues

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

type CheckboxListI

type CheckboxListI interface {
	MultiselectListI
	RenderItem(tag string, item ListItemI) (h string)
}

type ColumnBase

type ColumnBase struct {
	base.Base

	*html.Attributes // These are attributes that will appear on the cell
	// contains filtered or unexported fields
}

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

func (*ColumnBase) CellText

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

func (*ColumnBase) CellTexter

func (c *ColumnBase) CellTexter() CellTexter

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)

func (*ColumnBase) DrawColumnTag

func (c *ColumnBase) DrawColumnTag(ctx context.Context, buf *bytes.Buffer)

func (*ColumnBase) DrawFooterCell

func (c *ColumnBase) DrawFooterCell(ctx context.Context, row int, col int, count int, buf *bytes.Buffer)

func (*ColumnBase) FooterAttributes

func (c *ColumnBase) FooterAttributes(row int, col int) *html.Attributes

func (*ColumnBase) FooterCellHtml

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

func (*ColumnBase) HeaderAttributes

func (c *ColumnBase) HeaderAttributes(row int, col int) *html.Attributes

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

func (*ColumnBase) Init

func (c *ColumnBase) Init(self ColumnI)

func (*ColumnBase) IsHidden

func (c *ColumnBase) IsHidden() bool

func (*ColumnBase) IsSortable

func (c *ColumnBase) IsSortable() bool

func (*ColumnBase) ParentTable

func (c *ColumnBase) ParentTable() TableI

func (*ColumnBase) RenderSortButton

func (c *ColumnBase) RenderSortButton(labelHtml string) string

func (*ColumnBase) SetCellStyler

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

func (*ColumnBase) SetCellTexter

func (c *ColumnBase) SetCellTexter(s CellTexter)

func (*ColumnBase) SetFooterTexter

func (c *ColumnBase) SetFooterTexter(s CellTexter)

func (*ColumnBase) SetHeaderTexter

func (c *ColumnBase) SetHeaderTexter(s CellTexter)

func (*ColumnBase) SetHidden

func (c *ColumnBase) SetHidden(h bool)

func (*ColumnBase) SetID

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

SetId sets the id of the table. 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 propogate 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)

func (*ColumnBase) SetRenderAsHeader

func (c *ColumnBase) SetRenderAsHeader(r bool)

func (*ColumnBase) SetSortDirection

func (c *ColumnBase) SetSortDirection(d SortDirection)

SetSortDirection is used internally to set the sort direction indicator

func (*ColumnBase) SetSpan

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

func (*ColumnBase) SetTitle

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

func (*ColumnBase) SortDirection

func (c *ColumnBase) SortDirection() SortDirection

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

func (*ColumnBase) Title

func (c *ColumnBase) Title() string

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)
	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)
	SetCellTexter(s CellTexter)
	SetFooterTexter(s CellTexter)
	SetCellStyler(s html.Attributer)
	IsSortable() bool
	SortDirection() SortDirection
	SetSortDirection(SortDirection)
	Sortable() ColumnI
	SetIsHtml(columnIsHtml bool)
	// contains filtered or unexported methods
}

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 through 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 whole series of pages and not just for data on one override.

func NewDataPager

func NewDataPager(parent page.ControlI, id string, paginatedControl PaginatedControlI) *DataPager

func (*DataPager) Action

func (d *DataPager) Action(ctx context.Context, params page.ActionParams)

func (*DataPager) CalcBunch

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

func (*DataPager) Deserialize

func (d *DataPager) Deserialize(dec page.Decoder, p *page.Page) (err error)

func (*DataPager) DrawInnerHtml

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

func (*DataPager) DrawingAttributes

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

func (*DataPager) Init

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

func (*DataPager) MarshalState

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

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

func (*DataPager) NextButtonsHtml

func (d *DataPager) NextButtonsHtml() string

func (*DataPager) PageButtonsHtml

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

func (*DataPager) PaginatedControl

func (d *DataPager) PaginatedControl() PaginatedControlI

func (*DataPager) PreRender

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

func (*DataPager) PreviousButtonsHtml

func (d *DataPager) PreviousButtonsHtml() string

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)

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

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
}

func NewDateTextbox

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

func (*DateTextbox) Date

func (d *DateTextbox) Date() datetime.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)

func (*DateTextbox) SetFormat

func (d *DateTextbox) SetFormat(format DateTextboxFormat)

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 (*DateTextbox) SetText

func (d *DateTextbox) SetText(s string) page.ControlI

func (*DateTextbox) SetValue

func (d *DateTextbox) SetValue(val interface{}) *DateTextbox

func (*DateTextbox) Value

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

type DateTextboxFormat

type DateTextboxFormat int
const (
	DateTextboxUS   DateTextboxFormat = iota // default to US format M/D/Y
	DateTextboxEuro                          // D/M/Y
)

Go does not yet have internal support for international dates so we will need to do this ourselves

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

func (*DateTimeSpan) DrawInnerHtml

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

func (*DateTimeSpan) Init

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

func (*DateTimeSpan) SetDateTime

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

func (*DateTimeSpan) SetFormat

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

func (*DateTimeSpan) SetValue

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

func (*DateTimeSpan) Value

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

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 qcubed.js to create a minimal implementation of the dialog interface.

func NewDialog

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

func (*Dialog) Action

func (d *Dialog) Action(ctx context.Context, a page.ActionParams)

func (*Dialog) AddButton

func (d *Dialog) AddButton(
	label string,
	id string,
	options *DialogButtonOptions,
) page.ControlI

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 (by hiding it).

func (*Dialog) Close

func (d *Dialog) Close()

func (*Dialog) DrawTemplate

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

func (*Dialog) DrawingAttributes

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

func (*Dialog) HasCloseBox

func (d *Dialog) HasCloseBox() page.ControlI

func (*Dialog) Init

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

func (*Dialog) Open

func (d *Dialog) Open()

func (*Dialog) RemoveAllButtons

func (d *Dialog) RemoveAllButtons()

func (*Dialog) RemoveButton

func (d *Dialog) RemoveButton(id string)

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)

func (*Dialog) SetDialogState

func (d *Dialog) SetDialogState(s int) *Dialog

func (*Dialog) SetState

func (d *Dialog) SetState(state int) DialogI

func (*Dialog) SetTitle

func (d *Dialog) SetTitle(t string) DialogI

func (*Dialog) Title

func (d *Dialog) Title() string

type DialogButtonOptions

type DialogButtonOptions struct {
	// Set Validates to true to indicate that this button will validate the dialog
	Validates bool
	// Set IsPrimary to true to make this a submit button so the user can press enter to activate it
	IsPrimary bool
	// ConfirmationMessage 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) DialogI
	SetState(state int) DialogI
}

DialogI defines the publicly coconsumable api that the QCubed 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 tag(s), css and javascript widget. QCubed 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 both JQuery UI dialogs and Bootstrap dialogs. As more needs arise, * we can modify the interface to accomodate as many frammeworks as possible. * * Dialogs 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 JQuery UI and Bootstrap implementations for more * direction. * * Feel free to implement more than just the function listed. These are the minimal set to allow your dialog to be used * by the default QCubed framework.

func Alert

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

func DefaultAlert

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

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

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

func (*EmailTextbox) Validate

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

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

func (*Fieldset) DrawTag

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

func (*Fieldset) DrawingAttributes

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

func (*Fieldset) Init

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

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

type IDSetter interface {
	SetID(id string)
}

type IDer

type IDer interface {
	ID() string
}

IDer is an object that can embed a list

type IdSlice

type IdSlice []string

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

func (*Image) Alt

func (i *Image) Alt() string

func (*Image) Data

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

func (*Image) DrawingAttributes

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

func (*Image) Height

func (i *Image) Height() int

func (*Image) Init

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

Initializes a textbox. Normally you will not call this directly. However, sub controls should call this after creation to get the enclosed control initialized. Self is the newly created class. Like so: t := &MyTextBox{} t.Textbox.Init(t, parent, id) A parent control is isRequired. Leave id blank to have the system assign an id to the control.

func (*Image) SetAlt

func (i *Image) SetAlt(alt string)

func (*Image) SetData

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

func (*Image) SetHeight

func (i *Image) SetHeight(height int)

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)

func (*Image) SetWidth

func (i *Image) SetWidth(width int)

func (*Image) Src

func (i *Image) Src() string

func (*Image) Width

func (i *Image) Width() int

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. It is a kind of composite control that exports and image and button object that you can further manipulate after creation. It also has javascript to manage the actual image capture process. It does not currently permit uploading of image files. It only captures images from devices and browsers that support image capture.

func NewImageCapture

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

func (*ImageCapture) Data

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

func (*ImageCapture) DrawingAttributes

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

func (*ImageCapture) Init

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

Initializes a textbox. Normally you will not call this directly. However, sub controls should call this after creation to get the enclosed control initialized. Self is the newly created class. Like so: t := &MyTextBox{} t.Textbox.Init(t, parent, id) A parent control is isRequired. Leave id blank to have the system assign an id to the control.

func (*ImageCapture) PutCustomScript

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

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

func (*ImageCapture) UpdateFormValues

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

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 ItemDirection

type ItemDirection int
const (
	HorizontalItemDirection ItemDirection = 0
	VerticalItemDirection                 = 1
)

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

Items returns a slice of the ListItemI items, in the order they were added or arranged.

func (*ItemList) RemoveAt

func (l *ItemList) RemoveAt(index int)

RemoveAt 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()
	RemoveAt(index int)
	Len() int
	GetItem(id string) (foundItem ListItemI)
	GetItemByValue(value interface{}) (id string, foundItem ListItemI)
	// contains filtered or unexported methods
}

type ItemLister

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

type Labeler

type Labeler interface {
	Label() string
}

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

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
}

func (MaxLengthValidator) Validate

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

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
}

func (MinLengthValidator) Validate

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

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

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

func (*MultiselectList) DrawingAttributes

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

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

func (*MultiselectList) IsIdSelected

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

func (*MultiselectList) MarshalState

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

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

func (*MultiselectList) SelectedIds

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

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

func (*MultiselectList) SelectedItems

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

func (*MultiselectList) SelectedLabels

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

func (*MultiselectList) SelectedValues

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

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

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

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

func (*MultiselectList) UpdateFormValues

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

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

func (*MultiselectList) Validate

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

func (*MultiselectList) Value

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

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

type MultiselectListI

type MultiselectListI interface {
	page.ControlI
}

type OrderedList

type OrderedList struct {
	UnorderedList
}

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. After drawing, the items will be removed.

func NewOrderedList

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

func (*OrderedList) DrawInnerHtml

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

func (*OrderedList) Init

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

func (*OrderedList) NumberType

func (l *OrderedList) NumberType() string

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.

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)

func (*PaginatedControl) CalcPageCount

func (c *PaginatedControl) CalcPageCount() int

func (*PaginatedControl) PageNum

func (c *PaginatedControl) PageNum() int

func (*PaginatedControl) PageSize

func (c *PaginatedControl) PageSize() int

func (*PaginatedControl) SetPageNum

func (c *PaginatedControl) SetPageNum(n int)

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)

func (*PaginatedControl) TotalItems

func (c *PaginatedControl) TotalItems() int

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

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

func (*Panel) Init

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

func (*Panel) Value

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

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
}

func NewProxy

func NewProxy(parent page.ControlI) *Proxy

func (*Proxy) ActionAttributes

func (p *Proxy) ActionAttributes(actionValue string) *html.Attributes

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

func (*RadioButton) DrawingAttributes

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

func (*RadioButton) Group

func (c *RadioButton) Group() string

func (*RadioButton) SetChecked

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

func (*RadioButton) SetGroup

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

func (*RadioButton) UpdateFormValues

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

type RadioButtonI

type RadioButtonI interface {
	CheckboxI
}

type RadioList

type RadioList struct {
	CheckboxList
}

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

func (*RadioList) DrawingAttributes

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

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

func (*RadioList) RenderItem

func (l *RadioList) RenderItem(tag string, item ListItemI) (h string)

func (*RadioList) SelectedLabel

func (l *RadioList) SelectedLabel() string

func (*RadioList) SelectedValue

func (l *RadioList) SelectedValue() string

func (*RadioList) SetSelectedID

func (l *RadioList) SetSelectedID(id string)

func (*RadioList) SetSelectedValue

func (l *RadioList) SetSelectedValue(v interface{})

func (*RadioList) SetValue

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

func (*RadioList) UpdateFormValues

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

func (*RadioList) Value

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

type RadioListI

type RadioListI interface {
	CheckboxListI
}

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

func (*SelectList) DrawInnerHtml

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

func (*SelectList) DrawingAttributes

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

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

func (*SelectList) IntValue

func (l *SelectList) IntValue() int

func (*SelectList) MarshalState

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

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

func (*SelectList) SelectedItem

func (l *SelectList) SelectedItem() 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

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.

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

func (*SelectList) UnmarshalState

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

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

func (*SelectList) UpdateFormValues

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

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

func (*SelectList) Validate

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

func (*SelectList) Value

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

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

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

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

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

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

func (*SelectTable) PutCustomScript

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

func (*SelectTable) SelectedID

func (t *SelectTable) SelectedID() string

func (*SelectTable) SetSelectedID

func (t *SelectTable) SetSelectedID(id string)

func (*SelectTable) UnmarshalState

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

func (*SelectTable) UpdateFormValues

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

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

func (*Span) Init

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

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

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

func (*Table) DrawTag

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

func (*Table) DrawingAttributes

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

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

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
}

func NewTextbox

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

func (*Textbox) Deserialize

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

func (*Textbox) DrawInnerHtml

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

DrawInnerHtml is an internal function that renders the inner html of a tag. In this case, it is rendering the inner text of a textarea

func (*Textbox) DrawingAttributes

func (t *Textbox) DrawingAttributes() *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 (*Textbox) Init

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

Initializes a textbox. Normally you will not call this directly. However, sub controls should call this after creation to get the enclosed control initialized. Self is the newly created class. Like so: t := &MyTextBox{} t.Textbox.Init(t, parent, id) A parent control is isRequired. Leave id blank to have the system assign an id to the control.

func (*Textbox) MarshalState

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

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

func (*Textbox) MaxLength

func (t *Textbox) MaxLength() int

func (*Textbox) MinLength

func (t *Textbox) MinLength() int

func (*Textbox) Placeholder

func (t *Textbox) Placeholder() string

func (*Textbox) ResetValidators

func (t *Textbox) ResetValidators()

func (*Textbox) Sanitize

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

Sanitize takes user input and strips it of potential malicious XSS scripts. The default uses a global sanitizer creating a bootup. Override Sanitize in a subclass if you want a per-textbox sanitizer.

func (*Textbox) Serialize

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

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

func (*Textbox) SetMinLength

func (t *Textbox) SetMinLength(len int) *MinLengthValidator

func (*Textbox) SetPlaceholder

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

func (*Textbox) SetReadOnly

func (t *Textbox) SetReadOnly(r bool)

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, thought you can pass any string and it will become the input type

func (*Textbox) SetValue

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

func (*Textbox) Text

func (t *Textbox) Text() string

func (*Textbox) UnmarshalState

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

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

func (*Textbox) UpdateFormValues

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

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

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 TextboxValidator to the validator list

func (*Textbox) Value

func (t *Textbox) Value() interface{}

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. After drawing, the items will be removed.

func NewUnorderedList

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

func (*UnorderedList) DrawInnerHtml

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

func (*UnorderedList) DrawTag

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

func (*UnorderedList) DrawingAttributes

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

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

func (*UnorderedList) GetItemsHtml

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

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 bullet type. Choose from the UnorderedListStyle* constants.

func (*UnorderedList) SetSubTag

func (l *UnorderedList) SetSubTag(s string)

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