control

package
v0.31.10 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package control contains the Bootstrap control structures that when added to a page will result in Bootstrap styled controls.

Index

Constants

View Source
const (
	ButtonStylePrimary   ButtonStyle = "btn-primary"
	ButtonStyleSecondary             = "btn-secondary"
	ButtonStyleSuccess               = "btn-success"
	ButtonStyleInfo                  = "btn-info"
	ButtonStyleWarning               = "btn-warning"
	ButtonStyleDanger                = "btn-danger"
	ButtonStyleLight                 = "btn-light"
	ButtonStyleDark                  = "btn-dark"
	ButtonStyleLink                  = "btn-link"

	ButtonStyleOutlinePrimary   = "btn-outline-primary"
	ButtonStyleOutlineSecondary = "btn-outline-secondary"
	ButtonStyleOutlineSuccess   = "btn-outline-success"
	ButtonStyleOutlineInfo      = "btn-outline-info"
	ButtonStyleOutlineWarning   = "btn-outline-warning"
	ButtonStyleOutlineDanger    = "btn-outline-danger"
	ButtonStyleOutlineLight     = "btn-outline-light"
	ButtonStyleOutlineDark      = "btn-outline-dark"
)
View Source
const (
	ButtonSizeLarge  ButtonSize = "btn-lg"
	ButtonSizeMedium            = ""
	ButtonSizeSmall             = "btn-sm"
)
View Source
const (
	Container       ContainerClass = "container"
	ContainerFluid                 = "container-fluid"
	ContainerSmall                 = "container-sm"
	ContainerMedium                = "container-md"
	ContainerLarge                 = "container-lg"
	ContainerXL                    = "container-xl"
	ContainerXXL                   = "container-xxl"
)
View Source
const (
	TextColorPrimary   TextColorClass = "text-primary"
	TextColorSecondary                = "text-secondary"
	TextColorDanger                   = "text-danger"
	TextColorWarning                  = "text-warning"
	TextColorInfo                     = "text-info"
	TextColorLight                    = "text-light"
	TextColorDark                     = "text-dark"
	TextColorBody                     = "text-body"
	TextColorMuted                    = "text-muted"
	TextColorWhite                    = "text-white"
	TextColorWhite50                  = "text-white-50"
	TextColorBlack50                  = "text-black-50"
)
View Source
const (
	BackgroundColorPrimary     BackgroundColorClass = "bg-primary"
	BackgroundColorSecondary                        = "bg-secondary"
	BackgroundColorSuccess                          = "bg-danger"
	BackgroundColorDanger                           = "bg-danger"
	BackgroundColorWarning                          = "bg-warning"
	BackgroundColorInfo                             = "bg-info"
	BackgroundColorLight                            = "bg-light"
	BackgroundColorDark                             = "bg-dark"
	BackgroundColorWhite                            = "bg-white"
	BackgroundColorTransparent                      = "bg-transparent"
	BackgroundColorNone                             = "" // utility to allow custom background colors for components
)
View Source
const (
	NavTabs      = "nav-tabs"
	NavPills     = "nav-pills"
	NavJustified = "nav-justified"

	NavbarHeader   = "navbar-header"
	NavbarCollapse = "navbar-collapse"
	NavbarBrand    = "navbar-brand"
	NavbarToggle   = "navbar-toggle"
	NavbarNav      = "navbar-nav"
	NavbarLeft     = "navbar-left"
	NavbarRight    = "navbar-right"
	NavbarForm     = "navbar-form"
)
View Source
const (
	NavbarExpandExtraLarge NavbarExpandClass = "navbar-expand-xl"
	NavbarExpandLarge                        = "navbar-expand-lg"
	NavbarExpandMedium                       = "navbar-expand-md"
	NavbarExpandSmall                        = "navbar-expand-sm"
	// NavbarExpandNone will always show the navbar as collapsed at any size
	NavbarExpandNone = ""
)
View Source
const (
	TabStyleNone      = ""
	TabStyleTabs      = "tab"
	TabStylePills     = "pill"
	TabStyleUnderline = "underline"
)
View Source
const ButtonBlock = "btn-block"

ButtonBlock is a class you can add to a button to make it span a full block

View Source
const ButtonClass = "btn"
View Source
const (
	DialogClosed = iota + 10000 // The event code for a dialog that is closing
)
View Source
const DropdownSelect = "gr-bs-dropdownselect"
View Source
const NavbarSelect = "gr-bs-navbarselect"
View Source
const TabHidden = "gr-bs-tabhide"

TabHidden is the event generated when a tab is hidden. i.e. another tab is selected when this one was in front. The EventValueString of the event is the id of the child item that was hidden.

View Source
const TabSelect = "gr-bs-tabselect"

TabSelect is the event generated when a tab is selected. The EventValueString of the event is the id of the child item that was selected.

Variables

This section is empty.

Functions

func DropdownSelectEvent() *event.Event
func NavbarSelectEvent() *event.Event

func TabSelectEvent added in v0.31.2

func TabSelectEvent() *event.Event

Types

type BackgroundColorClass

type BackgroundColorClass string

type Button

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

Button will draw a Bootstrap styled control.

func GetButton added in v0.2.4

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

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

func NewButton

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

NewButton creates a new bootstrap html button

func (*Button) Deserialize

func (b *Button) Deserialize(d page.Decoder)

Deserialize reconstructs the control from the page state.

func (*Button) DrawingAttributes

func (b *Button) DrawingAttributes(ctx context.Context) html5tag.Attributes

DrawingAttributes returns the attributes to add to the tag just before the button is drawn.

func (*Button) Init

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

Init initializes the button

func (*Button) Serialize

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

Serialize serializes the state of the control for the pagestate

func (*Button) SetButtonSize

func (b *Button) SetButtonSize(size ButtonSize) ButtonI

SetButtonSize sets the size class of the button.

func (*Button) SetButtonStyle

func (b *Button) SetButtonStyle(style ButtonStyle) ButtonI

SetButtonStyle will set the button's style to one of the predefined bootstrap styles.

func (*Button) SetIsPrimary

func (b *Button) SetIsPrimary(isPrimary bool) grctl.ButtonI

SetIsPrimary determines whether the button is styled as a primary or secondary button.

type ButtonCreator added in v0.2.0

type ButtonCreator struct {
	// ID is the control id
	ID string
	// Text is the text displayed in the button
	Text string
	// OnSubmit is the action to take when the button is submitted. Use this specifically
	// for buttons that move to other pages or processes transactions, as it debounces the button
	// and waits until all other actions complete
	OnSubmit action.ActionI
	// OnClick is an action to take when the button is pressed. Do not specify both
	// a OnSubmit and OnClick.
	OnClick        action.ActionI
	Style          ButtonStyle
	Size           ButtonSize
	IsPrimary      bool
	ValidationType event.ValidationType
	page.ControlOptions
}

ButtonCreator is the initialization structure for the declarative creation of the control.

func (ButtonCreator) Create added in v0.2.0

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

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

func (ButtonCreator) Init added in v0.2.0

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

Init is called by implementations of Buttons to initialize a control with the creator.

type ButtonI

type ButtonI interface {
	grctl.ButtonI
	SetButtonStyle(style ButtonStyle) ButtonI
	SetButtonSize(size ButtonSize) ButtonI
}

ButtonI is the Bootstrap control Button interface.

type ButtonSize

type ButtonSize string

ButtonSize is one of the btn-* size classes.

type ButtonStyle

type ButtonStyle string

ButtonStyle represents a btn-* Bootstrap style class.

type Checkbox

type Checkbox struct {
	button.Checkbox
	// contains filtered or unexported fields
}

Checkbox is a Bootstrap styled checkbox control.

func GetCheckbox added in v0.2.0

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

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

func NewCheckbox

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

NewCheckbox returns a new Checkbox Bootstrap control.

func (*Checkbox) Deserialize

func (c *Checkbox) Deserialize(d page.Decoder)

func (*Checkbox) DrawTag

func (c *Checkbox) DrawTag(ctx context.Context, w io.Writer)

func (*Checkbox) DrawingAttributes

func (c *Checkbox) DrawingAttributes(ctx context.Context) html5tag.Attributes

func (*Checkbox) GetDrawingLabelAttributes added in v0.4.0

