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
Boris Kocherov
rjs_json_form
Commits
0fa703bd
Commit
0fa703bd
authored
Aug 07, 2018
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
enum rendering improved. now it allow render complex objects.
imho not usable, but needed for tests
parent
e3d91b30
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
3 deletions
+22
-3
jsonform/gadget_json_generated_form_child.js
jsonform/gadget_json_generated_form_child.js
+22
-3
No files found.
jsonform/gadget_json_generated_form_child.js
View file @
0fa703bd
...
...
@@ -94,6 +94,8 @@
var
input
=
document
.
createElement
(
"
select
"
),
option
,
i
,
ser_value
,
selected
=
false
,
enum_arr
=
schema
[
'
enum
'
];
input
.
size
=
1
;
if
(
schema
.
default
)
{
...
...
@@ -111,14 +113,28 @@
for
(
i
=
0
;
i
<
enum_arr
.
length
;
i
+=
1
)
{
if
(
enum_arr
.
hasOwnProperty
(
i
))
{
option
=
document
.
createElement
(
"
option
"
);
option
.
value
=
enum_arr
[
i
];
option
.
textContent
=
enum_arr
[
i
];
// XXX use number id for speedup
ser_value
=
JSON
.
stringify
(
enum_arr
[
i
]);
option
.
value
=
ser_value
;
option
.
textContent
=
ser_value
;
if
(
enum_arr
[
i
]
===
json_document
)
{
option
.
selected
=
true
;
selected
=
true
;
}
input
.
appendChild
(
option
);
}
}
if
(
json_document
!==
undefined
&&
!
selected
)
{
// save original json_document even if it
// not support with schema
// XXX element should be removed on first user interact
option
=
document
.
createElement
(
"
option
"
);
ser_value
=
JSON
.
stringify
(
json_document
);
option
.
value
=
ser_value
;
option
.
textContent
=
ser_value
;
option
.
selected
=
true
;
input
.
appendChild
(
option
);
}
return
input
;
}
...
...
@@ -1307,7 +1323,10 @@
}
else
{
if
(
input
.
required
||
input
.
value
!==
""
)
{
var
type
=
input
.
getAttribute
(
'
data-json-type
'
);
if
(
type
===
'
number
'
)
{
if
(
input
.
tagName
===
"
SELECT
"
&&
input
.
value
)
{
// selection used for enums
json_dict
[
input
.
name
]
=
JSON
.
parse
(
input
.
value
);
}
else
if
(
type
===
'
number
'
)
{
json_dict
[
input
.
name
]
=
parseFloat
(
input
.
value
);
}
else
if
(
type
===
"
integer
"
)
{
json_dict
[
input
.
name
]
=
parseInt
(
input
.
value
,
10
);
...
...
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