widget

package
v5.0.0-...-03972fd Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BoolFormatter    echo.Formatter // Must be defined in application level
	StringFormatter  = &echo.BaseFormatter{Decoder: echo.StringCodec}
	IntFormatter     = &echo.BaseFormatter{Decoder: echo.IntCodec}
	Int8Formatter    = &echo.BaseFormatter{Decoder: echo.Int8Codec}
	Int16Formatter   = &echo.BaseFormatter{Decoder: echo.Int16Codec}
	Int32Formatter   = &echo.BaseFormatter{Decoder: echo.Int32Codec}
	Int64Formatter   = &echo.BaseFormatter{Decoder: echo.Int64Codec}
	UintFormatter    = &echo.BaseFormatter{Decoder: echo.UintCodec}
	Uint8Formatter   = &echo.BaseFormatter{Decoder: echo.Uint8Codec}
	Uint16Formatter  = &echo.BaseFormatter{Decoder: echo.Uint16Codec}
	Uint32Formatter  = &echo.BaseFormatter{Decoder: echo.Uint32Codec}
	Uint64Formatter  = &echo.BaseFormatter{Decoder: echo.Uint64Codec}
	Float32Formatter = &echo.BaseFormatter{Decoder: echo.Float32Codec}
	Float64Formatter = &echo.BaseFormatter{Decoder: echo.Float64Codec}
	DefaultFormatter = StringFormatter
)

Formatters for standard types

View Source
var (
	MessagePagerPrev                = DeclareDefaultMsg(1000, "Prev")
	MessagePagerNext                = DeclareDefaultMsg(1001, "Next")
	MessageListRecords              = DeclareDefaultMsg(1002, "Shows rows from %d to %d of %d")
	MessageListNoRecords            = DeclareDefaultMsg(1003, "No data for display")
	MessageDetailsColumnKey         = DeclareDefaultMsg(1004, "Key")
	MessageDetailsColumnVal         = DeclareDefaultMsg(1005, "Value")
	MessageTableTooltipActionView   = DeclareDefaultMsg(1006, "View")
	MessageTableTooltipActionUpdate = DeclareDefaultMsg(1007, "Update")
	MessageTableTooltipActionDelete = DeclareDefaultMsg(1008, "Delete this row")
	MessageTableConfirmActionDelete = DeclareDefaultMsg(1009, "Are you sure delete row?")
	MessageConstraintInvalid        = DeclareDefaultMsg(1010, "Invalid value")
	MessageConstraintRequired       = DeclareDefaultMsg(1011, "Required value")
	MessageConstraintPattern        = DeclareDefaultMsg(1012, "Value don't match pattern")
	MessageConstraintMaxLength      = DeclareDefaultMsg(1013, "Value too long")
	MessageSelectorEmpty            = DeclareDefaultMsg(1014, "(Empty)")
	MessageMultistepFormPrev        = DeclareDefaultMsg(1015, "Prev")
	MessageMultistepFormNext        = DeclareDefaultMsg(1016, "Next")
)
View Source
var (
	DefaultDocumentParamRe     = regexp.MustCompile(`(?i:{{\s*([\w\d.\-]+)\s*}})`)
	DefaultDocumentReferenceRe = regexp.MustCompile(`\[([^]]+)]\(([a-z0-9]+)\)`)
)
View Source
var DefaultTableActionDelete = &TableAction{}
View Source
var DefaultTableActionUpdate = &TableAction{}
View Source
var DefaultTableActionView = &TableAction{}
View Source
var MultiStepNextBtn = &Action{
	Label: MessageMultistepFormNext,
}

Default definition of NEXT button for multistep form.

View Source
var MultiStepPrevBtn = &Action{
	Label: MessageMultistepFormPrev,
}

Default definition of PREV button for multistep form.

View Source
var (
	TimeInfinity int64 = 0x7fffffffffffffff
)

Functions

func AddMultiStepHandler

func AddMultiStepHandler(
	router echo.Router,
	handler echo.HandlerFunc,
)

Attach handler to MUX

func Coalesce

func Coalesce(
	ctx echo.Context,
	ws ...echo.Widget,
) (interface{}, error)

Render first of existing widgets

func ConvertToHtml

func ConvertToHtml(v interface{}) (string, error)

Convert value into Html.

func FormatMessage

func FormatMessage(
	ctx echo.Context,
	layout interface{},
	args ...interface{},
) (string, error)

Simple message formatter with fmt.Sprintf util.

func RenderDataSet

func RenderDataSet(
	ctx echo.Context,
	dataset echo.DataSet,
	selected map[string]bool,
) ([]interface{}, error)

Render data set

func RenderLink(
	ctx echo.Context,
	v interface{},
) (string, error)

Render link without escape.

func RenderList

func RenderList(
	ctx echo.Context,
	list List,
) ([]interface{}, error)

Render list of values.

func RenderMap

func RenderMap(
	ctx echo.Context,
	widgets Map,
) (map[string]interface{}, error)

Render map of values.

func RenderParams

func RenderParams(
	ctx echo.Context,
	params []interface{},
) ([]interface{}, error)

Translate striped parameters into plain representation.

func RenderValidationErrors

func RenderValidationErrors(
	ctx echo.Context,
	errors echo.ValidationErrors,
) ([]string, error)

Render all validation errors

Types

type Action

type Action struct {
	Label    interface{} // Visible label
	Action   interface{} // Action (url or url.URL or *url.URL)
	Confirm  interface{} // Confirmation text
	Tooltip  interface{} // Widget tooltip
	Type     ActionType  // Type of action (default Submit)
	Post     bool        // Use post request
	Hidden   bool        // Action is hidden and can't be render
	Disabled bool        // Action is disabled
	Name     string      // Name of action
	Value    interface{} // Value of action
}

