fieldtypes

package
v0.1.1-beta.2 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2023 License: MIT Imports: 21 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertParameters

func ConvertParameters(params fieldtype.FieldParameters, paramStruct interface{}) error

convert parameters(definition.FieldParameters - map[string]interface{}) to struct using mapstructure

func GenerateThumbnail

func GenerateThumbnail(imagePath string) error

func RegisterJSONOutputer

func RegisterJSONOutputer(identifier string, outputer querier.Outputer)

func ThumbnailFolder

func ThumbnailFolder() string

thumbnail folder with absolute path

Types

type CheckboxHandler

type CheckboxHandler struct {
	fieldtype.FieldDef
}

* Checkbox handler **

func (CheckboxHandler) DBField

func (handler CheckboxHandler) DBField() string

func (CheckboxHandler) LoadInput

func (handler CheckboxHandler) LoadInput(ctx context.Context, input interface{}, mode string) (interface{}, error)

Only allow 1/0 or "1"/"0"

type DatetimeHandler

type DatetimeHandler struct {
	fieldtype.FieldDef
}

func (DatetimeHandler) DBField

func (handler DatetimeHandler) DBField() string

func (DatetimeHandler) LoadInput

func (handler DatetimeHandler) LoadInput(ctx context.Context, input interface{}, mode string) (interface{}, error)

support 3 format: 2020-01-10, 2020-01-10 12:12:00(server side timezone), 2021-01-10T11:45:26+02:00, 1722145855(unix)

type DatetimeParameters

type DatetimeParameters struct {
	Dateonly bool `mapstructure:"dateonly"`
}

type FileHandler

type FileHandler struct {
	fieldtype.FieldDef
	Params FileParameters
}

func (FileHandler) AfterDelete

func (handler FileHandler) AfterDelete(ctx context.Context, value interface{}) error

After delete content, delete file, skip error if there is any wrong(eg. image not existing).

func (FileHandler) BeforeStore

func (handler FileHandler) BeforeStore(ctx context.Context, value interface{}, existing interface{}, mode string) (interface{}, error)

Image can be loaded from rest, or local api

func (FileHandler) DBField

func (handler FileHandler) DBField() string

func (FileHandler) LoadInput

func (handler FileHandler) LoadInput(ctx context.Context, input interface{}, mode string) (interface{}, error)

type FileParameters

type FileParameters struct {
	Format  string  `mapstructure:"format"`   //eg. "jpg, png" low case
	MaxSize float64 `mapstructure:"max_size"` //in MB, default 10MB.
}

type ImageHandler

type ImageHandler struct {
	fieldtype.FieldDef
}

func (ImageHandler) AfterDelete

func (handler ImageHandler) AfterDelete(ctx context.Context, value interface{}) error

After delete content, delete image&thumbnail, skip error if there is any wrong(eg. image not existing).

func (ImageHandler) BeforeStore

func (handler ImageHandler) BeforeStore(ctx context.Context, value interface{}, existing interface{}, mode string) (interface{}, error)

Image can be loaded from rest, or local api

func (ImageHandler) DBField

func (handler ImageHandler) DBField() string

func (ImageHandler) LoadInput

func (handler ImageHandler) LoadInput(ctx context.Context, input interface{}, mode string) (interface{}, error)

type ImageParameter

type ImageParameter struct {
	Format string `mapstructure:"format"` //eg. "jpg, png" low case
}

type IntHandler

type IntHandler struct {
	fieldtype.FieldDef
}

* Int handler *

func (IntHandler) DBField

func (handler IntHandler) DBField() string

func (IntHandler) LoadInput

func (handler IntHandler) LoadInput(ctx context.Context, input interface{}, mode string) (interface{}, error)

type JSONHandler

type JSONHandler struct {
	fieldtype.FieldDef
	Params JSONParameters
}

JSON Handler

func (JSONHandler) DBField

func (handler JSONHandler) DBField() string

func (JSONHandler) LoadInput

func (handler JSONHandler) LoadInput(ctx context.Context, input interface{}, mode string) (interface{}, error)

support string, []byte, object

func (JSONHandler) Output

func (handler JSONHandler) Output(ctx context.Context, querier querier.Querier, value interface{}) interface{}

type JSONParameters

type JSONParameters struct {
	Format   string `mapstructure:"format"`
	Settings string `mapstructure:"settings"`
}

type Json

type Json struct {
	Content []byte
}

func (Json) MarshalJSON

func (j Json) MarshalJSON() ([]byte, error)

func (*Json) Scan

func (j *Json) Scan(value interface{}) error

func (*Json) String

func (j *Json) String() string

