grider

package module
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2022 License: MIT Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

grider

Backend part of the web table view

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FieldTagLabel = "grid"

FieldTagLabel holds struct field tag key.

Functions

func AssignActionSet

func AssignActionSet(lw Widgeter, as ActionSet) error

func NewActionSet

func NewActionSet() map[ActionCode]Action

NewActionSet builds instance of ActionSet.

func SetLinkPrefix

func SetLinkPrefix(s string)

func ToSnakeCase

func ToSnakeCase(str string) string

ToSnakeCase converts string like RobertEgorov to robert_egorov.

func WitTitlePrefix

func WitTitlePrefix(prefix string) func(*Option)

func WithDownloadOption

func WithDownloadOption(b bool) func(*Option)

func WithI18n

func WithI18n() func(*Option)

Types

type Action

type Action struct {
	Code       ActionCode  `json:"code,omitempty"`
	Perm       string      `json:"perm,omitempty"`
	Title      string      `json:"title,omitempty"`
	Icon       *Icon       `json:"icon,omitempty"`
	DirectCall *DirectCall `json:"directCall,omitempty"`
}

Action describes an operation on UI user can invocate. An action could relate to the specific row or not.

type ActionCode

type ActionCode string

type ActionSet

type ActionSet map[ActionCode]Action

ActionSet holds Actions identified by code. The type is useful for describe all supported application actions.

func (ActionSet) Add

func (as ActionSet) Add(arr []ActionCode)

func (ActionSet) AssignActionValues

func (dst ActionSet) AssignActionValues(src ActionSet) error

type AttrValueWidget

type AttrValueWidget struct {
	*Widget
	Lines []Line `json:"lines,omitempty"`
}

func (AttrValueWidget) WidgetType

func (AttrValueWidget) WidgetType() WidgetType

type Column

type Column struct {
	Name       string `json:"name"`
	Hidden     bool   `json:"hidden,omitempty"`     // default false
	Sortable   bool   `json:"sortable,omitempty"`   // default false
	Filterable bool   `json:"filterable,omitempty"` // default false
	Title      string `json:"title,omitempty"`      // default ""
	Perm       string `json:"perm,omitempty"`       // default not permission
	Type       string `json:"type,omitempty"`       // default "" (regular text)
	Href       string `json:"href,omitempty"`       // default "" (no link)
	Align      string `json:"align,omitempty"`      // default "" ("left") cell align
	Caption    string `json:"caption,omitempty"`    // default ""
	Method     string `json:"method,omitempty"`     // ?
	Icons      string `json:"icons,omitempty"`      // comma separated fa-* icon names
	IconsAlign string `json:"ialign,omitempty"`     // default "" ("left") "right" - after text
	Target     string `json:"target,omitempty"`     // default "" browser window target for opening link
}

Column describes grid column's properties.

type ContentBodyType

type ContentBodyType int
const (
	Text     ContentBodyType = 1
	Html     ContentBodyType = 2
	Markdown ContentBodyType = 3
)

func (ContentBodyType) MarshalJSON

func (wt ContentBodyType) MarshalJSON() ([]byte, error)

func (ContentBodyType) String

func (wt ContentBodyType) String() string

type ContentWidget

type ContentWidget struct {
	*Widget
	Type ContentBodyType `json:"type"`
	Body string          `json:"body"`
}

func (ContentWidget) WidgetType

func (ContentWidget) WidgetType() WidgetType

type Date

type Date date.Date

func (Date) ConvertToString

func (t Date) ConvertToString(layout string) string

type DirectCall

type DirectCall struct {
	IsConfirmationRequired bool            `json:"isConfirmationRequired,omitempty"`
	ConfirmationMessage    string          `json:"confirmationMessage,omitempty"`
	Method                 string          `json:"method,omitempty"`
	Path                   string          `json:"path,omitempty"`
	Body                   json.RawMessage `json:"body,omitempty"`
}

DirectCall is action's extended attributes describing a simple action what does not have user interaction. As instance an action what directly calls server REST handler.

type DownloadResponse

type DownloadResponse struct {
	FileName    string
	ContentType string
	Content     string // base64
}

type EmptyWidget

type EmptyWidget struct {
	*Widget
}

func (EmptyWidget) WidgetType

func (EmptyWidget) WidgetType() WidgetType

type Float

type Float null.Float

func (Float) ConvertToString

func (t Float) ConvertToString(layout string) string

type Formatter

type Formatter interface {
	ConvertToString(layout string) string
}

type Grid

