Documentation
¶
Overview ¶
Package gen is a solution to the problem: How do you create HTML code dynamically?
In a web framework like Angular or React you can create a number of components out of markup, Typescript, and other code and then place those components inside other components. When the framework is compiled, the references between components are results and the output "dist" or distributable contains regular HTML, CSS, and Javascript files. In some other frameworks the references are resolved at runtime, which allows for a lot more flexibility. We COULD use a framework which resolves references at runtime, and when a user builds a form we could insert components with configuration into a file or template. Then we would run the compilation step of React (or Angular or whatever the framework is). This would give us either HTML or something else which we can run in order to run a web server.
In the case of "getting something else which we can run in order to run a web server" as with Angular, a user generating a new form would mean recompiling the entire project and then restarting the entire web server with the new components. That is too expensive of an operation, and would both disrupt other user's experience and cause tons of problems when many users are editing forms at the same time. Incidentally, this is why Angular was abandoned in this project.
In the case of generating HTML after running it through the build process it SHOULD be possible to add more routes dynamically without restarting the web server. The biggest reason this is not done is the long compile time of many of these web frameworks. For instance, Angular's incremental compile time is over 1 second. I wanted a user experience which functioned as fast as possible, and although a developer might be willing to wait a couple of seconds to compile the UI, I am not.
There is also a simpler argument against using a front-end framework (other than Bootstrap) to generate the components. These frameworks are designed to make a developer's life easier, and involve writing something simple, translating that into HTML, and then delivering that HTML to the client. Compare that to writing HTML directly and then sending it to the client. The difference? Not using a compilation step cuts out work. Compiling / using a framework introduces an extra step, and that's the opposite of keeping it simple, stupid.
Putting the discussion aside, this package contains HTML code. The HTML is placed into strings which are parsed as templates from text/template or html/template. This allows sufficient flexibility to create any web form. Obviously forms do not exist in a vaccuum and these forms need quite a bit of javascript to work well. Therefore some components are coupled to specific Javascript functions in main.js or 'if' cases in that code. They also use data-??? properties sometimes to communicate necessary information to the client-side javascript.
Index ¶
- func GenAlert(alert Alert, w io.Writer) error
- func GenAudioPlayer(a AudioPlayer, w io.Writer) error
- func GenAudioUpload(a AudioUpload, w io.Writer) error
- func GenBootstrapTheme(b BootstrapTheme, w io.Writer) error
- func GenBootstrapThemeDirectToCSS(b BootstrapThemeDirectToCSS, w io.Writer) error
- func GenBreadcrumbs(breadcrumbs Breadcrumbs, writer io.Writer) error
- func GenCover(c Cover, writer io.Writer) (fontLinks string, err error)
- func GenDiscussionThread(d DiscussionThread, w io.Writer) error
- func GenFormError(formError FormError, w io.Writer) error
- func GenFullTextSearch(f FullTextSearch, w io.Writer) error
- func GenGalleryEnd(w io.StringWriter)
- func GenGalleryStart(w io.StringWriter)
- func GenGeolocationAPI(g GeolocationAPI, w io.Writer) error
- func GenGiantLinks(input GiantLinks, writer io.Writer) error
- func GenGiantOptionSelect(input GiantOptionSelect, writer io.Writer) error
- func GenIFrame(IFrame IFrame, writer io.Writer) error
- func GenIconButton(IconButton IconButton, writer io.Writer) error
- func GenImage(image Image, w io.Writer) error
- func GenImageMedium(image Image, w io.Writer) error
- func GenImageSmall(image Image, w io.Writer) error
- func GenImageUpload(upload ImageUpload, w io.Writer) error
- func GenLabeledInput(inputs []LabeledInput, writer io.Writer) error
- func GenLink(navRef NavigationRef, writer io.Writer) error
- func GenList(l List, w io.Writer) error
- func GenListAccordion(listGeneric ListAccordion, w io.Writer) error
- func GenListLabeledInput(labeledInput ListLabeledInput, writer io.Writer) error
- func GenListSelectID(s ListSelectID, w io.Writer) error
- func GenNavigationBar(navBar NavigationBar, writer io.Writer) error
- func GenNestedAccordion(nestedAccordions []NestedAccordion, writer io.Writer) error
- func GenOneToOneFromTo(inputs []OneToOneFromTo, writer io.Writer) error
- func GenPlaceAutocomplete(PlaceAutocomplete PlaceAutocomplete, writer io.Writer) error
- func GenPredictFloat(f PredictFloat, w io.Writer) error
- func GenReportList(reportList []ReportListItem, w io.Writer) error
- func GenSearchLabeledInput(searchLabeledInput SearchLabeledInput, writer io.Writer) error
- func GenSearchLabeledInputResults(searchLabeledInputResult SearchLabeledInputResult, writer io.Writer) error
- func GenSectionEnd(start SectionStart, w io.StringWriter)
- func GenSectionStart(start SectionStart, w io.StringWriter)
- func GenSectionTaskStart(start SectionStart, polyappRef string, RefInParent string, w io.StringWriter)
- func GenSelectID(s SelectID, w io.Writer) error
- func GenSelectIDNoResultsHTML() string
- func GenSelectIDResultHTML(results []SelectIDResult, w io.Writer) error
- func GenSelectInput(input SelectInput, writer io.Writer) error
- func GenSimpleContainer(simpleContainer SimpleContainer, writer io.Writer) error
- func GenStaticContent(staticContent StaticContent, writer io.Writer) error
- func GenSummernote(summernote Summernote, w io.Writer) error
- func GenTable(table Table, writer io.Writer) error
- func GenTaskList(taskListItem []TaskListItem, w io.Writer) error
- func GenTextButton(TextButton TextButton, writer io.Writer) error
- func GenTime(ti Time, writer io.Writer) error
- func GenToast(t Toast, w io.Writer) error
- func GenUpload(u Upload, w io.Writer) error
- func GenVideo(video Video, w io.Writer) error
- func GenWorkflowNavigation(workflowNavigation WorkflowNavigation, w io.Writer) error
- type Alert
- type AudioPlayer
- type AudioUpload
- type BootstrapTheme
- type BootstrapThemeDirectToCSS
- type Breadcrumbs
- type Column
- type Cover
- type DiscussionThread
- type DiscussionThreadComment
- type FormError
- type FullTextSearch
- type GeolocationAPI
- type GiantLinks
- type GiantOptionSelect
- type IFrame
- type IconButton
- type Image
- type ImageUpload
- type LabeledInput
- type LabeledInputBy
- type List
- type ListAccordion
- type ListItem
- type ListLabeledInput
- type ListSelectID
- type ListSelectIDInitialValue
- type NavigationBar
- type NavigationRef
- type NestedAccordion
- type OneToOneFromTo
- type OneToOneFromToBy
- type OneToOneFromToSorter
- type PlaceAutocomplete
- type PredictFloat
- type ReportListItem
- type SearchLabeledInput
- type SearchLabeledInputResult
- type SectionStart
- type SelectID
- type SelectIDResult
- type SelectInput
- type SelectOption
- type SimpleContainer
- type StaticContent
- type Summernote
- type Table
- type TaskListItem
- type TextButton
- type Time
- type Toast
- type Upload
- type Video
- type WorkflowNavigation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenAlert ¶
GenAlert generates markup for an Alert. This could be inserted after some text to indicate a validation failure.
func GenAudioPlayer ¶
func GenAudioPlayer(a AudioPlayer, w io.Writer) error
GenAudioPlayer allows generating a control which can play audio.
func GenAudioUpload ¶
func GenAudioUpload(a AudioUpload, w io.Writer) error
GenAudioUpload generates a control which is used to upload audio.
func GenBootstrapTheme ¶
func GenBootstrapTheme(b BootstrapTheme, w io.Writer) error
GenBootstrapTheme uses the data in BootstrapTheme to create custom theme overrides for Bootstrap. It then runs an external program to turn those
func GenBootstrapThemeDirectToCSS ¶
func GenBootstrapThemeDirectToCSS(b BootstrapThemeDirectToCSS, w io.Writer) error
GenBootstrapThemeDirectToCSS directly inserts the Bootstrap Theme variables into the CSS which is normally output by a SASS compiler.
This method is prone to breaking, but it is safer and faster than relying on a third party package to provide this functionality.
func GenBreadcrumbs ¶
func GenBreadcrumbs(breadcrumbs Breadcrumbs, writer io.Writer) error
GenBreadcrumbs generates a URL-like list of links.
func GenCover ¶
GenCover generates a Cover, which is comprised of an image or video over a colored background and may include a heading or subheading. The returned headings are optimized to improve loading speed.
GenCover returns a string, fontLinks, which must be added to the header. It also can return an error.
func GenDiscussionThread ¶
func GenDiscussionThread(d DiscussionThread, w io.Writer) error
GenDiscussionThread is an []string control where only the last part of the array is editable. After clicking the "Done" button the current time and date and the user's name are affixed to the output and the text is rendered as HTML.
Summernote is used to edit the posts.
func GenFormError ¶
GenFormError generates markup for a little thing that goes under forms which have an error. To use this properly, you will also need to...
func GenFullTextSearch ¶
func GenFullTextSearch(f FullTextSearch, w io.Writer) error
GenFullTextSearch generates a control which is used to upload audio.
func GenGalleryEnd ¶
func GenGalleryEnd(w io.StringWriter)
func GenGalleryStart ¶
func GenGalleryStart(w io.StringWriter)
func GenGeolocationAPI ¶
func GenGeolocationAPI(g GeolocationAPI, w io.Writer) error
GenGeolocationAPI generates a read-only field which holds Latitude and Longitude coordinates of the position which was set when "Set Position" button was pressed. It also generates the "Set Position" button.
func GenGiantLinks ¶
func GenGiantLinks(input GiantLinks, writer io.Writer) error
GenGiantLinks generates giant buttons which are links to different pages.
func GenGiantOptionSelect ¶
func GenGiantOptionSelect(input GiantOptionSelect, writer io.Writer) error
GenGiantOptionSelect generates an Input which allows you to select between some giant options. The input TODO make this component keyboard accessible. It probably needs JS. https://www.w3.org/TR/2016/WD-wai-aria-practices-1.1-20160317/examples/radio/radio.html
func GenIconButton ¶
func GenIconButton(IconButton IconButton, writer io.Writer) error
GenIconButton generates a button containing an image in Template.
func GenImage ¶
GenImage displays images as part of a gallery with captions or simply in a responsive container.
func GenImageMedium ¶
GenImageMedium wraps GenImage and ensures that the image does not exceed a certain size. In general, the image size in GenImageMedium is set up to take up the full width on small screens like phones and then expand to up to 2 images wide on 1980 x 1080 screens.
func GenImageSmall ¶
GenImageSmall wraps GenImage and ensures that the image does not exceed a certain size. In general, the image size in GenImageSmall is set up to take up the full width on small screens like phones, has 2 columns on iPads, and 4 images wide on large screens.
func GenImageUpload ¶
func GenImageUpload(upload ImageUpload, w io.Writer) error
GenImageUpload for a control which allows uploading only images.
func GenLabeledInput ¶
func GenLabeledInput(inputs []LabeledInput, writer io.Writer) error
GenLabeledInput creates Template out of an array of LabeledInput.
func GenLink ¶
func GenLink(navRef NavigationRef, writer io.Writer) error
GenLink generates a simple link.
func GenList ¶
GenList allows generating a static, read-only list control attached to an array of booleans. When an element in this control is clicked the boolean index in Data is set.
func GenListAccordion ¶
func GenListAccordion(listGeneric ListAccordion, w io.Writer) error
GenListAccordion is of a list of Accordion elements which can be expanded to reveal additional content. Each Accordion element inside the list is part of a separate Task and is created with GenNestedAccordion.
func GenListLabeledInput ¶
func GenListLabeledInput(labeledInput ListLabeledInput, writer io.Writer) error
GenListLabeledInput is an ordered list of elements attached to a single label and field. labeledInput it used as a template for what a singleton of this list should look like. Each element in the list is given the ID_# where # starts at 1 and increases sequentially. There is only one wrapper, label, initial value, and type.
func GenListSelectID ¶
func GenListSelectID(s ListSelectID, w io.Writer) error
GenListSelectID is an ID Selection control which allows you to choose a Data, Task, Schema, or other collection's ID as those this were a list of <select> controls.
The person typing searches a particular field in a particular collection. The <select> is populated on the server with up to 100 values when a GET request is made.
func GenNavigationBar ¶
func GenNavigationBar(navBar NavigationBar, writer io.Writer) error
GenNavigationBar generates a Navigation Bar which should be placed at the top of the body of an HTML document.
func GenNestedAccordion ¶
func GenNestedAccordion(nestedAccordions []NestedAccordion, writer io.Writer) error
GenNestedAccordion wraps a nested component which can contain any number of fields and other things inside an Accordion such that users can expand or contract the accordion pieces to see or hide the Ref.
Because this is a layout component it uses text/template instead of html/template.
func GenOneToOneFromTo ¶
func GenOneToOneFromTo(inputs []OneToOneFromTo, writer io.Writer) error
GenOneToOneFromTo creates Template out of an array of OneToOneFromTo.
func GenPlaceAutocomplete ¶
func GenPlaceAutocomplete(PlaceAutocomplete PlaceAutocomplete, writer io.Writer) error
GenPlaceAutocomplete generates a Google Place Autocomplete form field.
func GenPredictFloat ¶
func GenPredictFloat(f PredictFloat, w io.Writer) error
func GenReportList ¶
func GenReportList(reportList []ReportListItem, w io.Writer) error
GenReportList creates a list of cards. Each card displays information about a Report - a preview, its Name, Help Text, etc - and links to edit the report and view the report.
func GenSearchLabeledInput ¶
func GenSearchLabeledInput(searchLabeledInput SearchLabeledInput, writer io.Writer) error
GenSearchLabeledInput generates a text control which has some associated JS which can display search results as you type them.
func GenSearchLabeledInputResults ¶
func GenSearchLabeledInputResults(searchLabeledInputResult SearchLabeledInputResult, writer io.Writer) error
GenSearchLabeledInputResults generates some UI used in search results.
Use DeleteSelector: "#{{.SearchLabeledInputID}}-ResultsWrapper".
Use InsertSelector: "#{{.SearchLabeledInputID}}-Wrapper".
Use Action: "beforeend"
func GenSectionEnd ¶
func GenSectionEnd(start SectionStart, w io.StringWriter)
func GenSectionStart ¶
func GenSectionStart(start SectionStart, w io.StringWriter)
GenSectionStart starts a new Section.
func GenSectionTaskStart ¶
func GenSectionTaskStart(start SectionStart, polyappRef string, RefInParent string, w io.StringWriter)
GenSectionTaskStart creates a subtask in the UX which contains this Section.
sectionID MUST be of the 'polyappRef' format. This can be created with common.CreateRef. Do not escape it nor add the polyappRef prefix.
func GenSelectID ¶
GenSelectID an ID Selection control which allows you to choose a Data, Task, Schema, or other collection's ID as those this were a <select>.
The person typing searches a particular field in a particular collection. The <select> is populated on the server with up to 100 values when a GET request is made.
func GenSelectIDNoResultsHTML ¶
func GenSelectIDNoResultsHTML() string
GenSelectIDNoResultsHTML generates some HTML which can be appended to the end of a GenSelectID.
func GenSelectIDResultHTML ¶
func GenSelectIDResultHTML(results []SelectIDResult, w io.Writer) error
GenSelectIDResultHTML generates some HTML which can be appended to the end of a GenSelectID. When one of the results is clicked, it updates the GenSelectID appropriately.
func GenSelectInput ¶
func GenSelectInput(input SelectInput, writer io.Writer) error
GenSelectInput generates an Input of type Select. TODO make this component keyboard accessible with things like aria-selected attribute.
func GenSimpleContainer ¶
func GenSimpleContainer(simpleContainer SimpleContainer, writer io.Writer) error
GenSimpleContainer generates a Div with a Container class
func GenStaticContent ¶
func GenStaticContent(staticContent StaticContent, writer io.Writer) error
GenStaticContent generates some static stuff
func GenSummernote ¶
func GenSummernote(summernote Summernote, w io.Writer) error
GenSummernote generates a full-fledged text editor called Summernote.
func GenTaskList ¶
func GenTaskList(taskListItem []TaskListItem, w io.Writer) error
GenTaskList creates a list of TaskListItems. It displays information about a Task - its Name, Help Text, etc - and links to important pages for the Task like "Change Data", "New Data", and "Edit Task".
func GenTextButton ¶
func GenTextButton(TextButton TextButton, writer io.Writer) error
GenTextButton generates a TextButton in Template.
func GenTime ¶
GenTime generates a date + time control by default. It can also generate a date-only control or a time-only control. https://getdatepicker.com/4/
func GenToast ¶
GenToast generates a Toast, which is typically used for notifications or showing errors.
func GenWorkflowNavigation ¶
func GenWorkflowNavigation(workflowNavigation WorkflowNavigation, w io.Writer) error
GenWorkflowNavigation creates a vertical navigation bar.
Types ¶
type Alert ¶
type Alert struct { // Text is the text of the error Text string // Severity is the severity of the error: "success", "info", "warning", "danger", "primary", "secondary", "dark", "light" Severity string }
Alert generates markup for a very visible alert.
type AudioPlayer ¶
type AudioPlayer struct { Title string // Title describes the audio. Subtitle string // Subtitle could include the artist's name or other information. Style string // Style is either "light" or "dark" Src string // Src is the full path to the audio file we'll be playing. }
AudioPlayer allows generating a control which can play audio.
func (AudioPlayer) Validate ¶
func (a AudioPlayer) Validate() error
Validate returns an error if the AudioPlayer object is not valid.
type AudioUpload ¶
AudioUpload can be used to upload an audio file.
func (AudioUpload) Validate ¶
func (a AudioUpload) Validate() error
Validate returns an error if not all required inputs are populated.
type BootstrapTheme ¶
type BootstrapTheme struct { // Primary is the primary color used in the template. Primary string // Secondary color Secondary string // Success color Success string // Info color Info string // Warning color Warning string // Danger color Danger string // Light color Light string // Dark color Dark string // BodyBackground is the color for the body's background. BodyBackground string // Body is the color of the body Body string }
func (*BootstrapTheme) Validate ¶
func (b *BootstrapTheme) Validate() error
type BootstrapThemeDirectToCSS ¶
type BootstrapThemeDirectToCSS struct { // Primary is the primary color used in the template. Primary string // Secondary color Secondary string // Light color Light string // Dark color Dark string // BodyBackground is the color for the body's background. BodyBackground string }
func (*BootstrapThemeDirectToCSS) Validate ¶
func (b *BootstrapThemeDirectToCSS) Validate() error
type Breadcrumbs ¶
type Breadcrumbs struct { // ID of the Breadcrumbs class ID string NavigationReferences []NavigationRef }
Breadcrumbs is used to show the current position in the application, like "Photos / Summer 2017 / Italy / Rome" Breadcrumbs OUGHT to be convertible to URLs, like polyapp.tech/task/polyapp/bot/create Breadcrumbs assumes that the last element in the breadcrumb is active.
func (Breadcrumbs) Validate ¶
func (b Breadcrumbs) Validate() error
Validate ensures the correct fields are populated without validating the output.
type Cover ¶
type Cover struct { // Scaling must be "Resize". If "Resize" the image is made smaller on smaller screen sizes. Scaling string // MediaURL is a URL of where to find the media used in the Cover. MediaURL string // AltText (optional) is the alt text placed on the media from MediaURL. AltText string // BackgroundColor (optional) for the Cover. BackgroundColor string // TextColor (optional) for the Cover. Default black. TextColor string // Heading (optional) for the Cover. Heading string // HeadingFont (optional) for the Cover. From the list of Google Fonts families. HeadingFont string // Subheading (optional) for the Cover. Subheading string // SubheadingFont (optional) for the Cover. From the list of Google Fonts families. SubheadingFont string }
type DiscussionThread ¶
type DiscussionThread struct { Label string ID string InitialComments []DiscussionThreadComment Readonly bool }
func (DiscussionThread) Validate ¶
func (d DiscussionThread) Validate() error
type DiscussionThreadComment ¶
type FormError ¶
type FormError struct { // Text is the text of the error Text string }
FormError generates markup for a validation error.
type FullTextSearch ¶
type FullTextSearch struct { ID string Label string HelpText string Readonly bool Collection string }
FullTextSearch can be used to upload an audio file.
func (FullTextSearch) Validate ¶
func (a FullTextSearch) Validate() error
Validate returns an error if not all required inputs are populated.
type GeolocationAPI ¶
func (GeolocationAPI) Validate ¶
func (g GeolocationAPI) Validate() error
type GiantLinks ¶
type GiantLinks struct { // Label for the links Label string // Links are the locations you wish to navigate to. I strongly recommend only using partial paths, ie /design Links []NavigationRef }
GiantLinks are giant links buttons. This should be the only thing on the page. WrapperID is auto-generated.
func (GiantLinks) Validate ¶
func (g GiantLinks) Validate() error
type GiantOptionSelect ¶
type GiantOptionSelect struct { // WrapperID is the ID of the surrounding element WrapperID string // Name of the input should be the field we're writing to's name Name string // Label for the options Label string // SelectOptions the labels of the options you can select and their values when submitted to the server. SelectOptions []SelectOption }
GiantOptionSelect can be used to create giant buttons which are tied to the same field.
func (GiantOptionSelect) Validate ¶
func (g GiantOptionSelect) Validate() error
Validate ensures the correct fields are populated without validating the output.
type IFrame ¶
type IFrame struct { // ID of the IFrame ID string // Source is the website the IFrame is showing Source string // Title describes the contents inside the IFrame. Title string }
IFrame can be used to create a simple IFrame
type IconButton ¶
type IconButton struct { // ID of the button ID string // ImagePath is a path in the public folder like "/assets/icons/edit-24px.svg" // It should be a full path, not a partial path. ImagePath string // AltText is used by users with screen readers to identify the image and the button. It should be a set of capitalized words without a period. AltText string // Text (optional) is some text to show to the right of the icon. You can't show it to the left of the icon intentionally. Text string // Inline (optional) places the button with inline-block. Inline bool // Readonly (optional) disables this button Readonly bool // NoBorder (optional) removes the 1px border. NoBorder bool }
IconButton can be used to create a button composed solely of an Icon and the button. Aka an image button. A related concept is the IconRadioInput. TODO create IconRadioInput and use it for the side bar.
func (IconButton) Validate ¶
func (b IconButton) Validate() error
type Image ¶
type Image struct { // ID of the element which contains the image src. ID string // URL is the image's src property. URL string // AltText is the text which describes what is in the image. It is used primarily by the blind. AltText string // Packed is true if you wish this image to not have any padding. False if you want about 15px of padding on the sides. // This setting is ignored for images which take up the full width of a container such as GenImage() calls. Packed bool // Layout is one of: "Title and Caption Below","Title on Top; Caption Below", "Show Title in Middle on Hover", "Show Title and Caption in Middle on Hover", // "Show Title and Caption on Bottom on Hover", "Show Title on Bottom on Hover". Layout string // Width (optional; used in responsive) is the width of the image Width string // Height (optional; used in responsive) is the height of the image Height string // Title (optional) is the title of the image. Title string // Caption (optional) is the text underneath the image in "captioned" Type. Caption string // Link (optional) is a URL to send the user to if the image is clicked on. By default there is no link applied to the image. Link string }
type ImageUpload ¶
type ImageUpload struct { // ID of the input element. ID string // Label above the input element. It's not actually a label, it's a <p> Label string // HelpText for this field. HelpText string // AllowMultiple (optional) allows multiple images to be uploaded with this control. AllowMultiple bool }
func (*ImageUpload) Validate ¶
func (i *ImageUpload) Validate() error
type LabeledInput ¶
type LabeledInput struct { // WrapperID is optional. It is the ID of the surrounding element. WrapperID string // Label is the Label of the input Label string // HelpText for this field. This is required. HelpText string // ID is the ID of the actual input ID string // InitialValues is the initial value of the field. InitialValue string // Type is the type of the input. "text", "textarea", "checkbox", "radio", "number", "color", "ref" Type string // Readonly is optional. If set, the field becomes read-only. Readonly bool // AutocompleteOff. If set, the field will not use autocomplete. AutocompleteOff bool }
LabeledInput can be used to get Input Template with GenLabeledInput.
func (LabeledInput) Validate ¶
func (labeledInput LabeledInput) Validate() error
Validate ensures the correct fields are populated without validating the output.
type LabeledInputBy ¶
type LabeledInputBy func(li1 *LabeledInput, li2 *LabeledInput) bool
LabeledInputSort sorts LabeledInput by the label itself. It follows a pattern similar to the SortKeys example in https://golang.org/pkg/sort/
func (LabeledInputBy) Sort ¶
func (by LabeledInputBy) Sort(lis []LabeledInput)
Sort is a method on the function type that sorts the argument slice according to the function.
type List ¶
List allows generating a static, read-only list control attached to an array of booleans. When an element in this control is clicked the boolean index in Data is set.
type ListAccordion ¶
type ListAccordion struct { // ID of the container. Must start with "_" for the convenience of the UI. ID string // Label is shown to users as the header. Label string // HelpText of this list. HelpText string // Deprecated. RenderedSubTasks are the already-populated templates of the subtasks. // Deprecated because this barely works if someone is loading information from a real field. You could argue this is OK // for static lists which can not be removed from / added to, but that's now how this control is currently set up. RenderedSubTasks []string // Deprecated. SubTaskNames has 1 entry for every RenderedSubTasks and is shown to users when the subtask is collapsed. // Deprecated because this barely works if someone is loading information from a real field. You could argue this is OK // for static lists which can not be removed from / added to, but that's now how this control is currently set up. SubTaskNames []string // Deprecated. SubTaskRefs are Refs. For more information about Ref, see common.Data. SubTaskRefs []string // DisplayNoneRenderedSubTask is a model list item. You probably need to examine func GenListLabeledInput to know what this means. // Deprecated because this barely works if someone is loading information from a real field. You could argue this is OK // for static lists which can not be removed from / added to, but that's now how this control is currently set up. DisplayNoneRenderedSubTask string // DisplayNoneTitleField is a field like "industry_domain_schema_some field" DisplayNoneTitleField string // DisplayNoneSubTaskRef is a Ref used when adding an element to the list. Its Data will be replaced, but not its UX or Schema. // // This should be constructed using this format: common.CreateRef("industry", "domain", "task", "ux", "schema", "polyappShouldBeOverwritten") // // For more information about Ref, see common.Data. DisplayNoneSubTaskRef string }
ListAccordion is a component which contains at its highest level a list. This component is designed to hold extremely generic elements so that it can hold a list of SubTasks. Because it is so generic, you must provide your own DisplayNoneRenderedSubTask which will play nice with main.js.
func (*ListAccordion) Validate ¶
func (l *ListAccordion) Validate() error
Validate ensures the correct fields are populated without validating the output.
type ListItem ¶
type ListItem struct { Heading string // Heading (optional) sets a h5 element at the top of the list item. SmallTopRight string // SmallTopRight (optional) sets a <small> element to the right of the Heading. Content string // Content (optional) sets a p element in the middle of the list item. SmallBottom string // SmallBottom (optional) sets a <small> and muted text on the bottom of the list item. ID string // ID (do not set). This is set based on the parent List's ID. }
ListItem controls the information contained in the list. Its elements mirror those in Bootstrap's List Group Custom Content example: https://getbootstrap.com/docs/4.6/components/list-group/#custom-content
type ListLabeledInput ¶
type ListLabeledInput struct { // HelpText is shown along with the control. HelpText string // Label is the Label of the input. There is only one label for the list. Label string // ID is the ID base of the inputs. The actual IDs will be {{.ID}}_# or {{.ID}} in the case of the wrapper ID. ID string // InitialValues is the initial value of the fields. InitialValues []string // DefaultValue is the default value of the fields if they are created anew. DefaultValue string // Type is the type of the input. "text", "number", "checkbox", "ref" Type string // Readonly disables all buttons in this control Readonly bool }
ListLabeledInput constructs a list of labeled input controls.
func (ListLabeledInput) Validate ¶
func (l ListLabeledInput) Validate() error
type ListSelectID ¶
type ListSelectID struct { Label string HelpText string ID string Collection string Field string // Field includes prefixes. Examples: "polyappIndustryID" or "ind_dom_sch_field" Readonly bool InitialValues []ListSelectIDInitialValue DisplayNoneItem ListSelectIDInitialValue // not required; overridden by parent }
func (ListSelectID) Validate ¶
func (s ListSelectID) Validate() error
type NavigationBar ¶
type NavigationBar struct { string Theme string NavigationRefs []NavigationRef }LogoSrc
NavigationBar represents the bar at the top of the screen which holds navigation links.
func (NavigationBar) Validate ¶
func (n NavigationBar) Validate() error
Validate returns an error if the NavigationBar will not render correctly.
type NavigationRef ¶
NavigationRef creates an 'a' tag.
func (NavigationRef) Validate ¶
func (navigationRef NavigationRef) Validate() error
Validate ensures the correct fields are populated without validating the output.
type NestedAccordion ¶
type NestedAccordion struct { // TitleField is the field name (id) whose value is shown when the section is collapsed or expanded. TitleField string // TitleStatic (optional) is used instead of TitleField. It's a static title for this section. TitleStatic string // Ref is a Reference to the document which InnerContent contains. Documentation about Ref format can be found under common.Data Ref string // InnerContent is placed inside the Accordion area when the Accordion is expanded. InnerContent string }
NestedAccordion wraps a nested component which can contain any number of fields and other things inside an Accordion such that users can expand or contract the accordion pieces to see or hide the Ref.
WrapperID is automatically assigned. There is no way to access the accordion elements via this component.
func (NestedAccordion) Validate ¶
func (n NestedAccordion) Validate() error
Validate ensures the correct fields are populated without validating the output.
type OneToOneFromTo ¶
type OneToOneFromTo struct { // WrapperID of the outermost div WrapperID string // HelpText of this component HelpText string // FromID is the ID of the field hosting the 'From' FromID string // FromLabel is the label of the field hosting the 'From' FromLabel string // FromInitialValue is the initial value of the 'From' field FromInitialValue string // FromType is the type of the To field; "text" "textarea" "number" "checkbox" FromType string // ToID is the ID of the field hosting the 'To'. ToID string // ToLabel is the label of the field hosting the 'To' ToLabel string // ToInitialValue is the initial value of the 'To' field ToInitialValue string // ToType is the type of the To field; "text" "textarea" "number" "checkbox" ToType string }
OneToOneFromTo is a simple component which shows a 'from' field and a 'to' field. It assumes we're mapping from a string to a string.
func (OneToOneFromTo) Validate ¶
func (o OneToOneFromTo) Validate() error
Validate ensures the correct fields are populated without validating the output.
type OneToOneFromToBy ¶
type OneToOneFromToBy func(li1 *OneToOneFromTo, li2 *OneToOneFromTo) bool
OneToOneFromToSort sorts OneToOneFromTo by the label itself. It follows a pattern similar to the SortKeys example in https://golang.org/pkg/sort/
func (OneToOneFromToBy) Sort ¶
func (by OneToOneFromToBy) Sort(lis []OneToOneFromTo)
Sort is a method on the function type that sorts the argument slice according to the function.
type OneToOneFromToSorter ¶
type OneToOneFromToSorter struct {
// contains filtered or unexported fields
}
OneToOneFromToSorter helps with sorting.
func (*OneToOneFromToSorter) Len ¶
func (s *OneToOneFromToSorter) Len() int
Len is part of sort.Interface.
func (OneToOneFromToSorter) Less ¶
func (s OneToOneFromToSorter) Less(i, j int) bool
Sort is a method on the function type, By, that sorts the argument slice.
func (*OneToOneFromToSorter) Swap ¶
func (s *OneToOneFromToSorter) Swap(i, j int)
Swap is part of sort.Interface.
type PlaceAutocomplete ¶
type PlaceAutocomplete struct { // Label is the Label of the input Label string // HelpText for this field HelpText string // ID is the ID of the actual input ID string // Readonly is optional. If set, the field becomes read-only. Readonly bool // APIKey is optional. If not set, the key used by Polyapp is used. APIKey string }
func (PlaceAutocomplete) Validate ¶
func (p PlaceAutocomplete) Validate() error
type PredictFloat ¶
func (PredictFloat) Validate ¶
func (p PredictFloat) Validate() error
type ReportListItem ¶
type ReportListItem struct { // ID is optional. ID string Name string HelpText string EditReportLink string ViewReportLink string }
ReportListItem is a card which can be used as a list item. It displays information about a Report - a preview, its Name, Help Text, etc - and links to edit the report and view the report.
func (ReportListItem) Validate ¶
func (r ReportListItem) Validate() error
type SearchLabeledInput ¶
type SearchLabeledInput struct { // Label is the Label of the input. Label string // HelpText for this input. HelpText string // ID is the ID of the field. ID string // InitialValues is the initial value of the field. InitialValue string // QueryPrefixedField is an array field you are querying for a value across. Ex: polyapp_Schema_polyappSchema_DataKeys. // If the field is not found or it is an Array, this will result in an error. QueryPrefixedField string }
SearchLabeledInput is similar to a labeled input except when a user types into the box a search query is initiated and the query results appear below what has been typed. This control only supports "text" inputs and all queries are assumed to be trying to find duplicates. Wrapper element is always set to {{.ID}}-Wrapper
func (SearchLabeledInput) Validate ¶
func (l SearchLabeledInput) Validate() error
type SearchLabeledInputResult ¶
type SearchLabeledInputResult struct { // Results are strings which are the search results. When clicked the input box is populated with these values. Results []string // SearchLabeledInputID is the ID of the input this is being inserted underneath. // // Ex. results SearchLabeledInputID string }
SearchLabeledInputResult should be inserted into the DOM beforeend WrapperID for searchLabeledInputTemplate
func (SearchLabeledInputResult) Validate ¶
func (s SearchLabeledInputResult) Validate() error
type SectionStart ¶
type SectionStart struct { // BackgroundColor is set to any valid CSS color. BackgroundColor string // SectionRow is the # of the section on the page. If this is even or odd it can change the styles used. SectionRow int // IsLastRow if true, this row expands to take up the remainder of the page. IsLastRow bool // Layout is one of: "Max Width", "2 Column", or "Standard" (default). Layout string }
SectionStart defines options for Sections.
type SelectID ¶
type SelectIDResult ¶
type SelectInput ¶
type SelectInput struct { // WrapperID (optional) is the ID of the surrounding element WrapperID string // HelpText to guide users. HelpText string // ID of the input ID string // Label for the full selection list Label string // SelectOptions the labels of the options you can select (and their values when submitted to the server). SelectOptions []SelectOption // MultiSelect, if true, allows selecting multiple options MultiSelect bool // TransmitUpdateNow, if set, forces Polyapp to immediately update the server when this field's value changes. TransmitUpdateNow bool }
SelectInput can be used to create an Input of type Select
func (*SelectInput) Validate ¶
func (s *SelectInput) Validate() error
Validate ensures the correct fields are populated without validating the output.
type SelectOption ¶
type SelectOption struct { // Selected is whether this option begins selected. Selected bool // Value is what the field will be set to in the database. This must be populated. // // Suggested value: "No Select Options Found. This may be an error with how the UX has been constructed." Value string // ID is always optional; one will be generated for you if you do not provide one and one is needed. ID string }
SelectOption is one possible thing you could choose from a list.
type SimpleContainer ¶
type SimpleContainer struct { // ID of the container ID string // Type is either "fixed" or "fluid" Type string // AlignCenter does what you think it does for the content inside the container // It overrides Type to use the "row" class AlignCenter bool // Template is the content inside the container Template string }
SimpleContainer is a Div which wraps the provided Template
func (SimpleContainer) Validate ¶
func (s SimpleContainer) Validate() error
Validate ensures the correct fields are populated without validating the output.
type StaticContent ¶
type StaticContent struct { // ID (optional) is the ID of the over-arching element all content will be placed in to ID string // Content is the textual content being created Content string // Tag is the tag being used for the content from this list: h1 h2 h3 h4 h5 h6 p small (secondary text in heading) // mark (yellow background) blockquote code Tag string }
StaticContent has information for generating static content. Don't use this for regular content creation - only creation via code.
func (StaticContent) Validate ¶
func (g StaticContent) Validate() error
Validate ensures the correct fields are populated without validating the output.
type Summernote ¶
func (*Summernote) Validate ¶
func (summernote *Summernote) Validate() error
type Table ¶
type Table struct { // ID of the table. If an element is selected, its value is stored at this ID. ID string // Industry of the table. Used when making the request to get the table's rows. Industry string // Domain of the table. Domain string // Schema of the table, such as "polyappTask". Schema string // Columns in the table Columns []Column // InitialSearch (optional) is the initial value to apply to the search bar when loading the table. // Overwritten by the table-initial-search URL parameter. InitialSearch string // InitialOrderColumn (optional) is the column to order in 'asc' when the table loads. The int is the column number (0 is first). // Overwritten by the table-initial-order-column URL parameter. InitialOrderColumn int // InitialLastDocumentID (optional) is the initial value to being sorting after. By setting this you can seek to a different // part of the table. Because Firestore isn't very clear about what your index is in the overall list, you can't // set the initial list # another way. // Overwritten by the table-initial-last-document-ID URL parameter. InitialLastDocumentID string }
Table which has all of the table features you may ever need or want.
type TaskListItem ¶
type TaskListItem struct { // ID is optional. ID string Name string HelpText string ChangeDataLink string NewDataLink string EditTaskLink string }
TaskListItem is a card which can be used as a list item. It displays information about a Task - its Name, Help Text, etc - and links to important pages for the Task like "Change Data", "New Data", and "Edit Task".
func (TaskListItem) Validate ¶
func (l TaskListItem) Validate() error
Validate returns an error if the object is not valid.
type TextButton ¶
type TextButton struct { // ID of the button ID string // Text on the button Text string // Styling is one of: "success", "info", "warning", "danger", "primary", "secondary", "dark", "light", "link" Styling string // Recaptcha (optional) if set to true, this button will be associated with a recaptcha. When a user presses the // button, the challenge will be initiated. Recaptcha bool RecaptchaSiteKey string Disabled bool // If true the button will be disabled in the UI }
TextButton can be used to create a simple Button
func (TextButton) Validate ¶
func (b TextButton) Validate() error
Validate ensures the correct fields are populated without validating the output.
type Time ¶
type Time struct { ID string Label string HelpText string // InitialValue is a UNIX Timestamp in UTC / GMT. // Javascript will convert the timestamp into the local time & back out to UTC again. InitialValue int64 // Format is "L" for date only or "LT" for time only. If empty, uses date and time. // Additional options from https://momentjs.com/docs/#/displaying/format/ include: LTS, l, LL, ll, LLL, lll, LLLL, llll Format string Readonly bool InitializeWithNow bool // if true will initialize the input with the current date and time. }
type Video ¶
type Video struct { // ID of the element which contains the video and the video URL. ID string // VideoURL is the source VideoURL of the video. // // If it is a Youtube video, the "v" parameter is extracted and the URL is reformed as: https://www.youtube.com/embed/{{.ID}} VideoURL string // OverlayText (optional) is shown on top of the Video. OverlayText string // Width (default: 640) of the player. Width string // Height (default: 360) of the player. Height string // Autoplay (optional) autoplays the video. Autoplay bool // Fullscreen (optional) ignores Width and Height and tries to play the video in fullscreen mode. Fullscreen bool }
Video is used when displaying videos in the UI.
type WorkflowNavigation ¶
type WorkflowNavigation struct {}
WorkflowNavigation is a vertical navigation bar.
func (WorkflowNavigation) Validate ¶
func (s WorkflowNavigation) Validate() error