Widget for display button or hyperlink. Example:

 apply := &widget.Action{
     Label: "Apply",
	 Action: "/user/update",
	 Post: true,
	 Hidden: !isOwner,
	 Type: widget.ActionTypeButton,
	 Value: "apply",
 }
 submit := &widget.Action{
     Label: "Apply",
     Type: widget.ActionTypeSubmit,
     Value: "apply",
 }

func (*Action) Render

func (w *Action) Render(
	ctx echo.Context,
) (interface{}, error)

type ActionType

type ActionType string
const (
	ActionTypeButton ActionType = "button"
	ActionTypeSubmit ActionType = "submit"
	ActionTypeReset  ActionType = "reset"
)

type Alert

type Alert struct {
	Hidden bool        // Message is hidden and can't be render
	Type   AlertType   // Type of message (default Info)
	Label  interface{} // Content of message
}

Widget for display highlighted message. May be used for display Flash messages. Example:

 alert := &widget.Alert{
	Label: "It`s OK"
	Type: widget.AlertSuccess,
}

func (*Alert) Render

func (w *Alert) Render(
	ctx echo.Context,
) (interface{}, error)

type AlertType

type AlertType string
const (
	AlertInfo    AlertType = "info"
	AlertSuccess AlertType = "siccess"
	AlertWarning AlertType = "warning"
	AlertDanger  AlertType = "danger"
)

type BOOLEAN

type BOOLEAN bool

Boolean value

func (BOOLEAN) Render

func (w BOOLEAN) Render(ctx echo.Context) (interface{}, error)

type Band

type Band struct {
	Pager           // Pager info
	Data   DataFunc // Custom data
	Hidden bool     // Band is hidden and not can't be render
}

Widget for display band of items. Widget supports pager for navigate between pages.

func (*Band) Render

func (w *Band) Render(ctx echo.Context) (interface{}, error)
type Breadcrumb struct {
	Label  interface{} // Label for action
	Action interface{} // Action (optional). May be (string or url.Url or *url.Url)
}

Single breadcrumb

type Breadcrumbs []*Breadcrumb

Widget for display path in the tree navigation.

func (w Breadcrumbs) Render(
	ctx echo.Context,
) (interface{}, error)

type DATETIME

type DATETIME string

Localize UTC datetime

func (DATETIME) Render

func (w DATETIME) Render(ctx echo.Context) (interface{}, error)

type DURATION

type DURATION int64

Time duration

func (DURATION) Render

func (w DURATION) Render(ctx echo.Context) (interface{}, error)

type DataFunc

type DataFunc func() (interface{}, error)

type Detail

type Detail struct {
	Hidden bool        // Detail is hidden and can't be render
	Label  interface{} // Detail title (string or Widget)
	Value  interface{} // Value (string or Widget)
	Type   string      // Column type (optional) for customization
}

func (*Detail) Render

func (w *Detail) Render(
	ctx echo.Context,
	level int,
) (interface{}, error)

type DetailView

type DetailView struct {
	Hidden    bool        // Details is hidden and not can't be render
	Items     Details     // Rows
	KeyColumn interface{} // Label for key column
	ValColumn interface{} // Label for value column
}

Widget for display list of key/value pairs. The widget generates the following structure: * Head ** Key - label for Key column ** Value - label for Value column * Body - contains sequence of details

func (*DetailView) Render

func (w *DetailView) Render(
	ctx echo.Context,
) (interface{}, error)

type Details

type Details map[string]Detail

type Document

type Document struct {
	Layout      interface{}            // Layout
	Params      generic.Params         // Message arguments
	References  map[string]interface{} // Map of hyperlinks name->action
	ParamRe     *regexp.Regexp         // RegEx pattern for replace params (default {{name@param}})
	ReferenceRe *regexp.Regexp         // RegEx pattern for replace reference (default [label](name))
}

Document is widget for format with complex named params and references.

func (*Document) Render

func (w *Document) Render(ctx echo.Context) (interface{}, error)

type ExpanderFunc

type ExpanderFunc func(data map[string]interface{}) error

type FLOAT32

type FLOAT32 float32

Decimal (float) value

func (FLOAT32) Render

func (w FLOAT32) Render(ctx echo.Context) (interface{}, error)

type FLOAT64

type FLOAT64 float64

Decimal (float) value

func (FLOAT64) Render

func (w FLOAT64) Render(ctx echo.Context) (interface{}, error)

type Form

type Form struct {
	Id     string      // Form identifier
	Name   string      // Form name
	Method string      // Form method (default POST)
	Action interface{} // Form action (default current URL)
	Model  echo.Model  // Primary form model
	Hidden bool        // Form is hidden and can't be render
}

Form is widget, that based on a Model and produced html form.

func (*Form) Render

func (w *Form) Render(
	ctx echo.Context,
) (interface{}, error)

type FormFieldFilterFunc

type FormFieldFilterFunc func(value string) string

type FormFile

type FormFile struct {
	Id       string      // Field identifier
	Name     string      // Field name
	Label    interface{} // Field label
	Disabled bool        // Field disabled
	Hidden   bool        // Field is hidden and can't be render
	Accept   string      // Accept filter
	Required bool        // Field is required
	// contains filtered or unexported fields
}

FormFile represent html entity <input type="file">.

func (*FormFile) AddError

func (field *FormFile) AddError(message echo.ValidationError)

Append a new error

func (*FormFile) GetBoolean

func (field *FormFile) GetBoolean() bool

func (*FormFile) GetDisabled

func (w *FormFile) GetDisabled() bool

func (*FormFile) GetErrors

func (field *FormFile) GetErrors() echo.ValidationErrors

Get list of field errors

func (*FormFile) GetFloat32

func (field *FormFile) GetFloat32() float32

func (*FormFile) GetFloat64

func (field *FormFile) GetFloat64() float64

func (*FormFile) GetHidden

