types

package
v0.0.0-...-ff5ac03 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2026 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NavBtnSiteName = "site setting"       // 站点设置按钮名称
	NavBtnInfoName = "site info"          // 站点信息按钮名称
	NavBtnToolName = "code generate tool" // 代码生成工具按钮名称
	NavBtnPlugName = "plugins"            // 插件按钮名称
)
View Source
const (
	ButtonTypeNavDropDownItem = "navdropdownitem" // 导航下拉菜单项按钮类型
	ButtonTypeNavDropDown     = "navdropdown"     // 导航下拉按钮类型
)
View Source
const (
	PostTypeCreate = iota
	PostTypeUpdate
)
View Source
const DefaultPageSize = 10

DefaultPageSize 是默认页面大小

Variables

View Source
var DefaultPageSizeList = []int{10, 20, 30, 50, 100}

DefaultPageSizeList 是默认页面大小列表

View Source
var JoinFieldValueDelimiter = utils.Uuid(8)

Functions

func AddGlobalDisplayProcessFn

func AddGlobalDisplayProcessFn(f FieldFilterFn)

AddGlobalDisplayProcessFn 添加全局显示处理函数

func GetJoinField

func GetJoinField(field string) string

func JoinField

func JoinField(table, field string) string

func ParseTableDataTmpl

func ParseTableDataTmpl(content interface{}) string

ParseTableDataTmpl 解析表格数据模板 参数:

  • content: 模板内容

返回: 解析后的字符串

func ParseTableDataTmplWithID

func ParseTableDataTmplWithID(id template.HTML, content string, value ...map[string]InfoItem) string

ParseTableDataTmplWithID 解析带ID的表格数据模板 参数:

  • id: 行ID
  • content: 模板内容
  • value: 可选的值映射

返回: 解析后的字符串

func RegisterDisplayFnGenerator

func RegisterDisplayFnGenerator(key string, gen DisplayFnGenerator)

RegisterDisplayFnGenerator 注册显示函数生成器

Types

type Action

type Action interface {
	Js() template.JS                                  // 获取JavaScript
	BtnAttribute() template.HTML                      // 获取按钮属性
	BtnClass() template.HTML                          // 获取按钮类名
	ExtContent(ctx *context.Context) template.HTML    // 获取扩展内容
	FooterContent(ctx *context.Context) template.HTML // 获取底部内容
	SetBtnId(btnId string)                            // 设置按钮ID
	SetBtnData(data interface{})                      // 设置按钮数据
	GetCallbacks() context.Node                       // 获取回调
}

Action 是操作接口

type ActionButton

type ActionButton struct {
	*BaseButton
}

ActionButton 是动作按钮结构体

func GetActionButton

func GetActionButton(title template.HTML, action Action, ids ...string) *ActionButton

GetActionButton 创建动作按钮

func (*ActionButton) Content

func (b *ActionButton) Content(ctx *context.Context) (template.HTML, template.JS)

Content 生成动作按钮的HTML内容和JavaScript代码

type ActionIconButton

type ActionIconButton struct {
	Icon template.HTML // 图标
	*BaseButton
}

ActionIconButton 是动作图标按钮结构体

func GetActionIconButton

func GetActionIconButton(icon string, action Action, ids ...string) *ActionIconButton

GetActionIconButton 创建动作图标按钮

func (*ActionIconButton) Content

func (b *ActionIconButton) Content(ctx *context.Context) (template.HTML, template.JS)

Content 生成动作图标按钮的HTML内容和JavaScript代码

type Actions

type Actions []Action

Actions 是操作列表

type AddFormFieldFn

type AddFormFieldFn func(panel *FormPanel)

AddFormFieldFn 是添加表单字段的函数类型

type AjaxData

type AjaxData struct {
	SuccessTitle   string
	SuccessText    string
	ErrorTitle     string
	ErrorText      string
	SuccessJumpURL string
	DisableJump    bool
	SuccessJS      string
	JumpInNewTab   string
}

type AlertAttribute

type AlertAttribute interface {
	SetTheme(value string) AlertAttribute          // 设置主题
	SetTitle(value template.HTML) AlertAttribute   // 设置标题
	SetContent(value template.HTML) AlertAttribute // 设置内容
	Warning(msg string) template.HTML              // 显示警告消息
	GetContent() template.HTML                     // 获取内容
}

AlertAttribute 警告属性接口

type Attribute

type Attribute struct {
	TemplateList map[string]string // 模板列表
	Separation   bool              // 是否分隔
}

Attribute 是模板的组件接口。模板的每个组件都应该实现它

type BaseButton

type BaseButton struct {
	Id, Url, Method, Name, TypeName string        // 按钮ID、URL、方法、名称和类型名称
	Title                           template.HTML // 按钮标题
	Action                          Action        // 按钮动作
}

BaseButton 是按钮的基础结构体

func (*BaseButton) Content

func (b *BaseButton) Content() (template.HTML, template.JS)

Content 返回空内容

func (*BaseButton) GetAction

func (b *BaseButton) GetAction() Action

GetAction 返回按钮动作

func (*BaseButton) GetName

func (b *BaseButton) GetName() string

GetName 返回按钮名称

func (*BaseButton) ID

func (b *BaseButton) ID() string

ID 返回按钮ID

func (*BaseButton) IsType

func (b *BaseButton) IsType(t string) bool

IsType 检查按钮是否为指定类型

func (*BaseButton) METHOD

func (b *BaseButton) METHOD() string

METHOD 返回HTTP方法

func (*BaseButton) SetName

func (b *BaseButton) SetName(name string)

SetName 设置按钮名称

func (*BaseButton) Type

func (b *BaseButton) Type() string

Type 返回按钮类型

func (*BaseButton) URL

func (b *BaseButton) URL() string

URL 返回按钮URL

type BaseDisplayFnGenerator

type BaseDisplayFnGenerator struct{}

BaseDisplayFnGenerator 基础显示函数生成器结构体

func (*BaseDisplayFnGenerator) HTML

func (base *BaseDisplayFnGenerator) HTML() template.HTML

func (*BaseDisplayFnGenerator) JS

type BoxAttribute

type BoxAttribute interface {
	SetHeader(value template.HTML) BoxAttribute       // 设置头部
	SetBody(value template.HTML) BoxAttribute         // 设置主体
	SetNoPadding() BoxAttribute                       // 设置无内边距
	SetFooter(value template.HTML) BoxAttribute       // 设置页脚
	SetTitle(value template.HTML) BoxAttribute        // 设置标题
	WithHeadBorder() BoxAttribute                     // 设置头部边框
	SetIframeStyle(iframe bool) BoxAttribute          // 设置iframe样式
	SetAttr(attr template.HTMLAttr) BoxAttribute      // 设置属性
	SetStyle(value template.HTMLAttr) BoxAttribute    // 设置样式
	SetHeadColor(value string) BoxAttribute           // 设置头部颜色
	SetClass(value string) BoxAttribute               // 设置类名
	SetTheme(value string) BoxAttribute               // 设置主题
	SetSecondHeader(value template.HTML) BoxAttribute // 设置第二头部
	SetSecondHeadColor(value string) BoxAttribute     // 设置第二头部颜色
	WithSecondHeadBorder() BoxAttribute               // 设置第二头部边框
	SetSecondHeaderClass(value string) BoxAttribute   // 设置第二头部类名
	GetContent() template.HTML                        // 获取内容
}

BoxAttribute 盒子属性接口

type Button

type Button interface {
	// Content 返回按钮的HTML内容和JavaScript代码
	Content(ctx *context.Context) (template.HTML, template.JS)
	// GetAction 获取按钮的动作
	GetAction() Action
	// URL 返回按钮的URL
	URL() string
	// METHOD 返回按钮的HTTP方法
	METHOD() string
	// ID 返回按钮的ID
	ID() string
	// Type 返回按钮的类型
	Type() string
	// GetName 返回按钮的名称
	GetName() string
	// SetName 设置按钮的名称
	SetName(name string)
	// IsType 检查按钮是否为指定类型
	IsType(t string) bool
}

Button 接口定义了按钮的基本行为

type ButtonAttribute

type ButtonAttribute interface {
	SetContent(value template.HTML) ButtonAttribute     // 设置内容
	SetOrientationRight() ButtonAttribute               // 设置右对齐
	SetOrientationLeft() ButtonAttribute                // 设置左对齐
	SetMarginLeft(int) ButtonAttribute                  // 设置左边距
	SetMarginRight(int) ButtonAttribute                 // 设置右边距
	SetThemePrimary() ButtonAttribute                   // 设置主主题
	SetSmallSize() ButtonAttribute                      // 设置小尺寸
	AddClass(class string) ButtonAttribute              // 添加类名
	SetID(id string) ButtonAttribute                    // 设置ID
	SetMiddleSize() ButtonAttribute                     // 设置中等尺寸
	SetHref(string) ButtonAttribute                     // 设置链接地址
	SetThemeWarning() ButtonAttribute                   // 设置警告主题
	SetTheme(value string) ButtonAttribute              // 设置主题
	SetLoadingText(value template.HTML) ButtonAttribute // 设置加载文本
	SetThemeDefault() ButtonAttribute                   // 设置默认主题
	SetType(string) ButtonAttribute                     // 设置类型
	GetContent() template.HTML                          // 获取内容
}

ButtonAttribute 按钮属性接口

type Buttons

type Buttons []Button

Buttons 是按钮切片类型

func (Buttons) Add

func (b Buttons) Add(btn Button) Buttons

Add 添加按钮

func (Buttons) AddNavButton

func (b Buttons) AddNavButton(ico, name string, action Action) Buttons

AddNavButton 添加导航按钮

func (Buttons) Callbacks

func (b Buttons) Callbacks() []context.Node

Callbacks 获取所有按钮的回调函数

func (Buttons) CheckExist

func (b Buttons) CheckExist(name string) bool

CheckExist 检查按钮是否存在

func (Buttons) CheckPermission

func (b Buttons) CheckPermission(user models.UserModel) Buttons

CheckPermission 检查用户是否有权限访问按钮

func (Buttons) CheckPermissionWhenURLAndMethodNotEmpty

func (b Buttons) CheckPermissionWhenURLAndMethodNotEmpty(user models.UserModel) Buttons

CheckPermissionWhenURLAndMethodNotEmpty 当URL和方法不为空时检查权限

func (Buttons) Content

func (b Buttons) Content(ctx *context.Context) (template.HTML, template.JS)

Content 生成所有按钮的HTML内容和JavaScript代码

func (Buttons) Copy

func (b Buttons) Copy() Buttons

Copy 复制按钮切片

func (Buttons) FooterContent

func (b Buttons) FooterContent(ctx *context.Context) template.HTML

FooterContent 生成所有按钮的页脚内容

func (Buttons) RemoveButtonByName

func (b Buttons) RemoveButtonByName(name string) Buttons

RemoveButtonByName 根据名称移除按钮

func (Buttons) RemoveInfoNavButton

func (b Buttons) RemoveInfoNavButton() Buttons

RemoveInfoNavButton 移除站点信息导航按钮

func (Buttons) RemovePlugNavButton

func (b Buttons) RemovePlugNavButton() Buttons

RemovePlugNavButton 移除插件导航按钮

func (Buttons) RemoveSiteNavButton

func (b Buttons) RemoveSiteNavButton() Buttons

RemoveSiteNavButton 移除站点设置导航按钮

func (Buttons) RemoveToolNavButton

func (b Buttons) RemoveToolNavButton() Buttons

RemoveToolNavButton 移除工具导航按钮

type Callbacks

type Callbacks []context.Node

Callbacks 是回调节点列表

func (Callbacks) AddCallback

func (c Callbacks) AddCallback(node context.Node) Callbacks

AddCallback 添加回调节点 参数:

  • node: 上下文节点

返回: 更新后的回调列表

type ColAttribute

type ColAttribute interface {
	SetSize(value S) ColAttribute                // 设置大小
	SetContent(value template.HTML) ColAttribute // 设置内容
	AddContent(value template.HTML) ColAttribute // 添加内容
	GetContent() template.HTML                   // 获取内容
}

ColAttribute 列属性接口

type Component

type Component interface {
	GetContent() template.HTML // 获取内容
	GetJS() template.JS        // 获取JavaScript
	GetCSS() template.CSS      // 获取样式
	GetCallbacks() Callbacks   // 获取回调
}

Component 是组件接口

type ContentWrapper

type ContentWrapper func(content template.HTML) template.HTML

ContentWrapper 是内容包装函数类型

type DataTableAttribute

type DataTableAttribute interface {
	GetDataTableHeader() template.HTML                          // 获取数据表格头部
	SetThead(value Thead) DataTableAttribute                    // 设置表头
	SetInfoList(value []map[string]InfoItem) DataTableAttribute // 设置信息列表
	SetEditUrl(value string) DataTableAttribute                 // 设置编辑URL
	SetDeleteUrl(value string) DataTableAttribute               // 设置删除URL
	SetNewUrl(value string) DataTableAttribute                  // 设置新建URL
	SetPrimaryKey(value string) DataTableAttribute              // 设置主键
	SetStyle(style string) DataTableAttribute                   // 设置样式
	SetAction(action template.HTML) DataTableAttribute          // 设置操作
	SetIsTab(value bool) DataTableAttribute                     // 设置是否为标签页
	SetActionFold(fold bool) DataTableAttribute                 // 设置操作折叠
	SetHideThead() DataTableAttribute                           // 设置隐藏表头
	SetLayout(value string) DataTableAttribute                  // 设置布局
	SetButtons(btns template.HTML) DataTableAttribute           // 设置按钮
	SetSticky(sticky bool) DataTableAttribute                   // 设置粘性定位
	SetHideFilterArea(value bool) DataTableAttribute            // 设置隐藏过滤区域
	SetHideRowSelector(value bool) DataTableAttribute           // 设置隐藏行选择器
	SetActionJs(aj template.JS) DataTableAttribute              // 设置操作JavaScript
	SetNoAction() DataTableAttribute                            // 设置无操作
	SetInfoUrl(value string) DataTableAttribute                 // 设置信息URL
	SetDetailUrl(value string) DataTableAttribute               // 设置详情URL
	SetHasFilter(hasFilter bool) DataTableAttribute             // 设置是否有过滤器
	SetSortUrl(value string) DataTableAttribute                 // 设置排序URL
	SetExportUrl(value string) DataTableAttribute               // 设置导出URL
	SetUpdateUrl(value string) DataTableAttribute               // 设置更新URL
	GetContent() template.HTML                                  // 获取内容
}

DataTableAttribute 数据表格属性接口

type DefaultAction

type DefaultAction struct {
	Attr   template.HTML // 属性
	JS     template.JS   // JavaScript
	Ext    template.HTML // 扩展内容
	Footer template.HTML // 底部内容
}

DefaultAction 是默认操作结构体

func NewDefaultAction

func NewDefaultAction(attr, ext, footer template.HTML, js template.JS) *DefaultAction

