Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
rjs_json_form
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
rjs_json_form
Commits
e3afa724
Commit
e3afa724
authored
Oct 02, 2018
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
usage article in README.md added
parent
822e8363
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
0 deletions
+65
-0
README.md
README.md
+65
-0
doc/array_rendered.png
doc/array_rendered.png
+0
-0
No files found.
README.md
View file @
e3afa724
# 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:
...
...
doc/array_rendered.png
0 → 100644
View file @
e3afa724
1.03 KB
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment