Documentation ¶
Index ¶
- Variables
- func EntgqlExtensionOptionsWrapper(opts ...entgql.ExtensionOption) []entgql.ExtensionOption
- func GenerateRefineScripts(ex *Extension) gen.Hook
- type Action
- type CodeFieldOptions
- type Extension
- type ExtensionOption
- func WithAppPath(path string) ExtensionOption
- func WithDefaultEdgesDiagram(name string) ExtensionOption
- func WithForceGraph2D(options ForceGraph2DOptions) ExtensionOption
- func WithGoJs(options GoJSOptions) ExtensionOption
- func WithMeta(meta map[string]any) ExtensionOption
- func WithSrcDirName(name string) ExtensionOption
- func WithTypeScriptPrefix(prefix string) ExtensionOption
- type ForceGraph2DOptions
- type GoJSOptions
- type JSDeps
- type RefineAnnotation
- func Actions(actions ...Action) RefineAnnotation
- func Badge(name string) RefineAnnotation
- func CodeField(config *CodeFieldOptions) RefineAnnotation
- func Description(description string) RefineAnnotation
- func FilterOperator(operator gen.Op) RefineAnnotation
- func HideOnCreate() RefineAnnotation
- func HideOnForm() RefineAnnotation
- func HideOnList() RefineAnnotation
- func HideOnShow() RefineAnnotation
- func HideOnUpdate() RefineAnnotation
- func Icon(icon string) RefineAnnotation
- func ImageField() RefineAnnotation
- func Label(label string) RefineAnnotation
- func MainImageField() RefineAnnotation
- func NoCreate() RefineAnnotation
- func NoEdit() RefineAnnotation
- func NoList() RefineAnnotation
- func NoShow() RefineAnnotation
- func OnlyOnForm() RefineAnnotation
- func OnlyOnList() RefineAnnotation
- func OnlyOnShow() RefineAnnotation
- func Prefix(prefix string) RefineAnnotation
- func RichTextField() RefineAnnotation
- func Suffix(suffix string) RefineAnnotation
- func TitleField() RefineAnnotation
- func URLField() RefineAnnotation
- func View(name string) RefineAnnotation
- func ViewOnForm(name string) RefineAnnotation
- func ViewOnList(name string) RefineAnnotation
- func ViewOnShow(name string) RefineAnnotation
- type RefineGen
- type SkipModes
Constants ¶
This section is empty.
Variables ¶
var ( // EditAction standard edit action EditAction = Action{ Operation: "Edit", OnList: true, OnShow: true, } // ShowAction standard show action ShowAction = Action{ Operation: "Show", OnList: true, } // DeleteAction standard delete action DeleteAction = Action{ Operation: "Delete", Label: "Delete", Icon: "RA.Icons.DeleteOutlined", OnList: true, OnShow: true, Bulk: true, Props: map[string]any{ "danger": true, }, } )
var ( Dependencies = JSDeps{ Deps: map[string]string{ "pluralize": "^8.0.0", "camelcase": "^6.2.0", "gql-query-builder": "^3.5.5", "graphql-request": "^4.3.0", "graphql": "^15.6.1", "lodash": "^4.17.21", }, DevDeps: map[string]string{ "@types/pluralize": "^0.0.29", "@types/lodash": "^4.14.171", }, } ForceGraph2DDependencies = JSDeps{ Deps: map[string]string{ "react-force-graph-2d": "^1.23.17", }, } GoJSDependencies = JSDeps{ Deps: map[string]string{ "gojs": "^2.3.1", "gojs-react": "^1.1.1", }, } )
Functions ¶
func EntgqlExtensionOptionsWrapper ¶
func EntgqlExtensionOptionsWrapper(opts ...entgql.ExtensionOption) []entgql.ExtensionOption
EntgqlExtensionOptionsWrapper Wrap options of EntGQL Sometimes entrefine using some custom GraphQL queries and mutations Wrapper can add custom configs/hooks
func GenerateRefineScripts ¶
Types ¶
type Action ¶
type Action struct { Operation string `json:"Operation,omitempty"` // Operation of graphql Fields []string `json:"Fields,omitempty"` // Fields to take after operation Props map[string]any `json:"Props,omitempty"` // Props are directly passing to react component Single bool `json:"Single"` // Show on single item Bulk bool `json:"Bulk,omitempty"` // Show on bulk selected items SuccessMessage string `json:"SuccessMessage,omitempty"` // Message on success FailMessage string `json:"FailMessage,omitempty"` // Message on fail CustomComponent string `json:"CustomComponent,omitempty"` // Custom component TODO: custom component Description string `json:"Description,omitempty"` // Description of action Label string `json:"Label,omitempty"` // Label of button Icon string `json:"Icon,omitempty"` // Icon of button OnList bool `json:"OnList,omitempty"` // Display on list OnShow bool `json:"OnShow,omitempty"` // Display on show OnEdit bool `json:"OnEdit,omitempty"` // Display on edit }
Action item related action
type CodeFieldOptions ¶
type CodeFieldOptions struct {
Language string `json:"Language,omitempty"`
}
CodeFieldOptions code field is configurable
**Example**
```go
CodeFieldOptions{ Language: "javascript" }
```
type Extension ¶
type Extension struct { entc.DefaultExtension AppPath string // AppPath JS Application path (packages.json directory path) SrcDirName string // SrcDirName JS Application source dir name Meta map[string]any // Meta to share with frontend application TypeScriptPrefix string GoJs GoJSOptions ForceGraph2D ForceGraph2DOptions DefaultEdgesDiagram string }
Extension main struct
func NewExtension ¶
func NewExtension(opts ...ExtensionOption) (*Extension, error)
NewExtension initialize extension
func (*Extension) Annotations ¶
func (ex *Extension) Annotations() []entc.Annotation
Annotations Define Ent annotations
type ExtensionOption ¶
func WithAppPath ¶
func WithAppPath(path string) ExtensionOption
WithAppPath define refine-project directory
func WithDefaultEdgesDiagram ¶
func WithDefaultEdgesDiagram(name string) ExtensionOption
WithDefaultEdgesDiagram set default edges graph/diagram view component name
func WithForceGraph2D ¶
func WithForceGraph2D(options ForceGraph2DOptions) ExtensionOption
WithForceGraph2D use react-force-graph-2d for edges diagrams
func WithGoJs ¶
func WithGoJs(options GoJSOptions) ExtensionOption
WithGoJs use gojs for edges diagrams
func WithMeta ¶
func WithMeta(meta map[string]any) ExtensionOption
WithMeta add metadata to `{AppPath}/entrefine.json`
func WithSrcDirName ¶
func WithSrcDirName(name string) ExtensionOption
WithSrcDirName additional option to configure Refine repo code-source directory, default value is `src`
func WithTypeScriptPrefix ¶
func WithTypeScriptPrefix(prefix string) ExtensionOption
WithTypeScriptPrefix define typescript types/vars prefix
type ForceGraph2DOptions ¶
type ForceGraph2DOptions struct {
Enabled bool `json:"Enabled,omitempty"`
}
type GoJSOptions ¶
type RefineAnnotation ¶
type RefineAnnotation struct { TitleField bool `json:"TitleField,omitempty"` // Mark field as title of entity ImageField bool `json:"ImageField,omitempty"` // Mark field as image MainImageField bool `json:"MainImageField,omitempty"` // Mark field as main image of entity CodeField *CodeFieldOptions `json:"CodeField,omitempty"` // Mark field as code field URLField bool `json:"URLField,omitempty"` // Mark field as url field RichTextField bool `json:"RichTextField,omitempty"` // Mark field as rich text field NoList bool `json:"NoList,omitempty"` NoShow bool `json:"NoShow,omitempty"` NoCreate bool `json:"NoCreate,omitempty"` NoEdit bool `json:"NoEdit,omitempty"` HideOnList bool `json:"HideOnList,omitempty"` HideOnShow bool `json:"HideOnShow,omitempty"` HideOnForm bool `json:"HideOnForm,omitempty"` HideOnCreate bool `json:"HideOnCreate,omitempty"` HideOnUpdate bool `json:"HideOnUpdate,omitempty"` FilterOperator *string `json:"FilterOperator,omitempty"` Icon *string `json:"Icon,omitempty"` Label *string `json:"Label,omitempty"` Description *string `json:"Description,omitempty"` Prefix *string `json:"Prefix,omitempty"` Suffix *string `json:"Suffix,omitempty"` Actions []Action `json:"Actions,omitempty"` View *string `json:"View,omitempty"` ViewOnShow *string `json:"ViewOnShow,omitempty"` ViewOnList *string `json:"ViewOnList,omitempty"` ViewOnForm *string `json:"ViewOnForm,omitempty"` Badge *string `json:"Badge,omitempty"` EdgesDiagram *string `json:"EdgesDiagram,omitempty"` }
RefineAnnotation struct container of all annotations
func Actions ¶
func Actions(actions ...Action) RefineAnnotation
Actions actions/buttons on list items
func CodeField ¶
func CodeField(config *CodeFieldOptions) RefineAnnotation
CodeField mark field as a code field
func Description ¶
func Description(description string) RefineAnnotation
Description define description of field/entity todo: implement generator
func FilterOperator ¶
func FilterOperator(operator gen.Op) RefineAnnotation
FilterOperator define entity field filter operator
func Icon ¶
func Icon(icon string) RefineAnnotation
Icon define icon of entity that will be shown on navigations, breadcrumbs e.t.c.
func Label ¶
func Label(label string) RefineAnnotation
Label define label of field todo: implement generator
func MainImageField ¶
func MainImageField() RefineAnnotation
MainImageField mark field as a main image field
func NoList ¶
func NoList() RefineAnnotation
NoList disable entity browse, also hide from navigation
func Prefix ¶
func Prefix(prefix string) RefineAnnotation
Prefix add prefix to value of field todo: implement generator
func RichTextField ¶
func RichTextField() RefineAnnotation
RichTextField mark field as a rich text field (wysiwyg editor)
func ViewOnForm ¶
func ViewOnForm(name string) RefineAnnotation
ViewOnForm define field view on form
func ViewOnList ¶
func ViewOnList(name string) RefineAnnotation
ViewOnList define field view on list
func ViewOnShow ¶
func ViewOnShow(name string) RefineAnnotation
ViewOnShow define field view on show page
func (RefineAnnotation) Merge ¶
func (ra RefineAnnotation) Merge(other schema.Annotation) schema.Annotation
Merge implements the schema.Merger interface.
type RefineGen ¶
type RefineGen struct { Extension *Extension Entities []ent.Interface Graph *gen.Graph SkipModes SkipModes Ops []gen.Op Prefix string }