func (c *Checkbox) GetDrawingLabelAttributes() html5tag.Attributes

func (*Checkbox) Serialize

func (c *Checkbox) Serialize(e page.Encoder)

func (*Checkbox) SetInline added in v0.0.4

func (c *Checkbox) SetInline(v bool) *Checkbox

type CheckboxCreator added in v0.2.0

type CheckboxCreator struct {
	// ID is the id of the control
	ID string
	// Text is the text of the label displayed right next to the checkbox.
	Text string
	// Checked will initialize the checkbox in its checked state.
	Checked bool
	// LabelMode specifies how the label is drawn with the checkbox.
	LabelMode html5tag.LabelDrawingMode
	// LabelAttributes are additional attributes placed on the label tag.
	LabelAttributes html5tag.Attributes
	// SaveState will save the value of the checkbox and restore it when the page is reentered.
	SaveState bool
	// OnChange is an action to take when the user checks or unchecks the control.
	OnChange action.ActionI
	// Set inline when drawing this checkbox inline or wrapped by an inline FormGroup
	Inline bool
	page.ControlOptions
}

func (CheckboxCreator) Create added in v0.2.0

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

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

type CheckboxList

type CheckboxList struct {
	list.CheckboxList
	// 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 GetCheckboxList added in v0.2.0

func GetCheckboxList(c page.ControlI, id string) *CheckboxList

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

func NewCheckboxList

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

func (*CheckboxList) Deserialize added in v0.9.3

func (l *CheckboxList) Deserialize(d page.Decoder)

func (*CheckboxList) DrawingAttributes

func (l *CheckboxList) DrawingAttributes(ctx context.Context) html5tag.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 any, parent page.ControlI, id string)

func (*CheckboxList) RenderItem added in v0.4.0

func (l *CheckboxList) RenderItem(item *list.Item) (h string)

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

func (*CheckboxList) Serialize added in v0.9.3

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

func (*CheckboxList) SetCellClass added in v0.2.0

func (l *CheckboxList) SetCellClass(c string)

SetCellClass sets a string that is applied to every cell. This is useful for setting responsive breakpoints

func (*CheckboxList) SetIsInline

func (l *CheckboxList) SetIsInline(i bool)

type CheckboxListCreator added in v0.2.0

type CheckboxListCreator struct {
	ID string
	// Items is a static list of labels and values that will be in the list. Or, use a DataProvider to dynamically generate the items.
	Items []list.ListValue
	// DataProvider is the control that will dynamically provide the data for the list and that implements the DataBinder interface.
	DataProvider control.DataBinder
	// DataProviderID is the id of a control that will dynamically provide the data for the list and that implements the DataBinder interface.
	DataProviderID string
	// ColumnCount specifies how many columns to show
	ColumnCount int
	// LayoutDirection determines how the items are arranged in the columns
	LayoutDirection control.LayoutDirection
	// LabelDrawingMode specifies how the labels on the radio buttons will be associated with the buttons
	LabelDrawingMode html5tag.LabelDrawingMode
	// IsScrolling will give the inner div a vertical scroll style. You will need to style the height of the outer control to have a fixed style as well.
	IsScrolling bool
	// RowClass is the class assigned to each row
	RowClass string
	// Value is the initial value of the textbox. Often its best to load the value in a separate Load step after creating the control.
	Value string
	// SaveState saves the selected value so that it is restored if the form is returned to.
	SaveState bool
	page.ControlOptions
}

func (CheckboxListCreator) Create added in v0.2.0

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

func (CheckboxListCreator) Init added in v0.2.0

type CheckboxListI

type CheckboxListI interface {
	list.CheckboxListI
}

type ContainerClass

type ContainerClass string

type DataPager

type DataPager struct {
	control.DataPager
	ButtonStyle    ButtonStyle
	HighlightStyle ButtonStyle
}

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, pagedControl control.PagedControlI) *DataPager

func (*DataPager) Deserialize

func (d *DataPager) Deserialize(dec page.Decoder)

func (*DataPager) DrawingAttributes

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

func (*DataPager) Init

func (d *DataPager) Init(self any, parent page.ControlI, id string, pagedControl control.PagedControlI)

func (*DataPager) NextButtonsHtml

func (d *DataPager) NextButtonsHtml() string

func (*DataPager) PageButtonsHtml

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

func (*DataPager) PreviousButtonsHtml

func (d *DataPager) PreviousButtonsHtml() string

func (*DataPager) Serialize

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

type DataPagerCreator added in v0.2.0

type DataPagerCreator struct {
	// ID is the control id
	ID string
	// MaxPageButtons is the maximum number of page buttons to display in the pager
	MaxPageButtons int
	// ObjectName is the name of the object being displayed in the table
	ObjectName string
	// ObjectPluralName is the plural name of the object being displayed
	ObjectPluralName string
	// LabelForNext is the text to use in the Next button
	LabelForNext string
	// LabelForPrevious is the text to use in the Previous button
	LabelForPrevious string
	// PagedControlID is the id of the control that will be paged by the pager
	PagedControlID string
	page.ControlOptions
	// ButtonStyle is the style that will be used to draw the standard buttons
	ButtonStyle ButtonStyle
	// HighlightStyle is the style that will be used to draw the highlighted buttons
	HighlightStyle ButtonStyle
}

DataPagerCreator is the initialization structure for declarative creation of data pagers

func (DataPagerCreator) Create added in v0.2.0

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

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

func (DataPagerCreator) Init added in v0.2.0

func (c DataPagerCreator) Init(ctx context.Context, ctrl DataPagerI)

Init is called by implementations of Buttons to initialize a control with the creator.

type DataPagerI

type DataPagerI interface {
	control.DataPagerI
}

type DateTextbox

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

func GetDateTextbox added in v0.2.0

func GetDateTextbox(c page.ControlI, id string) *DateTextbox

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

func NewDateTextbox

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

func (*DateTextbox) DrawingAttributes

func (t *DateTextbox) DrawingAttributes(ctx context.Context) html5tag.Attributes

type DateTextboxCreator added in v0.2.0

type DateTextboxCreator struct {
	// ID is the control id of the html widget and must be unique to the page
	ID string
	// Placeholder is the placeholder attribute of the textbox and shows as help text inside the field
	Placeholder string
	// Type is the type attribute of the textbox
	Type string
	// MinLength is the minimum number of characters that the user is required to enter. If the
	// length is less than this number, a validation error will be shown.
	MinLength int
	// MaxLength is the maximum number of characters that the user is required to enter. If the
	// length is more than this number, a validation error will be shown.
	MaxLength int
	// ColumnCount is the number of characters wide the textbox will be, and becomes the width attribute in the tag.
	// The actual width is browser dependent. For better control, use a width style property.
	ColumnCount int
	// ReadOnly sets the readonly attribute of the textbox, which prevents it from being changed by the user.
	ReadOnly bool
	// SaveState will save the text in the textbox, to be restored if the user comes back to the page.
	// It is particularly helpful when the textbox is being used to filter the results of a query, so that
	// when the user comes back to the page, he does not have to type the filter text again.
	SaveState bool
	// Text is the initial value of the textbox. Often its best to load the value in a separate Load step after creating the control.
	Text string
	// Formats is the time.format strings to use to decode the text into a date.
	Formats []string

	page.ControlOptions
}

DateTextboxCreator creates a date textbox. Pass it to AddControls of a control, or as a Child of a FormGroupCreator.

func (DateTextboxCreator) Create added in v0.2.0

func (DateTextboxCreator) Init added in v0.2.0

func (c DateTextboxCreator) Init(ctx context.Context, ctrl DateTextboxI)

type DateTextboxI added in v0.2.0

type DateTextboxI interface {
	textbox.DateI
}
type Dropdown struct {
	list.UnorderedList
	// contains filtered or unexported fields
}

A Dropdown implements the Bootstrap Dropdown control. The Dropdown is a button combined with a list. The button shows the list, allowing the user to select an item from the list.

Call SetAsNavItem to draw the button in a way compatible with being inside a navbar.

func GetDropdown added in v0.21.0

func GetDropdown(c page.ControlI, id string) *Dropdown

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

func NewDropdown added in v0.21.0

func NewDropdown(parent page.ControlI, id string) *Dropdown
func (l *Dropdown) ButtonAttributes() html5tag.Attributes