type Grid struct {
	Columns        []Column       `json:"columns"`
	Rows           [][]string     `json:"rows"`
	RowObjects     []interface{}  `json:"rowObjects,omitempty"`
	RowIDs         []int          `json:"rowIds,omitempty"`
	RowUIDs        []uuid.UUID    `json:"rowUids,omitempty"`
	RowActions     [][]ActionCode `json:"rowActions,omitempty"`
	GridActions    []ActionCode   `json:"gridActions,omitempty"`
	Action         ActionSet      `json:"action,omitempty"`
	IsDownloadable bool           `json:"isDownloadable"`
	IsFilterable   bool           `json:"isFilterable"`
	NoPagination   bool           `json:"noPagination,omitempty"`
	PaginationType PaginationType `json:"paginationType"`
	// contains filtered or unexported fields
}

Grid describes data and metadata for presenting grid.

func New

func New(opts ...func(*Option)) *Grid

func (*Grid) ApplySliceOfStruct

func (g *Grid) ApplySliceOfStruct(src interface{}) *Grid

ApplySliceOfStruct converts slice of any struct to Grid, slice of column and rows.

func (*Grid) AssignActionSet

func (g *Grid) AssignActionSet(as ActionSet) error

func (*Grid) DeleteColumns

func (g *Grid) DeleteColumns(col []string)

DeleteColumns deletes columns with exact names in cols.

func (*Grid) Excelize

func (r *Grid) Excelize(fname string) (*DownloadResponse, error)

func (*Grid) JSON

func (g *Grid) JSON() ([]byte, error)
func (g *Grid) ReplaceCellWithFullLinks() error

type GridWidget

type GridWidget struct {
	*Widget
	Grid *Grid `json:"grid,omitempty"`
}

func (GridWidget) WidgetType

func (GridWidget) WidgetType() WidgetType
type Header struct {
	ID int `json:"id,omitempty"`

	// Icon параметры иконки отображемой в заголовке.
	LeftIcons []Icon `json:"leftIcons,omitempty"`

	// Title может содержать код из ресурсов %слово%
	Title string `json:"title,omitempty"`

	// SubTitle может содержать код из ресурсов %слово%
	SubTitle string `json:"subTitle,omitempty"`

	RightIcons []Icon `json:"rightIcons,omitempty"`

	// URL для перехода на страницу объекта, если значение заполнено.
	URL string `json:"url,omitempty"`

	// BgColor содержит цвета фона заголовка в формате HTML: red, #fff или #fefefe.
	BgColor string `json:"bgColor,omitempty"`
}

Header describes header of the Page or Tab.

type Icon

type Icon struct {
	// Name is name of font-awesome icon.
	Name string `json:"name"`

	// Color in HTML format.
	Color string `json:"color,omitempty"`
}

Icon describes fa-icon properties.

type Int

type Int null.Int

func (Int) ConvertToString

func (t Int) ConvertToString(layout string) string

type LazyWidget

type LazyWidget struct {
	*Widget
	URL string `json:"url"`
}

func (LazyWidget) WidgetType

func (LazyWidget) WidgetType() WidgetType

type Line

type Line struct {
	ID    int      `json:"id,omitempty"`
	Icon  *Icon    `json:"icon,omitempty"`
	Label string   `json:"label,omitempty"`
	Value string   `json:"value,omitempty"`
	Type  LineType `json:"type,omitempty"`
	// RefBook заполняется только если Type = "refbook"
	RefBook    *RefBookType    `json:"refBook,omitempty"`
	Suggestion *SuggestionType `json:"suggestion,omitempty"`

	// URL заполняется при Type = href или exthref
	URL     string       `json:"url,omitempty"`
	Actions []ActionCode `json:"actions,omitempty"`
}

Line описывает одну информационную строчку

type LineType

type LineType string

LineType описывает поддерживаемые типы линий.

const (
	// LineTypeDefault обычная строка. Показывать как текст
	LineTypeDefault LineType = ""

	// LineTypeHref показывать Value как ссылку
	LineTypeHref LineType = "href"

	// LineTypeExtHref показывать Value как ссылку на внешний ресурс.
	LineTypeExtHref LineType = "exthref"

	// LineTypeRefbook отображать Value как ссылку активирующую режим редактирования
	// параметры отображения комбобокса в структуре RefBookType.
	LineTypeRefbook LineType = "refbook"

	// LineTypeSuggestion отображать Value как ссылку активирующую режим редактирования
	// параметры отображения комбобокса в структуре RefBookType.
	LineTypeSuggestion LineType = "suggestion"
)

type Media

type Media struct {
	// ThumbnailURL содержит URL который необходимо использовать для отображения
	// миниатюр.
	ThumbnailURL string `json:"thumbnailUrl"`

	// URL содержит адрес полной фотографии/видео.
	URL string `json:"url"`

	// IsVideo = true, если это видео. В миниатюре будет фото.
	IsVideo bool `json:"isVideo,omitempty"`
}