func (w *FormFile) GetHidden() bool

func (*FormFile) GetInt

func (field *FormFile) GetInt() int

func (*FormFile) GetInt16

func (field *FormFile) GetInt16() int16

func (*FormFile) GetInt32

func (field *FormFile) GetInt32() int32

func (*FormFile) GetInt64

func (field *FormFile) GetInt64() int64

func (*FormFile) GetInt8

func (field *FormFile) GetInt8() int8

func (*FormFile) GetName

func (w *FormFile) GetName() string

func (*FormFile) GetString

func (field *FormFile) GetString() string

func (*FormFile) GetUint

func (field *FormFile) GetUint() uint

func (*FormFile) GetUint16

func (field *FormFile) GetUint16() uint16

func (*FormFile) GetUint32

func (field *FormFile) GetUint32() uint32

func (*FormFile) GetUint64

func (field *FormFile) GetUint64() uint64

func (*FormFile) GetUint8

func (field *FormFile) GetUint8() uint8

func (*FormFile) GetVal

func (field *FormFile) GetVal() interface{}

func (*FormFile) GetValue

func (field *FormFile) GetValue() []string

func (*FormFile) IsValid

func (field *FormFile) IsValid() bool

Test for errors

func (*FormFile) Render

func (w *FormFile) Render(
	ctx echo.Context,
) (interface{}, error)

func (*FormFile) Reset

func (w *FormFile) Reset(ctx echo.Context) error

func (*FormFile) SetVal

func (field *FormFile) SetVal(
	ctx echo.Context,
	value interface{},
)

Set internal value of the field

func (*FormFile) SetValue

func (field *FormFile) SetValue(
	ctx echo.Context,
	value []string,
) error

Set external value of the field.

func (*FormFile) Upload

func (w *FormFile) Upload(
	ctx echo.Context,
	path string,
	name string,
) (fileName string, err error)

func (*FormFile) Validate

func (w *FormFile) Validate(
	ctx echo.Context,
) error

type FormFlag

type FormFlag struct {
	Id          string              // Field identifier
	Name        string              // Field name
	Label       interface{}         // Field label
	Disabled    bool                // Field disabled
	Hidden      bool                // Field is hidden and can't be render
	Default     interface{}         // Default value (optional)
	Placeholder interface{}         // Placeholder text (optional)
	Filter      FormFieldFilterFunc // Custom filter (optional)
	// contains filtered or unexported fields
}

FormFlag represents single html entity <input tpe="ckeckbox> Example:

subscribe := widget.FormFlag{
  Name: "Subscribe",
  Items: ....,
}

func (*FormFlag) AddError

func (field *FormFlag) AddError(message echo.ValidationError)

Append a new error

func (*FormFlag) GetBoolean

func (field *FormFlag) GetBoolean() bool

func (*FormFlag) GetDisabled

func (w *FormFlag) GetDisabled() bool

func (*FormFlag) GetErrors

func (field *FormFlag) GetErrors() echo.ValidationErrors

Get list of field errors

func (*FormFlag) GetFloat32

func (field *FormFlag) GetFloat32() float32

func (*FormFlag) GetFloat64

func (field *FormFlag) GetFloat64() float64

func (*FormFlag) GetHidden

func (w *FormFlag) GetHidden() bool

func (*FormFlag) GetInt

func (field *FormFlag) GetInt() int

func (*FormFlag) GetInt16

func (field *FormFlag) GetInt16() int16

func (*FormFlag) GetInt32

func (field *FormFlag) GetInt32() int32

func (*FormFlag) GetInt64

func (field *FormFlag) GetInt64() int64

func (*FormFlag) GetInt8

func (field *FormFlag) GetInt8() int8

func (*FormFlag) GetName

func (w *FormFlag) GetName() string

func (*FormFlag) GetString

func (field *FormFlag) GetString() string

func (*FormFlag) GetUint

func (field *FormFlag) GetUint() uint

func (*FormFlag) GetUint16

func (field *FormFlag) GetUint16() uint16

func (*FormFlag) GetUint32

func (field *FormFlag) GetUint32() uint32

func (*FormFlag) GetUint64

func (field *FormFlag) GetUint64() uint64

func (*FormFlag) GetUint8

func (field *FormFlag) GetUint8() uint8

func (*FormFlag) GetVal

func (field *FormFlag) GetVal() interface{}

func (*FormFlag) GetValue

func (field *FormFlag) GetValue() []string

func (*FormFlag) IsValid

func (field *FormFlag) IsValid() bool

Test for errors

func (*FormFlag) Render

func (w *FormFlag) Render(
	ctx echo.Context,
) (interface{}, error)

func (*FormFlag) Reset

func (w *FormFlag) Reset(ctx echo.Context) error

func (*FormFlag) SetVal

func (w *FormFlag) SetVal(ctx echo.Context, value interface{})

func (*FormFlag) SetValue

func (w *FormFlag) SetValue(
	ctx echo.Context,
	value []string,
) error

func (*FormFlag) Validate

func (field *FormFlag) Validate(
	ctx echo.Context,
) error

Validate is prototype for all descendants.

type FormFlags

type FormFlags struct {
	Id          string              // Field identifier
	Name        string              // Field name
	Label       interface{}         // Field label
	Disabled    bool                // Field disabled
	Hidden      bool                // Field is hidden and can't be render
	Filter      FormFieldFilterFunc // Custom filter (optional)
	Default     interface{}         // Default value (optional)
	Items       echo.DataSet        // List labels for allowed values
	Placeholder interface{}         // Placeholder text (optional)
	// contains filtered or unexported fields
}

FormFlags represent html entity <input type="checkbox">. Example:

subscribe := &widget.FormFlags{
    Name: "Subscribe",
    Items: ...,
}

func (*FormFlags) AddError

func (field *FormFlags) AddError(message echo.ValidationError)