NewDefaultAction 创建默认操作 参数:

  • attr: 属性HTML
  • ext: 扩展内容HTML
  • footer: 底部内容HTML
  • js: JavaScript代码

返回: 默认操作对象

func (*DefaultAction) BtnAttribute

func (def *DefaultAction) BtnAttribute() template.HTML

func (*DefaultAction) BtnClass

func (def *DefaultAction) BtnClass() template.HTML

func (*DefaultAction) ExtContent

func (def *DefaultAction) ExtContent(ctx *context.Context) template.HTML

func (*DefaultAction) FooterContent

func (def *DefaultAction) FooterContent(ctx *context.Context) template.HTML

func (*DefaultAction) GetCallbacks

func (def *DefaultAction) GetCallbacks() context.Node

func (*DefaultAction) Js

func (def *DefaultAction) Js() template.JS

func (*DefaultAction) SetBtnData

func (def *DefaultAction) SetBtnData(data interface{})

func (*DefaultAction) SetBtnId

func (def *DefaultAction) SetBtnId(btnId string)

type DefaultButton

type DefaultButton struct {
	*BaseButton
	Color     template.HTML // 按钮背景色
	TextColor template.HTML // 按钮文字颜色
	Icon      string        // 按钮图标
	Direction template.HTML // 按钮方向
	Group     bool          // 是否为按钮组
}

DefaultButton 是默认按钮结构体

func GetColumnButton

func GetColumnButton(title template.HTML, icon string, action Action, colors ...template.HTML) *DefaultButton

GetColumnButton 创建列按钮

func GetDefaultButton

func GetDefaultButton(title template.HTML, icon string, action Action, colors ...template.HTML) *DefaultButton

GetDefaultButton 创建默认按钮

func GetDefaultButtonGroup

func GetDefaultButtonGroup(title template.HTML, icon string, action Action, colors ...template.HTML) *DefaultButton

GetDefaultButtonGroup 创建默认按钮组

func (*DefaultButton) Content

func (b *DefaultButton) Content(ctx *context.Context) (template.HTML, template.JS)

Content 生成按钮的HTML内容和JavaScript代码

type DefaultSelection

type DefaultSelection struct {
	*BaseButton              // 基础按钮
	Options     FieldOptions // 选项列表
	Placeholder string       // 占位符
	Width       int          // 宽度
}

DefaultSelection 是默认选择框结构体

func GetDefaultSelection

func GetDefaultSelection(placeholder string, options FieldOptions, action Action, widths ...int) *DefaultSelection

GetDefaultSelection 获取默认选择框 参数:

  • placeholder: 占位符
  • options: 选项列表
  • action: 操作对象
  • widths: 可选的宽度

返回: 默认选择框对象

func (*DefaultSelection) Content

func (b *DefaultSelection) Content(ctx *context.Context) (template.HTML, template.JS)

Content 生成选择框的HTML和JavaScript 参数:

  • ctx: 上下文对象

返回: HTML内容和JavaScript代码

type DeleteFn

type DeleteFn func(ids []string) error

type DeleteFnWithRes

type DeleteFnWithRes func(ids []string, res error) error

type DisplayFnGenerator

type DisplayFnGenerator interface {
	Get(ctx *context.Context, args ...interface{}) FieldFilterFn // 获取显示函数
	JS() template.HTML                                           // 返回JavaScript代码
	HTML() template.HTML                                         // 返回HTML代码
}

DisplayFnGenerator 显示函数生成器接口

type DisplayProcessFnChains

type DisplayProcessFnChains []FieldFilterFn

DisplayProcessFnChains 显示处理函数链类型

func AddLimit

func AddLimit(limit int) DisplayProcessFnChains

AddLimit 添加长度限制处理函数到全局链

func AddSubstr

func AddSubstr(start int, end int) DisplayProcessFnChains

AddSubstr 添加子字符串处理函数到全局链

func AddToLower

func AddToLower() DisplayProcessFnChains

AddToLower 添加小写转换处理函数到全局链

func AddToTitle

func AddToTitle() DisplayProcessFnChains

AddToTitle 添加标题格式处理函数到全局链

func AddToUpper

func AddToUpper() DisplayProcessFnChains

AddToUpper 添加大写转换处理函数到全局链

func AddTrimSpace

func AddTrimSpace() DisplayProcessFnChains

AddTrimSpace 添加去除空格处理函数到全局链

func AddXssFilter

func AddXssFilter() DisplayProcessFnChains

AddXssFilter 添加XSS过滤处理函数到全局链

func AddXssJsFilter

func AddXssJsFilter() DisplayProcessFnChains

AddXssJsFilter 添加XSS JavaScript过滤处理函数到全局链

func (DisplayProcessFnChains) Add

Add 添加处理函数到链中

func (DisplayProcessFnChains) Append

Append 追加处理函数链

func (DisplayProcessFnChains) Copy

Copy 复制处理函数链

func (DisplayProcessFnChains) Valid

func (d DisplayProcessFnChains) Valid() bool

Valid 检查处理链是否有效

type ExportProcessFn

type ExportProcessFn func(param parameter.Parameters) (PanelInfo, error)

type Field

type Field struct {
	Head     string          // 字段标题
	Field    string          // 字段名
	TypeName db.DatabaseType // 数据库类型

	Joins Joins // 关联配置

	Width       int  // 字段宽度
	Sortable    bool // 是否可排序
	EditAble    bool // 是否可编辑
	Fixed       bool // 是否固定
	Filterable  bool // 是否可筛选
	Hide        bool // 是否隐藏
	HideForList bool // 在列表中是否隐藏

	EditType    table.Type   // 编辑类型
	EditOptions FieldOptions // 编辑选项

	FilterFormFields []FilterFormField // 筛选表单字段

	IsEditParam   bool // 是否为编辑参数
	IsDeleteParam bool // 是否为删除参数
	IsDetailParam bool // 是否为详情参数

	FieldDisplay // 字段显示配置
}

Field 表示表字段

func (Field) Exist

func (f Field) Exist() bool

Exist 判断字段是否存在 返回: 如果字段存在返回true,否则返回false

func (Field) GetFilterFormFields

func (f Field) GetFilterFormFields(params parameter.Parameters, headField string, sql ...*db.SQL) []FormField

GetFilterFormFields 获取筛选表单字段 参数:

  • params: 参数对象
  • headField: 头字段名
  • sql: 可选的SQL对象

返回: 筛选表单字段列表

type FieldDisplay

type FieldDisplay struct {
	Display              FieldFilterFn          // 显示函数
	DisplayProcessChains DisplayProcessFnChains // 显示处理函数链
}

FieldDisplay 字段显示结构体

func (FieldDisplay) AddLimit

func (f FieldDisplay) AddLimit(limit int) DisplayProcessFnChains

AddLimit 添加长度限制处理函数

func (FieldDisplay) AddSubstr

func (f FieldDisplay) AddSubstr(start int, end int) DisplayProcessFnChains

AddSubstr 添加子字符串处理函数

func (FieldDisplay) AddToLower

func (f FieldDisplay) AddToLower() DisplayProcessFnChains

AddToLower 添加小写转换处理函数

func (FieldDisplay) AddToTitle

func (f FieldDisplay) AddToTitle() DisplayProcessFnChains

AddToTitle 添加标题格式处理函数

func (FieldDisplay) AddToUpper

func (f FieldDisplay) AddToUpper() DisplayProcessFnChains

AddToUpper 添加大写转换处理函数

func (FieldDisplay) AddTrimSpace

func (f FieldDisplay) AddTrimSpace() DisplayProcessFnChains

AddTrimSpace 添加去除空格处理函数

func (FieldDisplay) IsNotSelectRes

func (f FieldDisplay) IsNotSelectRes(v interface{}) bool

IsNotSelectRes 检查值是否不是选择结果

func (FieldDisplay) ToDisplay

func (f FieldDisplay) ToDisplay(value FieldModel) interface{}

ToDisplay 将字段值转换为显示格式

func (FieldDisplay) ToDisplayHTML

func (f FieldDisplay) ToDisplayHTML(value FieldModel) template.HTML

ToDisplayHTML 将字段值转换为HTML格式

func (FieldDisplay) ToDisplayString

func (f FieldDisplay) ToDisplayString(value FieldModel) string

ToDisplayString 将字段值转换为字符串格式

func (FieldDisplay) ToDisplayStringArray

func (f FieldDisplay) ToDisplayStringArray(value FieldModel) []string

ToDisplayStringArray 将字段值转换为字符串数组格式

func (FieldDisplay) ToDisplayStringArrayArray

func (f FieldDisplay) ToDisplayStringArrayArray(value FieldModel) [][]string

ToDisplayStringArrayArray 将字段值转换为字符串二维数组格式

type FieldDotColor

type FieldDotColor string

FieldDotColor 是字段点颜色类型

const (
	FieldDotColorDanger  FieldDotColor = "danger"  // 危险颜色
	FieldDotColorInfo    FieldDotColor = "info"    // 信息颜色
	FieldDotColorPrimary FieldDotColor = "primary" // 主要颜色
	FieldDotColorSuccess FieldDotColor = "success" // 成功颜色
)

type FieldFilterFn

type FieldFilterFn func(value FieldModel) interface{}

FieldFilterFn 是数据过滤函数类型

type FieldGetImgArrFn

type FieldGetImgArrFn func(value string) []string

FieldGetImgArrFn 是获取图片数组函数类型

type FieldLabelParam

type FieldLabelParam struct {
	Color template.HTML // 颜色
	Type  string        // 类型
}

FieldLabelParam 是字段标签参数结构体

type FieldList

type FieldList []Field

FieldList 是字段列表类型

func (FieldList) GetFieldByFieldName

func (f FieldList) GetFieldByFieldName(name string) Field

func (FieldList) GetFieldFilterProcessValue

func (f FieldList) GetFieldFilterProcessValue(key, value, keyIndex string) string

func (FieldList) GetFieldJoinTable

func (f FieldList) GetFieldJoinTable(key string) string

func (FieldList) GetThead

func (f FieldList) GetThead(info TableInfo, params parameter.Parameters, columns []string) (Thead, string, string)

func (FieldList) GetTheadAndFilterForm

func (f FieldList) GetTheadAndFilterForm(info TableInfo, params parameter.Parameters, columns []string,
	sql ...func() *db.SQL) (Thead, string, string, string, []string, []FormField)

GetTheadAndFilterForm 获取表头和筛选表单 参数:

  • info: 表信息
  • params: 参数对象
  • columns: 列名数组
  • sql: 可选的SQL函数

返回: 表头、字段、关联字段、关联SQL、筛选表单

type FieldModel

type FieldModel struct {
	// The primaryKey of the table.
	ID string

	// The value of the single query result.
	Value string

	// The current row data.
	Row map[string]interface{}

	// Post type
	PostType PostType
}

FieldModel is the single query result.

func (FieldModel) IsCreate

func (m FieldModel) IsCreate() bool

func (FieldModel) IsUpdate

func (m FieldModel) IsUpdate() bool

type FieldModelValue

type FieldModelValue []string

FieldModelValue 是字段模型值类型

func (FieldModelValue) First

func (r FieldModelValue) First() string

First 获取第一个值 返回: 第一个值,如果不存在则返回空字符串

func (FieldModelValue) Value

func (r FieldModelValue) Value() string

Value 获取字段模型的值 返回: 第一个值

type FieldOption

type FieldOption struct {
	Text          string            `json:"text"`  // 选项显示的文本内容
	Value         string            `json:"value"` // 选项的实际值
	TextHTML      template.HTML     `json:"-"`     // 选项的HTML格式文本
	Selected      bool              `json:"-"`     // 是否被选中
	SelectedLabel template.HTML     `json:"-"`     // 选中状态的标签
	Extra         map[string]string `json:"-"`     // 额外的属性配置
}

FieldOption 表示表单字段的选项配置

type FieldOptions

type FieldOptions []FieldOption

FieldOptions 是 FieldOption 的切片类型,用于表示多个选项

func (FieldOptions) Copy

func (fo FieldOptions) Copy() FieldOptions

Copy 创建 FieldOptions 的副本,返回一个新的选项列表

func (FieldOptions) Marshal

func (fo FieldOptions) Marshal() string

Marshal 将 FieldOptions 序列化为 JSON 字符串 返回: JSON 格式的字符串,如果选项列表为空或序列化失败则返回空字符串

func (FieldOptions) SetSelected

func (fo FieldOptions) SetSelected(val interface{}, labels []template.HTML) FieldOptions

SetSelected 根据给定的值设置选项的选中状态,并设置对应的标签 参数:

  • val: 要匹配的值,可以是字符串数组或单个值
  • labels: 包含两个元素的标签数组,第一个用于选中状态,第二个用于未选中状态

返回: 更新后的 FieldOptions

func (FieldOptions) SetSelectedLabel

func (fo FieldOptions) SetSelectedLabel(labels []template.HTML) FieldOptions

SetSelectedLabel 为所有选项设置选中状态的标签 参数:

  • labels: 包含两个元素的标签数组,第一个用于选中状态,第二个用于未选中状态

返回: 更新后的 FieldOptions

type FieldProgressBarData

type FieldProgressBarData struct {
	Style string // 样式
	Size  string // 大小
	Max   int    // 最大值
}

FieldProgressBarData 是进度条数据结构体

type FilterFormField

type FilterFormField struct {
	Type        form.Type           // 表单类型
	Options     FieldOptions        // 选项列表
	OptionTable OptionTable         // 选项表配置
	Width       int                 // 字段宽度
	HeadWidth   int                 // 标题宽度
	InputWidth  int                 // 输入框宽度
	Style       template.HTMLAttr   // 样式属性
	Operator    FilterOperator      // 筛选操作符
	OptionExt   template.JS         // 选项扩展配置
	Head        string              // 标题
	Placeholder string              // 占位符
	HelpMsg     template.HTML       // 帮助信息
	NoIcon      bool                // 是否不显示图标
	ProcessFn   func(string) string // 处理函数
}

FilterFormField 是筛选表单字段结构体

type FilterOperator

type FilterOperator string

FilterOperator 是筛选操作符类型

const (
	FilterOperatorLike           FilterOperator = "like" // 模糊匹配操作符
	FilterOperatorGreater        FilterOperator = ">"    // 大于操作符
	FilterOperatorGreaterOrEqual FilterOperator = ">="   // 大于等于操作符
	FilterOperatorEqual          FilterOperator = "="    // 等于操作符
	FilterOperatorNotEqual       FilterOperator = "!="   // 不等于操作符
	FilterOperatorLess           FilterOperator = "<"    // 小于操作符
	FilterOperatorLessOrEqual    FilterOperator = "<="   // 小于等于操作符
	FilterOperatorFree           FilterOperator = "free" // 自由操作符
)

func GetOperatorFromValue

func GetOperatorFromValue(value string) FilterOperator

GetOperatorFromValue 根据值获取对应的筛选操作符 参数:

  • value: 操作符值字符串