ButtonAttributes returns the attributes for the internal button of the dropdown. If you change them, be sure to call Refresh().

func (l *Dropdown) Deserialize(d page.Decoder)

Deserialize reconstructs the control from the page state.

func (l *Dropdown) DrawInnerHtml(_ context.Context, w io.Writer)
func (l *Dropdown) DrawingAttributes(ctx context.Context) html5tag.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 (l *Dropdown) GetItemsHtml(items []*list.Item) string
func (l *Dropdown) Init(self any, parent page.ControlI, id string)
func (l *Dropdown) MenuAttributes() html5tag.Attributes

MenuAttributes returns the attributes for the internal button of the dropdown. If you change them, be sure to call Refresh().

func (l *Dropdown) OnClick(a action.ActionI) DropdownI

OnClick sets the action to take when a link in the Dropdown is selected. It will only respond to links whose href is "#", which indicates its an empty link. The EventValue will be the id of the link clicked.

func (l *Dropdown) Serialize(e page.Encoder)

Serialize serializes the state of the control for the pagestate

func (l *Dropdown) SetAsNavItem(asNavItem bool) DropdownI
type DropdownCreator struct {
	// ID is the id attribute for the html object and the id for the page control
	ID string
	// Text is the label that will appear in the dropdown button
	Text string
	// Items is a static list of labels and values that will be in the list. Or, use a DataProvider to dynamically generate the items.
	Items []list.ListValue
	// DataProvider is the control that will dynamically provide the data for the list and that implements the DataBinder interface.
	DataProvider control.DataBinder
	// DataProviderID is the id of a control that will dynamically provide the data for the list and that implements the DataBinder interface.
	DataProviderID string
	// AsNavItem determines whether to draw as an item in a navbar, or just a regular button.
	AsNavItem bool
	// ButtonAttributes are additional attributes that will be assigned to the button.
	ButtonAttributes html5tag.Attributes
	// MenuAttributes are additional attributes that will be assigned to the menu.
	MenuAttributes html5tag.Attributes
	// OnClick is the action to take when a link is clicked or selected. It will only respond
	// to anchor tags whose href is set to "#". The EventValue will be the value of the item clicked.
	OnClick action.ActionI
	// ControlOptions are additional settings for the control.
	// If this is part of a Navbar, you should add the "nav-item" class.
	page.ControlOptions
}
func (c DropdownCreator) Create(ctx context.Context, parent page.ControlI) page.ControlI

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

func (c DropdownCreator) Init(ctx context.Context, ctrl DropdownI)
type DropdownI interface {
	list.UnorderedListI
	SetAsNavItem(bool) DropdownI
	ButtonAttributes() html5tag.Attributes
	MenuAttributes() html5tag.Attributes
	OnClick(action action.ActionI) DropdownI
}

type EmailTextbox

type EmailTextbox struct {
	textbox.EmailTextbox
}

func GetEmailTextbox added in v0.2.0

func GetEmailTextbox(c page.ControlI, id string) *EmailTextbox

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

func NewEmailTextbox

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

func (*EmailTextbox) DrawingAttributes

func (t *EmailTextbox) DrawingAttributes(ctx context.Context) html5tag.Attributes

type EmailTextboxCreator added in v0.2.0

type EmailTextboxCreator struct {
	// ID is the control id of the html widget and must be unique to the page
	ID string
	// Placeholder is the placeholder attribute of the textbox and shows as help text inside the field
	Placeholder string
	// Type is the type attribute of the textbox
	Type string
	// MinLength is the minimum number of characters that the user is required to enter. If the
	// length is less than this number, a validation error will be shown.
	MinLength int
	// MaxLength is the maximum number of characters that the user is required to enter. If the
	// length is more than this number, a validation error will be shown.
	MaxLength int
	// ColumnCount is the number of characters wide the textbox will be, and becomes the width attribute in the tag.
	// The actual width is browser dependent. For better control, use a width style property.
	ColumnCount int
	// ReadOnly sets the readonly attribute of the textbox, which prevents it from being changed by the user.
	ReadOnly bool
	// SaveState will save the text in the textbox, to be restored if the user comes back to the page.
	// It is particularly helpful when the textbox is being used to filter the results of a query, so that
	// when the user comes back to the page, he does not have to type the filter text again.
	SaveState bool
	// Text is the initial value of the textbox. Often its best to load the value in a separate Load step after creating the control.
	Text string
	// MaxItemCount is the maximum number of email addresses allowed to be entered, separated by commas
	// By default it allows only 1.
	MaxItemCount int

	page.ControlOptions
}

EmailTextboxCreator creates an email textbox. Pass it to AddControls of a control, or as a Child of a FormFieldWrapper.

func (EmailTextboxCreator) Create added in v0.2.0

func (EmailTextboxCreator) Init added in v0.2.0

type EmailTextboxI added in v0.2.0

type EmailTextboxI interface {
	textbox.EmailI
}

type FloatTextbox

type FloatTextbox struct {
	textbox.FloatTextbox
}

func GetFloatTextbox added in v0.2.0

func GetFloatTextbox(c page.ControlI, id string) *FloatTextbox

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

func NewFloatTextbox

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

func (*FloatTextbox) DrawingAttributes

func (t *FloatTextbox) DrawingAttributes(ctx context.Context) html5tag.Attributes

type FloatTextboxCreator added in v0.2.0

type FloatTextboxCreator struct {
	// ID is the control id of the html widget and must be unique to the page
	ID string
	// Placeholder is the placeholder attribute of the textbox and shows as help text inside the field
	Placeholder string
	// Type is the type attribute of the textbox
	Type string
	// MinLength is the minimum number of characters that the user is required to enter. If the
	// length is less than this number, a validation error will be shown.
	MinLength int
	// MaxLength is the maximum number of characters that the user is required to enter. If the
	// length is more than this number, a validation error will be shown.
	MaxLength int
	// ColumnCount is the number of characters wide the textbox will be, and becomes the width attribute in the tag.
	// The actual width is browser dependent. For better control, use a width style property.
	ColumnCount int
	// RowCount creates a multi-line textarea with the given number of rows. By default the
	// textbox will expand vertically by this number of lines. Use a height style property for
	// better control of the height of a textbox.
	RowCount int
	// ReadOnly sets the readonly attribute of the textbox, which prevents it from being changed by the user.
	ReadOnly bool
	// SaveState will save the text in the textbox, to be restored if the user comes back to the page.
	// It is particularly helpful when the textbox is being used to filter the results of a query, so that
	// when the user comes back to the page, he does not have to type the filter text again.
	SaveState bool
	// MinValue is the minimum value the user can enter. If the user does not
	// enter at least this amount, or enters something that is not an integer, it will fail validation
	// and the FormFieldWrapper will show an error.
	MinValue *textbox.FloatLimit
	// MaxValue is the maximum value the user can enter. If the user enter more
	// than this amount, or enters something that is not an integer, it will fail validation
	// and the FormFieldWrapper will show an error.
	MaxValue *textbox.FloatLimit
	// Value is the initial value of the textbox. Often its best to load the value in a separate Load step after creating the control.
	Value interface{}

	page.ControlOptions
}

FloatTextboxCreator creates a textbox that only accepts numbers. Pass it to AddControls of a control, or as a Child of a FormFieldWrapper.

func (FloatTextboxCreator) Create added in v0.2.0

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

func (FloatTextboxCreator) Init added in v0.2.0

Init is called by implementations of Textboxes to initialize a control with the creator.

type FloatTextboxI added in v0.2.0

type FloatTextboxI interface {
	textbox.FloatI
}

type FormFieldset added in v0.2.0

type FormFieldset struct {
	control.Panel
	// contains filtered or unexported fields
}

FormFieldset is a FormGroup kind of wrapper that is specific to using a fieldset as a wrapper. See https://getbootstrap.com/docs/4.3/components/forms/#horizontal-form. You will need to coordinate with whatever you are drawing internally to get the formatting right.

func GetFormFieldset added in v0.2.0

func GetFormFieldset(c page.ControlI, id string) *FormFieldset

GetFormFieldset is a convenience method to return the fieldset with the given id from the page.

func NewFormFieldset added in v0.2.0

func NewFormFieldset(parent page.ControlI, id string) *FormFieldset

func (*FormFieldset) Deserialize added in v0.9.3

