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
f3caa368
Commit
f3caa368
authored
Apr 22, 2018
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add render_boolean() and use default value from schema
parent
4603653d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
10 deletions
+21
-10
gadget_json_generated_form.js
gadget_json_generated_form.js
+21
-10
No files found.
gadget_json_generated_form.js
View file @
f3caa368
...
@@ -140,6 +140,26 @@
...
@@ -140,6 +140,26 @@
return
input
;
return
input
;
}
}
function
render_boolean
(
schema
,
json_document
)
{
var
input
,
schema_for_selection
=
{
type
:
"
boolean
"
,
enum
:
[
true
,
false
]
};
// XXX change json_document on open is not correct @bk
if
(
json_document
===
"
true
"
)
{
json_document
=
true
;
}
if
(
json_document
===
"
false
"
)
{
json_document
=
false
;
}
if
(
getDocumentType
(
schema
.
default
)
===
"
boolean
"
)
{
schema_for_selection
.
default
=
schema
.
default
;
}
input
=
render_selection
(
schema_for_selection
,
json_document
);
return
input
;
}
function
render_textarea
(
json_field
,
default_value
,
data_format
)
{
function
render_textarea
(
json_field
,
default_value
,
data_format
)
{
var
input
=
document
.
createElement
(
"
textarea
"
);
var
input
=
document
.
createElement
(
"
textarea
"
);
if
(
default_value
!==
undefined
)
{
if
(
default_value
!==
undefined
)
{
...
@@ -676,16 +696,7 @@
...
@@ -676,16 +696,7 @@
}
}
if
(
type
===
"
boolean
"
)
{
if
(
type
===
"
boolean
"
)
{
if
(
default_value
===
"
true
"
)
{
input
=
render_boolean
(
json_field
,
default_value
);
default_value
=
true
;
}
if
(
default_value
===
"
false
"
)
{
default_value
=
false
;
}
input
=
render_selection
({
type
:
"
boolean
"
,
enum
:
[
true
,
false
]
},
default_value
);
}
}
if
(
!
input
&&
[
"
string
"
,
"
integer
"
,
"
number
"
].
indexOf
(
type
)
>=
0
)
{
if
(
!
input
&&
[
"
string
"
,
"
integer
"
,
"
number
"
].
indexOf
(
type
)
>=
0
)
{
...
...
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