返回: 对应的筛选操作符

func (FilterOperator) AddOrNot

func (o FilterOperator) AddOrNot() bool

AddOrNot 判断是否需要添加操作符字段 对于空字符串、free和like操作符返回false,其他返回true 返回: 是否需要添加操作符字段

func (FilterOperator) Label

func (o FilterOperator) Label() template.HTML

Label 返回操作符的标签HTML 对于like操作符返回空字符串,其他操作符返回其自身 返回: 操作符标签HTML

func (FilterOperator) String

func (o FilterOperator) String() string

String 返回操作符的字符串表示 返回: 操作符字符串

func (FilterOperator) Valid

func (o FilterOperator) Valid() bool

Valid 判断操作符是否有效 返回: 操作符是否有效

func (FilterOperator) Value

func (o FilterOperator) Value() string

Value 返回操作符的值字符串 返回: 操作符的值

type FilterType

type FilterType struct {
	Options     FieldOptions
	Process     func(string) string
	OptionExt   map[string]interface{}
	FormType    form.Type
	HelpMsg     template.HTML
	Style       template.HTMLAttr
	Operator    FilterOperator
	Head        string
	Placeholder string
	Width       int
	HeadWidth   int
	InputWidth  int
	NoHead      bool
	NoIcon      bool
}

type FormAttribute

type FormAttribute interface {
	SetHeader(value template.HTML) FormAttribute                // 设置表单头部
	SetContent(value FormFields) FormAttribute                  // 设置表单内容
	SetTabContents(value []FormFields) FormAttribute            // 设置标签页内容
	SetTabHeaders(value []string) FormAttribute                 // 设置标签页头部
	SetFooter(value template.HTML) FormAttribute                // 设置表单页脚
	SetPrefix(value string) FormAttribute                       // 设置前缀
	SetUrl(value string) FormAttribute                          // 设置URL
	SetPrimaryKey(value string) FormAttribute                   // 设置主键
	SetHorizontal(value bool) FormAttribute                     // 设置水平布局
	SetId(id string) FormAttribute                              // 设置ID
	SetAjax(successJS, errorJS template.JS) FormAttribute       // 设置AJAX成功和失败的JavaScript
	SetHiddenFields(fields map[string]string) FormAttribute     // 设置隐藏字段
	SetFieldsHTML(html template.HTML) FormAttribute             // 设置字段HTML
	SetMethod(value string) FormAttribute                       // 设置HTTP方法
	SetHeadWidth(width int) FormAttribute                       // 设置头部宽度
	SetInputWidth(width int) FormAttribute                      // 设置输入框宽度
	SetTitle(value template.HTML) FormAttribute                 // 设置标题
	SetLayout(layout form.Layout) FormAttribute                 // 设置布局
	SetOperationFooter(value template.HTML) FormAttribute       // 设置操作页脚
	GetDefaultBoxHeader(hideBack bool) template.HTML            // 获取默认盒子头部
	GetDetailBoxHeader(editUrl, deleteUrl string) template.HTML // 获取详情盒子头部
	GetBoxHeaderNoButton() template.HTML                        // 获取无按钮的盒子头部
	GetContent() template.HTML                                  // 获取内容
}

FormAttribute 表单属性接口

type FormField

type FormField struct {
	Field          string          `json:"field"`            // 字段名称
	FieldClass     string          `json:"field_class"`      // 字段CSS类名
	TypeName       db.DatabaseType `json:"type_name"`        // 数据库类型
	Head           string          `json:"head"`             // 字段标题
	Foot           template.HTML   `json:"foot"`             // 字段底部内容
	FormType       form2.Type      `json:"form_type"`        // 表单类型
	FatherFormType form2.Type      `json:"father_form_type"` // 父表单类型
	FatherField    string          `json:"father_field"`     // 父字段名称

	RowWidth int   // 行宽度
	RowFlag  uint8 // 行标志位

	Default                template.HTML  `json:"default"`                  // 默认值
	DefaultArr             interface{}    `json:"default_arr"`              // 默认值数组
	Value                  template.HTML  `json:"value"`                    // 字段值
	Value2                 string         `json:"value_2"`                  // 第二个值(用于文件上传等场景)
	ValueArr               []string       `json:"value_arr"`                // 值数组
	Value2Arr              []string       `json:"value_2_arr"`              // 第二个值数组
	Options                FieldOptions   `json:"options"`                  // 选项列表
	OptionsArr             []FieldOptions `json:"options_arr"`              // 选项数组列表
	DefaultOptionDelimiter string         `json:"default_option_delimiter"` // 默认选项分隔符
	Label                  template.HTML  `json:"label"`                    // 标签
	HideLabel              bool           `json:"hide_label"`               // 是否隐藏标签

	Placeholder string `json:"placeholder"` // 占位符文本

	CustomContent template.HTML `json:"custom_content"` // 自定义内容
	CustomJs      template.JS   `json:"custom_js"`      // 自定义JavaScript
	CustomCss     template.CSS  `json:"custom_css"`     // 自定义CSS样式

	Editable         bool `json:"editable"`            // 是否可编辑
	NotAllowEdit     bool `json:"not_allow_edit"`      // 是否不允许编辑
	NotAllowAdd      bool `json:"not_allow_add"`       // 是否不允许添加
	DisplayButNotAdd bool `json:"display_but_not_add"` // 是否显示但不允许添加
	Must             bool `json:"must"`                // 是否必填
	Hide             bool `json:"hide"`                // 是否隐藏
	CreateHide       bool `json:"create_hide"`         // 创建时是否隐藏
	EditHide         bool `json:"edit_hide"`           // 编辑时是否隐藏

	Width int `json:"width"` // 字段宽度

	InputWidth int `json:"input_width"` // 输入框宽度
	HeadWidth  int `json:"head_width"`  // 标题宽度

	Joins Joins `json:"-"` // 关联配置

	Divider      bool   `json:"divider"`       // 是否显示分隔线
	DividerTitle string `json:"divider_title"` // 分隔线标题

	HelpMsg template.HTML `json:"help_msg"` // 帮助信息

	TableFields FormFields // 表字段列表

	Style  template.HTMLAttr `json:"style"`   // 样式属性
	NoIcon bool              `json:"no_icon"` // 是否不显示图标

	OptionExt       template.JS     `json:"option_ext"`   // 选项扩展配置(JSON格式)
	OptionExt2      template.JS     `json:"option_ext_2"` // 选项扩展配置2(JSON格式)
	OptionInitFn    OptionInitFn    `json:"-"`            // 选项初始化函数
	OptionArrInitFn OptionArrInitFn `json:"-"`            // 选项数组初始化函数
	OptionTable     OptionTable     `json:"-"`            // 选项表配置

	FieldDisplay `json:"-"`        // 字段显示配置
	PostFilterFn PostFieldFilterFn `json:"-"` // 后置过滤函数
}

FormField 是表单字段结构体,包含字段的各种配置选项

func (*FormField) FillCustomContent

func (f *FormField) FillCustomContent() *FormField

FillCustomContent 填充自定义内容,包括自定义HTML、JavaScript和CSS 返回: 更新后的 FormField 指针

func (*FormField) GetRawValue

func (f *FormField) GetRawValue(columns []string, v interface{}) string

GetRawValue 从给定的值中获取原始值 参数:

  • columns: 列名数组
  • v: 值对象

返回: 原始字符串值

func (*FormField) UpdateDefaultValue

func (f *FormField) UpdateDefaultValue(sql *db.SQL) *FormField

UpdateDefaultValue 更新字段默认值 参数:

  • sql: SQL对象

返回: 更新后的 FormField 指针

func (*FormField) UpdateValue

func (f *FormField) UpdateValue(id, val string, res map[string]interface{}, sql *db.SQL) *FormField

UpdateValue 更新字段值 参数:

  • id: 记录ID
  • val: 新值
  • res: 结果映射
  • sql: SQL对象

返回: 更新后的 FormField 指针

type FormFields

type FormFields []FormField

func (FormFields) Add

func (f FormFields) Add(field *FormField) FormFields

func (FormFields) Copy

func (f FormFields) Copy() FormFields

func (FormFields) FillCustomContent

func (f FormFields) FillCustomContent() FormFields

func (FormFields) FindByFieldName

func (f FormFields) FindByFieldName(field string) *FormField

func (FormFields) FindIndexByFieldName

func (f FormFields) FindIndexByFieldName(field string) int

func (FormFields) FindTableChildren

func (f FormFields) FindTableChildren(father string) []*FormField

func (FormFields) FindTableField

func (f FormFields) FindTableField(field, father string) *FormField

func (FormFields) RemoveNotShow

func (f FormFields) RemoveNotShow() FormFields

type FormPanel

type FormPanel struct {
	FieldList FormFields `json:"field_list"` // 字段列表

	// 警告: 将来可能会被弃用 `json:""`
	TabGroups  TabGroups  `json:"tab_groups"`  // 标签组
	TabHeaders TabHeaders `json:"tab_headers"` // 标签头

	Table       string `json:"table"`       // 数据库表名
	Title       string `json:"title"`       // 表单标题
	Description string `json:"description"` // 表单描述

	Validator    FormPostFn       `json:"validator"`      // 验证函数
	PostHook     FormPostFn       `json:"post_hook"`      // 提交后钩子函数
	PreProcessFn FormPreProcessFn `json:"pre_process_fn"` // 预处理函数

	Callbacks Callbacks `json:"callbacks"` // 回调函数列表

	UpdateFn FormPostFn `json:"update_fn"` // 更新函数
	InsertFn FormPostFn `json:"insert_fn"` // 插入函数

	IsHideContinueEditCheckBox bool `json:"is_hide_continue_edit_check_box"` // 是否隐藏继续编辑复选框
	IsHideContinueNewCheckBox  bool `json:"is_hide_continue_new_check_box"`  // 是否隐藏继续新建复选框
	IsHideResetButton          bool `json:"is_hide_reset_button"`            // 是否隐藏重置按钮
	IsHideBackButton           bool `json:"is_hide_back_button"`             // 是否隐藏返回按钮

	Layout form2.Layout `json:"layout"` // 布局类型

	HTMLContent template.HTML `json:"html_content"` // HTML内容

	Header template.HTML `json:"header"` // 头部内容

	InputWidth int `json:"input_width"` // 输入框宽度
	HeadWidth  int `json:"head_width"`  // 标题宽度

	FormNewTitle    template.HTML `json:"form_new_title"`     // 新建表单标题
	FormNewBtnWord  template.HTML `json:"form_new_btn_word"`  // 新建按钮文字
	FormEditTitle   template.HTML `json:"form_edit_title"`    // 编辑表单标题
	FormEditBtnWord template.HTML `json:"form_edit_btn_word"` // 编辑按钮文字

	Ajax          bool        `json:"ajax"`            // 是否使用Ajax提交
	AjaxSuccessJS template.JS `json:"ajax_success_js"` // Ajax成功回调JavaScript
	AjaxErrorJS   template.JS `json:"ajax_error_js"`   // Ajax错误回调JavaScript

	Responder Responder `json:"responder"` // 响应处理函数

	Wrapper ContentWrapper `json:"wrapper"` // 内容包装器

	HideSideBar bool `json:"hide_side_bar"` // 是否隐藏侧边栏

	HeaderHtml template.HTML `json:"header_html"` // 头部HTML
	FooterHtml template.HTML `json:"footer_html"` // 底部HTML

	PageError     errors.PageError `json:"page_error"`      // 页面错误
	PageErrorHTML template.HTML    `json:"page_error_html"` // 页面错误HTML

	NoCompress bool `json:"no_compress"` // 是否不压缩
	// contains filtered or unexported fields
}

FormPanel 是表单面板结构体,用于管理表单的所有配置和字段

func NewFormPanel

func NewFormPanel() *FormPanel

NewFormPanel 创建一个新的表单面板实例 返回: 初始化后的 FormPanel 指针

func (*FormPanel) AddCSS

func (f *FormPanel) AddCSS(css template.CSS) *FormPanel

func (*FormPanel) AddField

func (f *FormPanel) AddField(head, field string, filedType db.DatabaseType, formType form2.Type) *FormPanel

AddField 添加一个字段到表单 参数:

  • head: 字段标题
  • field: 字段名
  • filedType: 数据库类型
  • formType: 表单类型

返回: 更新后的 FormPanel 指针

func (*FormPanel) AddFieldTr

func (f *FormPanel) AddFieldTr(ctx *context.Context, head, field string, filedType db.DatabaseType, formType form2.Type) *FormPanel

AddFieldTr 添加带翻译的字段(AddFieldWithTranslation的别名) 参数:

  • ctx: 上下文对象
  • head: 字段标题
  • field: 字段名
  • filedType: 数据库类型
  • formType: 表单类型

返回: 更新后的 FormPanel 指针

func (*FormPanel) AddFieldWithTranslation

func (f *FormPanel) AddFieldWithTranslation(ctx *context.Context, head, field string, filedType db.DatabaseType,
	formType form2.Type) *FormPanel

AddFieldWithTranslation 添加带翻译的字段 参数:

  • ctx: 上下文对象
  • head: 字段标题
  • field: 字段名
  • filedType: 数据库类型
  • formType: 表单类型

返回: 更新后的 FormPanel 指针

func (*FormPanel) AddJS

func (f *FormPanel) AddJS(js template.JS) *FormPanel

func (*FormPanel) AddLimitFilter

func (f *FormPanel) AddLimitFilter(limit int) *FormPanel

AddLimitFilter 添加长度限制过滤器 参数:

  • limit: 最大长度限制

返回: 更新后的 FormPanel 指针

func (*FormPanel) AddRow

func (f *FormPanel) AddRow(addFields AddFormFieldFn) *FormPanel

AddRow 添加一行字段 参数:

  • addFields: 添加字段的函数

返回: 更新后的 FormPanel 指针

func (*FormPanel) AddSubstrFilter

func (f *FormPanel) AddSubstrFilter(start int, end int) *FormPanel

AddSubstrFilter 添加子字符串过滤器 参数:

  • start: 起始位置
  • end: 结束位置

返回: 更新后的 FormPanel 指针

func (*FormPanel) AddTable

func (f *FormPanel) AddTable(head, field string, addFields AddFormFieldFn) *FormPanel

AddTable 添加一个表格类型的字段 参数:

  • head: 字段标题
  • field: 字段名
  • addFields: 添加字段的函数

返回: 更新后的 FormPanel 指针

func (*FormPanel) AddToLowerFilter

func (f *FormPanel) AddToLowerFilter() *FormPanel

AddToLowerFilter 添加小写转换过滤器 返回: 更新后的 FormPanel 指针

func (*FormPanel) AddToTitleFilter

func (f *FormPanel) AddToTitleFilter() *FormPanel

AddToTitleFilter 添加标题转换过滤器(将字符串转为标题格式) 返回: 更新后的 FormPanel 指针