func (c *FormFieldset) Deserialize(d page.Decoder)

func (*FormFieldset) DrawInnerHtml added in v0.4.0

func (c *FormFieldset) DrawInnerHtml(ctx context.Context, w io.Writer)

func (*FormFieldset) DrawingAttributes added in v0.4.0

func (c *FormFieldset) DrawingAttributes(ctx context.Context) html5tag.Attributes

func (*FormFieldset) Init added in v0.2.0

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

func (*FormFieldset) InstructionAttributes added in v0.2.0

func (c *FormFieldset) InstructionAttributes() html5tag.Attributes

func (*FormFieldset) LegendAttributes added in v0.2.0

func (c *FormFieldset) LegendAttributes() html5tag.Attributes

func (*FormFieldset) Serialize added in v0.9.3

func (c *FormFieldset) Serialize(e page.Encoder)

func (*FormFieldset) SetAsRow added in v0.2.0

func (c *FormFieldset) SetAsRow(r bool) FormFieldsetI

func (*FormFieldset) SetInstructions added in v0.2.0

func (c *FormFieldset) SetInstructions(instructions string) FormFieldsetI

type FormFieldsetCreator added in v0.2.0

type FormFieldsetCreator struct {
	// ID is the control id on the html form.
	ID string
	// Legend is the text that will be in the html label tag associated with the Child control.
	Legend string
	// Child should be a panel, or a control that draws a group of controls,
	// like a RadioList or CheckboxList
	Child page.Creator
	// LegendAttributes are additional attributes to add to the label tag.
	LegendAttributes html5tag.Attributes
	// Instructions contains help text that accompanies the control
	Instructions string
	// Set AsRow to true to put the legend on the same row as the content
	AsRow bool
	// ControlOptions are additional options for the wrapper tag
	ControlOptions page.ControlOptions
}

FormFieldsetCreator creates a bootstrap fieldset, which wraps a control group with a fieldset. The Child item should be a panel or a control that groups other controls, like a RadioList or CheckboxList

func (FormFieldsetCreator) Create added in v0.2.0

func (FormFieldsetCreator) Init added in v0.2.0

type FormFieldsetI added in v0.2.0

type FormFieldsetI interface {
	control.PanelI
	LegendAttributes() html5tag.Attributes
	SetAsRow(r bool) FormFieldsetI
	SetInstructions(instructions string) FormFieldsetI
}

type FormGroup

type FormGroup struct {
	control.FormFieldWrapper
	// contains filtered or unexported fields
}

FormGroup is a Goradd control that wraps other controls, and provides common companion functionality like a form label, validation state display, and help text.

func GetFormGroup added in v0.2.0

func GetFormGroup(c page.ControlI, id string) *FormGroup

GetFormGroup is a convenience method to return the form group with the given id from the page.

func NewFormGroup added in v0.2.0

func NewFormGroup(parent page.ControlI, id string) *FormGroup

func (*FormGroup) ChildValidationChanged added in v0.2.5

func (c *FormGroup) ChildValidationChanged()

func (*FormGroup) Deserialize added in v0.9.3

func (c *FormGroup) Deserialize(dec page.Decoder)

func (*FormGroup) DrawTag added in v0.4.0

func (c *FormGroup) DrawTag(ctx context.Context, w io.Writer)

func (*FormGroup) DrawingAttributes added in v0.4.0

func (c *FormGroup) DrawingAttributes(ctx context.Context) html5tag.Attributes

func (*FormGroup) Init added in v0.2.0

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

func (*FormGroup) InnerDivAttributes added in v0.2.0

func (c *FormGroup) InnerDivAttributes() html5tag.Attributes

func (*FormGroup) Serialize added in v0.9.3

func (c *FormGroup) Serialize(e page.Encoder)

func (*FormGroup) SetUseTooltips added in v0.2.0

func (c *FormGroup) SetUseTooltips(use bool) FormGroupI

SetUseTooltips sets whether to use tooltips to display validation messages.

func (*FormGroup) UseTooltips added in v0.2.0

func (c *FormGroup) UseTooltips() bool

func (*FormGroup) Validate added in v0.2.0

func (c *FormGroup) Validate(ctx context.Context) bool

type FormGroupCreator added in v0.2.0

type FormGroupCreator struct {
	// ID is the optional control id on the html form. If you do not specify this, it
	// will create on for you that is the ID of the child control + "-ff"
	ID string
	// Label is the text that will be in the html label tag associated with the Child control.
	Label string
	// Child is the creator of the child control you want to wrap
	Child page.Creator
	// Instructions contains help text that will follow the control and that further describes its purpose or use.
	Instructions string
	// For specifies the id of the control that the label is for, and that is the control that we are wrapping.
	// You normally do not need to specify this, as it will default to the first child control, but if for some reason
	// that control is wrapped, you should explicitly specify the For control id here.
	For string
	// LabelAttributes are additional attributes to add to the label tag.
	LabelAttributes html5tag.Attributes
	// ErrorAttributes are additional attributes to add to the tag that displays the error.
	ErrorAttributes html5tag.Attributes
	// InstructionAttributes are additional attributes to add to the tag that displays the instructions.
	InstructionAttributes html5tag.Attributes
	// Set IsInline to true to use a "span" instead of a "div" in the wrapping tag.
	IsInline bool
	// ControlOptions are additional options for the wrapper tag
	ControlOptions page.ControlOptions
	// InnerDivAttributes are the attributes for the additional div wrapper of the control
	// To achieve certain effects, Bootstrap needs this addition div. To display the div, you
	// must specify its attributes here. Otherwise, no inner div will be displayed.
	InnerDivAttributes html5tag.Attributes
	// UseTooltips will cause validation errors to be displayed with tooltips, a specific
	// feature of Bootstrap
	UseTooltips bool
}

FormGroupCreator creates a FormGroup, which wraps a control with a div or span that also has a label, validation error text and optional instructions. Pass the creator of the control you are wrapping as the Child item.

func (FormGroupCreator) Create added in v0.2.0

func (f FormGroupCreator) Create(ctx context.Context, parent page.ControlI) page.ControlI

Create is called by the framework to create the control. You do not normally need to call it.

func (FormGroupCreator) Init added in v0.2.0

func (f FormGroupCreator) Init(ctx context.Context, c FormGroupI)

Init is called by implementations of a FormFieldWrapper to initialize the creator.

type FormGroupI added in v0.2.0

type FormGroupI interface {
	control.FormFieldWrapperI
	SetUseTooltips(use bool) FormGroupI
	UseTooltips() bool
	InnerDivAttributes() html5tag.Attributes
}

type InputGroup added in v0.12.1

type InputGroup struct {
	grctl.Panel
}

func NewInputGroup added in v0.12.1

func NewInputGroup(parent page.ControlI, id string) *InputGroup

NewInputGroup creates a new input group

func (*InputGroup) DrawingAttributes added in v0.31.7

func (g *InputGroup) DrawingAttributes(ctx context.Context) html5tag.Attributes

func (*InputGroup) Init added in v0.12.1

func (g *InputGroup) Init(self any, parent page.ControlI, id string)

type InputGroupCreator added in v0.12.1

type InputGroupCreator struct {
	// ID is the control id
	ID       string
	Children []page.Creator
	page.ControlOptions
}

func (InputGroupCreator) Create added in v0.12.1

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

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

func (InputGroupCreator) Init added in v0.31.7

func (c InputGroupCreator) Init(ctx context.Context, ctrl InputGroupI)

Init is called by implementations to initialize a control with the creator.

type InputGroupI added in v0.12.1

type InputGroupI interface {
	grctl.PanelI
}

type IntegerTextbox

type IntegerTextbox struct {
	textbox.IntegerTextbox
}

func GetIntegerTextbox added in v0.2.0

func GetIntegerTextbox(c page.ControlI, id string) *IntegerTextbox

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

func NewIntegerTextbox

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

func (*IntegerTextbox) DrawingAttributes

func (t *IntegerTextbox) DrawingAttributes(ctx context.Context) html5tag.Attributes

type IntegerTextboxCreator added in v0.2.0

