forms

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2020 License: MIT, MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormDecode

func FormDecode(data []byte, form *Form) error

Types

type CheckBox

type CheckBox struct {
	Element

	IsChecked bool   `yaml:"isChecked" json:"isChecked"`
	Label     string `yaml:"label" json:"label"`
}

func NewCheckBox

func NewCheckBox(title string, subTitle string) *CheckBox

func (*CheckBox) ApplyRequest

func (this *CheckBox) ApplyRequest(req *http.Request) (value interface{}, skip bool, err error)

func (*CheckBox) Compose

func (this *CheckBox) Compose() string

func (*CheckBox) Super

func (this *CheckBox) Super() *Element

type CodeEditor

type CodeEditor struct {
	Element

	Lang     string
	Readonly bool
}

func NewCodeEditor

func NewCodeEditor(title string, subTitle string) *CodeEditor

func (*CodeEditor) ApplyRequest

func (this *CodeEditor) ApplyRequest(req *http.Request) (value interface{}, skip bool, err error)

func (*CodeEditor) Compose

func (this *CodeEditor) Compose() string

func (*CodeEditor) Super

func (this *CodeEditor) Super() *Element

type Element

type Element struct {
	ClassType  string            `yaml:"classType" json:"classType"`   // 字段类型
	Attrs      map[string]string `yaml:"attrs" json:"attrs"`           // 附加属性
	Namespace  string            `yaml:"namespace" json:"namespace"`   // 命名空间
	Code       string            `yaml:"code" json:"code"`             // 字段值代号
	Title      string            `yaml:"title" json:"title"`           // 标题
	Subtitle   string            `yaml:"subtitle" json:"subtitle"`     // 副标题
	IsRequired bool              `yaml:"isRequired" json:"isRequired"` // 是否为必填,并没有实际的约束作用,只是用来在字段左边标记星号
	IsComposed bool              `yaml:"isComposed" json:"isComposed"` // 是否已经组合,组合后的不需要再次组合

	Comment      string      `yaml:"comment" json:"comment"`           // 注释
	ValidateCode string      `yaml:"validateCode" json:"validateCode"` // 值校验代码
	InitCode     string      `yaml:"initCode" json:"initCode"`         // 值初始化代码
	Value        interface{} `yaml:"value" json:"value"`               // 字段值
	Javascript   string      `yaml:"javascript" json:"javascript"`     // 附加的Javascript代码
	CSS          string      `yaml:"css" json:"css"`                   // 附加的CSS代码
}

元素公共定义

func (*Element) Attr

func (this *Element) Attr(name string, value string)

func (*Element) ComposeAttrs

func (this *Element) ComposeAttrs(attrs map[string]string) string

type ElementInterface

type ElementInterface interface {
	Compose() string
	Super() *Element
	ApplyRequest(req *http.Request) (value interface{}, skip bool, err error)
}

元素接口

type EnvBox

type EnvBox struct {
	Element `yaml:",inline"`
}

环境变量

func NewEnvBox

func NewEnvBox(title string, subtitle string) *EnvBox

func (*EnvBox) ApplyRequest

func (this *EnvBox) ApplyRequest(req *http.Request) (value interface{}, skip bool, err error)

func (*EnvBox) Compose

func (this *EnvBox) Compose() string

func (*EnvBox) Super

func (this *EnvBox) Super() *Element

type Form

type Form struct {
	Namespace     string            `yaml:"namespace" json:"namespace"`
	Groups        []*Group          `yaml:"groups" json:"groups"`
	Javascript    string            `yaml:"javascript" json:"javascript"`
	CSS           string            `yaml:"css" json:"css"`
	ValidateCode  string            `yaml:"validateCode" json:"validateCode"`
	ComposedAttrs map[string]string `yaml:"composedAttrs" json:"composedAttrs"`
	// contains filtered or unexported fields
}

func NewForm

func NewForm(namespace string) *Form

func (*Form) ApplyRequest

func (this *Form) ApplyRequest(req *http.Request) (values map[string]interface{}, errField string, err error)

func (*Form) Compose

func (this *Form) Compose()

func (*Form) Encode

func (this *Form) Encode() ([]byte, error)

func (*Form) EncodePretty

func (this *Form) EncodePretty() ([]byte, error)

func (*Form) Init