Media описывает фото или видео для отображения в окне.

type MediaWidget

type MediaWidget struct {
	*Widget
	Media []Media `json:"media,omitempty"`
}

func (MediaWidget) WidgetType

func (MediaWidget) WidgetType() WidgetType

type NullTime

type NullTime null.Time

func (NullTime) ConvertToString

func (t NullTime) ConvertToString(layout string) string

type Option

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

type Page

type Page struct {
	ID     int     `json:"id,omitempty"`
	Header *Header `json:"header,omitempty"`

	Widgets []Widgeter `json:"widgets,omitempty"`

	// Tabs содержит описание подчиненных объектов.
	Tabs []Tab `json:"tabs,omitempty"`

	Action ActionSet `json:"action,omitempty"`

	// PageActions holds actions available in the drop down list on the page level.
	PageActions []ActionCode `json:"pageActions,omitempty"`
}

Page describes a single object page.

func (*Page) AssignActionSet

func (p *Page) AssignActionSet(supported ActionSet) error

Footer описывает содержимое нижней части окна.

type Footer struct {
	Media []Media `json:"media,omitempty"`
}

type PaginationType

type PaginationType int
const (
	PaginationServer  PaginationType = 0
	PaginationClient  PaginationType = 1
	PaginationWithout PaginationType = 2
)

func (PaginationType) MarshalJSON

func (pt PaginationType) MarshalJSON() ([]byte, error)

func (PaginationType) String

func (pt PaginationType) String() string

type RefBookType

type RefBookType struct {
	// Name содержит название справочника из /dictionary
	Name string `json:"name"`
	// SelectedID текущий ID элемента справочника.
	SelectedID int `json:"selectedId"`

	// SubmitURL адрес куда надо направить POST запрос содержащий новый выбранный id из справочника Name.
	// Структура запроса {"id" : 2}
	SubmitURL string `json:"sumbitUrl"`
}

RefBookType описывает параметры строчки которая является изменяемым элементом справочника.

type String

type String null.String

func (String) ConvertToString

func (t String) ConvertToString(layout string) string

type SuggestionType

type SuggestionType struct {
	// Name содержит название справочника из /dictionary
	Name string `json:"name"`
	// SelectedID текущий ID элемента справочника.
	SelectedID *int64 `json:"selectedId,omitempty"`

	UID string `json:"uid,omitempty"`

	// SubmitURL адрес куда надо направить POST запрос содержащий новый выбранный id из справочника Name.
	// Структура запроса {"id" : 2}
	SubmitURL string `json:"submitUrl"`
}

type Tab

type Tab struct {
	Header     *Header      `json:"header,omitempty"`
	TabActions []ActionCode `json:"tabActions,omitempty"`

	Widgets []Widgeter `json:"widgets,omitempty"`

	IsActive       bool `json:"isActive,omitempty"`
	IsInitRequired bool `json:"isInitRequired,omitempty"`
	IsDisabled     bool `json:"isDisabled,omitempty"`
}

Tab описывает содержимое одного связанного объекта.

type Time

type Time time.Time

func (Time) ConvertToString

func (t Time) ConvertToString(layout string) string

type Widget

type Widget struct {
	ID     int        `json:"id,omitempty"`
	Type   WidgetType `json:"type"`
	Header *Header    `json:"header,omitempty"`
	// Row     int          `json:"row"`
	// Col     int          `json:"col"`
	Width   int          `json:"width"`
	Actions []ActionCode `json:"widgetActions,omitempty"`

	// Action must be only filled if widget generated independent as
	// result of request from lazy widget.
	Action ActionSet `json:"action,omitempty"`

	// Object is an object in JSON. The object can be consumed
	// by customized UI logic. As instance: take data to init modal window.
	Object interface{} `json:"object,omitempty"`
}

type WidgetType

type WidgetType int
const (
	AttrValueType WidgetType = 1
	MediaType     WidgetType = 2
	GridType      WidgetType = 3
	MapType       WidgetType = 4
	ChartType     WidgetType = 5
	CustomType    WidgetType = 6
	LazyType      WidgetType = 7
	ContentType   WidgetType = 8
	EmptyType     WidgetType = 9
)

func (WidgetType) MarshalJSON

func (wt WidgetType) MarshalJSON() ([]byte, error)

func (WidgetType) String

func (wt WidgetType) String() string

type Widgeter

type Widgeter interface {
	WidgetType() WidgetType
}

Jump to

Keyboard shortcuts

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