func (*FormPanel) AddToUpperFilter

func (f *FormPanel) AddToUpperFilter() *FormPanel

AddToUpperFilter 添加大写转换过滤器 返回: 更新后的 FormPanel 指针

func (*FormPanel) AddTrimSpaceFilter

func (f *FormPanel) AddTrimSpaceFilter() *FormPanel

AddTrimSpaceFilter 添加去除空格过滤器 返回: 更新后的 FormPanel 指针

func (*FormPanel) AddXssFilter

func (f *FormPanel) AddXssFilter() *FormPanel

AddXssFilter 添加XSS过滤器 返回: 更新后的 FormPanel 指针

func (*FormPanel) AddXssJsFilter

func (f *FormPanel) AddXssJsFilter() *FormPanel

AddXssJsFilter 添加JavaScript XSS过滤器 返回: 更新后的 FormPanel 指针

func (*FormPanel) EnableAjax

func (f *FormPanel) EnableAjax(msgs ...string) *FormPanel

func (*FormPanel) EnableAjaxData

func (f *FormPanel) EnableAjaxData(data AjaxData) *FormPanel

func (*FormPanel) FieldCustomContent

func (f *FormPanel) FieldCustomContent(content template.HTML) *FormPanel

func (*FormPanel) FieldCustomCss

func (f *FormPanel) FieldCustomCss(css template.CSS) *FormPanel

func (*FormPanel) FieldCustomJs

func (f *FormPanel) FieldCustomJs(js template.JS) *FormPanel

func (*FormPanel) FieldDefault

func (f *FormPanel) FieldDefault(def string) *FormPanel

func (*FormPanel) FieldDefaultOptionDelimiter

func (f *FormPanel) FieldDefaultOptionDelimiter(delimiter string) *FormPanel

func (*FormPanel) FieldDisableWhenCreate

func (f *FormPanel) FieldDisableWhenCreate() *FormPanel

FieldDisableWhenCreate means when create record the field can not be edited, displayed and submitted.

func (*FormPanel) FieldDisableWhenUpdate

func (f *FormPanel) FieldDisableWhenUpdate() *FormPanel

FieldDisableWhenUpdate means when update record the field can not be edited, displayed and submitted.

func (*FormPanel) FieldDisplay

func (f *FormPanel) FieldDisplay(filter FieldFilterFn) *FormPanel

FieldDisplay 设置字段显示函数 参数:

  • filter: 字段过滤函数

返回: 更新后的 FormPanel 指针

func (*FormPanel) FieldDisplayButCanNotEditWhenCreate

func (f *FormPanel) FieldDisplayButCanNotEditWhenCreate() *FormPanel

FieldDisplayButCanNotEditWhenCreate means when create record the field can not be edited but will still be displayed and submitted.

func (*FormPanel) FieldDisplayButCanNotEditWhenUpdate

func (f *FormPanel) FieldDisplayButCanNotEditWhenUpdate() *FormPanel

FieldDisplayButCanNotEditWhenUpdate means when update record the field can not be edited but will still be displayed and submitted.

func (*FormPanel) FieldDivider

func (f *FormPanel) FieldDivider(title ...string) *FormPanel

FieldDivider 在当前字段后添加分隔线 参数:

  • title: 可选的分隔线标题

返回: 更新后的 FormPanel 指针

func (*FormPanel) FieldEnableFileUpload

func (f *FormPanel) FieldEnableFileUpload(data ...interface{}) *FormPanel

FieldEnableFileUpload 启用文件上传功能 参数:

  • data: 可选参数,第一个为上传URL,第二个为文件上传处理器

返回: 更新后的 FormPanel 指针

func (*FormPanel) FieldFoot

func (f *FormPanel) FieldFoot(foot template.HTML) *FormPanel

FieldFoot 设置当前字段的底部内容 参数:

  • foot: 底部HTML内容

返回: 更新后的 FormPanel 指针

func (*FormPanel) FieldFormType

func (f *FormPanel) FieldFormType(formType form2.Type) *FormPanel

func (*FormPanel) FieldHeadWidth

func (f *FormPanel) FieldHeadWidth(width int) *FormPanel

FieldHeadWidth 设置当前字段标题的宽度 参数:

  • width: 标题宽度值

返回: 更新后的 FormPanel 指针

func (*FormPanel) FieldHelpMsg

func (f *FormPanel) FieldHelpMsg(s template.HTML) *FormPanel

FieldHelpMsg 设置当前字段的帮助信息 参数:

  • s: 帮助信息HTML内容

返回: 更新后的 FormPanel 指针

func (*FormPanel) FieldHide

func (f *FormPanel) FieldHide() *FormPanel

FieldHide 隐藏当前字段 返回: 更新后的 FormPanel 指针

func (*FormPanel) FieldHideLabel

func (f *FormPanel) FieldHideLabel() *FormPanel

FieldHideLabel 隐藏当前字段的标签 返回: 更新后的 FormPanel 指针

func (*FormPanel) FieldHideWhenCreate

func (f *FormPanel) FieldHideWhenCreate() *FormPanel

FieldHideWhenCreate means when create record the field can not be edited and displayed, but will be submitted.

func (*FormPanel) FieldHideWhenUpdate

func (f *FormPanel) FieldHideWhenUpdate() *FormPanel

FieldHideWhenUpdate means when update record the field can not be edited and displayed, but will be submitted.

func (*FormPanel) FieldInputWidth

func (f *FormPanel) FieldInputWidth(width int) *FormPanel

FieldInputWidth 设置当前字段输入框的宽度 参数:

  • width: 输入框宽度值

返回: 更新后的 FormPanel 指针

func (*FormPanel) FieldLimit

func (f *FormPanel) FieldLimit(limit int) *FormPanel

FieldLimit limit the field length.

func (*FormPanel) FieldMust

func (f *FormPanel) FieldMust() *FormPanel

FieldMust 设置当前字段为必填字段 返回: 更新后的 FormPanel 指针

func (*FormPanel) FieldNotAllowAdd

func (f *FormPanel) FieldNotAllowAdd() *FormPanel

FieldNotAllowAdd means when create record the field can not be edited, displayed and submitted. Deprecated: Use FieldDisableWhenCreate instead.

func (*FormPanel) FieldNotAllowEdit

func (f *FormPanel) FieldNotAllowEdit() *FormPanel

FieldNotAllowEdit means when update record the field can not be edited but will still be displayed and submitted. Deprecated: Use FieldDisplayButCanNotEditWhenUpdate instead.

func (*FormPanel) FieldNow

func (f *FormPanel) FieldNow() *FormPanel

func (*FormPanel) FieldNowWhenInsert

func (f *FormPanel) FieldNowWhenInsert() *FormPanel

func (*FormPanel) FieldNowWhenUpdate

func (f *FormPanel) FieldNowWhenUpdate() *FormPanel

func (*FormPanel) FieldOnChoose

func (f *FormPanel) FieldOnChoose(val, field string, value template.HTML) *FormPanel

FieldOnChoose set the given value of the given field when choose the value of val.

func (*FormPanel) FieldOnChooseAjax

func (f *FormPanel) FieldOnChooseAjax(field, url string, handler Handler, custom ...template.HTML) *FormPanel

FieldOnChooseAjax set the url and handler that will be called when field be choosed. The handler will return the option of the field. It will help to link two or more form items. For example:

FieldOnChooseAjax("city", "/search/city", func(ctx *context.Context) (success bool, msg string, data interface{}) {
	return true, "ok", selection.Data{
		Results: selection.Options{
			{Text: "GuangZhou", ID: "1"},
			{Text: "ShenZhen", ID: "2"},
			{Text: "BeiJing", ID: "3"},
			{Text: "ShangHai", ID: "4"},
		}
	}
})

When you choose the country, it trigger the action of ajax which be sent to the given handler, and return the city options to the field city.

func (*FormPanel) FieldOnChooseCustom

func (f *FormPanel) FieldOnChooseCustom(js template.HTML) *FormPanel

FieldOnChooseCustom set the js that will be called when filter option be selected.

func (*FormPanel) FieldOnChooseDisable

func (f *FormPanel) FieldOnChooseDisable(value string, field ...string) *FormPanel

FieldOnChooseDisable disable the fields when value to be chosen.

func (*FormPanel) FieldOnChooseHide

func (f *FormPanel) FieldOnChooseHide(value string, field ...string) *FormPanel

FieldOnChooseHide hide the fields when value to be chosen.

func (*FormPanel) FieldOnChooseMap

func (f *FormPanel) FieldOnChooseMap(m map[string]LinkField) *FormPanel

FieldOnChooseMap set the actions that will be taken when filter option be selected. For example:

map[string]types.LinkField{
     "men": {Field: "ip", Value:"127.0.0.1"},
     "women": {Field: "ip", Hide: true},
     "other": {Field: "ip", Disable: true}
}

mean when choose men, the value of field ip will be set to 127.0.0.1, when choose women, field ip will be hidden, and when choose other, field ip will be disabled.

func (*FormPanel) FieldOnChooseOptionsHide

func (f *FormPanel) FieldOnChooseOptionsHide(values []string, field ...string) *FormPanel

FieldOnChooseOptionsHide display the fields when value to be chosen.

func (*FormPanel) FieldOnChooseOptionsShow

func (f *FormPanel) FieldOnChooseOptionsShow(values []string, field ...string) *FormPanel

FieldOnChooseOptionsShow display the fields when values to be chosen.

func (*FormPanel) FieldOnChooseShow

func (f *FormPanel) FieldOnChooseShow(value string, field ...string) *FormPanel

FieldFilterOnChooseShow display the fields when value to be chosen.

func (*FormPanel) FieldOnSearch

func (f *FormPanel) FieldOnSearch(url string, handler Handler, delay ...int) *FormPanel

FieldOnSearch set the url and the corresponding handler which has some backend logic and return the options of the field. For example:

FieldOnSearch("/search/city", func(ctx *context.Context) (success bool, msg string, data interface{}) {
	return true, "ok", selection.Data{
		Results: selection.Options{
			{Text: "GuangZhou", ID: "1"},
			{Text: "ShenZhen", ID: "2"},
			{Text: "BeiJing", ID: "3"},
			{Text: "ShangHai", ID: "4"},
		}
	}
}, 1000)

func (*FormPanel) FieldOptionExt

func (f *FormPanel) FieldOptionExt(m map[string]interface{}) *FormPanel

FieldOptionExt 设置字段的选项扩展JavaScript配置 参数:

  • m: 包含扩展配置的映射

返回: 更新后的 FormPanel 指针

func (*FormPanel) FieldOptionExt2

func (f *FormPanel) FieldOptionExt2(m map[string]interface{}) *FormPanel

FieldOptionExt2 设置字段的第二个选项扩展JavaScript配置 参数:

  • m: 包含扩展配置的映射

返回: 更新后的 FormPanel 指针

func (*FormPanel) FieldOptionExtJS

func (f *FormPanel) FieldOptionExtJS(js template.JS) *FormPanel

FieldOptionExtJS 直接设置字段的选项扩展JavaScript 参数:

  • js: JavaScript代码

返回: 更新后的 FormPanel 指针

func (*FormPanel) FieldOptionExtJS2

func (f *FormPanel) FieldOptionExtJS2(js template.JS) *FormPanel

FieldOptionExtJS2 直接设置字段的第二个选项扩展JavaScript 参数:

  • js: JavaScript代码

返回: 更新后的 FormPanel 指针

func (*FormPanel) FieldOptionInitFn

func (f *FormPanel) FieldOptionInitFn(fn OptionInitFn) *FormPanel

FieldOptionInitFn 设置当前字段的选项初始化函数 参数:

  • fn: 选项初始化函数

返回: 更新后的 FormPanel 指针

func (*FormPanel) FieldOptions

func (f *FormPanel) FieldOptions(options FieldOptions) *FormPanel

FieldOptions set options for a filterable field to select. It will work when you set the FormType of the field to SelectSingle/Select/SelectBox.

func (*FormPanel) FieldOptionsFromTable

func (f *FormPanel) FieldOptionsFromTable(table, textFieldName, valueFieldName string, process ...OptionTableQueryProcessFn) *FormPanel

FieldOptionsFromTable set options for a filterable field to select. The options is from other table. For example,

`FieldOptionsFromTable("roles", "name", "id")`

will generate the sql like:

`select id, name from roles`.

And the `id` will be the value of options, `name` is the text to be shown.

func (*FormPanel) FieldOptionsTableProcessFn

func (f *FormPanel) FieldOptionsTableProcessFn(fn OptionProcessFn) *FormPanel

func (*FormPanel) FieldPlaceholder

func (f *FormPanel) FieldPlaceholder(placeholder string) *FormPanel

FieldPlaceholder 设置当前字段的占位符文本 参数:

  • placeholder: 占位符文本

返回: 更新后的 FormPanel 指针

func (*FormPanel) FieldPostFilterFn

func (f *FormPanel) FieldPostFilterFn(post PostFieldFilterFn) *FormPanel

func (*FormPanel) FieldRowWidth

func (f *FormPanel) FieldRowWidth(width int) *FormPanel

FieldRowWidth 设置当前字段行的宽度 参数:

  • width: 行宽度值

返回: 更新后的 FormPanel 指针

func (*FormPanel) FieldSubstr

func (f *FormPanel) FieldSubstr(start int, end int) *FormPanel

FieldSubstr intercept string of the field.

func (*FormPanel) FieldToLower

func (f *FormPanel) FieldToLower() *FormPanel

FieldToLower update the field to a string with all Unicode letters mapped to their lower case.

func (*FormPanel) FieldToTitle

func (f *FormPanel) FieldToTitle() *FormPanel

FieldToTitle update the field to a string that begin words mapped to their Unicode title case.

func (*FormPanel) FieldToUpper

func (f *FormPanel) FieldToUpper() *FormPanel

FieldToUpper update the field to a string with all Unicode letters mapped to their upper case.

func (*FormPanel) FieldTrimSpace

func (f *FormPanel) FieldTrimSpace() *FormPanel

FieldTrimSpace trim space of the field.

func (*FormPanel) FieldValue

func (f *FormPanel) FieldValue(value string) *FormPanel

func (*FormPanel) FieldWidth

func (f *FormPanel) FieldWidth(width int) *FormPanel

FieldWidth 设置当前字段的宽度 参数:

  • width: 宽度值

返回: 更新后的 FormPanel 指针

func (*FormPanel) FieldXssFilter

func (f *FormPanel) FieldXssFilter() *FormPanel

FieldXssFilter escape field with html.Escape.

func (*FormPanel) FieldsWithDefaultValue

func (f *FormPanel) FieldsWithDefaultValue(sql ...func() *db.SQL) FormFields

func (*FormPanel) FieldsWithValue

func (f *FormPanel) FieldsWithValue(pk, id string, columns []string, res map[string]interface{}, sql func() *db.SQL) FormFields

func (*FormPanel) GetNewFormFields