func (this *Form) Init(values map[string]interface{})

func (*Form) NewGroup

func (this *Form) NewGroup() *Group

type Group

type Group struct {
	Namespace     string             `yaml:"namespace" json:"namespace"`
	Elements      []ElementInterface `yaml:"elements" json:"elements"`
	HTML          string             `yaml:"html" json:"html"`
	IsComposed    bool               `yaml:"isComposed" json:"isComposed"`
	ComposedAttrs map[string]string  `yaml:"composedAttrs" json:"composedAttrs"`
}

func (*Group) Add

func (this *Group) Add(element ElementInterface)

func (*Group) Compose

func (this *Group) Compose()

type HTTPBox

type HTTPBox struct {
	Element `yaml:",inline"`
}

HTTP参数组件

func NewHTTPBox

func NewHTTPBox(title string, subtitle string) *HTTPBox

获取新对象

func (*HTTPBox) ApplyRequest

func (this *HTTPBox) ApplyRequest(req *http.Request) (value interface{}, skip bool, err error)

func (*HTTPBox) Compose

func (this *HTTPBox) Compose() string

组合

func (*HTTPBox) Super

func (this *HTTPBox) Super() *Element

获取父级类型

type Option

type Option struct {
	Text  string
	Value string
}

type Options

type Options struct {
	Element `yaml:",inline"`

	Options []*Option
}

func NewOptions

func NewOptions(title string, subtitle string) *Options

func (*Options) AddOption

func (this *Options) AddOption(text string, value string)

func (*Options) ApplyRequest

func (this *Options) ApplyRequest(req *http.Request) (value interface{}, skip bool, err error)

func (*Options) Compose

func (this *Options) Compose() string

func (*Options) Super

func (this *Options) Super() *Element

type Presentation

type Presentation struct {
	HTML       string `yaml:"html" json:"html"`
	CSS        string `yaml:"css" json:"css"`
	Javascript string `yaml:"javascript" json:"javascript"`
}

界面显示信息

func NewPresentation

func NewPresentation() *Presentation

type ScriptBox

type ScriptBox struct {
	Element
}

func NewScriptBox

func NewScriptBox(title string, subTitle string) *ScriptBox

func (*ScriptBox) ApplyRequest

func (this *ScriptBox) ApplyRequest(req *http.Request) (value interface{}, skip bool, err error)

func (*ScriptBox) Compose

func (this *ScriptBox) Compose() string

func (*ScriptBox) Super

func (this *ScriptBox) Super() *Element

type SingleValueList

type SingleValueList struct {
	Element `yaml:",inline"`

	ValueName string `yaml:"valueName" json:"valueName"`
}

单值列表

func NewSingleValueList

func NewSingleValueList(title string, subtitle string) *SingleValueList

获取新对象

func (*SingleValueList) ApplyRequest

func (this *SingleValueList) ApplyRequest(req *http.Request) (value interface{}, skip bool, err error)

获取值

func (*SingleValueList) Compose

func (this *SingleValueList) Compose() string

组合

func (*SingleValueList) Super

func (this *SingleValueList) Super() *Element

获取父级类型

type TextBox

type TextBox struct {
	Element
	MaxLength   int
	Placeholder string
	Cols        int
	Rows        int
}

func NewTextBox

func NewTextBox(title string, subTitle string) *TextBox

func (*TextBox) ApplyRequest

func (this *TextBox) ApplyRequest(req *http.Request) (value interface{}, skip bool, err error)

func (*TextBox) Compose

func (this *TextBox) Compose() string

func (*TextBox) Super

func (this *TextBox) Super() *Element

type TextField

type TextField struct {
	Element     `yaml:",inline"`
	MaxLength   int    `yaml:"maxLength" json:"maxLength"`
	Placeholder string `yaml:"placeholder" json:"placeholder"`
	Size        int    `yaml:"size" json:"size"`
	RightLabel  string `yaml:"rightLabel" json:"rightLabel"`
}

func NewTextField

func NewTextField(title string, subTitle string) *TextField

func (*TextField) ApplyRequest

func (this *TextField) ApplyRequest(req *http.Request) (value interface{}, skip bool, err error)

func (*TextField) Compose

func (this *TextField) Compose() string

func (*TextField) Super

func (this *TextField) Super() *Element

Jump to

Keyboard shortcuts

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