Skip to content

Commit

Permalink
#156 updated documentation with quickstart instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
qial committed Sep 2, 2020
1 parent 88413f6 commit b8bcf2f
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 8 deletions.
41 changes: 40 additions & 1 deletion docs/datalist.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,45 @@
# Datalist Implementation

TODO: Add a quickstart guide to get a simple form and datalist up and running
### Quickstart
The easiest way to get started with the Datalist is to use the <code>$formsapp</code> javascript connected to a form. This will store data into your local browser storage that will then be displayed in the datalist.

Create a new page and add a Form component. Edit the form to use the following form model:

{
"fields": [
{
"type": "input",
"inputType": "text",
"label": "First Name",
"model": "firstName",
"id": "first_name",
"placeholder": "Your name",
"featured": true,
"required": true
},{
"type": "input",
"inputType": "text",
"label": "Last Name",
"model": "lastName",
"id": "last_name",
"placeholder": "Your name",
"featured": true,
"required": true
}
]}

- Endpoint URL: <code>list</code>
- Submit Function: <code>$formsapp.save</code>

Add a Datalist component. You can leave the *endpoint URL*, *load function*, and *delete function* blank. Add two columns
in the *Table Configuration* with the following values:
- Header: **First Name**
- Data Value: **firstName**
- Header: **Last Name**
- Data Value: **lastName**

Now, if you submit a first and last name through the form and refresh the page, your values should show up in the table.
If you edit the Datalist component and turn on *Selectable Table* you will get the option to delete rows from the table.

### Datalist Component Configuration

Expand Down
74 changes: 67 additions & 7 deletions docs/forms.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,78 @@
# Forms Implementation

TODO: Add a quickstart guide to get a simple form and datalist up and running
### Quickstart

Check out the Datalist documentation for a quickstart using a form that saves to your local browser storage and shows the results in a table.

This section will describe setting up a contact form that posts to an external URL.

Create a new page and add the Form - Contact sample component. This component has a form model configured with a first name, last name, email, and text area.

{
"fields": [
{
"type": "input",
"inputType": "text",
"label": "First Name",
"model": "first_name",
"id": "first_name",
"placeholder": "First Name"
},{
"type": "input",
"inputType": "text",
"label": "Last Name",
"model": "last_name",
"id": "last_name",
"placeholder": "Last Name"
},{
"type": "input",
"inputType": "text",
"label": "Email",
"model": "email",
"id": "email",
"placeholder": "Email",
"featured": true,
"required": true
},{
"type": "textArea",
"label": "Text",
"model": "text",
"id": "text",
"rows": 4,
"placeholder": "Enter text here",
"featured": true,
"required": true
}
]}

Edit the component configuration and update the following:
- Endpoint URL: *url you would like to post to*
- Failure Message: "Error processing form"
- Success Page: *path to page when form submits successfully*

Now the form will attempt to do an AJAX post to the endpoint URL. If you put an invalid URL, you can see that the failure message will show up when the form attempts to submit. If the submission is successful (the POST request gets a 200 OK HTTP status), then peregrine will forward the user to the configured success page.

### Form Component Configuration

#### Form Model
The Form Model takes a Vue Form Generator JSON configuration. For an example and a list of the configuration options for each type of field see the [Vue Form Generator fields documentation](https://vue-generators.gitbook.io/vue-generators/fields)

Here is an example form with a single field called name:

{
"fields": [
{
"type": "input",
"inputType": "text",
"label": "Name",
"model": "name",
"id": "user_name",
"placeholder": "Your name",
"featured": true,
"required": true
}
]}

#### Form Submit Endpoint URL
The form will do an ajax POST with the form data to this URL. If the response is successful, it will forward the user to the configured Submit Success Page.

Expand All @@ -26,9 +92,3 @@ If there is an error processing the form, this message will be shown in an error
#### Submit Success Page

If not empty, on successful form submission it will forward the user to this page.

TODO: Add Datalist component configuration docs

TODO: Cleanup descriptions so its not quite so dry

TODO: Better formatting?

0 comments on commit b8bcf2f

Please sign in to comment.