interfaces

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: May 10, 2023 License: BSD-1-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Deleter

type Deleter interface {
	Delete() error
}

type EXAMPLE_FullFieldImplementation

type EXAMPLE_FullFieldImplementation interface {
	// FormValues for the field will be passed into this. (Can not be used together with FileField)
	Field
	// FormFiles for the field will be passed into this. (Can not be used together with Field)
	FileField
	// This will be called before the field is rendered.
	//
	// This is to generate HTML input and label elements.
	FormField
	// This will be called right after FormValues or FormFiles is called,
	// and before saving the form.
	Validator
}

This is a full implementation of the interfaces.

These are all the possible interfaces that can be implemented on a field.

type Element

type Element interface {
	String() string
	HTML() template.HTML
}

type Field

type Field interface {
	FormValues([]string) error // Formvalues for the field will be passed into this.
}

type File

type File interface {
	Name() string
	Open() (io.ReadSeekCloser, error)
}

type FileField

type FileField interface {
	FormFiles([]File) error // Formvalues for the field will be passed into this.
}

type FormField

type FormField interface {
	LabelHTML(r *request.Request, form_name string, display_text string, tagmap tags.TagMap) Element
	InputHTML(r *request.Request, form_name string, tagmap tags.TagMap) Element
}

type Initializer

type Initializer interface {
	Initial(r *request.Request, model any, fieldname string)
}

This method is called on FormFields, and not models.

type Lister

type Lister[T any] interface {
	List(page, itemsPerPage int) (items []T, totalCount int64, err error)
}

type MultiOptionsGetter

type MultiOptionsGetter interface {
	GetXXXOptions___1() ([]Option, []Option)

	GetXXXOptions___2(r *request.Request) ([]Option, []Option)

	GetXXXOptions___3(r *request.Request, model any) ([]Option, []Option)

	GetXXXOptions___4(r *request.Request, model any, fieldName string) ([]Option, []Option)
}

Options getter for fields defined in fields/multi_select.go

type Option

type Option interface {
	Value() string
	Label() string
}

type OptionsGetter

type OptionsGetter interface {
	// XXX is the fieldname, ___1 should be omitted.
	GetXXXOptions___1(r *request.Request) []string

	// XXX is the fieldname, ___2 should be omitted.
	GetXXXOptions___2(r *request.Request, model any) []string

	// XXX is the fieldname, ___3 should be omitted.
	GetXXXOptions___3(r *request.Request, model any, fieldName string) []string
}

Options getter for fields defined in fields/slices.go

type Saver

type Saver interface {
	Save(isNew bool) error
}

Fields of the creator model must adhere to the Field or FileField interface!

It is also optional to implement the Validator interface, or the Initializer interface on the fields.

type Scripter

type Scripter interface {
	Script() (key string, value template.HTML)
}

A function to import JS into the form.

type StringGetter

type StringGetter[T any] interface {
	StringID() string
	GetFromStringID(id string) (item T, err error) // Returns the type of the model it was called on.
}

type Updater

type Updater interface {
	Update() error
}

type Validator

type Validator interface {
	Validate() error
}

type ValidatorTagged

type ValidatorTagged interface {
	ValidateWithTags(t tags.TagMap) error
}

Jump to

Keyboard shortcuts

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