Append a new error

func (*FormFlags) GetBoolean

func (field *FormFlags) GetBoolean() bool

func (*FormFlags) GetDisabled

func (w *FormFlags) GetDisabled() bool

func (*FormFlags) GetErrors

func (field *FormFlags) GetErrors() echo.ValidationErrors

Get list of field errors

func (*FormFlags) GetFloat32

func (field *FormFlags) GetFloat32() float32

func (*FormFlags) GetFloat64

func (field *FormFlags) GetFloat64() float64

func (*FormFlags) GetHidden

func (w *FormFlags) GetHidden() bool

func (*FormFlags) GetInt

func (field *FormFlags) GetInt() int

func (*FormFlags) GetInt16

func (field *FormFlags) GetInt16() int16

func (*FormFlags) GetInt32

func (field *FormFlags) GetInt32() int32

func (*FormFlags) GetInt64

func (field *FormFlags) GetInt64() int64

func (*FormFlags) GetInt8

func (field *FormFlags) GetInt8() int8

func (*FormFlags) GetName

func (w *FormFlags) GetName() string

func (*FormFlags) GetString

func (field *FormFlags) GetString() string

func (*FormFlags) GetUint

func (field *FormFlags) GetUint() uint

func (*FormFlags) GetUint16

func (field *FormFlags) GetUint16() uint16

func (*FormFlags) GetUint32

func (field *FormFlags) GetUint32() uint32

func (*FormFlags) GetUint64

func (field *FormFlags) GetUint64() uint64

func (*FormFlags) GetUint8

func (field *FormFlags) GetUint8() uint8

func (*FormFlags) GetVal

func (field *FormFlags) GetVal() interface{}

func (*FormFlags) GetValue

func (field *FormFlags) GetValue() []string

func (*FormFlags) IsValid

func (field *FormFlags) IsValid() bool

Test for errors

func (*FormFlags) Render

func (w *FormFlags) Render(
	ctx echo.Context,
) (interface{}, error)

func (*FormFlags) Reset

func (w *FormFlags) Reset(ctx echo.Context) error

func (*FormFlags) SetVal

func (w *FormFlags) SetVal(ctx echo.Context, value interface{})

func (*FormFlags) SetValue

func (w *FormFlags) SetValue(
	ctx echo.Context,
	value []string,
) error

func (*FormFlags) Validate

func (field *FormFlags) Validate(
	ctx echo.Context,
) error

Validate is prototype for all descendants.

type FormHidden

type FormHidden struct {
	Id        string      // Field identifier
	Name      string      // Field name
	Hidden    bool        // Field is hidden and can't be render
	Default   interface{} // Default value (optional)
	Required  bool        // Field is required
	Pattern   string      // Field pattern
	MaxLength int         // Field max length
	// contains filtered or unexported fields
}

FormHidden represent html entity <input type="hidden">.

func (*FormHidden) AddError

func (field *FormHidden) AddError(message echo.ValidationError)

Append a new error

func (*FormHidden) GetBoolean

func (field *FormHidden) GetBoolean() bool

func (*FormHidden) GetDisabled

func (w *FormHidden) GetDisabled() bool

func (*FormHidden) GetErrors

func (field *FormHidden) GetErrors() echo.ValidationErrors

Get list of field errors

func (*FormHidden) GetFloat32

func (field *FormHidden) GetFloat32() float32

func (*FormHidden) GetFloat64

func (field *FormHidden) GetFloat64() float64

func (*FormHidden) GetHidden

func (w *FormHidden) GetHidden() bool

func (*FormHidden) GetInt

func (field *FormHidden) GetInt() int

func (*FormHidden) GetInt16

func (field *FormHidden) GetInt16() int16

func (*FormHidden) GetInt32

func (field *FormHidden) GetInt32() int32

func (*FormHidden) GetInt64

func (field *FormHidden) GetInt64() int64

func (*FormHidden) GetInt8

func (field *FormHidden) GetInt8() int8

func (*FormHidden) GetName

func (w *FormHidden) GetName() string

func (*FormHidden) GetString

func (field *FormHidden) GetString() string

func (*FormHidden) GetUint

func (field *FormHidden) GetUint() uint

func (*FormHidden) GetUint16

func (field *FormHidden) GetUint16() uint16

func (*FormHidden) GetUint32

func (field *FormHidden) GetUint32() uint32

func (*FormHidden) GetUint64

func (field *FormHidden) GetUint64() uint64

func (*FormHidden) GetUint8

func (field *FormHidden) GetUint8() uint8

func (*FormHidden) GetVal

func (field *FormHidden) GetVal() interface{}

func (*FormHidden) GetValue

func (field *FormHidden) GetValue() []string

func (*FormHidden) IsValid

func (field *FormHidden) IsValid() bool

Test for errors

func (*FormHidden) Render

func (w *FormHidden) Render(
	ctx echo.Context,
) (interface{}, error)

func (*FormHidden) Reset

func (w *FormHidden) Reset(ctx echo.Context) error

func (*FormHidden) SetVal

func (field *FormHidden) SetVal(
	ctx echo.Context,
	value interface{},
)

Set internal value of the field

func (*FormHidden) SetValue

func (field *FormHidden) SetValue(
	ctx echo.Context,
	value []string,
) error

Set external value of the field.

func (*FormHidden) Validate

func (w *FormHidden) Validate(
	ctx echo.Context,
) error

type FormSelect

type FormSelect struct {
	Id       string              // Field identifier
	Name     string              // Field name
	Label    interface{}         // Field label
	Disabled bool                // Field disabled
	Hidden   bool                // Field is hidden and can't be render
	Filter   FormFieldFilterFunc // Custom filter (optional)
	Default  interface{}         // Default value (optional)
	Required bool                // Value is required
	Items    echo.DataSet        // Field items
	// contains filtered or unexported fields
}