type IntegerTextboxCreator struct {
	// ID is the control id of the html widget and must be unique to the page
	ID string
	// Placeholder is the placeholder attribute of the textbox and shows as help text inside the field
	Placeholder string
	// Type is the type attribute of the textbox
	Type string
	// MinLength is the minimum number of characters that the user is required to enter. If the
	// length is less than this number, a validation error will be shown.
	MinLength int
	// MaxLength is the maximum number of characters that the user is required to enter. If the
	// length is more than this number, a validation error will be shown.
	MaxLength int
	// ColumnCount is the number of characters wide the textbox will be, and becomes the width attribute in the tag.
	// The actual width is browser dependent. For better control, use a width style property.
	ColumnCount int
	// RowCount creates a multi-line textarea with the given number of rows. By default the
	// textbox will expand vertically by this number of lines. Use a height style property for
	// better control of the height of a textbox.
	RowCount int
	// ReadOnly sets the readonly attribute of the textbox, which prevents it from being changed by the user.
	ReadOnly bool
	// SaveState will save the text in the textbox, to be restored if the user comes back to the page.
	// It is particularly helpful when the textbox is being used to filter the results of a query, so that
	// when the user comes back to the page, he does not have to type the filter text again.
	SaveState bool
	// MinValue is the minimum value the user can enter. If the user does not
	// enter at least this amount, or enters something that is not an integer, it will fail validation
	// and the FormFieldWrapper will show an error.
	MinValue *textbox.IntegerLimit
	// MaxValue is the maximum value the user can enter. If the user enter more
	// than this amount, or enters something that is not an integer, it will fail validation
	// and the FormFieldWrapper will show an error.
	MaxValue *textbox.IntegerLimit
	// Value is the initial value of the textbox. Often its best to load the value in a separate Load step after creating the control.
	Value interface{}

	page.ControlOptions
}

IntegerTextboxCreator creates an integer textbox. Pass it to AddControls of a control, or as a Child of a FormFieldWrapper.

func (IntegerTextboxCreator) Create added in v0.2.0

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

func (IntegerTextboxCreator) Init added in v0.2.0

Init is called by implementations of Textboxes to initialize a control with the creator.

type IntegerTextboxI added in v0.2.0

type IntegerTextboxI interface {
	textbox.IntegerI
}

type ItemDirection

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

type ListGroup

type ListGroup struct {
	list.UnorderedList
	// contains filtered or unexported fields
}

A ListGroup implements the Bootstrap ListGroup control. Since just a static list isn't all that interesting, this is a dynamic list whose individual items are considered clickable. To conform with the html standard and accessibility rules, items should appear as anchors if they link to another page, but as buttons if they cause a different action, like popping up a dialog.

Use the data provider to AddItems to the list, assigning attributes as needed to produce the items you want. You can also use a proxy control to create the attributes.

func GetListGroup added in v0.2.0

func GetListGroup(c page.ControlI, id string) *ListGroup

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

func NewListGroup

func NewListGroup(parent page.ControlI, id string) *ListGroup

func (*ListGroup) Deserialize added in v0.27.1

func (l *ListGroup) Deserialize(dec page.Decoder)

func (*ListGroup) DoPrivateAction added in v0.27.1

func (l *ListGroup) DoPrivateAction(_ context.Context, a action.Params)

func (*ListGroup) GetItemsHtml

func (l *ListGroup) GetItemsHtml(items []*list.Item) string

func (*ListGroup) Init

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

func (*ListGroup) SelectedID added in v0.27.1

func (l *ListGroup) SelectedID() string

SelectedID returns the id of the currently selected item.

func (*ListGroup) Serialize added in v0.27.1

func (l *ListGroup) Serialize(e page.Encoder)

func (*ListGroup) SetIsSelectable added in v0.27.1

func (l *ListGroup) SetIsSelectable(canSelect bool)

SetIsSelectable sets whether the list group will remember and show the most recently selected item as selected. Do this AFTER you set the item tag.

type ListGroupCreator added in v0.2.0

type ListGroupCreator struct {
	ID string
	// Items is a static list of labels and values that will be in the list. Or, use a DataProvider to dynamically generate the items.
	Items []list.ListValue
	// DataProvider is the control that will dynamically provide the data for the list and that implements the DataBinder interface.
	DataProvider control.DataBinder
	// DataProviderID is the id of a control that will dynamically provide the data for the list and that implements the DataBinder interface.
	DataProviderID string
	page.ControlOptions
	// ItemTag is the tag of the items. It defaults to "a".
	ItemTag string
	// IsSelectable determines whether a clicked item will be shown as selected.
	IsSelectable bool
	// OnClick is the action to take when an item is clicked.
	// The id of the item will appear as the action's ControlValue.
	OnClick action.ActionI
}

func (ListGroupCreator) Create added in v0.2.0

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

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

func (ListGroupCreator) Init added in v0.2.0

func (c ListGroupCreator) Init(ctx context.Context, ctrl ListGroupI)

type ListGroupI added in v0.2.0

type ListGroupI interface {
	list.UnorderedListI
	SetIsSelectable(bool)
}
type Modal struct {
	control.Panel
	// contains filtered or unexported fields
}

Modal is a Bootstrap modal dialog control.

To create Modal, you have a few options:

  • Call NewModal()
  • Pass a ModalCreator object to the form's AddControls() function.
  • Since Modal implements dialog.DialogI, you can also call the dialog.Alert function. If you have previously called setupBootstrap() in your project's config/goradd.go file, then that function will call NewModal to create a Bootstrap style modal dialog.

To use a custom template in a bootstrap modal, add a Panel child element or subclass of a panel child element. To use the grid system, add the container-fluid class to that embedded panel.

A modal dialog starts out hidden. Call Show() on the modal dialog to display it.

func GetModal added in v0.2.3

func GetModal(c page.ControlI, id string) *Modal

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

func NewModal

func NewModal(parent page.ControlI, id string) *Modal

NewModal creates a new Modal dialog control.

func (*Modal) AddButton

func (m *Modal) AddButton(
	label string,
	id string,
	options *dialog.ButtonOptions,
)

AddButton adds a button to the modal. Buttons should be added in the order to appear. Styling options you can include in options.Options:

style - ButtonStyle value
size - ButtonSize value

func (*Modal) AddCloseButton

func (m *Modal) 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 (*Modal) AddTitlebarClass

func (m *Modal) AddTitlebarClass(class string)

AddTitlebarClass adds a css class to the class of the title bar.

func (*Modal) Deserialize added in v0.9.3

func (m *Modal) Deserialize(d page.Decoder)

Deserialize is called by the framework to restore the state of the dialog.

func (*Modal) DoPrivateAction added in v0.23.0

func (m *Modal) DoPrivateAction(_ context.Context, a action.Params)

DoPrivateAction is called by the framework to record that a dialog was closed.

func (*Modal) DrawTemplate

func (d *Modal) DrawTemplate(ctx context.Context, _w io.Writer) (err error)

func (*Modal) DrawingAttributes

func (m *Modal) DrawingAttributes(ctx context.Context) html5tag.Attributes

func (*Modal) Hide added in v0.5.0

func (m *Modal) Hide()

Hide will visibly hide the modal, but will keep its html and javascript code in the client.

func (*Modal) Init

func (m *Modal) Init(self any, parent page.ControlI, id string)

Init is called by the framework to initialize a modal dialog.

Subclasses should call Init after creating themselves.

func (*Modal) MergeButtonAttributes added in v0.27.0

func (m *Modal) MergeButtonAttributes(id string, a html5tag.Attributes)

MergeButtonAttributes merges the give attributes into the button's current attributes.

func (*Modal) PutCustomScript

func (m *Modal) PutCustomScript(_ context.Context, response *page.Response)

PutCustomScript is called by the framework to insert the javascript required to manage the Bootstrap modal.

func (*Modal) RemoveAllButtons

func (m *Modal) RemoveAllButtons()

RemoveAllButtons removes all the buttons from the modal.

func (*Modal) RemoveButton

func (m *Modal) RemoveButton(id string)

RemoveButton removes the button from the dialog with the given id.

func (*Modal) Serialize added in v0.9.3

func (m *Modal) Serialize(e page.Encoder)

Serialize is called by the framework to record the state of the modal dialog object.

func (*Modal) SetBackdrop

func (m *Modal) SetBackdrop(b ModalBackdropType)

SetBackdrop determines whether the modal dialog will close when clicking on the backdrop.

func (*Modal) SetButtonStyle