func (f *FormPanel) GetNewFormFields(sql ...func() *db.SQL) (FormFields, []FormFields, []string)

func (*FormPanel) GroupField

func (f *FormPanel) GroupField(sql ...func() *db.SQL) ([]FormFields, []string)

func (*FormPanel) GroupFieldWithValue

func (f *FormPanel) GroupFieldWithValue(pk, id string, columns []string, res map[string]interface{}, sql func() *db.SQL) ([]FormFields, []string)

func (*FormPanel) HasError

func (f *FormPanel) HasError() bool

func (*FormPanel) HideBackButton

func (f *FormPanel) HideBackButton() *FormPanel

HideBackButton 隐藏返回按钮 返回: 更新后的 FormPanel 指针

func (*FormPanel) HideContinueEditCheckBox

func (f *FormPanel) HideContinueEditCheckBox() *FormPanel

HideContinueEditCheckBox 隐藏继续编辑复选框 返回: 更新后的 FormPanel 指针

func (*FormPanel) HideContinueNewCheckBox

func (f *FormPanel) HideContinueNewCheckBox() *FormPanel

HideContinueNewCheckBox 隐藏继续新建复选框 返回: 更新后的 FormPanel 指针

func (*FormPanel) HideResetButton

func (f *FormPanel) HideResetButton() *FormPanel

HideResetButton 隐藏重置按钮 返回: 更新后的 FormPanel 指针

func (*FormPanel) OperationURL

func (f *FormPanel) OperationURL(id string) string

func (*FormPanel) Set400Error

func (f *FormPanel) Set400Error(content ...template.HTML) *FormPanel

func (*FormPanel) Set403Error

func (f *FormPanel) Set403Error(content ...template.HTML) *FormPanel

func (*FormPanel) Set404Error

func (f *FormPanel) Set404Error(content ...template.HTML) *FormPanel

func (*FormPanel) Set500Error

func (f *FormPanel) Set500Error(content ...template.HTML) *FormPanel

func (*FormPanel) SetAjaxErrorJS

func (f *FormPanel) SetAjaxErrorJS(js template.JS) *FormPanel

func (*FormPanel) SetAjaxSuccessJS

func (f *FormPanel) SetAjaxSuccessJS(js template.JS) *FormPanel

func (*FormPanel) SetDescription

func (f *FormPanel) SetDescription(desc string) *FormPanel

func (*FormPanel) SetError

func (f *FormPanel) SetError(err errors.PageError, content ...template.HTML) *FormPanel

func (*FormPanel) SetFooterHtml

func (f *FormPanel) SetFooterHtml(footer template.HTML) *FormPanel

func (*FormPanel) SetFormEditBtnWord

func (f *FormPanel) SetFormEditBtnWord(word template.HTML) *FormPanel

func (*FormPanel) SetFormEditTitle

func (f *FormPanel) SetFormEditTitle(title template.HTML) *FormPanel

func (*FormPanel) SetFormNewBtnWord

func (f *FormPanel) SetFormNewBtnWord(word template.HTML) *FormPanel

func (*FormPanel) SetFormNewTitle

func (f *FormPanel) SetFormNewTitle(title template.HTML) *FormPanel

func (*FormPanel) SetHTMLContent

func (f *FormPanel) SetHTMLContent(content template.HTML) *FormPanel

func (*FormPanel) SetHeadWidth

func (f *FormPanel) SetHeadWidth(width int) *FormPanel

func (*FormPanel) SetHeader

func (f *FormPanel) SetHeader(content template.HTML) *FormPanel

func (*FormPanel) SetHeaderHtml

func (f *FormPanel) SetHeaderHtml(header template.HTML) *FormPanel

func (*FormPanel) SetHideSideBar

func (f *FormPanel) SetHideSideBar() *FormPanel

func (*FormPanel) SetInputWidth

func (f *FormPanel) SetInputWidth(width int) *FormPanel

func (*FormPanel) SetInsertFn

func (f *FormPanel) SetInsertFn(fn FormPostFn) *FormPanel

func (*FormPanel) SetLayout

func (f *FormPanel) SetLayout(layout form2.Layout) *FormPanel

func (*FormPanel) SetNoCompress

func (f *FormPanel) SetNoCompress() *FormPanel

func (*FormPanel) SetPostHook

func (f *FormPanel) SetPostHook(fn FormPostFn) *FormPanel

func (*FormPanel) SetPostValidator

func (f *FormPanel) SetPostValidator(va FormPostFn) *FormPanel

func (*FormPanel) SetPreProcessFn

func (f *FormPanel) SetPreProcessFn(fn FormPreProcessFn) *FormPanel

func (*FormPanel) SetPrimaryKey

func (f *FormPanel) SetPrimaryKey(name string, typ db.DatabaseType) *FormPanel

SetPrimaryKey 设置主键 参数:

  • name: 主键字段名
  • typ: 数据库类型

返回: 更新后的 FormPanel 指针

func (*FormPanel) SetResponder

func (f *FormPanel) SetResponder(responder Responder) *FormPanel

func (*FormPanel) SetTabGroups

func (f *FormPanel) SetTabGroups(groups TabGroups) *FormPanel

func (*FormPanel) SetTabHeaders

func (f *FormPanel) SetTabHeaders(headers ...string) *FormPanel

func (*FormPanel) SetTable

func (f *FormPanel) SetTable(table string) *FormPanel

SetTable 设置数据库表名 参数:

  • table: 表名

返回: 更新后的 FormPanel 指针

func (*FormPanel) SetTitle

func (f *FormPanel) SetTitle(title string) *FormPanel

func (*FormPanel) SetUpdateFn

func (f *FormPanel) SetUpdateFn(fn FormPostFn) *FormPanel

func (*FormPanel) SetWrapper

func (f *FormPanel) SetWrapper(wrapper ContentWrapper) *FormPanel

type FormPostFn

type FormPostFn func(values form.Values) error

type FormPreProcessFn

type FormPreProcessFn func(values form.Values) form.Values

type GetDataFn

type GetDataFn func(param parameter.Parameters) ([]map[string]interface{}, int)

type GetPanelFn

type GetPanelFn func(ctx interface{}) (Panel, error)

GetPanelFn 是获取面板的函数类型

type GetPanelInfoFn

type GetPanelInfoFn func(ctx *context.Context) (Panel, error)

GetPanelInfoFn 是获取面板信息的函数类型

type GroupFieldHeaders

type GroupFieldHeaders []string

type GroupFormFields

type GroupFormFields []FormFields

type Handler

type Handler func(ctx *context.Context) (success bool, msg string, data interface{})

Handler 是处理函数类型

func (Handler) Wrap

func (h Handler) Wrap() context.Handler

Wrap 包装处理函数为上下文处理函数 返回: 上下文处理函数

type ImgAttribute

type ImgAttribute interface {
	SetWidth(value string) ImgAttribute      // 设置宽度
	SetHeight(value string) ImgAttribute     // 设置高度
	WithModal() ImgAttribute                 // 使用模态框
	SetSrc(value template.HTML) ImgAttribute // 设置源地址
	GetContent() template.HTML               // 获取内容
}

ImgAttribute 图片属性接口

type InfoItem

type InfoItem struct {
	Content template.HTML `json:"content"` // HTML内容
	Value   string        `json:"value"`   // 值
}

InfoItem 表示信息项

type InfoList

type InfoList []map[string]InfoItem

InfoList 是信息项列表的别名

func (InfoList) GroupBy

func (i InfoList) GroupBy(groups TabGroups) []InfoList

GroupBy 根据标签组对信息列表进行分组 参数:

  • groups: 标签组

返回: 分组后的信息列表数组

type InfoPanel

type InfoPanel struct {
	Ctx *context.Context

	FieldList FieldList

	Table       string
	Title       string
	Description string

	// Warn: may be deprecated future.
	TabGroups  TabGroups
	TabHeaders TabHeaders

	Sort      Sort
	SortField string

	PageSizeList    []int
	DefaultPageSize int

	ExportType      int
	ExportProcessFn ExportProcessFn

	IsHideNewButton    bool
	IsHideExportButton bool
	IsHideEditButton   bool
	IsHideDeleteButton bool
	IsHideDetailButton bool
	IsHideFilterButton bool
	IsHideRowSelector  bool
	IsHidePagination   bool
	IsHideFilterArea   bool
	IsHideQueryInfo    bool
	FilterFormLayout   form.Layout

	FilterFormHeadWidth  int
	FilterFormInputWidth int

	Wheres    Wheres
	WhereRaws WhereRaw

	Callbacks Callbacks

	Buttons Buttons

	TableLayout string

	DeleteHook  DeleteFn
	PreDeleteFn DeleteFn
	DeleteFn    DeleteFn

	DeleteHookWithRes DeleteFnWithRes

	GetDataFn GetDataFn

	ActionButtons    Buttons
	ActionButtonFold bool

	DisplayGeneratorRecords map[string]struct{}

	QueryFilterFn       QueryFilterFn
	UpdateParametersFns []UpdateParametersFn

	Wrapper ContentWrapper

	// column operation buttons
	Action     template.HTML
	HeaderHtml template.HTML
	FooterHtml template.HTML

	PageError     errors.PageError
	PageErrorHTML template.HTML

	NoCompress  bool
	HideSideBar bool

	AutoRefresh uint
	// contains filtered or unexported fields
}

InfoPanel

func NewInfoPanel

func NewInfoPanel(ctx *context.Context, pk string) *InfoPanel

NewInfoPanel 创建新的信息面板 参数:

  • ctx: 上下文对象
  • pk: 主键

返回: 初始化后的信息面板

func (*InfoPanel) AddActionButton

func (i *InfoPanel) AddActionButton(ctx *context.Context, title template.HTML, action Action, ids ...string) *InfoPanel

AddActionButton 添加操作按钮 参数:

  • ctx: 上下文对象
  • title: 按钮标题
  • action: 操作对象
  • ids: 可选的ID列表

返回: 更新后的信息面板

func (*InfoPanel) AddActionButtonFront

func (i *InfoPanel) AddActionButtonFront(ctx *context.Context, title template.HTML, action Action, ids ...string) *InfoPanel

AddActionButtonFront 在前面添加操作按钮 参数:

  • ctx: 上下文对象
  • title: 按钮标题
  • action: 操作对象
  • ids: 可选的ID列表

返回: 更新后的信息面板

func (*InfoPanel) AddActionIconButton

func (i *InfoPanel) AddActionIconButton(ctx *context.Context, icon string, action Action, ids ...string) *InfoPanel

AddActionIconButton 添加操作图标按钮 参数:

  • ctx: 上下文对象
  • icon: 图标
  • action: 操作对象
  • ids: 可选的ID列表

返回: 更新后的信息面板

func (*InfoPanel) AddButton

func (i *InfoPanel) AddButton(ctx *context.Context, title template.HTML, icon string, action Action, color ...template.HTML) *InfoPanel

AddButton 添加按钮 参数:

  • ctx: 上下文对象
  • title: 按钮标题
  • icon: 图标
  • action: 操作对象
  • color: 可选的颜色

返回: 更新后的信息面板

func (*InfoPanel) AddButtonRaw

func (i *InfoPanel) AddButtonRaw(ctx *context.Context, btn Button, action Action) *InfoPanel

AddButtonRaw 添加原始按钮 参数:

  • ctx: 上下文对象
  • btn: 按钮对象
  • action: 操作对象

返回: 更新后的信息面板

func (*InfoPanel) AddCSS

func (i *InfoPanel) AddCSS(css template.CSS) *InfoPanel

func (*InfoPanel) AddColumn

func (i *InfoPanel) AddColumn(head string, fun FieldFilterFn) *InfoPanel

AddColumn 添加列 参数:

  • head: 列标题
  • fun: 字段过滤函数

返回: 更新后的信息面板

func (*InfoPanel) AddColumnButtons

func (i *InfoPanel) AddColumnButtons(ctx *context.Context, head string, buttons ...Button) *InfoPanel

AddColumnButtons 添加按钮列 参数:

  • ctx: 上下文对象
  • head: 列标题
  • buttons: 按钮列表

返回: 更新后的信息面板

func (*InfoPanel) AddField

func (i *InfoPanel) AddField(head, field string, typeName db.DatabaseType) *InfoPanel

AddField 添加字段 参数:

  • head: 字段标题
  • field: 字段名
  • typeName: 数据库类型

返回: 更新后的信息面板

func (*InfoPanel) AddFieldTr

func (i *InfoPanel) AddFieldTr(ctx *context.Context, head, field string, typeName db.DatabaseType) *InfoPanel

AddFieldTr 添加带翻译的字段 参数:

  • ctx: 上下文对象
  • head: 字段标题
  • field: 字段名
  • typeName: 数据库类型

返回: 更新后的信息面板

func (*InfoPanel) AddFieldWithTranslation

func (i *InfoPanel) AddFieldWithTranslation(ctx *context.Context, head, field string, typeName db.DatabaseType) *InfoPanel

AddFieldWithTranslation 添加带翻译的字段 参数:

  • ctx: 上下文对象
  • head: 字段标题
  • field: 字段名
  • typeName: 数据库类型

返回: 更新后的信息面板

func (*InfoPanel) AddFilter

func (i *InfoPanel) AddFilter(head, field string, typeName db.DatabaseType, fn UpdateParametersFn, filterType ...FilterType) *InfoPanel

AddFilter 添加筛选字段 参数:

  • head: 字段标题
  • field: 字段名
  • typeName: 数据库类型
  • fn: 更新参数函数
  • filterType: 可选的筛选类型

返回: 更新后的信息面板

func (*InfoPanel) AddJS

func (i *InfoPanel) AddJS(js template.JS) *InfoPanel

func (*InfoPanel) AddJSModule

func (i *InfoPanel) AddJSModule(js template.JS) *InfoPanel

func (*InfoPanel) AddLimitFilter

func (i *InfoPanel) AddLimitFilter(limit int) *InfoPanel

AddLimitFilter 添加长度限制过滤器 参数:

  • limit: 限制长度

返回: 更新后的信息面板

func (*InfoPanel) AddSelectBox

func (i *InfoPanel) AddSelectBox(ctx *context.Context, placeholder string, options FieldOptions, action Action, width ...int) *InfoPanel

AddSelectBox 添加选择框 参数:

  • ctx: 上下文对象
  • placeholder: 占位符
  • options: 选项列表
  • action: 操作对象
  • width: 可选的宽度

返回: 更新后的信息面板

func (*InfoPanel) AddSubstrFilter

func (i *InfoPanel) AddSubstrFilter(start int, end int) *InfoPanel

AddSubstrFilter 添加子字符串过滤器 参数:

  • start: 起始位置
  • end: 结束位置

返回: 更新后的信息面板

func (*InfoPanel) AddToLowerFilter

func (i *InfoPanel) AddToLowerFilter() *InfoPanel

AddToLowerFilter 添加小写过滤器 返回: 更新后的信息面板

func (*InfoPanel) AddToTitleFilter

