DiogenesAnalytics / parley

Browser-based interview/application form.
https://diogenesanalytics.com/parley/
MIT License
0 stars 3 forks source link
dynamic form html-form javascript pytest

tests docker pages-build-deployment

Parley

(noun)

Pronunciation: /ˈpɑːrli/

Definition: A formal discussion or negotiation between parties, especially enemies, typically to resolve a conflict or dispute peacefully. It often implies a temporary truce or cessation of hostilities to facilitate dialogue.

Example Sentence: The warring factions agreed to a parley at the neutral ground to seek a diplomatic solution to their long-standing conflict.

Introduction

The motivation behind this software is simple: to develop a completely static HTML Form that can be deployed anywhere (including on GitHub Pages), to allow for simple configuration (i.e. no need to edit the web source directly) using a JSON file (config.json), and for the software to be RIGOROUSLY tested (using pytest) to prove the features work. That is what Parley is about: a "once for all" solution for those who need a simple, testable, and stable form solution now.

Features

Here we will attempt to list all the features that are available and tested in the software:

Usage

Here we outline the Parley software's intended use. Specifically we will go over the config.json schema and what is supported vs. disallowed.

Configuration

Below is a minimal configuration of the Parley software:

{
  "instructions": "Your custom form usage instructions",
  "subject": "Your Form Subject",
  "title": "Your Custom Title",
  "send_button_text": "Custom Submit Text",
  "download_button_text": "Custom Download Text",
  "missing_field_message": "Custom Missing Field Alert Message",
  "enable_form_download": true,
  "form_backend_url": null,
  "ignore_file_upload": false,
  "email": "your_email@example.com",
  "questions": [
    {
      "label": "Message",
      "name": "message",
      "type": "textarea",
      "required": true
    }
  ]
}

The above example config file is written in JSON, and each attribute will be explained below in more detail (NOTE: attributes with a * mark are required):

Basic Input Types

As discussed above, there are a few different input types currently available. These are listed below:

Information describing these types can be found in the MDN Input Element Docs,^1 except for selectbox and textarea which are custom input types.

Custom Input Types

While setting the input type to textarea simply allows you to use a textarea element (as opposed to an input element of type text), setting the input type to selectbox is a little more interesting:

{
  "subject": "Your Form Subject",
  "title": "Your Custom Title",
  "form_backend_url": null,
  "email": "your_email@example.com",
  "questions": [
    {
      "label": "Select your country",
      "name": "country",
      "type": "selectbox",
      "required": true,
      "options": [
        {"label": "--Select--", "value": "", "selected": true, "disabled": true},
        {"label": "USA", "value": "USA"},
        {"label": "Canada", "value": "CAN"},
        {"label": "United Kingdom", "value": "UK"},
        {"label": "Australia", "value": "AUS"}
      ],
      "custom": {
        "multiple": true
      }
    }
  ]
}

When using the selectbox input type, you now have access to the options attribute, where you can set the different options that will be "selectable" by the user. Each option has 4 possible attributes (NOTE: attributes with a * mark are required):

While you can set the options attribute in the config.json file for a question without setting the type to selectbox, nothing will happen but the website should function normally.

Additional Attributes

You will notice in the above section the presence of a custom attribute:

{
  "custom": {
    "multiple": true
  }
}

The role of this attribute is to configure ANY additional attributes related to the form input element you are using for your "question." In this case we are setting the multiple attribute to true for the select element (so that the user can select multiple options in the selectbox).

Development

Here we introduce the various tools related to developing the Parley software.

Make

A Makefile is available in the project root, and implements several commands to make the development process easier. All commands are executed by the following format: make [COMMAND]. To see the contents of a command that will be executed upon invocation of the command, simply run make -n [COMMAND] (NOTE: this serves as a good way to test a command and see what exactly will be executed before running the command). Below is the list of the commands and their short descriptions:

Example Uses

Here we will show some common use cases for the Makefile:

References