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
Rafael Monnerat
rjs_json_form
Commits
94269625
Commit
94269625
authored
Mar 02, 2018
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
now rendering use queue it need for subgadget
parent
e4a50931
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
32 deletions
+51
-32
gadget_json_generated_form.js
gadget_json_generated_form.js
+51
-32
No files found.
gadget_json_generated_form.js
View file @
94269625
...
...
@@ -42,13 +42,14 @@
return
input
;
}
function
render_field
(
gadget
,
key
,
path
,
json_field
,
default_value
)
{
function
render_field
(
gadget
,
key
,
path
,
json_field
,
default_value
,
root
)
{
var
div
,
label
,
div_input
,
span_info
,
span_error
,
input
;
input
,
queue
=
RSVP
.
Queue
();
// var input = document.createElement("input");
...
...
@@ -99,12 +100,15 @@
}
if
(
json_field
.
type
===
"
object
"
)
{
render_object
(
gadget
,
json_field
,
default_value
,
div_input
,
path
+
"
/
"
+
key
);
queue
.
push
(
function
()
{
return
render_object
(
gadget
,
json_field
,
default_value
,
div_input
,
path
+
"
/
"
+
key
);
});
}
if
(
input
)
{
...
...
@@ -126,7 +130,11 @@
div_input
.
appendChild
(
span_error
);
div
.
appendChild
(
div_input
);
return
div
;
return
queue
.
push
(
function
()
{
root
.
appendChild
(
div
);
return
div
;
});
}
function
render_object
(
gadget
,
json_field
,
default_dict
,
root
,
path
)
{
...
...
@@ -134,7 +142,8 @@
key
,
div
,
input
,
default_used_list
=
[];
default_used_list
=
[],
queue
=
RSVP
.
Queue
();
if
(
default_dict
===
undefined
)
{
default_dict
=
{};
...
...
@@ -172,13 +181,17 @@
for
(
key
in
default_dict
)
{
if
(
default_dict
.
hasOwnProperty
(
key
))
{
default_used_list
.
push
(
key
);
div_input
=
document
.
createElement
(
"
div
"
);
div_input
.
setAttribute
(
"
class
"
,
"
slapos-parameter-dict-key
"
);
div_input
.
appendChild
(
render_field
(
gadget
,
key
,
path
,
json_field
.
patternProperties
[
'
.*
'
],
default_dict
[
key
])
);
div
.
appendChild
(
div_input
);
// div.appendChild(div_input);
queue
.
push
(
addSubForm
.
bind
(
gadget
,
gadget
,
{
key
:
key
,
path
:
path
,
element
:
input
,
schema_part
:
json_field
.
patternProperties
[
'
.*
'
],
default_dict
:
default_dict
[
key
]
})
);
}
}
root
.
appendChild
(
div
);
...
...
@@ -187,26 +200,29 @@
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
+
'
)
'
;
}
div
=
render_field
(
gadget
,
key
,
path
,
json_field
.
properties
[
key
],
default_dict
[
key
]);
root
.
appendChild
(
div
);
default_used_list
.
push
(
key
);
queue
.
push
(
render_field
.
bind
(
gadget
,
gadget
,
key
,
path
,
json_field
.
properties
[
key
],
default_dict
[
key
],
root
)
);
}
}
for
(
key
in
default_dict
)
{
if
(
default_dict
.
hasOwnProperty
(
key
))
{
if
(
default_used_list
.
indexOf
(
key
)
<
0
)
{
div
=
render_field
(
gadget
,
key
,
path
,
{
"
type
"
:
"
string
"
,
"
info
"
:
"
(Not part of the schema)
"
},
default_dict
[
key
]);
root
.
appendChild
(
div
);
queue
.
push
(
render_field
.
bind
(
gadget
,
gadget
,
key
,
path
,
{
"
type
"
:
"
string
"
,
"
info
"
:
"
(Not part of the schema)
"
},
default_dict
[
key
],
root
)
);
}
}
}
return
root
;
return
queue
;
}
function
getFormValuesAsJSONDict
(
g
)
{
...
...
@@ -286,8 +302,9 @@
function
addSubForm
(
g
,
options
)
{
var
element
=
options
.
element
,
key
=
element
.
parentNode
.
querySelector
(
"
input[type='text']
"
).
value
,
scope
=
element
.
name
+
"
/
"
+
key
;
key
=
options
.
key
||
element
.
parentNode
.
querySelector
(
"
input[type='text']
"
).
value
,
scope
=
(
options
.
path
||
element
.
name
)
+
"
/
"
+
key
;
if
(
!
key
||
g
.
props
.
subforms
.
hasOwnProperty
(
scope
))
{
return
false
;
...
...
@@ -302,7 +319,7 @@
div
.
setAttribute
(
"
class
"
,
"
slapos-parameter-dict-key
"
);
div
.
appendChild
(
form_gadget
.
element
);
element
.
parentNode
.
parentNode
.
insertBefore
(
div
,
element
.
parentNode
.
parentNode
.
children
[
1
]);
return
form_gadget
.
renderParameterForm
(
options
.
schema_part
,
{}
,
key
,
scope
);
return
form_gadget
.
renderParameterForm
(
options
.
schema_part
,
options
.
default_dict
,
key
,
scope
);
});
}
...
...
@@ -446,9 +463,11 @@
while
(
g
.
element
.
firstChild
)
{
g
.
element
.
removeChild
(
g
.
element
.
firstChild
);
}
g
.
element
.
appendChild
(
render_field
(
g
,
key
,
""
,
schema
,
default_dict
));
g
.
listenEvents
();
return
g
.
element
;
return
render_field
(
g
,
key
,
""
,
schema
,
default_dict
,
g
.
element
)
.
push
(
function
()
{
g
.
listenEvents
();
return
g
.
element
;
});
})
.
declareMethod
(
'
renderFailoverTextArea
'
,
function
(
content
,
error
)
{
...
...
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