FormSelect represent html entity <select> or other same widget. Notice: Field Codec must be ignored (internal and external representations are same).

func (*FormSelect) AddError

func (field *FormSelect) AddError(message echo.ValidationError)

Append a new error

func (*FormSelect) GetBoolean

func (field *FormSelect) GetBoolean() bool

func (*FormSelect) GetDisabled

func (w *FormSelect) GetDisabled() bool

func (*FormSelect) GetErrors

func (field *FormSelect) GetErrors() echo.ValidationErrors

Get list of field errors

func (*FormSelect) GetFloat32

func (field *FormSelect) GetFloat32() float32

func (*FormSelect) GetFloat64

func (field *FormSelect) GetFloat64() float64

func (*FormSelect) GetHidden

func (w *FormSelect) GetHidden() bool

func (*FormSelect) GetInt

func (field *FormSelect) GetInt() int

func (*FormSelect) GetInt16

func (field *FormSelect) GetInt16() int16

func (*FormSelect) GetInt32

func (field *FormSelect) GetInt32() int32

func (*FormSelect) GetInt64

func (field *FormSelect) GetInt64() int64

func (*FormSelect) GetInt8

func (field *FormSelect) GetInt8() int8

func (*FormSelect) GetName

func (w *FormSelect) GetName() string

func (*FormSelect) GetString

func (field *FormSelect) GetString() string

func (*FormSelect) GetUint

func (field *FormSelect) GetUint() uint

func (*FormSelect) GetUint16

func (field *FormSelect) GetUint16() uint16

func (*FormSelect) GetUint32

func (field *FormSelect) GetUint32() uint32

func (*FormSelect) GetUint64

func (field *FormSelect) GetUint64() uint64

func (*FormSelect) GetUint8

func (field *FormSelect) GetUint8() uint8

func (*FormSelect) GetVal

func (field *FormSelect) GetVal() interface{}

func (*FormSelect) GetValue

func (field *FormSelect) GetValue() []string

func (*FormSelect) IsValid

func (field *FormSelect) IsValid() bool

Test for errors

func (*FormSelect) Render

func (w *FormSelect) Render(
	ctx echo.Context,
) (interface{}, error)

func (*FormSelect) Reset

func (w *FormSelect) Reset(ctx echo.Context) error

func (*FormSelect) SetVal

func (field *FormSelect) SetVal(
	ctx echo.Context,
	value interface{},
)

Set internal value of the field

func (*FormSelect) SetValue

func (w *FormSelect) SetValue(
	ctx echo.Context,
	value []string,
) error

func (*FormSelect) Validate

func (w *FormSelect) Validate(
	ctx echo.Context,
) error

type FormSubmit

type FormSubmit struct {
	Id       string              // Field identifier
	Name     string              // Field name
	Label    interface{}         // Field label
	Disabled bool                // Field disabled
	Hidden   bool                // Field is hidden and can't be render
	Filter   FormFieldFilterFunc // Custom filter (optional)
	Default  interface{}         // Default value (optional)
	Required bool                // Value is required
	Items    echo.DataSet        // Field items
	// contains filtered or unexported fields
}

FormSubmit represents action Submit

func (*FormSubmit) AddError

func (field *FormSubmit) AddError(message echo.ValidationError)

Append a new error

func (*FormSubmit) GetBoolean

func (field *FormSubmit) GetBoolean() bool

func (*FormSubmit) GetDisabled

func (w *FormSubmit) GetDisabled() bool

func (*FormSubmit) GetErrors

func (field *FormSubmit) GetErrors() echo.ValidationErrors

Get list of field errors

func (*FormSubmit) GetFloat32

func (field *FormSubmit) GetFloat32() float32

func (*FormSubmit) GetFloat64

func (field *FormSubmit) GetFloat64() float64

func (*FormSubmit) GetHidden

func (w *FormSubmit) GetHidden() bool

func (*FormSubmit) GetInt

func (field *FormSubmit) GetInt() int

func (*FormSubmit) GetInt16

func (field *FormSubmit) GetInt16() int16

func (*FormSubmit) GetInt32

func (field *FormSubmit) GetInt32() int32

func (*FormSubmit) GetInt64

func (field *FormSubmit) GetInt64() int64

func (*FormSubmit) GetInt8

func (field *FormSubmit) GetInt8() int8

func (*FormSubmit) GetName

func (w *FormSubmit) GetName() string

func (*FormSubmit) GetString

func (field *FormSubmit) GetString() string

func (*FormSubmit) GetUint

func (field *FormSubmit) GetUint() uint

func (*FormSubmit) GetUint16

func (field *FormSubmit) GetUint16() uint16

func (*FormSubmit) GetUint32

func (field *FormSubmit) GetUint32() uint32

func (*FormSubmit) GetUint64

func (field *FormSubmit) GetUint64() uint64

func (*FormSubmit) GetUint8

func (field *FormSubmit) GetUint8() uint8

func (*FormSubmit) GetVal

func (field *FormSubmit) GetVal() interface{}

func (*FormSubmit) GetValue

func (field *FormSubmit) GetValue() []string

func (*FormSubmit) IsValid

func (field *FormSubmit) IsValid() bool

Test for errors

func (*FormSubmit) Render

func (w *FormSubmit) Render(
	ctx echo.Context,
) (interface{}, error)

func (*FormSubmit) Reset

func (w *FormSubmit) Reset(ctx echo.Context) error

func (*FormSubmit) SetVal

func (field *FormSubmit) SetVal(
	ctx echo.Context,
	value interface{},
)

Set internal value of the field

func (*FormSubmit) SetValue

func (w *FormSubmit) SetValue(
	ctx echo.Context,
	value []string,
) error

func (*FormSubmit) Validate

func (w *FormSubmit) Validate(
	ctx echo.Context,
) error

