generator

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2019 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BuildingExamples bool

This is specific to automating the build of the examples database code. You do not normally need to set this.

View Source
var DefaultControlTypeFunc = DefaultControlType

DefaultControlTypeFunc is the injected function that determines the default control type for a particular type of database column. It gets initialized here, so that if you want to replace it, you can first call the default function

View Source
var DefaultFormFieldCreator = "goraddctrl.FormFieldWrapperCreator"

DefaultWrapper defines what wrapper will be used for generated controls. It should correspond to the string the wrapper was registered with.

View Source
var OneTimeTemplates []OneTimeTemplateI
View Source
var TableTemplates []TableTemplateI

Will be populated by the individual templates found

View Source
var TypeTableTemplates []TypeTableTemplateI

Functions

func AddOneTimeTemplate

func AddOneTimeTemplate(t OneTimeTemplateI)

func AddTableTemplate

func AddTableTemplate(t TableTemplateI)

func AddTypeTableTemplate

func AddTypeTableTemplate(t TypeTableTemplateI)

func AsConstant

func AsConstant(i interface{}, typ query.GoColumnType) string

Returns the value formatted as a constant. Essentially this just surrounds strings in quotes.

func ExportCreator added in v0.2.0

func ExportCreator(creator interface{}) string

Exports the given creator so that it can be embedded in a go file. Empty items are not exported Not all creators can be exported. This function is mainly a helper for code generation of controls. Specifically, events and actions do not export cleanly currently. But that should not be a problem for code generation.

func Generate

func Generate()

func RegisterControlGenerator

func RegisterControlGenerator(c ControlGenerator)

func WrapFormField added in v0.2.0

func WrapFormField(label string, forId string, child string) string

Types

type CodeGenerator added in v0.2.1

type CodeGenerator struct {
	Tables     map[string]map[string]TableType
	TypeTables map[string]map[string]TypeTableType
}

type ColumnType

type ColumnType struct {
	*db.ColumnDescription
	// Related control information
	ControlDescription
}

ColumnType combines a database ColumnDescription with a ControlDescription

type ConnectorParam

type ConnectorParam struct {
	Name        string
	Description string
	Typ         ControlType
	Template    string
	DoFunc      func(c page.ControlI, val interface{})
}

type ControlCreationInfo

type ControlCreationInfo struct {
	Typ        string
	CreateFunc string
	ImportName string
}

func DefaultControlType

func DefaultControlType(col *db.ColumnDescription) ControlCreationInfo

type ControlDescription

type ControlDescription struct {
	Import         *ImportType
	ControlType    string
	NewControlFunc string
	ControlName    string
	ControlID      string // default id to generate
	DefaultLabel   string
	Generator      ControlGenerator
	Connector      string
}

ControlDescription is matched with a ColumnDescription below and provides additional information regarding how information in a column can be used to generate a default control to edit that information.

func (*ControlDescription) ControlIDConst added in v0.2.4

func (cd *ControlDescription) ControlIDConst() string

type ControlGenerator

type ControlGenerator interface {
	Type() string
	Imports() []ImportPath
	SupportsColumn(col *ColumnType) bool
	GenerateCreator(col *ColumnType) string
	GenerateRefresh(col *ColumnType) string
	GenerateUpdate(col *ColumnType) string
}

func GetControlGenerator

func GetControlGenerator(imp string, typ string) ControlGenerator

type ControlGeneratorRegistryKey

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

type ControlType

type ControlType int

type ImportPath added in v0.2.3

type ImportPath struct {
	Alias string
	Path  string
}

type ImportType

type ImportType struct {
	Path    string
	Alias   string // blank if not needing an alias
	Primary bool
}

ImportType represents an import path required for a control. This is analyzed per-table.

type OneTimeTemplateI

type OneTimeTemplateI interface {
	GenerateOnce(codegen CodeGenerator, dd *db.DatabaseDescription, buf *bytes.Buffer)
	FileName(key string) string
	Overwrite() bool
}

type ProviderGenerator added in v0.2.0

type ProviderGenerator interface {
	GenerateProvider(col *ColumnType) string
}

type TableTemplateI

type TableTemplateI interface {
	GenerateTable(codegen CodeGenerator, dd *db.DatabaseDescription, t TableType, buf *bytes.Buffer)
	FileName(key string, t TableType) string
	Overwrite() bool
}

type TableType

type TableType struct {
	*db.TableDescription
	Columns []ColumnType
	Imports []*ImportType
}

func (*TableType) GetColumnByDbName

func (t *TableType) GetColumnByDbName(name string) *ColumnType

type Template

type Template struct {
	Overwrite bool
	TargetDir string
}

type TypeTableTemplateI

type TypeTableTemplateI interface {
	GenerateTypeTable(codegen CodeGenerator, dd *db.DatabaseDescription, t TypeTableType, buf *bytes.Buffer)
	FileName(key string, t TypeTableType) string
	Overwrite() bool
}

type TypeTableType

type TypeTableType struct {
	*db.TypeTableDescription
}

Jump to

Keyboard shortcuts

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