Commit e3afa724 authored by Boris Kocherov's avatar Boris Kocherov

usage article in README.md added

parent 822e8363
# JSON Schema form generator RenderJS gadget
## Usage
It's assumed that a developer is familiar with RenderJS gadget documentation (https://renderjs.nexedi.com/).
Gadget api is similar to any renderjs field api.
```javascript
gadget.render({
key: 'field_identificator',
value: [1,2],
schema: {
type: 'array',
items: {
type: 'integer'
}
}
})
```
![rendered](doc/array_rendered.png)
If schema_url is specified instead of schema property then schema_url is used for schema download.
Schema_url parameter should be specified for proper computation of an absolute url. If schema_url is omitted
then the current gadget url is used as base_url.
Parent gadget should have declared notification methods to catch validation status.
```javascript
rJS(window)
.allowPublicAcquisition("notifyValid", function (arr, scope) {
})
.allowPublicAcquisition("notifyInvalid", function (arr, scope) {
})
.allowPublicAcquisition("notifyChange", function (arr, scope) {
});
```
In parent gadget downloadJSON() can be declared. DownloadJSON() can be used to
fetch schema from jio storage. Example:
```javascript
rJS(window)
.allowPublicAcquisition("downloadJSON", function (arr) {
var g = this,
url = arr[0],
reference,
args;
// return g.jio_getAttachment(id, "data", {format: "json"});
if (url.startsWith("urn:jio:reference?")) {
reference = decodeURIComponent(url.replace("urn:jio:reference?", ""));
args = {
query: '(portal_type: "JSON Schema") AND ((reference: "' + reference + '"))',
limit: [0, 1],
select_list: [],
sort_on: [["modification_date", "descending"]]
};
return g.jio_allDocs(args)
.push(function (result) {
return g.jio_getAttachment(result.data.rows[0].id, "data", {format: "json"});
});
}
})
```
## What inside
gadget consists of three parts:
......
Markdown is supported
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