func (m *Modal) SetButtonStyle(id string, a html5tag.Style)

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

func (*Modal) SetButtonText added in v0.13.4

func (m *Modal) SetButtonText(id string, text string)

SetButtonText sets the text of a button that is already on the dialog

func (*Modal) SetButtonVisible

func (m *Modal) SetButtonVisible(id string, visible bool)

SetButtonVisible sets the visible state of the button with the given id.

func (*Modal) SetDialogStyle added in v0.0.3

func (m *Modal) SetDialogStyle(style dialog.Style)

SetDialogStyle sets the style of the dialog.

These styles are mapped to Bootstrap TextColor* styles.

func (*Modal) SetHasCloseBox

func (m *Modal) SetHasCloseBox(h bool)

SetHasCloseBox determines if the modal has a close box in the upper corner which will close the dialog.

func (*Modal) SetTitle

func (m *Modal) SetTitle(t string)

SetTitle sets the content of the title of the modal dialog.

func (*Modal) Show added in v0.5.0

func (m *Modal) Show()

Show will cause the modal to appear.

func (*Modal) Title

func (m *Modal) Title() string

Title returns the title of the dialog.

type ModalBackdropType

type ModalBackdropType int
const (
	ModalBackdrop       ModalBackdropType = iota // Standard bootstrap backdrop. Clicking the backdrop closes the modal.
	ModalStaticBackdrop                          // Clicking the backdrop will not close the modal.
)

type ModalButtonCreator added in v0.2.3

type ModalButtonCreator struct {
	Label               string
	ID                  string
	Validates           bool
	ConfirmationMessage string
	PushLeft            bool
	IsClose             bool
	Options             map[string]interface{}
}

ModalButtonCreator declares a dialog button to put on a modal. Pass the structure to the ModalButtons function.

func ModalButtons added in v0.2.3

func ModalButtons(buttons ...ModalButtonCreator) []ModalButtonCreator

ModalButtons is a helper for declaring buttons on a Modal dialog control. Pass it to the Buttons parameter of a ModalCreator.

type ModalCreator added in v0.2.3

type ModalCreator struct {
	ID            string
	Title         string
	TitlebarClass string
	HasCloseBox   bool
	Style         dialog.Style
	Backdrop      ModalBackdropType
	Buttons       []ModalButtonCreator
	OnButton      action.ActionI
	page.ControlOptions
	Children []page.Creator
}

ModalCreator declares a Bootstrap modal dialog. Pass this structure to the AddControls function of a form.

For example, the following will create a dialog with a title, text, and two buttons.

	 form.AddControls(
	   ModalCreator {
      ID: "my-modal",
      Title: "Look Out!",
      Style: dialog.WarningStyle,
      Buttons: ModalButtons(
        ModalButtonCreator {
          Label: "OK",
          ID: "ok",
          IsClose: true,
        },
        ModalButtonCreator {
          Label: "Cancel",
          ID: "cancel",
          IsClose: true,
        }
      ),
	   }
	 )

func (ModalCreator) Create added in v0.2.3

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

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

type ModalI

type ModalI interface {
	dialog.DialogI
}
type NavLink struct {
	grctl.ActiveLink
}

NavLink creates an anchor tag with a nav-link class. It is used to create a link in a NavBar, and generally should be a child item of a NavGroup.

func GetNavLink(c page.ControlI, id string) *NavLink

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

func NewNavLink(parent page.ControlI, id string) *NavLink

NewNavLink creates a new NavLink.

func (l *NavLink) DrawingAttributes(ctx context.Context) html5tag.Attributes

DrawingAttributes returns the attributes to add to the tag just before the button is drawn.

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

Init initializes the button

type NavLinkCreator struct {
	// ID is the control id. This is also the eventValue sent by the enclosing Navbar.
	ID string
	// Text is the text displayed in the link
	Text string
	// Location is the content of the href, which is the url where the link will go.
	// Alternatively, add an On handler to the ControlOptions
	Location string
	// ActiveAttributes are additional attributes to add to the active link. By default, the ActiveAttributes
	// will add the "active" class and aria-current=page.
	ActiveAttributes html5tag.Attributes
	page.ControlOptions
}

NavLinkCreator is the initialization structure for the declarative creation of the control.

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

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

func (c NavLinkCreator) Init(ctx context.Context, ctrl NavLinkI)

Init is called by implementations of NavLinks to initialize a control with the creator.

type NavLinkI interface {
	grctl.ActiveLinkI
}
type Navbar struct {
	page.ControlBase
	// contains filtered or unexported fields
}

Navbar is a bootstrap navbar object. Use SetText() to set the logo text of the navbar, and SetTextIsHtml() to true to turn off encoding if needed. Add child controls to populate it. When adding NavLink objects, they should be grouped together using the NavGroup object.

func GetNavbar added in v0.2.0

func GetNavbar(c page.ControlI, id string) *Navbar

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

func NewNavbar

func NewNavbar(parent page.ControlI, id string) *Navbar

NewNavbar returns a newly created Bootstrap Navbar object

func (b *Navbar) Deserialize(d page.Decoder)
func (b *Navbar) DrawTemplate(ctx context.Context, _w io.Writer) (err error)
func (b *Navbar) DrawingAttributes(ctx context.Context) html5tag.Attributes
func (b *Navbar) Init(self any, parent page.ControlI, id string)
func (b *Navbar) OnClick(a action.ActionI) NavbarI

OnClick sets the action to take when a link in the Navbar is selected. It will only respond to links whose href is "#", which indicates its an empty link. The EventValue will be the id of the link clicked.

func (b *Navbar) Serialize(e page.Encoder)
func (b *Navbar) SetBackgroundClass(c BackgroundColorClass) NavbarI
func (b *Navbar) SetBrand(label string, anchor string, p NavbarCollapsedBrandPlacement) NavbarI
func (b *Navbar) SetContainerClass(class ContainerClass) NavbarI
func (b *Navbar) SetExpand(e NavbarExpandClass) NavbarI
func (b *Navbar) SetNavbarStyle(style NavbarStyle) NavbarI
type NavbarCollapsedBrandPlacement int

NavbarCollapsedBrandPlacement controls the location of the brand when the navbar is collapsed

const (
	// NavbarCollapsedBrandLeft will place the brand on the left and the toggle button on the right when collapsed
	NavbarCollapsedBrandLeft NavbarCollapsedBrandPlacement = iota
	// NavbarCollapsedBrandRight will place the brand on the right and the toggle button on the left when collapsed
	NavbarCollapsedBrandRight
	// NavbarCollapsedBrandHidden means the brand will be hidden when collapsed, and shown when expanded
	NavbarCollapsedBrandHidden
)
type NavbarCreator struct {
	ID string
	// Brand is the string to use for the brand
	Brand string
	// BrandIsHtml can be set to true to specify that the Brand string should not be escaped
	BrandIsHtml bool
	// BrandAnchor is the url to go to when the main logo in the navbar is clicked
	BrandAnchor string
	// Style is either NavbarDark or NavbarLight
	Style NavbarStyle
	// BackgroundColorClass is one of the background colors that you can assign the navbar
	BackgroundColorClass BackgroundColorClass
	// Expand determines at what screen width the navbar will be expanded.
	Expand NavbarExpandClass
	// BrandLocation controls the placement of the brand item
	BrandLocation NavbarCollapsedBrandPlacement
	// ContainerClass is the class of the container that will wrap the contents of the navbar
	ContainerClass ContainerClass

	// OnClick is the action to take when a link is clicked. It will only respond
	// to nav-link items that have an href of "#". The EventValue will be the id of the item clicked.
	OnClick action.ActionI

	page.ControlOptions
	Children []page.Creator
}
func (c NavbarCreator) Create(ctx context.Context, parent page.ControlI) page.ControlI

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

func (c NavbarCreator) Init(ctx context.Context, ctrl NavbarI)
type NavbarExpandClass string
type NavbarI interface {
	page.ControlI
	SetNavbarStyle(style NavbarStyle) NavbarI
	SetBrand(label string, anchor string, p NavbarCollapsedBrandPlacement) NavbarI
	SetBackgroundClass(c BackgroundColorClass) NavbarI
	SetExpand(e NavbarExpandClass) NavbarI
	SetContainerClass(class ContainerClass) NavbarI
	OnClick(action action.ActionI) NavbarI
}
type NavbarStyle string
const (
	NavbarDark  NavbarStyle = "navbar-dark" // black on white
	NavbarLight             = "navbar-light"
)

