model

package
v0.0.0-...-592cec2 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2023 License: LGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Bool = Type("bool")

	String = Type("string")

	Int   = Type("int")
	Int8  = Type("int8")
	Int16 = Type("int16")
	Int32 = Type("int32")
	Int64 = Type("int64")

	UInt   = Type("uint")
	UInt8  = Type("uint8")
	UInt16 = Type("uint16")
	UInt32 = Type("uint32")
	UInt64 = Type("uint64")

	Byte = Type("byte")
	Rune = Type("rune")

	Float32 = Type("float32")
	Float64 = Type("float64")

	Complex64  = Type("complex64")
	Complex128 = Type("complex128")

	Password = Type("password")

	Uuid = Type("uuid")

	Select   = Type("select")
	Datalist = Type("data-list")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Attribute

type Attribute struct {
	Name       string              `json:"name"`
	Label      map[string]string   `json:"label"`
	ReadOnly   bool                `json:"readonly"`
	Required   bool                `json:"required"`
	Visibility AttributeVisibility `json:"visibility"`
	Rules      []string            `json:"rules"`

	Type Type `json:"type"`

	Options []string `json:"options"`

	ErrorText string `json:"-"`
	// contains filtered or unexported fields
}

func (*Attribute) Copy

func (attr *Attribute) Copy() *Attribute

func (*Attribute) DisplayValue

func (attr *Attribute) DisplayValue() string

func (*Attribute) GetLabel

func (attr *Attribute) GetLabel() string

func (*Attribute) GetLabelByLanguage

func (attr *Attribute) GetLabelByLanguage(language string) string

func (*Attribute) HasVisibility

func (attr *Attribute) HasVisibility(visibility AttributeVisibility) bool

func (*Attribute) Parse

func (attr *Attribute) Parse(value string) (any, error)

func (*Attribute) SetErrorText

func (attr *Attribute) SetErrorText(errorText string)

func (*Attribute) SetValue

func (attr *Attribute) SetValue(value any) error

func (*Attribute) Value

func (attr *Attribute) Value() any

type AttributeVisibility

type AttributeVisibility = uint
const (
	VisibilityNew AttributeVisibility = 1 << iota
	VisibilityRead
	VisibilityEdit
	VisibilityQuery

	Always = VisibilityNew | VisibilityRead | VisibilityEdit | VisibilityQuery
)
const (
	VisibilityNever AttributeVisibility = 0
)

type CustomAction

type CustomAction struct {
	Name    string            `json:"name"`
	Label   map[string]string `json:"label"`
	Icon    string            `json:"icon"`
	Objects []string          `json:"objects"`
	Queries []string          `json:"queries"`
}

func (*CustomAction) GetLabel

func (action *CustomAction) GetLabel() string

func (*CustomAction) GetLabelByLanguage

func (action *CustomAction) GetLabelByLanguage(language string) string

type Db

type Db struct {
	Objects       map[string]*PersistentObject `json:"objects"`
	Queries       map[string]*Query            `json:"queries"`
	CustomActions map[string]*CustomAction     `json:"customActions"`
	Nav           *Nav                         `json:"nav"`
}

func LoadModelDb

func LoadModelDb() (*Db, error)

func (*Db) BindObject

func (db *Db) BindObject(name string, createStruct func() any)

func (*Db) GetCustomAction

func (db *Db) GetCustomAction(name string) *CustomAction

func (*Db) GetObject

func (db *Db) GetObject(name string) *PersistentObject

func (*Db) GetQuery

func (db *Db) GetQuery(name string) *Query

func (*Db) Merge

func (db *Db) Merge(other *Db)

func (*Db) NewCustomAction

func (db *Db) NewCustomAction(name string) *CustomAction

func (*Db) NewNav

func (db *Db) NewNav() *Nav

func (*Db) NewObject

func (db *Db) NewObject(name string) *PersistentObject

func (*Db) NewQuery

func (db *Db) NewQuery(name string) *Query

type ExecutedQuery

type ExecutedQuery struct {
	*Query
	Rows []*QueryRow

	Page    int
	MaxPage int

	CustomActions []*CustomAction

	Notifications []Notification
}

