Documentation
¶
Overview ¶
Package editor enables users to create edit templates from their entities structs so that admins can manage entities
Index ¶
- Constants
- Variables
- func Checkbox(fieldName string, p interface{}, attrs map[string]string) []byte
- func DOMCheckboxSelfClose(e *Element) []byte
- func DOMElement(e *Element) []byte
- func DOMElementWithChildrenSelect(e *Element, children []*Element) []byte
- func DOMInputSelfClose(e *Element) []byte
- func FieldCollection(fieldName, label string, p interface{}, ...) []byte
- func File(publicPath, fieldName string, p interface{}, attrs map[string]string) []byte
- func FileRepeater(fieldName string, p interface{}, attrs map[string]string) []byte
- func Form(post Editable, fields ...Field) ([]byte, error)
- func Input(fieldName string, p interface{}, attrs map[string]string, args *FieldArgs) []byte
- func InputRepeater(fieldName string, p interface{}, attrs map[string]string) []byte
- func MultiSelectWithDataProvider(fieldName string, p interface{}, attrs map[string]string, args *FieldArgs, ...) []byte
- func Nested(fieldName string, p interface{}, args *FieldArgs, fields ...Field) []byte
- func NestedRepeater(publicPath, fieldName string, p interface{}, args *FieldArgs, ...) []byte
- func ReferenceSelect(publicPath, fieldName string, p interface{}, attrs map[string]string, ...) []byte
- func ReferenceSelectRepeater(publicPath, fieldName string, p interface{}, attrs map[string]string, ...) []byte
- func RepeatController(fieldName string, p interface{}, inputSelector, cloneSelector string) []byte
- func Richtext(fieldName string, p interface{}, attrs map[string]string, args *FieldArgs) []byte
- func Select(fieldName string, p interface{}, attrs map[string]string, options []string, ...) []byte
- func SelectWithDataProvider(fieldName string, p interface{}, attrs map[string]string, args *FieldArgs, ...) []byte
- func TagNameFromStructField(name string, post interface{}, args *FieldArgs) string
- func TagNameFromStructFieldMulti(name string, i int, post interface{}) string
- func Tags(fieldName string, p interface{}, attrs map[string]string) []byte
- func Textarea(fieldName string, p interface{}, attrs map[string]string) []byte
- func Timestamp(fieldName string, p interface{}, attrs map[string]string) []byte
- func ValueByName(name string, post interface{}, args *FieldArgs) reflect.Value
- func ValueFromStructField(name string, post interface{}, args *FieldArgs) interface{}
- type ContentMetadata
- type Editable
- type Editor
- type Element
- type Field
- type FieldArgs
- type FieldCollectionConstructor
- type MultiSelectData
- type NestedFieldGenerator
- type ReferenceSelectDataProvider
- type SelectClientOptionsProvider
- type SelectData
- type SelectInitialOptionsProvider
- type SelectOption
- type SelectType
- type Tab
Constants ¶
const PonzuFileStorageRoute = "/api/uploads"
Variables ¶
var ( SingleSelect SelectType = "single" MultipleSelect SelectType = "multiple" SelectOptionTemplate = ` <li class="mdc-list-item" role="option" data-value="@>id"> <span class="mdc-list-item__text">"@>name"</span> </li> ` // SelectedOptionTemplate is used on the client to render selected entry as a chip. // Must be synced with chip_template in multi_select.gohtml SelectedOptionTemplate = `` /* 458-byte string literal not displayed */ )
Functions ¶
func Checkbox ¶
Checkbox returns the []byte of a set of <input type="checkbox"> HTML elements wrapped in a <div> with a label. IMPORTANT: The `fieldName` argument will cause a panic if it is not exactly the string form of the struct field that this editor input is representing
func DOMCheckboxSelfClose ¶ added in v0.5.0
func DOMInputSelfClose ¶ added in v0.5.0
func FieldCollection ¶
func FieldCollection(fieldName, label string, p interface{}, types map[string]FieldCollectionConstructor) []byte
func File ¶
File returns the []byte of a <input type="file"> HTML element with a label. IMPORTANT: The `fieldName` argument will cause a panic if it is not exactly the string form of the struct field that this editor input is representing
func FileRepeater ¶
FileRepeater returns the []byte of a <input type="file"> HTML element with a label. It also includes repeat controllers (+ / -) so the element can be dynamically multiplied or reduced. IMPORTANT: The `fieldName` argument will cause a panic if it is not exactly the string form of the struct field that this editor input is representing
func Form ¶
Form takes editable entities and any number of Field funcs to describe the edit page for any entities struct added by a user
func Input ¶
Input returns the []byte of an <input> HTML element with a label. IMPORTANT: The `fieldName` argument will cause a panic if it is not exactly the string form of the struct field that this editor input is representing
type Person struct { item.Item editor editor.Editor Name string `json:"name"` //... } func (p *Person) MarshalEditor() ([]byte, error) { view, err := editor.Form(p, editor.Field{ Template: editor.Input("Name", p, map[string]string{ "label": "Name", "type": "text", "placeholder": "Enter the Name here", }), } ) }
func InputRepeater ¶
func MultiSelectWithDataProvider ¶ added in v0.6.0
func NestedRepeater ¶
func NestedRepeater(publicPath, fieldName string, p interface{}, args *FieldArgs, nestedFieldGenerator NestedFieldGenerator) []byte
func ReferenceSelect ¶ added in v0.6.0
func ReferenceSelect( publicPath, fieldName string, p interface{}, attrs map[string]string, args *FieldArgs, contentType string, ) []byte
ReferenceSelect returns the []byte of a <select> HTML element plus internal <options> with a label. IMPORTANT: The `fieldName` argument will cause a panic if it is not exactly the string form of the struct field that this editor input is representing
func ReferenceSelectRepeater ¶ added in v0.6.0
func ReferenceSelectRepeater( publicPath, fieldName string, p interface{}, attrs map[string]string, args *FieldArgs, contentType string, ) []byte
ReferenceSelectRepeater returns the []byte of a <select> HTML element plus internal <options> with a label. It also includes repeat controllers (+ / -) so the element can be dynamically multiplied or reduced. IMPORTANT: The `fieldName` argument will cause a panic if it is not exactly the string form of the struct field that this editor input is representing
func RepeatController ¶
RepeatController generates the javascript to control any repeatable form element in an editor based on its type, field name and HTML tag name
func Richtext ¶
Richtext returns the []byte of a rich text editor (provided by http://summernote.org/) with a label. IMPORTANT: The `fieldName` argument will cause a panic if it is not exactly the string form of the struct field that this editor input is representing
func Select ¶
func Select(fieldName string, p interface{}, attrs map[string]string, options []string, args *FieldArgs) []byte
Select returns the []byte of a <select> HTML element plus internal <options> with a label. IMPORTANT: The `fieldName` argument will cause a panic if it is not exactly the string form of the struct field that this editor input is representing
func SelectWithDataProvider ¶ added in v0.6.0
func TagNameFromStructField ¶
func TagNameFromStructFieldMulti ¶
TagNameFromStructFieldMulti calls TagNameFromStructField and formats is for use with gorilla/schema due to the format in which gorilla/schema expects form names to be when one is associated with multiple values, we need to output the name as such. Ex. 'category.0', 'category.1', 'category.2' and so on.
func Tags ¶
Tags returns the []byte of a tag input (in the style of Materialze 'Chips') with a label. IMPORTANT: The `fieldName` argument will cause a panic if it is not exactly the string form of the struct field that this editor input is representing
func Textarea ¶
Textarea returns the []byte of a <textarea> HTML element with a label. IMPORTANT: The `fieldName` argument will cause a panic if it is not exactly the string form of the struct field that this editor input is representing
func Timestamp ¶
Timestamp returns the []byte of an <input> HTML element with a label. IMPORTANT: The `fieldName` argument will cause a panic if it is not exactly the string form of the struct field that this editor input is representing
func ValueFromStructField ¶
ValueFromStructField returns the value of a field in a struct
Types ¶
type ContentMetadata ¶
type ContentMetadata struct {
TypeName string
}
type Element ¶
type Element struct { TagName string Attrs map[string]string Name string Label string Data string ViewBuf *bytes.Buffer }
Element is a basic struct for representing DOM elements
type Field ¶
type Field struct {
View []byte
}
Field is used to create the editable view for a field within a particular entities struct
type FieldCollectionConstructor ¶ added in v0.8.0
type MultiSelectData ¶ added in v0.6.0
type MultiSelectData struct { SelectData Selected []string }
type NestedFieldGenerator ¶ added in v0.7.1
type ReferenceSelectDataProvider ¶ added in v0.6.0
type ReferenceSelectDataProvider struct { ContentType string PublicPath string OptionTemplate string SelectedOptionTemplate string SelectType }
func (*ReferenceSelectDataProvider) RenderClientOptionsProvider ¶ added in v0.6.0
func (provider *ReferenceSelectDataProvider) RenderClientOptionsProvider(w io.Writer, selector string) error
type SelectClientOptionsProvider ¶ added in v0.6.0
type SelectData ¶ added in v0.6.0
type SelectInitialOptionsProvider ¶ added in v0.6.0
type SelectInitialOptionsProvider interface {
GetInitialOptions() ([]SelectOption, error)
}
type SelectOption ¶ added in v0.7.0
type SelectType ¶ added in v0.6.0
type SelectType string