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
9ba0bebd
Commit
9ba0bebd
authored
Feb 28, 2018
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
not use json.parse json.stringify for generation button action
parent
d13dae53
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
6 deletions
+11
-6
gadget_json_generated_form.js
gadget_json_generated_form.js
+11
-6
No files found.
gadget_json_generated_form.js
View file @
9ba0bebd
...
...
@@ -119,11 +119,14 @@
div_input
.
appendChild
(
input
);
input
=
document
.
createElement
(
"
button
"
);
input
.
value
=
btoa
(
JSON
.
stringify
(
json_field
.
patternProperties
[
'
.*
'
]));
input
.
setAttribute
(
"
class
"
,
"
add-sub-form
"
);
input
.
type
=
"
button
"
;
input
.
name
=
path
;
input
.
textContent
=
"
Add
"
;
gadget
.
props
.
add_buttons
.
push
({
element
:
input
,
schema_part
:
json_field
.
patternProperties
[
'
.*
'
]
});
div_input
.
appendChild
(
input
);
div
.
appendChild
(
div_input
);
...
...
@@ -274,8 +277,9 @@
return
gadget
.
processValidation
(
json_url
);
}
function
addSubForm
(
g
,
element
)
{
var
subform_json
=
JSON
.
parse
(
atob
(
element
.
value
)),
function
addSubForm
(
g
,
options
)
{
var
element
=
options
.
element
,
subform_json
=
options
.
schema_part
,
input_text
=
element
.
parentNode
.
querySelector
(
"
input[type='text']
"
),
div
=
document
.
createElement
(
"
div
"
),
label
;
...
...
@@ -301,7 +305,7 @@
function
loadEventList
(
gadget
)
{
var
g
=
gadget
,
field_list
=
g
.
props
.
inputs
,
button_list
=
g
.
element
.
querySelectorAll
(
'
button.add-sub-form
'
)
,
button_list
=
g
.
props
.
add_buttons
,
label_list
=
g
.
element
.
querySelectorAll
(
'
label.slapos-parameter-dict-key
'
),
i
,
promise_list
=
[];
...
...
@@ -317,7 +321,7 @@
for
(
i
=
0
;
i
<
button_list
.
length
;
i
=
i
+
1
)
{
promise_list
.
push
(
loopEventListener
(
button_list
[
i
],
button_list
[
i
]
.
element
,
'
click
'
,
false
,
addSubForm
.
bind
(
g
,
g
,
button_list
[
i
])
...
...
@@ -401,7 +405,8 @@
.
declareMethod
(
'
renderParameterForm
'
,
function
(
schema
,
default_dict
)
{
var
g
=
this
,
parent_element
=
document
.
createDocumentFragment
();
g
.
params
.
inputs
=
[];
g
.
props
.
inputs
=
[];
g
.
props
.
add_buttons
=
[];
render_subform
(
g
,
schema
,
default_dict
,
parent_element
);
while
(
g
.
element
.
firstChild
)
{
g
.
element
.
removeChild
(
g
.
element
.
firstChild
);
...
...
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