func (i *InfoPanel) AddToTitleFilter() *InfoPanel

AddToTitleFilter 添加标题过滤器 返回: 更新后的信息面板

func (*InfoPanel) AddToUpperFilter

func (i *InfoPanel) AddToUpperFilter() *InfoPanel

AddToUpperFilter 添加大写过滤器 返回: 更新后的信息面板

func (*InfoPanel) AddTrimSpaceFilter

func (i *InfoPanel) AddTrimSpaceFilter() *InfoPanel

AddTrimSpaceFilter 添加去空格过滤器 返回: 更新后的信息面板

func (*InfoPanel) AddUpdateParametersFn

func (i *InfoPanel) AddUpdateParametersFn(fn UpdateParametersFn) *InfoPanel

AddUpdateParametersFn 添加更新参数函数 参数:

  • fn: 更新参数函数

返回: 更新后的信息面板

func (*InfoPanel) AddXssFilter

func (i *InfoPanel) AddXssFilter() *InfoPanel

AddXssFilter 添加XSS过滤器 返回: 更新后的信息面板

func (*InfoPanel) AddXssJsFilter

func (i *InfoPanel) AddXssJsFilter() *InfoPanel

AddXssJsFilter 添加XSS JS过滤器 返回: 更新后的信息面板

func (*InfoPanel) ExportValue

func (i *InfoPanel) ExportValue() *InfoPanel

ExportValue 设置导出类型为值 返回: 更新后的信息面板

func (*InfoPanel) FieldAsDeleteParam

func (i *InfoPanel) FieldAsDeleteParam() *InfoPanel

func (*InfoPanel) FieldAsDetailParam

func (i *InfoPanel) FieldAsDetailParam() *InfoPanel

func (*InfoPanel) FieldAsEditParam

func (i *InfoPanel) FieldAsEditParam() *InfoPanel

func (*InfoPanel) FieldBool

func (i *InfoPanel) FieldBool(flags ...string) *InfoPanel

FieldBool 设置字段为布尔值显示 参数:

  • flags: 标志列表

返回: 更新后的信息面板

func (*InfoPanel) FieldCarousel

func (i *InfoPanel) FieldCarousel(fn FieldGetImgArrFn, size ...int) *InfoPanel

FieldCarousel 设置字段为轮播图显示 参数:

  • fn: 获取图片数组函数
  • size: 可选的大小

返回: 更新后的信息面板

func (*InfoPanel) FieldCopyable

func (i *InfoPanel) FieldCopyable(prefix ...string) *InfoPanel

FieldCopyable 设置字段为可复制显示 参数:

  • prefix: 可选的前缀

返回: 更新后的信息面板

func (*InfoPanel) FieldDate

func (i *InfoPanel) FieldDate(format string) *InfoPanel

FieldDate 设置字段为日期显示 参数:

  • format: 日期格式

返回: 更新后的信息面板

func (*InfoPanel) FieldDisplay

func (i *InfoPanel) FieldDisplay(filter FieldFilterFn) *InfoPanel

FieldDisplay 设置字段显示函数 参数:

  • filter: 字段过滤函数

返回: 更新后的信息面板

func (*InfoPanel) FieldDot

func (i *InfoPanel) FieldDot(icons map[string]FieldDotColor, defaultDot FieldDotColor) *InfoPanel

FieldDot 设置字段为点显示 参数:

  • icons: 图标映射
  • defaultDot: 默认点颜色

返回: 更新后的信息面板

func (*InfoPanel) FieldDownLoadable

func (i *InfoPanel) FieldDownLoadable(prefix ...string) *InfoPanel

FieldDownLoadable 设置字段为可下载显示 参数:

  • prefix: 可选的前缀

返回: 更新后的信息面板

func (*InfoPanel) FieldEditAble

func (i *InfoPanel) FieldEditAble(editType ...table.Type) *InfoPanel

func (*InfoPanel) FieldEditOptions

func (i *InfoPanel) FieldEditOptions(options FieldOptions, extra ...map[string]string) *InfoPanel

func (*InfoPanel) FieldFileSize

func (i *InfoPanel) FieldFileSize() *InfoPanel

FieldFileSize 设置字段为文件大小显示 返回: 更新后的信息面板

func (*InfoPanel) FieldFilterOnChoose

func (i *InfoPanel) FieldFilterOnChoose(val, field string, value template.HTML) *InfoPanel

FieldFilterOnChoose set the given value of the given field when choose the value of val.

func (*InfoPanel) FieldFilterOnChooseAjax

func (i *InfoPanel) FieldFilterOnChooseAjax(field, url string, handler Handler) *InfoPanel

FieldFilterOnChooseAjax set the url and handler that will be called when field be choosed. The handler will return the option of the field. It will help to link two or more form items. For example:

FieldFilterOnChooseAjax("city", "/search/city", func(ctx *context.Context) (success bool, msg string, data interface{}) {
	return true, "ok", selection.Data{
		Results: selection.Options{
			{Text: "GuangZhou", ID: "1"},
			{Text: "ShenZhen", ID: "2"},
			{Text: "BeiJing", ID: "3"},
			{Text: "ShangHai", ID: "4"},
		}
	}
})

When you choose the country, it trigger the action of ajax which be sent to the given handler, and return the city options to the field city.

func (*InfoPanel) FieldFilterOnChooseCustom

func (i *InfoPanel) FieldFilterOnChooseCustom(js template.HTML) *InfoPanel

FieldFilterOnChooseCustom set the js that will be called when filter option be selected.

func (*InfoPanel) FieldFilterOnChooseDisable

func (i *InfoPanel) FieldFilterOnChooseDisable(value string, field ...string) *InfoPanel

FieldFilterOnChooseDisable disable the fields when value to be chosen.

func (*InfoPanel) FieldFilterOnChooseHide

func (i *InfoPanel) FieldFilterOnChooseHide(value string, field ...string) *InfoPanel

FieldFilterOnChooseHide hide the fields when value to be chosen.

func (*InfoPanel) FieldFilterOnChooseMap

func (i *InfoPanel) FieldFilterOnChooseMap(m map[string]LinkField) *InfoPanel

FieldFilterOnChooseMap set the actions that will be taken when filter option be selected. For example:

map[string]types.LinkField{
     "men": {Field: "ip", Value:"127.0.0.1"},
     "women": {Field: "ip", Hide: true},
     "other": {Field: "ip", Disable: true}
}

mean when choose men, the value of field ip will be set to 127.0.0.1, when choose women, field ip will be hidden, and when choose other, field ip will be disabled.

func (*InfoPanel) FieldFilterOnChooseShow

func (i *InfoPanel) FieldFilterOnChooseShow(value string, field ...string) *InfoPanel

FieldFilterOnChooseShow display the fields when value to be chosen.

func (*InfoPanel) FieldFilterOnSearch

func (i *InfoPanel) FieldFilterOnSearch(url string, handler Handler, delay ...int) *InfoPanel

FieldFilterOnSearch set the url and the corresponding handler which has some backend logic and return the options of the field. For example:

FieldFilterOnSearch("/search/city", func(ctx *context.Context) (success bool, msg string, data interface{}) {
	return true, "ok", selection.Data{
		Results: selection.Options{
			{Text: "GuangZhou", ID: "1"},
			{Text: "ShenZhen", ID: "2"},
			{Text: "BeiJing", ID: "3"},
			{Text: "ShangHai", ID: "4"},
		}
	}
}, 1000)

func (*InfoPanel) FieldFilterOptionExt

func (i *InfoPanel) FieldFilterOptionExt(m map[string]interface{}) *InfoPanel

FieldFilterOptionExt set the option extension js of the field.

func (*InfoPanel) FieldFilterOptions

func (i *InfoPanel) FieldFilterOptions(options FieldOptions) *InfoPanel

FieldFilterOptions set options for a filterable field to select. It will work when you set the FormType of the field to SelectSingle/Select/SelectBox.

func (*InfoPanel) FieldFilterOptionsFromTable

func (i *InfoPanel) FieldFilterOptionsFromTable(table, textFieldName, valueFieldName string, process ...OptionTableQueryProcessFn) *InfoPanel

FieldFilterOptionsFromTable set options for a filterable field to select. The options is from other table. For example,

`FieldFilterOptionsFromTable("roles", "name", "id")`

will generate the sql like:

`select id, name from roles`.

And the `id` will be the value of options, `name` is the text to be shown.

func (*InfoPanel) FieldFilterProcess

func (i *InfoPanel) FieldFilterProcess(process func(string) string) *InfoPanel

FieldFilterProcess process the field content. For example:

FieldFilterProcess(func(val string) string {
		return val + "ms"
})

func (*InfoPanel) FieldFilterable

func (i *InfoPanel) FieldFilterable(filterType ...FilterType) *InfoPanel

FieldFilterable set a field filterable which will display in the filter box.

func (*InfoPanel) FieldFixed

func (i *InfoPanel) FieldFixed() *InfoPanel

func (*InfoPanel) FieldHide

func (i *InfoPanel) FieldHide() *InfoPanel

FieldHide hide field. Include the filter area.

func (*InfoPanel) FieldHideForList

func (i *InfoPanel) FieldHideForList() *InfoPanel

FieldHide hide field for only the table.

func (*InfoPanel) FieldIcon

func (i *InfoPanel) FieldIcon(icons map[string]string, defaultIcon string) *InfoPanel

FieldIcon 设置字段为图标显示 参数:

  • icons: 图标映射
  • defaultIcon: 默认图标

返回: 更新后的信息面板

func (*InfoPanel) FieldImage

func (i *InfoPanel) FieldImage(width, height string, prefix ...string) *InfoPanel

FieldImage 设置字段为图片显示 参数:

  • width: 宽度
  • height: 高度
  • prefix: 可选的前缀

返回: 更新后的信息面板

func (*InfoPanel) FieldJoin

func (i *InfoPanel) FieldJoin(join Join) *InfoPanel

FieldJoin gets the field of the concatenated table.

Join {
    BaseTable:   "users",
    Field:       "role_id",
    Table:       "roles",
    JoinField:   "id",
}

It will generate the join table sql like:

select ... from users left join roles on roles.id = users.role_id

func (*InfoPanel) FieldLabel

func (i *InfoPanel) FieldLabel(args ...FieldLabelParam) *InfoPanel

FieldLabel 设置字段标签 参数:

  • args: 标签参数

返回: 更新后的信息面板

func (*InfoPanel) FieldLimit

func (i *InfoPanel) FieldLimit(limit int) *InfoPanel

FieldLimit limit the field length.

func (i *InfoPanel) FieldLink(src string, openInNewTab ...bool) *InfoPanel

FieldLink 设置字段为链接显示 参数:

  • src: 链接地址
  • openInNewTab: 是否在新标签页打开

返回: 更新后的信息面板

func (*InfoPanel) FieldLoading

func (i *InfoPanel) FieldLoading(data []string) *InfoPanel

FieldLoading 设置字段为加载中显示 参数:

  • data: 数据列表

返回: 更新后的信息面板

func (*InfoPanel) FieldProgressBar

func (i *InfoPanel) FieldProgressBar(data ...FieldProgressBarData) *InfoPanel

FieldProgressBar 设置字段为进度条显示 参数:

  • data: 进度条数据

返回: 更新后的信息面板

func (*InfoPanel) FieldQrcode

func (i *InfoPanel) FieldQrcode() *InfoPanel

FieldQrcode 设置字段为二维码显示 返回: 更新后的信息面板

func (*InfoPanel) FieldSortable

func (i *InfoPanel) FieldSortable() *InfoPanel

FieldSortable 设置字段可排序 返回: 更新后的信息面板

func (*InfoPanel) FieldSubstr

func (i *InfoPanel) FieldSubstr(start int, end int) *InfoPanel

FieldSubstr intercept string of the field.

func (*InfoPanel) FieldToLower

func (i *InfoPanel) FieldToLower() *InfoPanel

FieldToLower update the field to a string with all Unicode letters mapped to their lower case.

func (*InfoPanel) FieldToTitle

func (i *InfoPanel) FieldToTitle() *InfoPanel

FieldToTitle update the field to a string that begin words mapped to their Unicode title case.

func (*InfoPanel) FieldToUpper

func (i *InfoPanel) FieldToUpper() *InfoPanel

FieldToUpper update the field to a string with all Unicode letters mapped to their upper case.

func (*InfoPanel) FieldTrimSpace

func (i *InfoPanel) FieldTrimSpace() *InfoPanel

FieldTrimSpace trim space of the field.

func (*InfoPanel) FieldWidth

func (i *InfoPanel) FieldWidth(width int) *InfoPanel

FieldWidth 设置字段宽度 参数:

  • width: 宽度

返回: 更新后的信息面板

func (*InfoPanel) FieldXssFilter

func (i *InfoPanel) FieldXssFilter() *InfoPanel

FieldXssFilter escape field with html.Escape.

func (*InfoPanel) GetPageSizeList

func (i *InfoPanel) GetPageSizeList() []string

func (*InfoPanel) GetSort

func (i *InfoPanel) GetSort() string

func (*InfoPanel) HasError

func (i *InfoPanel) HasError() bool

func (*InfoPanel) HideCheckBoxColumn

func (i *InfoPanel) HideCheckBoxColumn() *InfoPanel

func (*InfoPanel) HideColumn

func (i *InfoPanel) HideColumn(n int) *InfoPanel

func (*InfoPanel) HideDeleteButton

func (i *InfoPanel) HideDeleteButton() *InfoPanel

func (*InfoPanel) HideDetailButton

func (i *InfoPanel) HideDetailButton() *InfoPanel

func (*InfoPanel) HideEditButton

func (i *InfoPanel) HideEditButton() *InfoPanel

func (*InfoPanel) HideExportButton

func (i *InfoPanel) HideExportButton() *InfoPanel

func (*InfoPanel) HideFilterArea

func (i *InfoPanel) HideFilterArea() *InfoPanel

func (*InfoPanel) HideFilterButton

func (i *InfoPanel) HideFilterButton() *InfoPanel

func (*InfoPanel) HideNewButton

func (i *InfoPanel) HideNewButton() *InfoPanel

func (*InfoPanel) HidePagination

func (i *InfoPanel) HidePagination() *InfoPanel

func (*InfoPanel) HideQueryInfo

func (i *InfoPanel) HideQueryInfo() *InfoPanel

func (*InfoPanel) HideRowSelector

func (i *InfoPanel) HideRowSelector() *InfoPanel

func (*InfoPanel) IsExportValue

func (i *InfoPanel) IsExportValue() bool

IsExportValue 判断是否导出值 返回: 如果是导出值返回true,否则返回false

func (*InfoPanel) OperationURL

func (i *InfoPanel) OperationURL(id string) string

OperationURL get the operation api url.

func (*InfoPanel) Set400Error

func (i *InfoPanel) Set400Error(content ...template.HTML) *InfoPanel

func (*InfoPanel) Set403Error

