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
48b4dabe
Commit
48b4dabe
authored
Oct 12, 2018
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save default value = empty object and use it for getContent if object does not have properties
parent
e432b77c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
0 deletions
+18
-0
jsonform/gadget_json_generated_form_child.js
jsonform/gadget_json_generated_form_child.js
+18
-0
No files found.
jsonform/gadget_json_generated_form_child.js
View file @
48b4dabe
...
...
@@ -1104,6 +1104,7 @@
//input.setAttribute("class", "slapos-parameter");
div_input
.
appendChild
(
input
);
}
else
{
div
.
setAttribute
(
"
data-parent-scope
"
,
gadget
.
element
.
getAttribute
(
"
data-gadget-scope
"
));
div
.
setAttribute
(
"
data-json-path
"
,
first_path
+
'
/
'
);
div
.
setAttribute
(
"
data-json-type
"
,
type
);
}
...
...
@@ -1325,6 +1326,11 @@
root
.
appendChild
(
child
);
}
if
(
JSON
.
stringify
(
schema
.
default
)
===
'
{}
'
)
{
// save default value as attribute only for empty values
root
.
parentElement
.
setAttribute
(
"
data-default-value
"
,
'
{}
'
);
}
if
(
json_document
===
undefined
)
{
if
(
schema
.
hasOwnProperty
(
'
default
'
))
{
json_document
=
schema
.
default
;
...
...
@@ -1588,6 +1594,18 @@
});
}
// set empty object if default value require this
array
=
g
.
element
.
querySelectorAll
(
"
div[data-parent-scope='
"
+
g
.
element
.
getAttribute
(
"
data-gadget-scope
"
)
+
"
']
"
);
for
(
i
=
0
;
i
<
array
.
length
;
i
+=
1
)
{
path
=
array
[
i
].
getAttribute
(
"
data-json-path
"
).
slice
(
0
,
-
1
);
if
(
array
[
i
].
getAttribute
(
"
data-default-value
"
)
===
"
{}
"
)
{
convertOnMultiLevel
(
multi_level_dict
,
path
,
{});
}
}
for
(
path
in
options
.
arrays
)
{
if
(
options
.
arrays
.
hasOwnProperty
(
path
))
{
array
=
options
.
arrays
[
path
]
...
...
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