type FormText

type FormText struct {
	Id          string              // Field identifier
	Name        string              // Field name
	Label       interface{}         // Field label
	Disabled    bool                // Field disabled
	Hidden      bool                // Field is hidden and can't be render
	Filter      FormFieldFilterFunc // Custom filter (optional)
	Codec       echo.Codec          // Field codec (optional)
	Default     interface{}         // Default value (optional)
	Required    bool                // Field is required
	Pattern     string              // Field pattern (optional)
	Placeholder interface{}         // Field placeholder (optional)
	MaxLength   int                 // Field max length
	ReadOnly    bool                // Field is read only
	Rows        int                 // Max count of visible rows
	// contains filtered or unexported fields
}

FormText represent html entity <textarea> or <input type="text"> or <input type="password">.

func (*FormText) AddError

func (field *FormText) AddError(message echo.ValidationError)

Append a new error

func (*FormText) GetBoolean

func (field *FormText) GetBoolean() bool

func (*FormText) GetDisabled

func (w *FormText) GetDisabled() bool

func (*FormText) GetErrors

func (field *FormText) GetErrors() echo.ValidationErrors

Get list of field errors

func (*FormText) GetFloat32

func (field *FormText) GetFloat32() float32

func (*FormText) GetFloat64

func (field *FormText) GetFloat64() float64

func (*FormText) GetHidden

func (w *FormText) GetHidden() bool

func (*FormText) GetInt

func (field *FormText) GetInt() int

func (*FormText) GetInt16

func (field *FormText) GetInt16() int16

func (*FormText) GetInt32

func (field *FormText) GetInt32() int32

func (*FormText) GetInt64

func (field *FormText) GetInt64() int64

func (*FormText) GetInt8

func (field *FormText) GetInt8() int8

func (*FormText) GetName

func (w *FormText) GetName() string

func (*FormText) GetString

func (field *FormText) GetString() string

func (*FormText) GetUint

func (field *FormText) GetUint() uint

func (*FormText) GetUint16

func (field *FormText) GetUint16() uint16

func (*FormText) GetUint32

func (field *FormText) GetUint32() uint32

func (*FormText) GetUint64

func (field *FormText) GetUint64() uint64

func (*FormText) GetUint8

func (field *FormText) GetUint8() uint8

func (*FormText) GetVal

func (field *FormText) GetVal() interface{}

func (*FormText) GetValue

func (field *FormText) GetValue() []string

func (*FormText) IsValid

func (field *FormText) IsValid() bool

Test for errors

func (*FormText) Render

func (w *FormText) Render(
	ctx echo.Context,
) (interface{}, error)

func (*FormText) Reset

func (w *FormText) Reset(ctx echo.Context) error

func (*FormText) SetVal

func (w *FormText) SetVal(ctx echo.Context, value interface{})

func (*FormText) SetValue

func (w *FormText) SetValue(
	ctx echo.Context,
	value []string,
) error

func (*FormText) Validate

func (w *FormText) Validate(
	ctx echo.Context,
) error

type GuidMaker

type GuidMaker interface {
	CreateGuid() uint64
}

type HTML

type HTML template.HTML

Striped Html text

func (HTML) Render

func (w HTML) Render(ctx echo.Context) (interface{}, error)

type INT

type INT int

Signed integer value

func (INT) Render

func (w INT) Render(ctx echo.Context) (interface{}, error)

type INT16

type INT16 int16

Signed integer value

func (INT16) Render

func (w INT16) Render(ctx echo.Context) (interface{}, error)

type INT32

type INT32 int32

Signed integer value

func (INT32) Render

func (w INT32) Render(ctx echo.Context) (interface{}, error)

type INT64

type INT64 int64

Signed integer value

func (INT64) Render

func (w INT64) Render(ctx echo.Context) (interface{}, error)

type INT8

type INT8 int8

Signed integer value

func (INT8) Render

func (w INT8) Render(ctx echo.Context) (interface{}, error)

type List

type List []interface{}

List of widgets, that renders each widget. The list allows index access to the item.

func (List) Render

func (ws List) Render(ctx echo.Context) (interface{}, error)

type MESSAGE

type MESSAGE uint32

Message

func DeclareDefaultMsg

func DeclareDefaultMsg(msg MESSAGE, message string) MESSAGE

func (MESSAGE) Error

func (w MESSAGE) Error() string

func (MESSAGE) Render

func (w MESSAGE) Render(ctx echo.Context) (interface{}, error)

func (MESSAGE) String

func (w MESSAGE) String(ctx echo.Context) (string, error)

func (MESSAGE) Translate

func (w MESSAGE) Translate(
	ctx echo.Context,
) (string, error)

type Map

type Map map[string]interface{}

Map of widgets, that renders each widget. The map allows named access to the item.

func (Map) Clone

func (ws Map) Clone() Map

func (Map) Render

func (ws Map) Render(ctx echo.Context) (interface{}, error)

type MultiForm

type MultiForm struct {
	Id     string      // Form identifier
	Name   string      // Form name
	Method string      // Form method (default POST)
	Action interface{} // Form action (default current url)
	Models echo.Models // Primary form model
	Hidden bool        // Form is hidden and can't be render
}

MultiForm is form, that contains list of models.

func (*MultiForm) Render

func (w *MultiForm) Render(
	ctx echo.Context,
) (interface{}, error)

type MultiStepBaseStage

type MultiStepBaseStage struct {
	PrevBtn *Action
	NextBtn *Action
}

Prototype for all MultiStepStages

func (*MultiStepBaseStage) Consume

func (stage *MultiStepBaseStage) Consume(
	ctx echo.Context,
	state *MultiStepState,
	model echo.Model,
) (reply interface{}, err error)

func (*MultiStepBaseStage) Publish

