Commit 924b682b authored by Rafael Ostertag's avatar Rafael Ostertag
Browse files

Work in progress commit of API.md.

parent cf61161b
<!-- -*- markdown -*- -->
API: Client / Server
====================
......@@ -19,74 +21,99 @@ data-required: 'yes'|'no' - yes: The element is required. The form can't be su
Asynchronous request (read AJAX) initiated by the client receive a JSON Response from the server containing at least:
{
"status": "success"|"error",
"message": "<message>"
{
"status": "success"|"error",
"message": "<message>"
}
`status` indicates whether or not the request has been fullfiled by the server (`"success"`) or encountered an error (`"error"`).
On `"error"` the client must display `"<message>"` to the user. On `"success"`, the client may display `"<message>"` to the user.
On `"error"` the client must display `"<message>"` to the user. On
`"success"`, the client may display `"<message>"` to the user.
Depending on the request, the server may provide additional
information in the response, as outlined below.
### Form Group Configuration
As part of the server response, the JSON stream may contain a key
`form-update`. It contains an array of objects having following
`form-update`. It contains an array of objects having the following
structure
{
...
"form-update" : [
{
"form-element": "<element_name>",
"hidden": true | false,
"disabled": true | false,
"required": true | false,
"value": <value>
},
...
],
...
...
"form-update" : [
{
"form-element": "<element_name>",
"hidden": true | false,
"disabled": true | false,
"required": true | false,
"value": <value>
},
...
],
...
}
`"form-element"`
: the name of the HTML Form Element as it appears in the `name`
attribute.
: the name of the HTML Form Element as it appears in the `name` attribute.
`"hidden"`
: whether the Form Group is visible (value: `false`) or
invisible (value: `true`).
: whether the Form Group is visible (value: `false`) or invisible (value: `true`).
`"disabled"`
: whether or not the Form Element is disabled HTML-wise.
`"required"`
: whether or not the Form Element receives the HTML5 `required`
attribute.
: whether or not the Form Element receives the HTML5 `required` attribute.
`"value"`
: For textual HTML Form Input elements, it is supposed to be a
scalar value, which is set on the element.
: For textual HTML Form Input elements, it is supposed to be a scalar value, which is set on the element.
When `"form-element"` references a `<select>` element, a scalar value
selects the corresponding value from the option list. In order to replace
the option list, use an array of objects, having this format
the entire option list, use an array of objects, having this format
[
{
"value": 100,
"text": "a",
"selected": true
},
{
"value": 200,
"text": "b",
"selected": false
}
{
"value": 100,
"text": "a",
"selected": true
},
{
"value": 200,
"text": "b",
"selected": false
}
]
`"select"` is optional, as is `"text"`. If `"text"` is omitted, it
will be derived from value.
HTML checkboxes are ticked with a `"value"` of `true`. They are
unchecked with `false`.
HTML radio buttons are activated by providing the value of the
radio button `value`-attribute to be activated in `"value"`.
### Redirection
Depending on the request, the server may return redirection
information to client. It is up to the client to respect the
redirection information. The format of redirect information is
outlined below
{
...
"redirect": "no" | "url" | "client"
"redirect-url": "<url>"
...
}
`"redirect"`
Form load (update)
......@@ -285,3 +312,6 @@ HTML Form Element
Form Group
: The sourrounding `<div>` containing the `.control-label`,
`.form-control` `<div>`s, and `.help-block` `<p>`.
Client
:
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment