Documentation ¶
Index ¶
- Constants
- Variables
- func RegisterViewPath(path string) error
- type Action
- type Admin
- func (admin *Admin) AddMenu(menu *Menu)
- func (admin *Admin) AddResource(value interface{}, config ...*Config) *Resource
- func (admin Admin) GetMenu(name string) *Menu
- func (admin Admin) GetMenus() []*Menu
- func (admin *Admin) GetResource(name string) *Resource
- func (admin *Admin) GetResources() []*Resource
- func (admin *Admin) GetRouter() *Router
- func (admin *Admin) MountTo(prefix string, mux *http.ServeMux)
- func (admin *Admin) NewContext(w http.ResponseWriter, r *http.Request) *Context
- func (admin *Admin) NewResource(value interface{}, config ...*Config) *Resource
- func (admin *Admin) RegisterFuncMap(name string, fc interface{})
- func (admin *Admin) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (admin *Admin) SetAuth(auth Auth)
- type AssetManager
- type Auth
- type Config
- type Context
- func (context *Context) Execute(name string, result interface{})
- func (context *Context) FindTemplate(tmpl *template.Template, layout string) (*template.Template, error)
- func (context *Context) Flash(message, typ string)
- func (context *Context) FlashNow(message, typ string)
- func (context *Context) FuncMap() template.FuncMap
- func (context *Context) GetFlashes() []Flash
- func (context *Context) GetResource(name string) *Resource
- func (context *Context) GetScopes() (menus []*scopeMenu)
- func (context *Context) LinkTo(text interface{}, link interface{}) template.HTML
- func (context *Context) NewResourceContext(name ...string) *Context
- func (context *Context) Pagination() *[]Page
- func (context *Context) Render(name string, results ...interface{}) template.HTML
- func (context *Context) RenderForm(value interface{}, metas []*Meta) template.HTML
- func (context *Context) T(key string, values ...interface{}) string
- func (context *Context) UrlFor(value interface{}, resources ...*Resource) string
- func (context *Context) ValueOf(value interface{}, meta *Meta) interface{}
- type Filter
- type Flash
- type HasPermissioner
- type I18n
- type Injector
- type Menu
- type Meta
- func (meta *Meta) GetFieldName() string
- func (meta *Meta) GetMetas() []resource.Metaor
- func (meta *Meta) GetName() string
- func (meta *Meta) GetResource() resource.Resourcer
- func (meta *Meta) GetSetter() ...
- func (meta *Meta) GetValuer() func(interface{}, *qor.Context) interface{}
- func (meta *Meta) HasPermission(mode roles.PermissionMode, context *qor.Context) bool
- type Middleware
- type Page
- type Pagination
- type Resource
- func (res *Resource) Action(action *Action)
- func (res *Resource) Decode(context *qor.Context, value interface{}) error
- func (res *Resource) EditAttrs(columns ...string) []string
- func (res *Resource) Filter(filter *Filter)
- func (res Resource) GetAdmin() *Admin
- func (res *Resource) GetMeta(name string) *Meta
- func (res *Resource) GetMetas(attrs []string) []resource.Metaor
- func (res *Resource) HasPermission(mode roles.PermissionMode, context *qor.Context) bool
- func (res *Resource) IndexAttrs(columns ...string) []string
- func (res *Resource) Meta(meta *Meta)
- func (res *Resource) NewAttrs(columns ...string) []string
- func (res *Resource) Scope(scope *Scope)
- func (res *Resource) SearchAttrs(columns ...string) []string
- func (res *Resource) ShowAttrs(columns ...string) []string
- func (res *Resource) SortableAttrs(columns ...string) []string
- func (res Resource) ToParam() string
- func (res Resource) UseTheme(theme string) []string
- type ResourceNamer
- type Router
- type Scope
- type Searcher
- func (s *Searcher) Filter(name, query string) *Searcher
- func (s *Searcher) FindMany() (interface{}, error)
- func (s *Searcher) FindOne() (interface{}, error)
- func (s *Searcher) Page(num int) *Searcher
- func (s *Searcher) PrePage(num int) *Searcher
- func (s *Searcher) Scope(names ...string) *Searcher
- func (s *Searcher) WithPagination() *Searcher
Constants ¶
View Source
const (
DEFAULT_PAGE_COUNT = 20
)
View Source
const HTTPUnprocessableEntity = 422
View Source
const (
VISIBLE_PAGE_COUNT = 8
)
Variables ¶
View Source
var DefaultHandler = func(name string, value string, scope *gorm.DB, context *qor.Context) *gorm.DB { lastIndex := strings.LastIndex(name, "_") operation := name[lastIndex+1 : len(name)] column := name[0:lastIndex] switch operation { case "cont": return scope.Where(fmt.Sprintf("%v ILIKE ?", scope.NewScope(nil).Quote(column)), "%"+value+"%") case "eq": return scope.Where(fmt.Sprintf("%v = ?", scope.NewScope(nil).Quote(column)), value) case "gt": return scope.Where(fmt.Sprintf("%v > ?", scope.NewScope(nil).Quote(column)), value) case "gteq": return scope.Where(fmt.Sprintf("%v >= ?", scope.NewScope(nil).Quote(column)), value) case "lt": return scope.Where(fmt.Sprintf("%v < ?", scope.NewScope(nil).Quote(column)), value) case "lteq": return scope.Where(fmt.Sprintf("%v <= ?", scope.NewScope(nil).Quote(column)), value) } return scope }
View Source
var Root, _ = os.Getwd()
Functions ¶
func RegisterViewPath ¶
Types ¶
type Admin ¶
func (*Admin) AddResource ¶
func (*Admin) GetResource ¶
func (*Admin) GetResources ¶
func (*Admin) NewContext ¶
func (*Admin) NewResource ¶
func (*Admin) RegisterFuncMap ¶
type AssetManager ¶
type AssetManager struct { ID int File media_library.FileSystem `media_library:"URL:/system/assets/{{primary_key}}/{{filename_with_hash}}"` }
func (*AssetManager) InjectQorAdmin ¶
func (*AssetManager) InjectQorAdmin(res *Resource)
type Context ¶
type Context struct { *qor.Context *Searcher Flashes []Flash Resource *Resource Admin *Admin Result interface{} Content template.HTML }
func (*Context) FindTemplate ¶
func (*Context) GetFlashes ¶
func (*Context) GetResource ¶
func (*Context) NewResourceContext ¶
func (*Context) Pagination ¶
Keep VISIBLE_PAGE_COUNT's pages visible, exclude prev and next link Assume there are 12 pages in total. When current page is 1 [current, 2, 3, 4, 5, 6, 7, 8, next] When current page is 6 [prev, 2, 3, 4, 5, current, 7, 8, 9, 10, next] When current page is 10 [prev, 5, 6, 7, 8, 9, current, 11, 12] If total page count less than VISIBLE_PAGE_COUNT, always show all pages
func (*Context) RenderForm ¶
type HasPermissioner ¶
type HasPermissioner interface {
HasPermission(roles.PermissionMode, *qor.Context) bool
}
type Menu ¶
type Menu struct { Name string Link string Ancestors []string // contains filtered or unexported fields }
func (*Menu) GetSubMenus ¶
type Meta ¶
type Meta struct { Name string DBName string Alias string Label string Type string Valuer func(interface{}, *qor.Context) interface{} Setter func(resource interface{}, metaValue *resource.MetaValue, context *qor.Context) Metas []resource.Metaor Resource resource.Resourcer Collection interface{} GetCollection func(interface{}, *qor.Context) [][]string Permission *roles.Permission // contains filtered or unexported fields }
func (*Meta) GetFieldName ¶
func (*Meta) GetResource ¶
func (*Meta) HasPermission ¶
type Middleware ¶
type Middleware struct { Handler func(*Context, *Middleware) // contains filtered or unexported fields }
func (Middleware) Next ¶
func (middleware Middleware) Next(context *Context)
type Resource ¶
type Resource struct { resource.Resource Config *Config Metas []*Meta SearchHandler func(keyword string, context *qor.Context) *gorm.DB // contains filtered or unexported fields }
func (*Resource) HasPermission ¶
func (*Resource) IndexAttrs ¶
func (*Resource) SearchAttrs ¶
func (*Resource) SortableAttrs ¶
type ResourceNamer ¶
type ResourceNamer interface {
ResourceName() string
}
type Router ¶
type Router struct { Prefix string // contains filtered or unexported fields }
func (*Router) Use ¶
func (r *Router) Use(handler func(*Context, *Middleware))
type Searcher ¶
type Searcher struct { *Context Pagination Pagination // contains filtered or unexported fields }
func (*Searcher) WithPagination ¶
Click to show internal directories.
Click to hide internal directories.