adsa-cms: github.com/mmanjoura/adsa-cms/widget Index | Files

package widget

import "github.com/mmanjoura/adsa-cms/widget"

Index

Package Files

context.go controller.go func_map.go render.go scope.go setting.go widget.go

type Config Uses

type Config struct {
    DB    *gorm.DB
    Admin *admin.Admin
}

Config widget config

type Context Uses

type Context struct {
    Widgets          *Widgets
    DB               *gorm.DB
    InlineEdit       bool
    AvailableWidgets []string
    Options          map[string]interface{}
}

Context widget context

func NewContext Uses

func NewContext(options map[string]interface{}) *Context

NewContext new widget context

func (Context) Get Uses

func (context Context) Get(name string) (interface{}, bool)

Get get option with name

func (*Context) GetDB Uses

func (context *Context) GetDB() *gorm.DB

GetDB set option by name

func (*Context) Render Uses

func (context *Context) Render(widgetName string, widgetGroupName string) template.HTML

Render render widget based on context

func (*Context) Set Uses

func (context *Context) Set(name string, value interface{})

Set set option by name

type QorWidgetSetting Uses

type QorWidgetSetting struct {
    Name        string `gorm:"primary_key"`
    WidgetType  string `gorm:"primary_key"`
    Scope       string `gorm:"primary_key;default:'default'"`
    GroupName   string
    ActivatedAt *time.Time
    Template    string
    serializable_meta.SerializableMeta
    CreatedAt time.Time
    UpdatedAt time.Time
}

QorWidgetSetting default qor widget setting struct

func (*QorWidgetSetting) BeforeCreate Uses

func (widgetSetting *QorWidgetSetting) BeforeCreate()

func (*QorWidgetSetting) BeforeUpdate Uses

func (widgetSetting *QorWidgetSetting) BeforeUpdate(scope *gorm.Scope) error

func (*QorWidgetSetting) ConfigureQorResource Uses

func (qorWidgetSetting *QorWidgetSetting) ConfigureQorResource(res resource.Resourcer)

ConfigureQorResource a method used to config Widget for qor admin

func (QorWidgetSetting) GetGroupName Uses

func (qorWidgetSetting QorWidgetSetting) GetGroupName() string

GetGroupName get widget setting's group name

func (QorWidgetSetting) GetScope Uses

func (qorWidgetSetting QorWidgetSetting) GetScope() string

GetScope get widget's scope

func (*QorWidgetSetting) GetSerializableArgumentKind Uses

func (widgetSetting *QorWidgetSetting) GetSerializableArgumentKind() string

func (*QorWidgetSetting) GetSerializableArgumentResource Uses

func (qorWidgetSetting *QorWidgetSetting) GetSerializableArgumentResource() *admin.Resource

GetSerializableArgumentResource get setting's argument's resource

func (QorWidgetSetting) GetTemplate Uses

func (qorWidgetSetting QorWidgetSetting) GetTemplate() string

GetTemplate get used widget template

func (QorWidgetSetting) GetWidgetName Uses

func (qorWidgetSetting QorWidgetSetting) GetWidgetName() string

GetWidgetName get widget setting's group name

func (*QorWidgetSetting) ResourceName Uses

func (widgetSetting *QorWidgetSetting) ResourceName() string

func (*QorWidgetSetting) SetGroupName Uses

func (qorWidgetSetting *QorWidgetSetting) SetGroupName(groupName string)

SetGroupName set widget setting's group name

func (*QorWidgetSetting) SetScope Uses

func (qorWidgetSetting *QorWidgetSetting) SetScope(scope string)

SetScope set widget setting's scope

func (*QorWidgetSetting) SetSerializableArgumentKind Uses

func (widgetSetting *QorWidgetSetting) SetSerializableArgumentKind(name string)

func (*QorWidgetSetting) SetTemplate Uses

func (qorWidgetSetting *QorWidgetSetting) SetTemplate(template string)

SetTemplate set used widget's template

func (*QorWidgetSetting) SetWidgetName Uses

func (qorWidgetSetting *QorWidgetSetting) SetWidgetName(name string)

SetWidgetName set widget setting's group name

type QorWidgetSettingInterface Uses

type QorWidgetSettingInterface interface {
    GetWidgetName() string
    SetWidgetName(string)
    GetGroupName() string
    SetGroupName(string)
    GetScope() string
    SetScope(string)
    GetTemplate() string
    SetTemplate(string)
    serializable_meta.SerializableMetaInterface
}

type Scope Uses

type Scope struct {
    Name    string
    Param   string
    Visible func(*Context) bool
}

Scope widget scope

func (*Scope) ToParam Uses

func (scope *Scope) ToParam() string

ToParam generate param for scope

type Widget Uses

type Widget struct {
    Name      string
    Templates []string
    Setting   *admin.Resource
    Context   func(context *Context, setting interface{}) *Context
}

Widget widget struct

func GetWidget Uses

func GetWidget(name string) *Widget

GetWidget get widget by name

func (*Widget) Render Uses

func (w *Widget) Render(context *Context, file string) template.HTML

Render register widget itself content

type Widgets Uses

type Widgets struct {
    Config                *Config
    Resource              *admin.Resource
    WidgetSettingResource *admin.Resource
}

Widgets widgets container

func New Uses

func New(config *Config) *Widgets

New new widgets container

func (*Widgets) ConfigureQorResourceBeforeInitialize Uses

func (widgets *Widgets) ConfigureQorResourceBeforeInitialize(res resource.Resourcer)

ConfigureQorResource a method used to config Widget for qor admin

func (*Widgets) FuncMap Uses

func (widgets *Widgets) FuncMap(enableInlineEdit bool) template.FuncMap

FuncMap return view functions map

func (*Widgets) NewContext Uses

func (widgets *Widgets) NewContext(context *Context) *Context

func (*Widgets) RegisterScope Uses

func (widgets *Widgets) RegisterScope(scope *Scope)

RegisterScope register scope for widget

func (*Widgets) RegisterViewPath Uses

func (widgets *Widgets) RegisterViewPath(p string)

RegisterViewPath register views directory

func (*Widgets) RegisterWidget Uses

func (widgets *Widgets) RegisterWidget(w *Widget)

RegisterWidget register a new widget

func (*Widgets) RegisterWidgetsGroup Uses

func (widgets *Widgets) RegisterWidgetsGroup(group *WidgetsGroup)

RegisterWidgetGroup register widgets group

func (*Widgets) Render Uses

func (widgets *Widgets) Render(widgetName string, widgetGroupName string) template.HTML

Render find widget by name, render it based on current context

type WidgetsGroup Uses

type WidgetsGroup struct {
    Name    string
    Widgets []string
}

WidgetsGroup widgets Group

Package widget imports 19 packages (graph) and is imported by 2 packages. Updated 2017-06-08. Refresh now. Tools for package owners.