type PhoneTextbox added in v0.7.1

type PhoneTextbox struct {
	textbox.PhoneTextbox
}

func GetPhoneTextbox added in v0.7.1

func GetPhoneTextbox(c page.ControlI, id string) *PhoneTextbox

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

func NewPhoneTextbox added in v0.7.1

func NewPhoneTextbox(parent page.ControlI, id string) *PhoneTextbox

func (*PhoneTextbox) DrawingAttributes added in v0.7.1

func (t *PhoneTextbox) DrawingAttributes(ctx context.Context) html5tag.Attributes

type PhoneTextboxCreator added in v0.7.1

type PhoneTextboxCreator struct {
	// ID is the control id of the html widget and must be unique to the page
	ID string
	// Placeholder is the placeholder attribute of the textbox and shows as help text inside the field
	Placeholder string
	// Type is the type attribute of the textbox
	Type string
	// MinLength is the minimum number of characters that the user is required to enter. If the
	// length is less than this number, a validation error will be shown.
	MinLength int
	// MaxLength is the maximum number of characters that the user is required to enter. If the
	// length is more than this number, a validation error will be shown.
	MaxLength int
	// ColumnCount is the number of characters wide the textbox will be, and becomes the width attribute in the tag.
	// The actual width is browser dependent. For better control, use a width style property.
	ColumnCount int
	// ReadOnly sets the readonly attribute of the textbox, which prevents it from being changed by the user.
	ReadOnly bool
	// SaveState will save the text in the textbox, to be restored if the user comes back to the page.
	// It is particularly helpful when the textbox is being used to filter the results of a query, so that
	// when the user comes back to the page, he does not have to type the filter text again.
	SaveState bool
	// Text is the initial value of the textbox. Often its best to load the value in a separate Load step after creating the control.
	Text string

	page.ControlOptions
}

PhoneTextboxCreator creates an phone textbox. Pass it to AddControls of a control, or as a Child of a FormFieldWrapper.

func (PhoneTextboxCreator) Create added in v0.7.1

func (PhoneTextboxCreator) Init added in v0.7.1

type PhoneTextboxI added in v0.7.1

type PhoneTextboxI interface {
	textbox.PhoneI
}

type RadioButton

type RadioButton struct {
	button.RadioButton
	// contains filtered or unexported fields
}

func GetRadioButton added in v0.2.0

func GetRadioButton(c page.ControlI, id string) *RadioButton

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

func NewRadioButton

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

func (*RadioButton) Deserialize

func (c *RadioButton) Deserialize(d page.Decoder)

func (*RadioButton) DrawTag

func (c *RadioButton) DrawTag(ctx context.Context, w io.Writer)

func (*RadioButton) DrawingAttributes

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

func (*RadioButton) GetDrawingLabelAttributes added in v0.4.0

func (c *RadioButton) GetDrawingLabelAttributes() html5tag.Attributes

func (*RadioButton) Serialize

func (c *RadioButton) Serialize(e page.Encoder)

func (*RadioButton) SetInline added in v0.0.4

func (c *RadioButton) SetInline(v bool) *RadioButton

type RadioButtonCreator added in v0.2.0

type RadioButtonCreator struct {
	// ID is the id of the control
	ID string
	// Text is the text of the label displayed right next to the checkbox.
	Text string
	// Checked will initialize the checkbox in its checked state.
	Checked bool
	// LabelMode specifies how the label is drawn with the checkbox.
	LabelMode html5tag.LabelDrawingMode
	// LabelAttributes are additional attributes placed on the label tag.
	LabelAttributes html5tag.Attributes
	// SaveState will save the value of the checkbox and restore it when the page is reentered.
	SaveState bool
	// Group is the name of the group that the button belongs to
	Group string
	// Inline draws the radio group inline. Specify this when drawing the
	// radio button inline or in an inline FormGroup.
	Inline bool
	page.ControlOptions
}

func (RadioButtonCreator) Create added in v0.2.0

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

type RadioButtonI

type RadioButtonI interface {
	button.RadioButtonI
}

type RadioList

type RadioList struct {
	list.RadioList
	// contains filtered or unexported fields
}

RadioList is a multi-select control that presents its choices as a list of radio buttons. Styling is provided by divs and spans that you can provide css for in your style sheets. The goradd.css file has default styling to handle the basics. It wraps the whole thing in a div that can be set to scroll as well, so that the final structure can be styled like a multi-table table, or a single-table scrolling list much like a standard html select list.

func GetRadioList added in v0.2.0

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

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

func NewRadioList

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

func (*RadioList) Deserialize added in v0.9.3

func (l *RadioList) Deserialize(d page.Decoder)

func (*RadioList) DrawingAttributes added in v0.4.0

func (l *RadioList) DrawingAttributes(ctx context.Context) html5tag.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 any, parent page.ControlI, id string)

func (*RadioList) RenderItem added in v0.4.0

func (l *RadioList) RenderItem(item *list.Item) (h string)

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

func (*RadioList) Serialize added in v0.9.3

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

func (*RadioList) SetCellClass added in v0.2.0

func (l *RadioList) SetCellClass(c string)

SetCellClass sets a string that is applied to every cell. This is useful for setting responsive breakpoints

func (*RadioList) SetIsInline added in v0.2.0

func (l *RadioList) SetIsInline(i bool)

type RadioListCreator added in v0.2.0

type RadioListCreator struct {
	ID string
	// Items is a static list of labels and values that will be in the list. Or, use a DataProvider to dynamically generate the items.
	Items []list.ListValue
	// DataProvider is the control that will dynamically provide the data for the list and that implements the DataBinder interface.
	DataProvider control.DataBinder
	// DataProviderID is the id of a control that will dynamically provide the data for the list and that implements the DataBinder interface.
	DataProviderID string
	// ColumnCount specifies how many columns to show
	ColumnCount int
	// LayoutDirection determines how the items are arranged in the columns
	LayoutDirection control.LayoutDirection
	// LabelDrawingMode specifies how the labels on the radio buttons will be associated with the buttons
	LabelDrawingMode html5tag.LabelDrawingMode
	// IsScrolling will give the inner div a vertical scroll style. You will need to style the height of the outer control to have a fixed style as well.
	IsScrolling bool
	// RowClass is the class assigned to each row
	RowClass string
	// Value is the initial value of the textbox. Often its best to load the value in a separate Load step after creating the control.
	Value string
	// OnChange is the action to take when any of the radio buttons in the list change
	OnChange action.ActionI
	// SaveState saves the selected value so that it is restored if the form is returned to.
	SaveState bool
	page.ControlOptions
}

func (RadioListCreator) Create added in v0.2.0

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

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

func (RadioListCreator) Init added in v0.2.0

func (c RadioListCreator) Init(ctx context.Context, ctrl RadioListI)

type RadioListGroup added in v0.12.0

type RadioListGroup struct {
	RadioList
	// contains filtered or unexported fields
}

RadioListGroup is a RadioList styled as a group.

See https://getbootstrap.com/docs/4.4/components/buttons/#checkbox-and-radio-buttons

func GetRadioListGroup added in v0.12.0

func GetRadioListGroup(c page.ControlI, id string) *RadioListGroup

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

func NewRadioListGroup added in v0.12.0

func NewRadioListGroup(parent page.ControlI, id string) *RadioListGroup

func (*RadioListGroup) Deserialize added in v0.12.0

func (l *RadioListGroup) Deserialize(d page.Decoder)

func (*RadioListGroup) DrawingAttributes added in v0.12.0

func (l *RadioListGroup) DrawingAttributes(ctx context.Context) html5tag.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 (*RadioListGroup) Init added in v0.12.0

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

func (*RadioListGroup) RenderItem added in v0.12.0

func (l *RadioListGroup) RenderItem(item *list.Item) (h string)

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

func (*RadioListGroup) Serialize added in v0.12.0

func (l *RadioListGroup) Serialize(e page.Encoder)

func (*RadioListGroup) SetButtonStyle added in v0.12.0

func (l *RadioListGroup) SetButtonStyle(buttonStyle string) RadioListGroupI

type RadioListGroupCreator added in v0.12.0

