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
2690e7d8
Commit
2690e7d8
authored
Mar 06, 2018
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add render object.additionalProperties
parent
cf7bf0b7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
58 deletions
+63
-58
README.md
README.md
+1
-1
gadget_json_generated_form.js
gadget_json_generated_form.js
+62
-57
No files found.
README.md
View file @
2690e7d8
...
...
@@ -70,7 +70,7 @@ Below is the list of JSON Schema validation properties and current supported sta
**object**
*
`additionalProperties`
-
rendering is not supported
-
**fixed**
rendering is not supported
*
`dependencies`
-
rendering is not supported
*
`maxProperties`
...
...
gadget_json_generated_form.js
View file @
2690e7d8
...
...
@@ -201,31 +201,14 @@
}
function
render_object
(
gadget
,
json_field
,
default_dict
,
root
,
path
)
{
var
div_input
,
key
,
div
,
input
,
var
key
,
default_used_list
=
[],
queue
=
RSVP
.
Queue
();
if
(
default_dict
===
undefined
)
{
default_dict
=
{};
}
for
(
key
in
json_field
.
properties
)
{
if
(
json_field
.
properties
.
hasOwnProperty
(
key
))
{
default_used_list
.
push
(
key
);
if
(
json_field
.
properties
[
key
].
default
!==
undefined
)
{
json_field
.
properties
[
key
].
info
=
'
(default =
'
+
json_field
.
properties
[
key
].
default
+
'
)
'
;
}
queue
.
push
(
render_field
.
bind
(
gadget
,
gadget
,
key
,
path
,
json_field
.
properties
[
key
],
default_dict
[
key
],
root
)
);
}
}
if
(
json_field
.
patternProperties
!==
undefined
)
{
if
(
json_field
.
patternProperties
[
'
.*
'
]
!==
undefined
)
{
function
addAdditional
(
schema
)
{
var
div
,
div_input
,
input
;
div
=
document
.
createElement
(
"
div
"
);
div
.
setAttribute
(
"
class
"
,
"
subfield
"
);
...
...
@@ -245,12 +228,12 @@
input
.
textContent
=
"
Add
"
;
gadget
.
props
.
add_buttons
.
push
({
element
:
input
,
schema_part
:
json_field
.
patternProperties
[
'
.*
'
]
schema_part
:
schema
});
div_input
.
appendChild
(
input
);
div
.
appendChild
(
div_input
);
for
(
key
in
default_dict
)
{
if
(
default_dict
.
hasOwnProperty
(
key
)
&&
default_used_list
.
indexOf
(
key
)
<
0
)
{
default_used_list
.
push
(
key
);
...
...
@@ -260,14 +243,41 @@
key
:
key
,
path
:
path
,
element
:
input
,
schema_part
:
json_field
.
patternProperties
[
'
.*
'
]
,
schema_part
:
schema
,
default_dict
:
default_dict
[
key
]
})
);
}
}
queue
.
push
(
function
()
{
root
.
appendChild
(
div
);
});
}
if
(
default_dict
===
undefined
)
{
default_dict
=
{};
}
for
(
key
in
json_field
.
properties
)
{
if
(
json_field
.
properties
.
hasOwnProperty
(
key
))
{
default_used_list
.
push
(
key
);
if
(
json_field
.
properties
[
key
].
default
!==
undefined
)
{
json_field
.
properties
[
key
].
info
=
'
(default =
'
+
json_field
.
properties
[
key
].
default
+
'
)
'
;
}
queue
.
push
(
render_field
.
bind
(
gadget
,
gadget
,
key
,
path
,
json_field
.
properties
[
key
],
default_dict
[
key
],
root
)
);
}
}
if
(
json_field
.
patternProperties
!==
undefined
)
{
if
(
json_field
.
patternProperties
[
'
.*
'
]
!==
undefined
)
{
addAdditional
(
json_field
.
patternProperties
[
'
.*
'
]);
}
}
if
(
json_field
.
additionalProperties
!==
undefined
&&
json_field
.
additionalProperties
.
type
)
{
addAdditional
(
json_field
.
additionalProperties
);
}
for
(
key
in
default_dict
)
{
...
...
@@ -286,7 +296,7 @@
}
function
getFormValuesAsJSONDict
(
g
)
{
var
multi_level_dict
=
{},
var
multi_level_dict
=
{
""
:{}
},
scope
,
options
=
g
.
props
,
array
,
...
...
@@ -295,14 +305,10 @@
queue
=
RSVP
.
Queue
();
function
convertOnMultiLevel
(
d
,
key
,
value
)
{
var
orig_d
=
d
,
i
,
var
i
,
kk
,
key_list
=
key
.
split
(
"
/
"
);
if
(
key
===
""
)
{
return
value
;
}
for
(
i
=
1
;
i
<
key_list
.
length
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
key_list
.
length
;
i
+=
1
)
{
kk
=
key_list
[
i
];
if
(
i
===
key_list
.
length
-
1
)
{
if
(
value
===
undefined
)
{
...
...
@@ -317,7 +323,6 @@
d
=
d
[
kk
];
}
}
return
orig_d
;
}
function
recursiveGetContent
(
gadget
,
scope
)
{
...
...
@@ -340,7 +345,7 @@
})
.
push
(
function
(
jdict
)
{
var
array
=
convertOnMultiLevel
(
multi_level_dict
,
parent_scope
);
if
(
!
array
)
{
if
(
!
(
array
instanceof
Array
)
)
{
array
=
[];
convertOnMultiLevel
(
multi_level_dict
,
parent_scope
,
array
);
}
...
...
@@ -394,10 +399,10 @@
});
for
(
key
in
json_dict
)
{
if
(
json_dict
.
hasOwnProperty
(
key
))
{
multi_level_dict
=
convertOnMultiLevel
(
multi_level_dict
,
key
,
json_dict
[
key
]);
convertOnMultiLevel
(
multi_level_dict
,
key
,
json_dict
[
key
]);
}
}
return
multi_level_dict
;
return
multi_level_dict
[
""
]
;
});
}
...
...
@@ -435,7 +440,7 @@
// add after button
// element.parentNode.parentNode.insertBefore(div, element.parentNode.parentNode.children[1]);
// add to end of list
element
.
parentNode
.
parentNode
.
appendChild
(
div
);
element
.
parentNode
.
appendChild
(
div
);
return
form_gadget
.
renderForm
({
schema
:
options
.
schema_part
,
...
...
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