func (stage *MultiStepBaseStage) Publish(
	ctx echo.Context,
	state *MultiStepState,
	form *MultiStepForm,
) error

func (*MultiStepBaseStage) Resolve

func (stage *MultiStepBaseStage) Resolve(
	ctx echo.Context,
	state *MultiStepState,
	model echo.Model,
) error

type MultiStepForm

type MultiStepForm struct {
	Form
	Security GuidMaker    // Optional
	Storage  echo.Storage // Optional
	Strategy MultiStepStrategy
	Timeout  time.Duration
}

Multi step form (with standard buttons) Example:

func actionXXX(ctx echo.Context) error{
  form := &widget.MultiStepForm{
    Strategy: MyStrategy,
    Security: security,
    Timeout: 100,
    ...
  }
  return form.Execute(env)
}

Define stages for the form (must implements MultiStepStage)

type MyStage struct {
   widgets.MultiStepBaseStage
}

Initialize router

func Init(){
   InitMultiStepRouter(router, actionXXX)
}

func (*MultiStepForm) Execute

func (w *MultiStepForm) Execute(
	ctx echo.Context,
) (state *MultiStepState, err error)

type MultiStepStage

type MultiStepStage interface {
	// Get model of stage
	Model(ctx echo.Context, state *MultiStepState) (echo.Model, error)
	// Import data into the model and validate it.
	Resolve(ctx echo.Context, state *MultiStepState, model echo.Model) error
	// Consume stage data. Return new state reference or nil (see method MultiStepState.Become)
	Consume(ctx echo.Context, state *MultiStepState, model echo.Model) (reply interface{}, err error)
	// Publish form
	Publish(ctx echo.Context, state *MultiStepState, form *MultiStepForm) error
}

Abstract stage of form

type MultiStepState

type MultiStepState struct {
	Stage      string         `json:"stage"`      // Stage name
	History    []string       `json:"history"`    // List of stage names
	Params     generic.Params `json:"values"`     // Map of accepted parameters
	Expiration int64          `json:"expiration"` // Expiration (UNIX timestamp)
}

MultiStepState is persistent state of form/

func (*MultiStepState) Become

func (s *MultiStepState) Become(
	newState interface{},
) error

Become to the new state newState is variant:

  • string - name of new state
  • numeric - relative offset for reduce

type MultiStepStrategy

type MultiStepStrategy interface {
	// Started initialization. Executed for restart strategy only.
	Setup(ctx echo.Context, values generic.Params) (stage string, err error)
	// Create stage instance
	Stage(ctx echo.Context, state *MultiStepState) (MultiStepStage, error)
}
type NavBar struct {
	Brand interface{} // Brand
	Items Map         // Nav bar items
}

Widget for display primary navigation bar. Example:

  menu := &widget.NavBar{
		Brand: "My brand",
		Items: widget.Map{
			"Home": &widget.NavBarItem{
		         Label:  "Home",
		         Action: "/",
	        },
			"Auth": &widget.NavBarItem{
				Label:  "Login",
				Action: "/login",
			},
			"Language": &widget.NavBarDropDown{
				Label: &widget.Sprintf{
					Layout: "Language (%s)",
					Params: []interface{}{curLang},
				},
				Items: widget.List{
                 &widget.NavBarItem{
				        Label:  "English",
				        Action: "/lang/english",
			        },
                 &widget.NavBarItem{
				        Label:  "Russian",
				        Action: "/lang/russian",
			        },
				},
			},
		},
	 }
func (w *NavBar) Render(ctx echo.Context) (interface{}, error)
type NavBarDropDown struct {
	Label      interface{} // Title of submenu
	Items      List        // Items of submenu (NavBarItem)
	Hidden     bool        // Submenu is hidden and can't be render
	AllowEmpty bool        // Allow empty submenu (otherwise hide)
}

Drop down submenu of navigation bar. Must be nested for NavBarNav

func (w *NavBarDropDown) Render(ctx echo.Context) (interface{}, error)
type NavBarForm struct {
	Form // Form elements
}

Inline form, nested in navigation bar Must be nested for NavBarNav (not navbar link)

func (w *NavBarForm) Render(ctx echo.Context) (interface{}, error)
type NavBarItem struct {
	Label  interface{} // Label of element
	Action interface{} // Url of element
	Hidden bool        // Element is hidden and can't be render
	Active bool        // Element is active (highlighted)
}

Simple menu item of navigation bar. Must be nested for NavBarNav or NavBarDropDown.

func (w *NavBarItem) Render(ctx echo.Context) (interface{}, error)
type NavBarLink struct {
	Label   interface{} // Hyperlink label
	Action  interface{} // Hyperlink action
	Tooltip interface{} // Hyperlink tooltip
	Post    bool        // Hyperlink used post
	Hidden  bool        // Hyperlink is hidden and can't be render
}

Hyperlink, nested in navigation bar. Must be nested for NavBarText (not in navbar link)

func (w *NavBarLink) Render(ctx echo.Context) (interface{}, error)
type NavBarText struct {
	Body   interface{} // Text
	Hidden bool        // Text is hidden and can't be render
}

Simple text, nested in navigatin bar. Must be nested for NavBarNav (not navbar link)

func (w *NavBarText) Render(ctx echo.Context) (interface{}, error)

type Optional

type Optional struct {
	Hidden bool        // Content is hidden and can't be render
	Value  interface{} // Internal content
}

Optional content. Widget allows wrap optional content for disable it rendering.

func (*Optional) Render

func (w *Optional) Render(ctx echo.Context) (interface{}, error)

type Pager