func (*ExecutedQuery) AddNotification

func (query *ExecutedQuery) AddNotification(text string, notificationType NotificationType)

func (*ExecutedQuery) MinusPage

func (query *ExecutedQuery) MinusPage() int

func (*ExecutedQuery) PlusPage

func (query *ExecutedQuery) PlusPage() int
type Nav struct {
	Items []*NavItem `json:"items"`
}
func (nav *Nav) Active() *NavItem
func (nav *Nav) Copy() *Nav
func (nav *Nav) FindItem(id string) *NavItem
type NavItem struct {
	Name   string            `json:"name"`
	Icon   string            `json:"icon"`
	Label  map[string]string `json:"label"`
	Query  string            `json:"query"`
	Object string            `json:"object"`

	Active bool `json:"-"`
}
func (i *NavItem) Copy() *NavItem
func (i *NavItem) GetLabel() string
func (i *NavItem) GetLabelByLanguage(language string) string
func (i *NavItem) GetModel() string

type Notification

type Notification struct {
	Text string
	Type NotificationType
}

type NotificationType

type NotificationType int
const (
	NotificationSuccess NotificationType = iota
	NotificationError
	NotificationWarning
	NotificationInfo
)

type PersistentObject

type PersistentObject struct {
	Name       string            `json:"name"`
	Label      map[string]string `json:"label"`
	Attributes []*Attribute      `json:"attributes"`
	Table      string            `json:"table"`
	Breadcrumb string            `json:"breadcrumb"`
	ReadOnly   bool              `json:"readonly"`

	Id string

	IsNew bool

	CreateStruct func() any

	CustomActions []*CustomAction

	Notifications []Notification
}

func (*PersistentObject) AddNotification

func (obj *PersistentObject) AddNotification(text string, notificationType NotificationType)

func (*PersistentObject) ClearPasswords

func (obj *PersistentObject) ClearPasswords()

func (*PersistentObject) Copy

func (obj *PersistentObject) Copy() *PersistentObject

func (*PersistentObject) CopyFrom

func (obj *PersistentObject) CopyFrom(data any)

func (*PersistentObject) CopyTo

func (obj *PersistentObject) CopyTo() any

func (*PersistentObject) GetAttribute

func (obj *PersistentObject) GetAttribute(id string) *Attribute

func (*PersistentObject) GetLabel

func (obj *PersistentObject) GetLabel() string

func (*PersistentObject) GetLabelByLanguage

func (obj *PersistentObject) GetLabelByLanguage(language string) string

func (*PersistentObject) HasError

func (obj *PersistentObject) HasError() bool

func (*PersistentObject) IsReadOnly

func (obj *PersistentObject) IsReadOnly() bool

type Query

type Query struct {
	Name       string            `json:"name"`
	Label      map[string]string `json:"label"`
	Object     string            `json:"object"`
	Columns    []*QueryColumn    `json:"columns"`
	Pagination int               `json:"pagination"`
}

func (*Query) GetLabel

func (obj *Query) GetLabel() string

func (*Query) GetLabelByLanguage

func (obj *Query) GetLabelByLanguage(language string) string

type QueryColumn

type QueryColumn struct {
	Name  string            `json:"name"`
	Label map[string]string `json:"label"`
}

func (*QueryColumn) GetLabel

func (column *QueryColumn) GetLabel() string

func (*QueryColumn) GetLabelByLanguage

func (column *QueryColumn) GetLabelByLanguage(language string) string

type QueryResult

type QueryResult struct {
	Items []any
}

type QueryRow

type QueryRow struct {
	Items []*QueryRowItem
	Id    string
}

func (*QueryRow) Item

func (row *QueryRow) Item(id string) *QueryRowItem

type QueryRowItem

type QueryRowItem struct {
	Name  string
	Value any
}

func (*QueryRowItem) SetValue

func (item *QueryRowItem) SetValue(value any)

type Type

type Type string

func (Type) IsNumber

func (t Type) IsNumber() bool

Jump to

Keyboard shortcuts

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