forms

package
v2.2.7+incompatible Latest Latest
Warning

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

Go to latest
Published: May 6, 2021 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package forms provides utility methods to generate XML that is interpreted by the Front End to build forms.

Some plugins publish configurations using this: resulting forms are used in Admin GUI to adjust plugin settings.

Index

Constants

View Source
const (
	SwitchFieldValueKey   = "@value"
	SwitchFieldTypePrefix = "group_switch:"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field interface {
	Serialize(T i18n.TranslateFunc) []*SerialFormParam
}

type Form

type Form struct {
	Groups     []*Group
	I18NBundle *i18n2.I18nBundle
}

func (*Form) Serialize

func (f *Form) Serialize(languages ...string) interface{}

Return List of serializable fields

type FormField

type FormField struct {
	Name             string
	Type             ParamType
	Label            string
	Description      string
	Default          interface{}
	Mandatory        bool
	Editable         bool
	ChoicePresetList []map[string]string
	ChoiceJsonList   string
}

func (*FormField) Serialize

func (b *FormField) Serialize(T i18n.TranslateFunc) (params []*SerialFormParam)

type Group

type Group struct {
	Label  string
	Fields []Field
}

type ParamType

type ParamType string
const (
	ParamString        ParamType = "string"
	ParamTextarea      ParamType = "textarea"
	ParamPassword      ParamType = "password"
	ParamValidPassword ParamType = "valid-password"
	ParamBool          ParamType = "boolean"
	ParamInteger       ParamType = "integer"
	ParamLegend        ParamType = "legend"
	ParamHidden        ParamType = "hidden"

	ParamSelect           ParamType = "select"
	ParamAutoComplete     ParamType = "autocomplete"
	ParamAutoCompleteTree ParamType = "autocomplete-tree"

	ParamButton  ParamType = "button"
	ParamMonitor ParamType = "monitor"
	ParamImage   ParamType = "image"
)

type ReplicableFields

type ReplicableFields struct {
	Id          string
	Title       string
	Description string
	Mandatory   bool
	Fields      []Field
}

func (*ReplicableFields) Serialize

func (r *ReplicableFields) Serialize(T i18n.TranslateFunc) (params []*SerialFormParam)

type SerialForm

type SerialForm struct {
	XMLName xml.Name `xml:"form" json:"-"`
	Params  []*SerialFormParam
}

type SerialFormParam

type SerialFormParam struct {
	XMLName xml.Name `xml:"param" json:"-"`

	GroupSwitchName  string `xml:"group_switch_name,attr,omitempty" json:"group_switch_name,omitempty"`
	GroupSwitchValue string `xml:"group_switch_value,attr,omitempty" json:"group_switch_value,omitempty"`
	GroupSwitchLabel string `xml:"group_switch_label,attr,omitempty" json:"group_switch_label,omitempty"`

	Name        string `xml:"name,attr" json:"name"`
	Type        string `xml:"type,attr" json:"type"`
	Label       string `xml:"label,attr,omitempty" json:"label,omitempty"`
	Description string `xml:"description,attr,omitempty" json:"description,omitempty"`
	Group       string `xml:"group,attr" json:"group"`
	Default     string `xml:"default,omitempty,attr" json:"default,omitempty"`
	Mandatory   bool   `xml:"mandatory,omitempty,attr" json:"mandatory,omitempty"`
	Editable    bool   `xml:"editable,omitempty,attr" json:"editable,omitempty"`

	Choices string `xml:"choices,omitempty,attr" json:"choices,omitempty"`

	UploadAction string `xml:"uploadAction,attr,omitempty" json:"uploadAction,omitempty"`
	LoadAction   string `xml:"loadAction,attr,omitempty" json:"loadAction,omitempty"`
	DefaultImage string `xml:"defaultImage,attr,omitempty" json:"defaultImage,omitempty"`

	ReplicationGroup       string `xml:"replicationGroup,attr,omitempty" json:"replicationGroup,omitempty"`
	ReplicationTitle       string `xml:"replicationTitle,attr,omitempty" json:"replicationTitle,omitempty"`
	ReplicationDescription string `xml:"replicationDescription,attr,omitempty" json:"replicationDescription,omitempty"`
	ReplicationMandatory   string `xml:"replicationMandatory,attr,omitempty" json:"replicationMandatory,omitempty"`
}

type SwitchField

type SwitchField struct {
	Name        string
	Label       string
	Description string
	Default     string
	Mandatory   bool
	Editable    bool

	Values []*SwitchValue
}

func (*SwitchField) Serialize

func (g *SwitchField) Serialize(T i18n.TranslateFunc) (params []*SerialFormParam)

type SwitchValue

type SwitchValue struct {
	Name   string
	Value  string
	Label  string
	Fields []Field
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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