resource

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	Name, Label string
	Handler     ActionHandler
}

type ActionHandler

type ActionHandler func(res *Resource, w http.ResponseWriter, r *http.Request)

type Association

type Association struct{ Type, Name, ResourceName, ForeignKey, Label string }

type BatchAction

type BatchAction struct {
	Name, Label string
	Handler     BatchActionHandler
}

type BatchActionHandler

type BatchActionHandler func(res *Resource, ids []string, w http.ResponseWriter, r *http.Request)

type DecoratorFunc

type DecoratorFunc func(val interface{}) template.HTML

type Field

type Field struct {
	Name, Label, Type string
	Options           []string
	Readonly          bool
	Searchable        bool
	SearchResource    string
	Decorator         DecoratorFunc
	Sortable          bool
}

type Resource

type Resource struct {
	Model             interface{}
	Name, Path, Group string
	Fields            []Field
	IndexFields       []string
	ShowFields        []string
	EditFields        []string
	MemberActions     []Action
	CollectionActions []Action
	BatchActions      []BatchAction
	Scopes            []Scope
	Associations      []Association
	Sidebars          []Sidebar
	Attributes        map[string]interface{}
}

func NewResource

func NewResource(model interface{}) *Resource

func (*Resource) AddBatchAction

func (r *Resource) AddBatchAction(n, l string, h BatchActionHandler) *Resource

func (*Resource) AddCollectionAction

func (r *Resource) AddCollectionAction(n, l string, h ActionHandler) *Resource

func (*Resource) AddMemberAction

func (r *Resource) AddMemberAction(n, l string, h ActionHandler) *Resource

func (*Resource) AddScope

func (r *Resource) AddScope(n, l string, h ScopeFunc) *Resource

func (*Resource) AddSidebar

func (r *Resource) AddSidebar(label string, handler SidebarHandler) *Resource

func (*Resource) BelongsTo

func (r *Resource) BelongsTo(n, l, tr, fk string) *Resource

func (*Resource) GetFieldsFor

func (r *Resource) GetFieldsFor(view string) []Field

func (*Resource) HasMany

func (r *Resource) HasMany(n, l, tr, fk string) *Resource

func (*Resource) RegisterField

func (r *Resource) RegisterField(name, label string, readonly bool) *Resource

func (*Resource) SetDecorator

func (r *Resource) SetDecorator(name string, fn DecoratorFunc) *Resource

func (*Resource) SetEditFields

func (r *Resource) SetEditFields(n ...string) *Resource

func (*Resource) SetFieldType

func (r *Resource) SetFieldType(n, t string, opt ...string) *Resource

func (*Resource) SetGroup

func (r *Resource) SetGroup(group string) *Resource

func (*Resource) SetIndexFields

func (r *Resource) SetIndexFields(n ...string) *Resource

func (*Resource) SetSearchable

func (r *Resource) SetSearchable(f, tr string) *Resource

func (*Resource) SetShowFields

func (r *Resource) SetShowFields(n ...string) *Resource

func (*Resource) SetSortable

func (r *Resource) SetSortable(name string, sortable bool) *Resource

type Scope

type Scope struct {
	Name, Label string
	Handler     ScopeFunc
}

type ScopeFunc

type ScopeFunc func(db *gorm.DB) *gorm.DB
type Sidebar struct {
	Label   string
	Handler SidebarHandler
}

type SidebarHandler

type SidebarHandler func(res *Resource, item interface{}) template.HTML

Jump to

Keyboard shortcuts

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