table

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPrimaryKeyName = "id"
	DefaultConnectionName = "default"
)

Variables

View Source
var (
	Generators = make(GeneratorList)
	List       = map[string]Table{}
)
View Source
var DefaultConfig = Config{
	Driver:     db.DriverMysql,
	CanAdd:     true,
	Editable:   true,
	Deletable:  true,
	Exportable: false,
	Connection: DefaultConnectionName,
	PrimaryKey: PrimaryKey{
		Type: db.Int,
		Name: DefaultPrimaryKeyName,
	},
}

Functions

func GetNewFormList

func GetNewFormList(groupHeaders []string, group [][]string, old []types.Form, primaryKey string) ([]types.Form, [][]types.Form, []string)

func InitTableList

func InitTableList()

func RefreshTableList

func RefreshTableList()

RefreshTableList refresh the table list when the table relationship changed.

func SetGenerators

func SetGenerators(generators map[string]Generator)

SetGenerators update Generators.

Types

type Columns

type Columns []string

type Config

type Config struct {
	Driver     string
	Connection string
	CanAdd     bool
	Editable   bool
	Deletable  bool
	Exportable bool
	PrimaryKey PrimaryKey
}

func DefaultConfigWithDriver

func DefaultConfigWithDriver(driver string) Config

func DefaultConfigWithDriverAndConnection

func DefaultConfigWithDriverAndConnection(driver, conn string) Config

func (Config) SetCanAdd added in v0.1.0

func (config Config) SetCanAdd(canAdd bool) Config

func (Config) SetConnection added in v0.1.0

func (config Config) SetConnection(connection string) Config

func (Config) SetDeletable added in v0.1.0

func (config Config) SetDeletable(deletable bool) Config

func (Config) SetEditable added in v0.1.0

func (config Config) SetEditable(editable bool) Config

func (Config) SetExportable added in v0.1.0

func (config Config) SetExportable(exportable bool) Config

func (Config) SetPrimaryKeyType added in v0.1.0

func (config Config) SetPrimaryKeyType(typ string) Config

type DefaultTable

type DefaultTable struct {
	// contains filtered or unexported fields
}

func (DefaultTable) DeleteDataFromDatabase

func (tb DefaultTable) DeleteDataFromDatabase(id string)

DeleteDataFromDatabase delete data.

func (DefaultTable) GetCanAdd

func (tb DefaultTable) GetCanAdd() bool

func (DefaultTable) GetDataFromDatabase

func (tb DefaultTable) GetDataFromDatabase(path string, params parameter.Parameters) PanelInfo

GetDataFromDatabase query the data set.

func (DefaultTable) GetDataFromDatabaseWithId

func (tb DefaultTable) GetDataFromDatabaseWithId(id string) ([]types.Form, [][]types.Form, []string, string, string)

GetDataFromDatabaseWithId query the single row of data.

func (DefaultTable) GetDataFromDatabaseWithIds added in v0.0.11

func (tb DefaultTable) GetDataFromDatabaseWithIds(path string, params parameter.Parameters, ids []string) PanelInfo

GetDataFromDatabaseWithIds query the data set.

func (DefaultTable) GetDeletable

func (tb DefaultTable) GetDeletable() bool

func (DefaultTable) GetEditable

func (tb DefaultTable) GetEditable() bool

func (DefaultTable) GetExportable added in v0.0.11

func (tb DefaultTable) GetExportable() bool

func (DefaultTable) GetFiltersMap

func (tb DefaultTable) GetFiltersMap() []map[string]string

func (DefaultTable) GetForm

func (tb DefaultTable) GetForm() *types.FormPanel

func (DefaultTable) GetInfo

func (tb DefaultTable) GetInfo() *types.InfoPanel

func (DefaultTable) GetPrimaryKey added in v0.1.0

func (tb DefaultTable) GetPrimaryKey() PrimaryKey

func (DefaultTable) InsertDataFromDatabase

func (tb DefaultTable) InsertDataFromDatabase(dataList form.Values) error

InsertDataFromDatabase insert data.

func (DefaultTable) UpdateDataFromDatabase

func (tb DefaultTable) UpdateDataFromDatabase(dataList form.Values) error

UpdateDataFromDatabase update data.

type Generator

type Generator func() Table

type GeneratorList

type GeneratorList map[string]Generator

func (GeneratorList) Add

func (g GeneratorList) Add(key string, gen Generator)

type InfoList added in v0.3.0

type InfoList []map[string]template.HTML

func (InfoList) GroupBy added in v0.3.0

func (i InfoList) GroupBy(group [][]string) []InfoList

type PanelInfo

type PanelInfo struct {
	Thead       Thead
	InfoList    InfoList
	Paginator   types.PaginatorAttribute
	Title       string
	Description string
}

type PrimaryKey added in v0.1.0

type PrimaryKey struct {
	Type db.DatabaseType
	Name string
}

type Table

type Table interface {
	GetInfo() *types.InfoPanel
	GetForm() *types.FormPanel
	GetCanAdd() bool
	GetEditable() bool
	GetDeletable() bool
	GetExportable() bool
	GetPrimaryKey() PrimaryKey
	GetFiltersMap() []map[string]string
	GetDataFromDatabase(path string, params parameter.Parameters) PanelInfo
	GetDataFromDatabaseWithIds(path string, params parameter.Parameters, ids []string) PanelInfo
	GetDataFromDatabaseWithId(id string) ([]types.Form, [][]types.Form, []string, string, string)
	UpdateDataFromDatabase(dataList form.Values) error
	InsertDataFromDatabase(dataList form.Values) error
	DeleteDataFromDatabase(id string)
}

func GetManagerTable

func GetManagerTable() (ManagerTable Table)

func GetMenuTable

func GetMenuTable() (MenuTable Table)

func GetOpTable

func GetOpTable() (OpTable Table)

func GetPermissionTable

func GetPermissionTable() (PermissionTable Table)

func GetRolesTable

func GetRolesTable() (RolesTable Table)

func NewDefaultTable

func NewDefaultTable(cfg Config) Table

type Thead added in v0.3.0

type Thead []map[string]string

func (Thead) GroupBy added in v0.3.0

func (t Thead) GroupBy(group [][]string) []Thead

Jump to

Keyboard shortcuts

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