func (i *InfoPanel) Set403Error(content ...template.HTML) *InfoPanel

func (*InfoPanel) Set404Error

func (i *InfoPanel) Set404Error(content ...template.HTML) *InfoPanel

func (*InfoPanel) Set500Error

func (i *InfoPanel) Set500Error(content ...template.HTML) *InfoPanel

func (*InfoPanel) SetAction

func (i *InfoPanel) SetAction(action template.HTML) *InfoPanel

func (*InfoPanel) SetActionButtonFold

func (i *InfoPanel) SetActionButtonFold() *InfoPanel

SetActionButtonFold 设置操作按钮折叠 返回: 更新后的信息面板

func (*InfoPanel) SetAutoRefresh

func (i *InfoPanel) SetAutoRefresh(interval uint) *InfoPanel

func (*InfoPanel) SetDefaultPageSize

func (i *InfoPanel) SetDefaultPageSize(defaultPageSize int) *InfoPanel

func (*InfoPanel) SetDeleteFn

func (i *InfoPanel) SetDeleteFn(fn DeleteFn) *InfoPanel

SetDeleteFn 设置删除函数 参数:

  • fn: 删除函数

返回: 更新后的信息面板

func (*InfoPanel) SetDeleteHook

func (i *InfoPanel) SetDeleteHook(fn DeleteFn) *InfoPanel

SetDeleteHook 设置删除钩子 参数:

  • fn: 删除函数

返回: 更新后的信息面板

func (*InfoPanel) SetDeleteHookWithRes

func (i *InfoPanel) SetDeleteHookWithRes(fn DeleteFnWithRes) *InfoPanel

SetDeleteHookWithRes 设置带结果的删除钩子 参数:

  • fn: 带结果的删除函数

返回: 更新后的信息面板

func (*InfoPanel) SetDescription

func (i *InfoPanel) SetDescription(desc string) *InfoPanel

func (*InfoPanel) SetError

func (i *InfoPanel) SetError(err errors.PageError, content ...template.HTML) *InfoPanel

func (*InfoPanel) SetExportProcessFn

func (i *InfoPanel) SetExportProcessFn(fn ExportProcessFn) *InfoPanel

SetExportProcessFn 设置导出处理函数 参数:

  • fn: 导出处理函数

返回: 更新后的信息面板

func (*InfoPanel) SetFilterFormHeadWidth

func (i *InfoPanel) SetFilterFormHeadWidth(w int) *InfoPanel

func (*InfoPanel) SetFilterFormInputWidth

func (i *InfoPanel) SetFilterFormInputWidth(w int) *InfoPanel

func (*InfoPanel) SetFilterFormLayout

func (i *InfoPanel) SetFilterFormLayout(layout form.Layout) *InfoPanel

func (*InfoPanel) SetFooterHtml

func (i *InfoPanel) SetFooterHtml(footer template.HTML) *InfoPanel

func (*InfoPanel) SetGetDataFn

func (i *InfoPanel) SetGetDataFn(fn GetDataFn) *InfoPanel

SetGetDataFn 设置获取数据函数 参数:

  • fn: 获取数据函数

返回: 更新后的信息面板

func (*InfoPanel) SetHeaderHtml

func (i *InfoPanel) SetHeaderHtml(header template.HTML) *InfoPanel

func (*InfoPanel) SetHideSideBar

func (i *InfoPanel) SetHideSideBar() *InfoPanel

func (*InfoPanel) SetNoCompress

func (i *InfoPanel) SetNoCompress() *InfoPanel

func (*InfoPanel) SetPageSizeList

func (i *InfoPanel) SetPageSizeList(pageSizeList []int) *InfoPanel

func (*InfoPanel) SetPreDeleteFn

func (i *InfoPanel) SetPreDeleteFn(fn DeleteFn) *InfoPanel

SetPreDeleteFn 设置删除前函数 参数:

  • fn: 删除函数

返回: 更新后的信息面板

func (*InfoPanel) SetPrimaryKey

func (i *InfoPanel) SetPrimaryKey(name string, typ db.DatabaseType) *InfoPanel

SetPrimaryKey 设置主键 参数:

  • name: 主键名
  • typ: 数据库类型

返回: 更新后的信息面板

func (*InfoPanel) SetQueryFilterFn

func (i *InfoPanel) SetQueryFilterFn(fn QueryFilterFn) *InfoPanel

SetQueryFilterFn 设置查询过滤函数 参数:

  • fn: 查询过滤函数

返回: 更新后的信息面板

func (*InfoPanel) SetSortAsc

func (i *InfoPanel) SetSortAsc() *InfoPanel

func (*InfoPanel) SetSortDesc

func (i *InfoPanel) SetSortDesc() *InfoPanel

func (*InfoPanel) SetSortField

func (i *InfoPanel) SetSortField(field string) *InfoPanel

func (*InfoPanel) SetTabGroups

func (i *InfoPanel) SetTabGroups(groups TabGroups) *InfoPanel

func (*InfoPanel) SetTabHeaders

func (i *InfoPanel) SetTabHeaders(headers ...string) *InfoPanel

func (*InfoPanel) SetTable

func (i *InfoPanel) SetTable(table string) *InfoPanel

func (*InfoPanel) SetTableFixed

func (i *InfoPanel) SetTableFixed() *InfoPanel

SetTableFixed 设置表格布局为固定 返回: 更新后的信息面板

func (*InfoPanel) SetTitle

func (i *InfoPanel) SetTitle(title string) *InfoPanel

func (*InfoPanel) SetWrapper

func (i *InfoPanel) SetWrapper(wrapper ContentWrapper) *InfoPanel

SetWrapper 设置内容包装器 参数:

  • wrapper: 内容包装函数

返回: 更新后的信息面板

func (*InfoPanel) Where

func (i *InfoPanel) Where(field string, operator string, arg interface{}) *InfoPanel

Where 添加WHERE条件 参数:

  • field: 字段名
  • operator: 操作符
  • arg: 参数

返回: 更新后的信息面板

func (*InfoPanel) WhereOr

func (i *InfoPanel) WhereOr(field string, operator string, arg interface{}) *InfoPanel

WhereOr 添加OR条件的WHERE条件 参数:

  • field: 字段名
  • operator: 操作符
  • arg: 参数

返回: 更新后的信息面板

func (*InfoPanel) WhereRaw

func (i *InfoPanel) WhereRaw(raw string, arg ...interface{}) *InfoPanel

WhereRaw 添加原始WHERE条件 参数:

  • raw: 原始SQL语句
  • arg: 参数

返回: 更新后的信息面板

type Join

type Join struct {
	Table      string // 关联表名
	TableAlias string // 表别名
	Field      string // 当前表字段
	JoinField  string // 关联表字段
	BaseTable  string // 基础表名
}

Join 存储关联表信息。例如:

Join {
    BaseTable:   "users",
    Field:       "role_id",
    Table:       "roles",
    JoinField:   "id",
}

它将生成如下关联表SQL:

... left join roles on roles.id = users.role_id ...

func (Join) GetTableName

func (j Join) GetTableName(delimiter ...string) string

func (Join) Valid

func (j Join) Valid() bool

type Joins

type Joins []Join

func (Joins) Last

func (j Joins) Last() Join

func (Joins) Valid

func (j Joins) Valid() bool

type LabelAttribute

type LabelAttribute interface {
	SetContent(value template.HTML) LabelAttribute // 设置内容
	SetColor(value template.HTML) LabelAttribute   // 设置颜色
	SetType(value string) LabelAttribute           // 设置类型
	GetContent() template.HTML                     // 获取内容
}

LabelAttribute 标签属性接口

type LinkAttribute

type LinkAttribute interface {
	OpenInNewTab() LinkAttribute                        // 在新标签页打开
	SetURL(value string) LinkAttribute                  // 设置URL
	SetAttributes(attr template.HTMLAttr) LinkAttribute // 设置属性
	SetClass(class template.HTML) LinkAttribute         // 设置类名
	NoPjax() LinkAttribute                              // 不使用pjax
	SetTabTitle(value template.HTML) LinkAttribute      // 设置标签页标题
	SetContent(value template.HTML) LinkAttribute       // 设置内容
	GetContent() template.HTML                          // 获取内容
}

LinkAttribute 链接属性接口

type LinkField

type LinkField struct {
	Field   string
	Value   template.HTML
	Hide    bool
	Disable bool
}
type NavButton struct {
	*BaseButton
	Icon string // 图标
}

NavButton 是导航按钮结构体

func GetNavButton

func GetNavButton(title template.HTML, icon string, action Action, names ...string) *NavButton

GetNavButton 创建导航按钮

func (n *NavButton) Content(ctx *context.Context) (template.HTML, template.JS)

Content 生成导航按钮的HTML内容和JavaScript代码

type NavDropDownButton struct {
	*BaseButton
	Icon  string                   // 图标
	Items []*NavDropDownItemButton // 下拉菜单项
}

NavDropDownButton 是导航下拉按钮结构体

func GetDropDownButton

func GetDropDownButton(title template.HTML, icon string, items []*NavDropDownItemButton, names ...string) *NavDropDownButton

GetDropDownButton 创建下拉按钮

func (n *NavDropDownButton) AddItem(item *NavDropDownItemButton)

AddItem 添加下拉菜单项

Content 生成下拉按钮的HTML内容和JavaScript代码

func (n *NavDropDownButton) SetItems(items []*NavDropDownItemButton)

SetItems 设置下拉菜单项

type NavDropDownItemButton struct {
	*BaseButton
}

NavDropDownItemButton 是导航下拉菜单项按钮结构体

func GetDropDownItemButton

func GetDropDownItemButton(title template.HTML, action Action, names ...string) *NavDropDownItemButton

GetDropDownItemButton 创建下拉菜单项按钮

Content 生成下拉菜单项按钮的HTML内容和JavaScript代码

type NewPageParam

type NewPageParam struct {
	User           models.UserModel // 用户模型
	Menu           *menu.Menu       // 菜单
	UpdateMenu     bool             // 是否更新菜单
	Panel          Panel            // 面板
	Assets         template.HTML    // 资源
	Buttons        Buttons          // 按钮
	Iframe         bool             // 是否以iframe加载
	TmplHeadHTML   template.HTML    // 模板头部HTML
	TmplFootJS     template.HTML    // 模板底部JS
	NavButtonsHTML template.HTML    // 导航按钮HTML
	NavButtonsJS   template.HTML    // 导航按钮JS
}

NewPageParam 是创建新页面的参数结构体

func (*NewPageParam) NavButtonsAndJS

func (param *NewPageParam) NavButtonsAndJS(ctx *context.Context) (template.HTML, template.HTML)

NavButtonsAndJS 获取导航按钮和JS 参数:

  • ctx: 上下文对象

返回: 导航按钮HTML和底部HTML

type NilAction

type NilAction struct{}

NilAction 是空操作结构体

func (*NilAction) BtnAttribute

func (def *NilAction) BtnAttribute() template.HTML

func (*NilAction) BtnClass

func (def *NilAction) BtnClass() template.HTML

func (*NilAction) ExtContent

func (def *NilAction) ExtContent(ctx *context.Context) template.HTML

func (*NilAction) FooterContent

func (def *NilAction) FooterContent(ctx *context.Context) template.HTML

func (*NilAction) GetCallbacks

func (def *NilAction) GetCallbacks() context.Node

func (*NilAction) Js

func (def *NilAction) Js() template.JS

func (*NilAction) SetBtnData

func (def *NilAction) SetBtnData(data interface{})

func (*NilAction) SetBtnId

func (def *NilAction) SetBtnId(btnId string)

type OptionArrInitFn

type OptionArrInitFn func(val FieldModel) []FieldOptions

OptionArrInitFn 是选项数组初始化函数类型,根据字段模型生成多个选项列表

type OptionInitFn

type OptionInitFn func(val FieldModel) FieldOptions

OptionInitFn 是选项初始化函数类型,根据字段模型生成选项列表

type OptionProcessFn

type OptionProcessFn func(options FieldOptions) FieldOptions

OptionProcessFn 是选项处理函数类型,用于对选项进行自定义处理

type OptionTable

type OptionTable struct {
	Table          string                    // 数据库表名
	TextField      string                    // 用于显示文本的字段名
	ValueField     string                    // 用于值的字段名
	QueryProcessFn OptionTableQueryProcessFn // 查询处理函数
	ProcessFn      OptionProcessFn           // 选项处理函数
}

OptionTable 定义了从数据库表中获取选项的配置

type OptionTableQueryProcessFn

type OptionTableQueryProcessFn func(sql *db.SQL) *db.SQL

OptionTableQueryProcessFn 是表查询处理函数类型,用于处理 SQL 查询

type Page

type Page struct {
	// User 是登录用户
	User models.UserModel

	// Menu 是模板的左侧菜单
	Menu menu.Menu

	// Panel 是模板的主要内容
	Panel Panel

	// System 包含一些系统信息
	System SystemInfo

	// UrlPrefix 是URL的前缀
	UrlPrefix string

	// Title 是网页的标题
	Title string

	Logo template.HTML

	MiniLogo template.HTML

	// ColorScheme 是模板的颜色方案
	ColorScheme string

	// IndexUrl 是站点的主页URL
	IndexUrl string

	// AssetUrl 是资源的CDN链接
	CdnUrl string

	// Custom html in the tag head -> 自定义head标签内的HTML
	CustomHeadHtml template.HTML

	// Custom html after body -> 自定义body后的HTML
	CustomFootHtml template.HTML

	TmplHeadHTML template.HTML // 模板头部HTML
	TmplFootJS   template.HTML // 模板底部JS

	// Components assets -> 组件资源
	AssetsList template.HTML

	// Footer info -> 页脚信息
	FooterInfo template.HTML

	// Load as Iframe or not -> 是否以iframe加载
	Iframe bool

	// Whether update menu or not -> 是否更新菜单
	UpdateMenu bool

	NavButtonsHTML template.HTML
	// contains filtered or unexported fields
}

Page 在模板中用作顶级变量

func NewPage

func NewPage(ctx *context.Context, param *NewPageParam) *Page

NewPage 创建新页面 参数:

  • ctx: 上下文对象
  • param: 页面参数

返回: 页面对象

func NewPagePanel

func NewPagePanel(panel Panel) *Page

NewPagePanel 创建新页面面板 参数:

  • panel: 面板对象

返回: 页面对象

func (*Page) AddButton

func (page *Page) AddButton(ctx *context.Context, title template.HTML, icon string, action Action) *Page

AddButton 添加按钮 参数:

  • ctx: 上下文对象
  • title: 按钮标题
  • icon: 图标
  • action: 操作对象

返回: 更新后的页面对象

type PaginatorAttribute