type Pager struct {
	Id       string        // Pager identifier (optional)
	MsgEmpty echo.Widget   // Message for empty record set (optional)
	MsgStats echo.Widget   // Message for statistics )optional)
	Label    echo.Widget   // Pager label (optional)
	Prev     echo.Widget   // Previous page label (optional)
	Next     echo.Widget   // Next page label (optional)
	Param    string        // Hot parameter of URI for get page number (default "pg")
	Capacity int           // Items count per page (default 10). Without data provider it is row count
	BtnCount int           // Links count in pager (default 10)
	Url      *url.URL      // Base url (default used current request url)
	Provider data.Provider // Data provider
}

Widget for make data pagination. It used for composition in complex widgets (band and table). This is widget get page number from URI. After that, it requests the required data from the provider in the required amount.

type PagerInfo

type PagerInfo struct {
	CurPage      int // Current page number (the numbering starts from 1)
	LastPage     int // Last page number (the numbering starts from 1)
	FirstVisible int // First visible record number (the numbering starts from 1)
	LastVisible  int // Last visible record number (the numbering starts from 1)
	Total        int // Total records count
	Count        int // Visible records count
}

Pager statistics

type PagerReport

type PagerReport struct {
	Id      string                 // Pager identifier
	Info    PagerInfo              // Pager statistics
	Buttons map[string]interface{} // Buttons (prev, next, band)
	Message interface{}            // Actual message
}

Report of applying pager

type RESOURCE

type RESOURCE uint32

Resource

func (RESOURCE) Render

func (w RESOURCE) Render(ctx echo.Context) (interface{}, error)

type Sprintf

type Sprintf struct {
	Layout interface{}   // Layout
	Params []interface{} // Message parameters
}

Sprintf is widget for format layout (using fmt.Sprintf)

func (*Sprintf) Error

func (w *Sprintf) Error() string

func (*Sprintf) Render

func (w *Sprintf) Render(ctx echo.Context) (interface{}, error)

func (*Sprintf) String

func (w *Sprintf) String(ctx echo.Context) (string, error)

func (*Sprintf) Translate

func (w *Sprintf) Translate(
	ctx echo.Context,
) (string, error)

type TEXT

type TEXT string

Raw text

func (TEXT) Render

func (w TEXT) Render(ctx echo.Context) (interface{}, error)

func (TEXT) String

func (w TEXT) String(ctx echo.Context) (string, error)

type TIMESTAMP

type TIMESTAMP int64

Time

func (TIMESTAMP) Render

func (w TIMESTAMP) Render(ctx echo.Context) (interface{}, error)

type Table

type Table struct {
	Pager
	Columns     TableColumns // Columns declaration
	RowExpander ExpanderFunc // Row expander
}

Widget for display simple html table. Example:

provider := &myDataProvider{ ... }
table := &widget.Table{
    Pager: widget.Pager{
        Provider: provider,
    },
    Columns: widget.TableColumns{
        &widget.TableColumn{
            Label: "Name",
            Data: func() (interface{}, error){
                return provider.row.Name, nil
            },
        },
        &widget.TableActions{
            RowId: func() interface{}{
                return provider.row.Id
            },
            Items: Map{
                "View": widget.DefaultTableActionView,
                "Update": widget.DefaultTableActionUpdate,
                "Message": &widget.TableAction{
                     Action: fmt.Sptintf("/user/message/%d", row.Id),
                     Tooltip: "Send message",
                },
            },
        },
    },
    // Highlight selected rows
    RowExpander: func(cell map[string]interface{}) error {
        if provider.row.Selected {
            cell["Class"] = "selected"
        }
        return nil
    },
}

func (*Table) Render

func (w *Table) Render(
	ctx echo.Context,
) (interface{}, error)

type TableAction

type TableAction struct {
	Action  interface{} // Custom action (string or url.Url or *url.Url)
	Tooltip interface{} // Action tooltip
	Confirm interface{} // Confirmation text
	Post    bool        // Use post request
	Hidden  bool        // Action is hidden and can't be render
}

Single table action

func (*TableAction) Render

func (w *TableAction) Render(
	ctx echo.Context,
) (interface{}, error)

type TableActions

type TableActions struct {
	RowId interface{} // Current row identifier or func for read it.
	Path  string      // Base path to family of actions (optional)
	Items Map         // Action map.
}

TableActions is widget for make column with action list.

func (*TableActions) Render

func (w *TableActions) Render(
	ctx echo.Context,
) (interface{}, error)

type TableColumn

type TableColumn struct {
	Label    interface{}  // Column label
	Hidden   bool         // Column is hidden and can't be render
	Data     DataFunc     // Column data provider
	Expander ExpanderFunc // Column expander for generate extra info
}

Table column definition

type TableColumns

type TableColumns map[string]*TableColumn

type UINT

type UINT uint

Unsigned integer value

func (UINT) Render

func (w UINT) Render(ctx echo.Context) (interface{}, error)

type UINT16

type UINT16 uint16

Unsigned integer value

func (UINT16) Render

func (w UINT16) Render(ctx echo.Context) (interface{}, error)

type UINT32

type UINT32 uint32

Unsigned integer value

func (UINT32) Render

func (w UINT32) Render(ctx echo.Context) (interface{}, error)

type UINT64

type UINT64 uint64

Unsigned integer value

func (UINT64) Render

func (w UINT64) Render(ctx echo.Context) (interface{}, error)

type UINT8

type UINT8 uint8

Unsigned integer value

func (UINT8) Render

func (w UINT8) Render(ctx echo.Context) (interface{}, error)

type Variant

type Variant struct {
	echo.Formatter             // Strategy for format data
	Value          interface{} // Raw data, that need formats
}

Any value with formatter

func (*Variant) Render

func (w *Variant) Render(ctx echo.Context) (interface{}, error)

type WidgetFunc

type WidgetFunc func(ctx echo.Context) (interface{}, error)

WidgetFunc allows use custom function as Widget.

func (WidgetFunc) Render

func (fn WidgetFunc) Render(ctx echo.Context) (interface{}, error)

Jump to

Keyboard shortcuts

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