forms

package
v0.1.72 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2019 License: MIT Imports: 15 Imported by: 3

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"`     // 是否为必填,并没有实际的约束作用,只是用来在字段左边标记星号
	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
}

环境变量

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"`
	// 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"`
}

func (*Group) Add

func (this *Group) Add(element ElementInterface)

func (*Group) Compose

func (this *Group) Compose()

type Option

type Option struct {
	Text  string
	Value string
}

type Options

type Options struct {
	Element

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