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
8f61be1d
Commit
8f61be1d
authored
Mar 06, 2018
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support rfc6901 in json paths (json pointer)
parent
a452f1dc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
4 deletions
+14
-4
README.md
README.md
+1
-1
gadget_json_generated_form.js
gadget_json_generated_form.js
+13
-3
No files found.
README.md
View file @
8f61be1d
...
...
@@ -16,7 +16,7 @@
*
**done**
remove slapos specific code
*
**partly done**
remove jquery dependence
*
**partly done**
full support of json schema
*
support in path
[
rfc6901
](
https://tools.ietf.org/html/rfc6901
)
*
**done**
support in path
[
rfc6901
](
https://tools.ietf.org/html/rfc6901
)
*
using changeState and mutex
*
separate form design from code for form generation
*
add general using documentation
...
...
gadget_json_generated_form.js
View file @
8f61be1d
...
...
@@ -4,6 +4,16 @@
(
function
(
window
,
document
,
rJS
,
$
,
loopEventListener
)
{
"
use strict
"
;
function
decodeJsonPointer
(
_str
)
{
// https://tools.ietf.org/html/rfc6901#section-5
return
_str
.
replace
(
/~1/g
,
'
/
'
).
replace
(
/~0/g
,
'
~
'
);
}
function
encodeJsonPointer
(
_str
)
{
// https://tools.ietf.org/html/rfc6901#section-5
return
_str
.
replace
(
/~/g
,
'
~0
'
).
replace
(
/
\/
/g
,
'
~1
'
);
}
function
render_selection
(
json_field
,
default_value
)
{
var
input
=
document
.
createElement
(
"
select
"
),
option
=
document
.
createElement
(
"
option
"
),
...
...
@@ -103,7 +113,7 @@
queue
=
RSVP
.
Queue
();
if
(
path
&&
key
)
{
first_path
=
path
+
key
;
first_path
=
path
+
encodeJsonPointer
(
key
)
;
}
else
{
first_path
=
""
;
}
...
...
@@ -308,7 +318,7 @@
kk
,
key_list
=
key
.
split
(
"
/
"
);
for
(
i
=
0
;
i
<
key_list
.
length
;
i
+=
1
)
{
kk
=
key_list
[
i
]
;
kk
=
decodeJsonPointer
(
key_list
[
i
])
;
if
(
i
===
key_list
.
length
-
1
)
{
if
(
value
===
undefined
)
{
return
d
[
kk
];
...
...
@@ -417,7 +427,7 @@
key
=
options
.
key
||
element
.
parentNode
.
querySelector
(
"
input[type='text']
"
).
value
;
}
scope
=
parent_path
+
key
;
scope
=
parent_path
+
encodeJsonPointer
(
key
)
;
if
(
!
key
||
g
.
props
.
subforms
.
hasOwnProperty
(
scope
))
{
return
false
;
...
...
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