type PaginatorAttribute interface {
	SetCurPageStartIndex(value string) PaginatorAttribute        // 设置当前页起始索引
	SetCurPageEndIndex(value string) PaginatorAttribute          // 设置当前页结束索引
	SetTotal(value string) PaginatorAttribute                    // 设置总数
	SetPreviousClass(value string) PaginatorAttribute            // 设置上一页类名
	SetPreviousUrl(value string) PaginatorAttribute              // 设置上一页URL
	SetPages(value []map[string]string) PaginatorAttribute       // 设置页码列表
	SetPageSizeList(value []string) PaginatorAttribute           // 设置每页条数列表
	SetNextClass(value string) PaginatorAttribute                // 设置下一页类名
	SetNextUrl(value string) PaginatorAttribute                  // 设置下一页URL
	SetOption(value map[string]template.HTML) PaginatorAttribute // 设置选项
	SetUrl(value string) PaginatorAttribute                      // 设置URL
	SetExtraInfo(value template.HTML) PaginatorAttribute         // 设置额外信息
	SetEntriesInfo(value template.HTML) PaginatorAttribute       // 设置条目信息
	GetContent() template.HTML                                   // 获取内容
}

PaginatorAttribute 分页器属性接口

type Panel

type Panel struct {
	Title       template.HTML // 标题
	Description template.HTML // 描述
	Content     template.HTML // 内容

	CSS template.CSS // 样式
	JS  template.JS  // JavaScript
	Url string       // URL

	// Whether to toggle the sidebar -> 是否切换侧边栏
	MiniSidebar bool

	// Auto refresh page switch -> 自动刷新页面开关
	AutoRefresh bool
	// Refresh page intervals, the unit is second -> 刷新页面间隔,单位为秒
	RefreshInterval []int

	Callbacks Callbacks // 回调列表
}

Panel 包含模板的主要内容,用作pjax

func (Panel) AddComponent

func (p Panel) AddComponent(comp Component) Panel

AddComponent 添加组件 参数:

  • comp: 组件对象

返回: 更新后的面板

func (Panel) AddJS

func (p Panel) AddJS(js template.JS) Panel

AddJS 添加JavaScript 参数:

  • js: JavaScript代码

返回: 更新后的面板

func (Panel) GetContent

func (p Panel) GetContent(params ...bool) Panel

GetContent 获取面板内容 参数:

  • params: 可选参数,第一个参数表示是否压缩,第二个参数表示是否启用动画

返回: 更新后的面板

type PanelInfo

type PanelInfo struct {
	Thead    Thead    `json:"thead"`     // 表头
	InfoList InfoList `json:"info_list"` // 信息列表
}

PanelInfo 面板信息结构体

type PopupAttribute

type PopupAttribute interface {
	SetID(value string) PopupAttribute                // 设置ID
	SetTitle(value template.HTML) PopupAttribute      // 设置标题
	SetDraggable() PopupAttribute                     // 设置可拖动
	SetHideFooter() PopupAttribute                    // 设置隐藏页脚
	SetWidth(width string) PopupAttribute             // 设置宽度
	SetHeight(height string) PopupAttribute           // 设置高度
	SetFooter(value template.HTML) PopupAttribute     // 设置页脚
	SetFooterHTML(value template.HTML) PopupAttribute // 设置页脚HTML
	SetBody(value template.HTML) PopupAttribute       // 设置主体
	SetSize(value string) PopupAttribute              // 设置尺寸
	GetContent() template.HTML                        // 获取内容
}

PopupAttribute 弹窗属性接口

type PostFieldFilterFn

type PostFieldFilterFn func(value PostFieldModel) interface{}

PostFieldFilterFn 是数据过滤函数类型

type PostFieldModel

type PostFieldModel struct {
	ID    string            // 记录ID
	Value FieldModelValue   // 字段模型值
	Row   map[string]string // 当前行数据
	// 提交类型
	PostType PostType
}

PostFieldModel 包含单个查询结果的ID和值以及当前行数据

func (PostFieldModel) IsCreate

func (m PostFieldModel) IsCreate() bool

IsCreate 判断是否为创建操作 返回: 如果是创建操作返回true,否则返回false

func (PostFieldModel) IsUpdate

func (m PostFieldModel) IsUpdate() bool

IsUpdate 判断是否为更新操作 返回: 如果是更新操作返回true,否则返回false

type PostType

type PostType uint8

type QueryFilterFn

type QueryFilterFn func(param parameter.Parameters, conn db.Connection) (ids []string, stopQuery bool)

QueryFilterFn 是查询过滤函数类型

type Responder

type Responder func(ctx *context.Context)

Responder 是响应处理函数类型

type RowAttribute

type RowAttribute interface {
	SetContent(value template.HTML) RowAttribute // 设置内容
	AddContent(value template.HTML) RowAttribute // 添加内容
	GetContent() template.HTML                   // 获取内容
}

RowAttribute 行属性接口

type S

type S map[string]string

S 是屏幕尺寸映射类型

func Size

func Size(sm, md, lg int) S

Size 创建屏幕尺寸映射 参数:

  • sm: 小屏幕尺寸
  • md: 中等屏幕尺寸
  • lg: 大屏幕尺寸

返回: 屏幕尺寸映射

func SizeLG

func SizeLG(lg int) S

SizeLG 创建大屏幕尺寸映射 参数:

  • lg: 大屏幕尺寸

返回: 屏幕尺寸映射

func SizeMD

func SizeMD(md int) S

SizeMD 创建中等屏幕尺寸映射 参数:

  • md: 中等屏幕尺寸

返回: 屏幕尺寸映射

func SizeSM

func SizeSM(sm int) S

SizeSM 创建小屏幕尺寸映射 参数:

  • sm: 小屏幕尺寸

返回: 屏幕尺寸映射

func SizeXL

func SizeXL(xl int) S

SizeXL 创建超大屏幕尺寸映射 参数:

  • xl: 超大屏幕尺寸

返回: 屏幕尺寸映射

func SizeXS

func SizeXS(xs int) S

SizeXS 创建超小屏幕尺寸映射 参数:

  • xs: 超小屏幕尺寸

返回: 屏幕尺寸映射

func (S) LG

func (s S) LG(lg int) S

LG 设置大屏幕尺寸 参数:

  • lg: 大屏幕尺寸

返回: 更新后的屏幕尺寸映射

func (S) MD

func (s S) MD(md int) S

MD 设置中等屏幕尺寸 参数:

  • md: 中等屏幕尺寸

返回: 更新后的屏幕尺寸映射

func (S) SM

func (s S) SM(sm int) S

SM 设置小屏幕尺寸 参数:

  • sm: 小屏幕尺寸

返回: 更新后的屏幕尺寸映射

func (S) XL

func (s S) XL(xl int) S

XL 设置超大屏幕尺寸 参数:

  • xl: 超大屏幕尺寸

返回: 更新后的屏幕尺寸映射

func (S) XS

func (s S) XS(xs int) S

XS 设置超小屏幕尺寸 参数:

  • xs: 超小屏幕尺寸

返回: 更新后的屏幕尺寸映射

type Sort

type Sort uint8
const (
	SortDesc Sort = iota
	SortAsc
)

type SystemInfo

type SystemInfo struct {
	Version string // 版本号
	Theme   string // 主题
}

SystemInfo 包含系统的基本信息

type TabGroups

type TabGroups [][]string

func NewTabGroups

func NewTabGroups(items ...string) TabGroups

func (TabGroups) AddGroup

func (t TabGroups) AddGroup(items ...string) TabGroups

func (TabGroups) Valid

func (t TabGroups) Valid() bool

type TabHeaders

type TabHeaders []string

func (TabHeaders) Add

func (t TabHeaders) Add(header string) TabHeaders

type TableAttribute

type TableAttribute interface {
	SetThead(value Thead) TableAttribute                    // 设置表头
	SetInfoList(value []map[string]InfoItem) TableAttribute // 设置信息列表
	SetType(value string) TableAttribute                    // 设置类型
	SetName(name string) TableAttribute                     // 设置名称
	SetMinWidth(value string) TableAttribute                // 设置最小宽度
	SetHideThead() TableAttribute                           // 设置隐藏表头
	SetSticky(sticky bool) TableAttribute                   // 设置粘性定位
	SetLayout(value string) TableAttribute                  // 设置布局
	SetStyle(style string) TableAttribute                   // 设置样式
	GetContent() template.HTML                              // 获取内容
}

TableAttribute 表格属性接口

type TableInfo

type TableInfo struct {
	Table      string // 表名
	PrimaryKey string // 主键
	Delimiter  string // 左分隔符
	Delimiter2 string // 右分隔符
	Driver     string // 数据库驱动
}

TableInfo 是表信息结构体

type TableRowData

type TableRowData struct {
	Id    template.HTML       // 行ID
	Ids   template.HTML       // 行ID列表
	Value map[string]InfoItem // 值映射
}

TableRowData 是表格行数据结构体

type TabsAttribute

type TabsAttribute interface {
	SetData(value []map[string]template.HTML) TabsAttribute // 设置数据
	GetContent() template.HTML                              // 获取内容
}

TabsAttribute 标签页属性接口

type Thead

type Thead []TheadItem

Thead 表头类型

func (Thead) GroupBy

func (t Thead) GroupBy(group [][]string) []Thead

GroupBy 按分组对表头进行分组

type TheadItem

type TheadItem struct {
	Head       string       `json:"head"`        // 表头文本
	Sortable   bool         `json:"sortable"`    // 是否可排序
	Field      string       `json:"field"`       // 字段名
	Hide       bool         `json:"hide"`        // 是否隐藏
	Editable   bool         `json:"editable"`    // 是否可编辑
	EditType   string       `json:"edit_type"`   // 编辑类型
	EditOption FieldOptions `json:"edit_option"` // 编辑选项
	Width      string       `json:"width"`       // 宽度
}

TheadItem 表头项结构体

type TreeAttribute

type TreeAttribute interface {
	SetTree(value []menu.Item) TreeAttribute // 设置树数据
	SetEditUrl(value string) TreeAttribute   // 设置编辑URL
	SetOrderUrl(value string) TreeAttribute  // 设置排序URL
	SetUrlPrefix(value string) TreeAttribute // 设置URL前缀
	SetDeleteUrl(value string) TreeAttribute // 设置删除URL
	GetContent() template.HTML               // 获取内容
	GetTreeHeader() template.HTML            // 获取树头部
}

TreeAttribute 树属性接口

type TreeViewAttribute

type TreeViewAttribute interface {
	SetTree(value TreeViewData) TreeViewAttribute // 设置树数据
	SetUrlPrefix(value string) TreeViewAttribute  // 设置URL前缀
	SetID(id string) TreeViewAttribute            // 设置ID
	GetContent() template.HTML                    // 获取内容
}

TreeViewAttribute 树视图属性接口

type TreeViewData

type TreeViewData struct {
	Data                   TreeViewItems `json:"data,omitempty"`                   // 树视图项列表
	Levels                 int           `json:"levels,omitempty"`                 // 层级数
	BackColor              string        `json:"backColor,omitempty"`              // 背景色
	BorderColor            string        `json:"borderColor,omitempty"`            // 边框颜色
	CheckedIcon            string        `json:"checkedIcon,omitempty"`            // 选中图标
	CollapseIcon           string        `json:"collapseIcon,omitempty"`           // 折叠图标
	Color                  string        `json:"color,omitempty"`                  // 颜色
	EmptyIcon              string        `json:"emptyIcon,omitempty"`              // 空图标
	EnableLinks            bool          `json:"enableLinks,omitempty"`            // 启用链接
	ExpandIcon             string        `json:"expandIcon,omitempty"`             // 展开图标
	MultiSelect            bool          `json:"multiSelect,omitempty"`            // 多选
	NodeIcon               string        `json:"nodeIcon,omitempty"`               // 节点图标
	OnhoverColor           string        `json:"onhoverColor,omitempty"`           // 悬停颜色
	SelectedIcon           string        `json:"selectedIcon,omitempty"`           // 选中图标
	SearchResultColor      string        `json:"searchResultColor,omitempty"`      // 搜索结果颜色
	SelectedBackColor      string        `json:"selectedBackColor,omitempty"`      // 选中背景色
	SelectedColor          string        `json:"selectedColor,omitempty"`          // 选中颜色
	ShowBorder             bool          `json:"showBorder,omitempty"`             // 显示边框
	ShowCheckbox           bool          `json:"showCheckbox,omitempty"`           // 显示复选框
	ShowIcon               bool          `json:"showIcon,omitempty"`               // 显示图标
	ShowTags               bool          `json:"showTags,omitempty"`               // 显示标签
	UncheckedIcon          string        `json:"uncheckedIcon,omitempty"`          // 未选中图标
	SearchResultBackColor  string        `json:"searchResultBackColor,omitempty"`  // 搜索结果背景色
	HighlightSearchResults bool          `json:"highlightSearchResults,omitempty"` // 高亮搜索结果
}

TreeViewData 树视图数据结构体

type TreeViewItem

type TreeViewItem struct {
	Text         string            `json:"text,omitempty"`          // 文本
	Icon         string            `json:"icon,omitempty"`          // 图标
	SelectedIcon string            `json:"selected_icon,omitempty"` // 选中图标
	Color        string            `json:"color,omitempty"`         // 颜色
	BackColor    string            `json:"backColor,omitempty"`     // 背景色
	Href         string            `json:"href,omitempty"`          // 链接地址
	Selectable   bool              `json:"selectable,omitempty"`    // 是否可选择
	State        TreeViewItemState `json:"state,omitempty"`         // 状态
	Tags         []string          `json:"tags,omitempty"`          // 标签列表
	Nodes        TreeViewItems     `json:"nodes,omitempty"`         // 子节点列表
}

TreeViewItem 树视图项结构体

type TreeViewItemState

type TreeViewItemState struct {
	Checked  bool `json:"checked,omitempty"`  // 是否选中
	Disabled bool `json:"disabled,omitempty"` // 是否禁用
	Expanded bool `json:"expanded,omitempty"` // 是否展开
	Selected bool `json:"selected,omitempty"` // 是否被选择
}

TreeViewItemState 树视图项状态结构体

type TreeViewItems

type TreeViewItems []TreeViewItem

TreeViewItems 树视图项列表类型

type UpdateParametersFn

type UpdateParametersFn func(param *parameter.Parameters)

UpdateParametersFn 是更新参数函数类型

type Where

type Where struct {
	Join     string
	Field    string
	Operator string
	Arg      interface{}
}

type WhereRaw

type WhereRaw struct {
	Raw  string        // 原始SQL
	Args []interface{} // 参数数组
}

WhereRaw 是原始WHERE条件结构体

func (WhereRaw) Statement

func (wh WhereRaw) Statement(wheres string, whereArgs []interface{}) (string, []interface{})

Statement 生成WHERE语句 参数:

  • wheres: WHERE条件字符串
  • whereArgs: WHERE参数数组

返回: WHERE语句和参数数组

type Wheres

type Wheres []Where

func (Wheres) Statement

func (whs Wheres) Statement(wheres, delimiter, delimiter2 string, whereArgs []interface{}, existKeys, columns []string) (string, []interface{})

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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