type RadioListGroupCreator struct {
	ID string
	// Items is a static list of labels and values that will be in the list. Or, use a DataProvider to dynamically generate the items.
	Items []list.ListValue
	// DataProvider is the control that will dynamically provide the data for the list and that implements the DataBinder interface.
	DataProvider control.DataBinder
	// DataProviderID is the id of a control that will dynamically provide the data for the list and that implements the DataBinder interface.
	DataProviderID string
	// Value is the initial value of the radio list. Often its best to load the value in a separate Load step after creating the control.
	Value string
	// SaveState saves the selected value so that it is restored if the form is returned to.
	ButtonStyle string
	// OnChange is the action to take when any of the radio buttons in the list change
	OnChange  action.ActionI
	SaveState bool
	page.ControlOptions
}

func (RadioListGroupCreator) Create added in v0.12.0

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

func (RadioListGroupCreator) Init added in v0.12.0

type RadioListGroupI added in v0.12.0

type RadioListGroupI interface {
	RadioListI
	SetButtonStyle(string) RadioListGroupI
}

type RadioListI

type RadioListI interface {
	list.RadioListI
}

type SelectList

type SelectList struct {
	list.SelectList
}

func GetSelectList added in v0.2.0

func GetSelectList(c page.ControlI, id string) *SelectList

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

func NewSelectList

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

func (*SelectList) DrawingAttributes

func (l *SelectList) DrawingAttributes(ctx context.Context) html5tag.Attributes

func (*SelectList) Init added in v0.3.0

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

type SelectListCreator added in v0.2.0

type SelectListCreator struct {
	ID string
	// Items is a static list of labels and values that will be in the list. Or, use a DataProvider to dynamically generate the items.
	Items []list.ListValue
	// NilItem is a helper to add an item at the top of the list with a nil value. This is often
	// used to specify no selection, or a message that a selection is required.
	NilItem string
	// DataProvider is the control that will dynamically provide the data for the list and that implements the DataBinder interface.
	DataProvider control.DataBinder
	// DataProviderID is the id of a control that will dynamically provide the data for the list and that implements the DataBinder interface.
	DataProviderID string
	// Size specifies how many items to show, and turns the list into a scrolling list
	Size int
	// Value is the initial value of the select. Often its best to load the value in a separate Load step after creating the control.
	Value string
	// SaveState saves the selected value so that it is restored if the form is returned to.
	SaveState bool
	// OnChange is an action to take when the user changes what is selected (as in, when the javascript change event fires).
	OnChange action.ActionI
	page.ControlOptions
}

func (SelectListCreator) Create added in v0.2.0

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

func (SelectListCreator) Init added in v0.2.0

func (c SelectListCreator) Init(ctx context.Context, ctrl SelectListI)

type SelectListI added in v0.2.0

type SelectListI interface {
	list.SelectListI
}

type Tabs

type Tabs struct {
	control.Panel
	// contains filtered or unexported fields
}

Tabs draws its child controls as a set of tabs. The Text value of the children serve as the tab labels.

This currently draws everything at once, with the current panel visible, but everything else has hidden html. By default, it will save its state so that refreshes of the page, or coming back to the same page, will cause it to remember what tab it was on last.

Whenever a tab is clicked, the TabSelect event will be fired via an Ajax call. Containers of the Tabs control can listen for this event by simply implementing DoAction without needing to create a TabSelect event listener.

If you need to know that a tab is being hidden, you can watch the TabHidden event.

Call SelectedId to return the id of the currently selected tab.

Call SetTabStyle to set the style to be tabs, pills or underline.

The tab structure is surrounded by a Card, and the content is drawn in a div with class card-body.

func GetTabs added in v0.2.0

func GetTabs(c page.ControlI, id string) *Tabs

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

func NewTabs

func NewTabs(ctx context.Context, parent page.ControlI, id string) *Tabs

func (*Tabs) Deserialize added in v0.9.3

func (t *Tabs) Deserialize(d page.Decoder)

func (*Tabs) DoAction added in v0.31.2

func (t *Tabs) DoAction(ctx context.Context, a action.Params)

func (*Tabs) DrawInnerHtml added in v0.31.3

func (t *Tabs) DrawInnerHtml(ctx context.Context, _w io.Writer)

func (*Tabs) DrawingAttributes

func (t *Tabs) DrawingAttributes(ctx context.Context) html5tag.Attributes

func (*Tabs) Init

func (t *Tabs) Init(ctx context.Context, self any, parent page.ControlI, id string)

func (*Tabs) MarshalState added in v0.31.2

func (t *Tabs) MarshalState(m page.SavedState)

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

func (*Tabs) SelectedId added in v0.31.2

func (t *Tabs) SelectedId() string

func (*Tabs) Serialize added in v0.9.3

func (t *Tabs) Serialize(e page.Encoder)

func (*Tabs) SetTabStyle added in v0.31.2

func (t *Tabs) SetTabStyle(s string)

SetTabStyle sets the style of the tabs.

Choose one of:

  • TabStyleNone
  • TabStyleTabs
  • TabStylePills
  • TabStyleUnderline

func (*Tabs) UnmarshalState added in v0.31.2

func (t *Tabs) UnmarshalState(m page.SavedState)

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

type TabsCreator added in v0.2.0

type TabsCreator struct {
	// ID is the control id of the html widget and must be unique to the page
	ID string
	page.ControlOptions
	Children []page.Creator
	TabStyle string
}

TabsCreator is the declarative definition of a tab pane.

Set the Children to control.Panel objects that will contain the content of each tab shown. The Text value of each Panel will be the label of the tab.

TabStyle should be one of:

  • TabStyleNone
  • TabStyleTabs
  • TabStylePills
  • TabStyleUnderline

func (TabsCreator) Create added in v0.2.0

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

type TabsI added in v0.2.0

type TabsI interface {
	control.PanelI
}

type TextColorClass

type TextColorClass string

type Textbox

type Textbox struct {
	textbox.Textbox
}

func GetTextbox added in v0.2.3

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

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

func NewTextbox

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

func (*Textbox) DrawingAttributes

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

type TextboxCreator added in v0.2.0

type TextboxCreator struct {
	// ID is the control id of the html widget and must be unique to the page
	ID string
	// Placeholder is the placeholder attribute of the textbox and shows as help text inside the field
	Placeholder string
	// Type is the type attribute of the textbox
	Type string
	// MinLength is the minimum number of characters that the user is required to enter. If the
	// length is less than this number, a validation error will be shown.
	MinLength int
	// MaxLength is the maximum number of characters that the user is required to enter. If the
	// length is more than this number, a validation error will be shown.
	MaxLength int
	// ColumnCount is the number of characters wide the textbox will be, and becomes the width attribute in the tag.
	// The actual width is browser dependent. For better control, use a width style property.
	ColumnCount int
	// RowCount creates a multi-line textarea with the given number of rows. By default, the
	// textbox will expand vertically by this number of lines. Use a height style property for
	// better control of the height of a textbox.
	RowCount int
	// ReadOnly sets the readonly attribute of the textbox, which prevents it from being changed by the user.
	ReadOnly bool
	// SaveState will save the text in the textbox, to be restored if the user comes back to the page.
	// It is particularly helpful when the textbox is being used to filter the results of a query, so that
	// when the user comes back to the page, he does not have to type the filter text again.
	SaveState bool
	// Text is the initial value of the textbox. Generally you would not use this, but rather load the value in a separate Load step after creating the control.
	Text string

	page.ControlOptions
}

TextboxCreator creates a textbox. Pass it to AddControls of a control, or as a Child of a FormGroup.

func (TextboxCreator) Create added in v0.2.0

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

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

func (TextboxCreator) Init added in v0.2.0

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

type TextboxI added in v0.2.0

type TextboxI interface {
	textbox.TextboxI
}

type TitleBar

type TitleBar struct {
	control.Panel
	HasCloseBox bool
	Title       string
}

TitleBar is a control that displays the title bar portion of a modal dialog.

func NewTitleBar

func NewTitleBar(parent page.ControlI, id string) *TitleBar

NewTitleBar creates a new TitleBar control.

func (*TitleBar) DrawTemplate

func (d *TitleBar) DrawTemplate(ctx context.Context, _w io.Writer) (err error)

Jump to

Keyboard shortcuts

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