func (Json) Value

func (j Json) Value() (driver.Value, error)

insert as string

type Map

type Map map[string]interface{}

Map defines a key - value map

func (*Map) Scan

func (a *Map) Scan(value interface{}) error

func (Map) Value

func (a Map) Value() (driver.Value, error)

type MapHandler

type MapHandler struct {
	fieldtype.FieldDef
}

MapHandler

func (MapHandler) DBField

func (handler MapHandler) DBField() string

func (MapHandler) LoadInput

func (handler MapHandler) LoadInput(ctx context.Context, input interface{}, mode string) (interface{}, error)

type MapList

type MapList []Map

List defines an array Map

func (*MapList) Scan

func (a *MapList) Scan(value interface{}) error

func (MapList) Value

func (a MapList) Value() (driver.Value, error)

type MapListHandler

type MapListHandler struct {
	fieldtype.FieldDef
}

MapListHandler

func (MapListHandler) DBField

func (handler MapListHandler) DBField() string

func (MapListHandler) LoadInput

func (handler MapListHandler) LoadInput(ctx context.Context, input interface{}, mode string) (interface{}, error)

type PasswordHandler

type PasswordHandler struct {
	fieldtype.FieldDef
}

* Password handler *

func (PasswordHandler) DBField

func (handler PasswordHandler) DBField() string

func (PasswordHandler) LoadInput

func (handler PasswordHandler) LoadInput(ctx context.Context, input interface{}, mode string) (interface{}, error)

type RadioHandler

type RadioHandler struct {
	fieldtype.FieldDef
}

* Radio handler **

func (RadioHandler) DBField

func (handler RadioHandler) DBField() string

func (RadioHandler) LoadInput

func (handler RadioHandler) LoadInput(ctx context.Context, input interface{}, mode string) (interface{}, error)

max 30 length

type RelationHandler

type RelationHandler struct {
	fieldtype.FieldDef
}

func (RelationHandler) DBField

func (handler RelationHandler) DBField() string

func (RelationHandler) LoadInput

func (handler RelationHandler) LoadInput(ctx context.Context, input interface{}, mode string) (interface{}, error)

max 30 length

type RelationListHandler

type RelationListHandler struct {
	fieldtype.FieldDef
}

func (RelationListHandler) DBField

func (handler RelationListHandler) DBField() string

func (RelationListHandler) LoadInput

func (handler RelationListHandler) LoadInput(ctx context.Context, input interface{}, mode string) (interface{}, error)

LoadFromInput load data from input before validation

func (RelationListHandler) Store

func (handler RelationListHandler) Store(ctx context.Context, value interface{}, contentType string, cid int, transaction *sql.Tx) error

todo: pass the current content and value

type RichTextHandler

type RichTextHandler struct {
	fieldtype.FieldDef
}

**** RichTextHandler *****

func (RichTextHandler) DBField

func (handler RichTextHandler) DBField() string

func (RichTextHandler) LoadInput

func (handler RichTextHandler) LoadInput(ctx context.Context, input interface{}, mode string) (interface{}, error)

func (RichTextHandler) Output

func (r RichTextHandler) Output(ctx context.Context, querier querier.Querier, value interface{}) interface{}

type SelectHandler

type SelectHandler struct {
	fieldtype.FieldDef
	Params SelectParameters
}

func (SelectHandler) DBField

func (handler SelectHandler) DBField() string

func (SelectHandler) LoadInput

func (handler SelectHandler) LoadInput(ctx context.Context, input interface{}, mode string) (interface{}, error)

Only allow 1/0 or "1"/"0"

func (SelectHandler) Output

func (handler SelectHandler) Output(ctx context.Context, querier querier.Querier, value interface{}) interface{}

type SelectParameters

type SelectParameters struct {
	Multi bool                `mapstructure:"multi"`
	List  []map[string]string `mapstructure:"list"`
}

type TextHandler

type TextHandler struct {
	fieldtype.FieldDef
	Params TextParameters
}

func (TextHandler) DBField

func (handler TextHandler) DBField() string

func (TextHandler) LoadInput

func (handler TextHandler) LoadInput(ctx context.Context, input interface{}, mode string) (interface{}, error)

func (TextHandler) ValidateDefinition

func (handler TextHandler) ValidateDefinition() error

type TextParameters

type TextParameters struct {
	MinLength     int    `mapstructure:"min_length"`
	MaxLength     int    `mapstructure:"max_length"`
	RegExp        string `mapstructure:"regexp"`
	RegExpMessage string `mapstructure:"regexp_message"`
}

Jump to

Keyboard shortcuts

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