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
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 @@
...
@@ -42,13 +42,14 @@
return
input
;
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
,
var
div
,
label
,
label
,
div_input
,
div_input
,
span_info
,
span_info
,
span_error
,
span_error
,
input
;
input
,
queue
=
RSVP
.
Queue
();
// var input = document.createElement("input");
// var input = document.createElement("input");
...
@@ -99,12 +100,15 @@
...
@@ -99,12 +100,15 @@
}
}
if
(
json_field
.
type
===
"
object
"
)
{
if
(
json_field
.
type
===
"
object
"
)
{
render_object
(
queue
gadget
,
.
push
(
function
()
{
json_field
,
return
render_object
(
default_value
,
gadget
,
div_input
,
json_field
,
path
+
"
/
"
+
key
);
default_value
,
div_input
,
path
+
"
/
"
+
key
);
});
}
}
if
(
input
)
{
if
(
input
)
{
...
@@ -126,7 +130,11 @@
...
@@ -126,7 +130,11 @@
div_input
.
appendChild
(
span_error
);
div_input
.
appendChild
(
span_error
);
div
.
appendChild
(
div_input
);
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
)
{
function
render_object
(
gadget
,
json_field
,
default_dict
,
root
,
path
)
{
...
@@ -134,7 +142,8 @@
...
@@ -134,7 +142,8 @@
key
,
key
,
div
,
div
,
input
,
input
,
default_used_list
=
[];
default_used_list
=
[],
queue
=
RSVP
.
Queue
();
if
(
default_dict
===
undefined
)
{
if
(
default_dict
===
undefined
)
{
default_dict
=
{};
default_dict
=
{};
...
@@ -172,13 +181,17 @@
...
@@ -172,13 +181,17 @@
for
(
key
in
default_dict
)
{
for
(
key
in
default_dict
)
{
if
(
default_dict
.
hasOwnProperty
(
key
))
{
if
(
default_dict
.
hasOwnProperty
(
key
))
{
default_used_list
.
push
(
key
);
default_used_list
.
push
(
key
);
// div.appendChild(div_input);
div_input
=
document
.
createElement
(
"
div
"
);
queue
div_input
.
setAttribute
(
"
class
"
,
"
slapos-parameter-dict-key
"
);
.
push
(
div_input
.
appendChild
(
addSubForm
.
bind
(
gadget
,
gadget
,
{
render_field
(
gadget
,
key
,
path
,
json_field
.
patternProperties
[
'
.*
'
],
default_dict
[
key
])
key
:
key
,
);
path
:
path
,
div
.
appendChild
(
div_input
);
element
:
input
,
schema_part
:
json_field
.
patternProperties
[
'
.*
'
],
default_dict
:
default_dict
[
key
]
})
);
}
}
}
}
root
.
appendChild
(
div
);
root
.
appendChild
(
div
);
...
@@ -187,26 +200,29 @@
...
@@ -187,26 +200,29 @@
for
(
key
in
json_field
.
properties
)
{
for
(
key
in
json_field
.
properties
)
{
if
(
json_field
.
properties
.
hasOwnProperty
(
key
))
{
if
(
json_field
.
properties
.
hasOwnProperty
(
key
))
{
default_used_list
.
push
(
key
);
if
(
json_field
.
properties
[
key
].
default
!==
undefined
)
{
if
(
json_field
.
properties
[
key
].
default
!==
undefined
)
{
json_field
.
properties
[
key
].
info
=
'
(default =
'
+
json_field
.
properties
[
key
].
default
+
'
)
'
;
json_field
.
properties
[
key
].
info
=
'
(default =
'
+
json_field
.
properties
[
key
].
default
+
'
)
'
;
}
}
div
=
render_field
(
gadget
,
key
,
path
,
json_field
.
properties
[
key
],
default_dict
[
key
]);
queue
root
.
appendChild
(
div
);
.
push
(
render_field
.
bind
(
gadget
,
gadget
,
key
,
path
,
default_used_list
.
push
(
key
);
json_field
.
properties
[
key
],
default_dict
[
key
],
root
)
);
}
}
}
}
for
(
key
in
default_dict
)
{
for
(
key
in
default_dict
)
{
if
(
default_dict
.
hasOwnProperty
(
key
))
{
if
(
default_dict
.
hasOwnProperty
(
key
))
{
if
(
default_used_list
.
indexOf
(
key
)
<
0
)
{
if
(
default_used_list
.
indexOf
(
key
)
<
0
)
{
div
=
render_field
(
gadget
,
key
,
path
,
{
queue
"
type
"
:
"
string
"
,
.
push
(
render_field
.
bind
(
gadget
,
gadget
,
key
,
path
,
{
"
info
"
:
"
(Not part of the schema)
"
"
type
"
:
"
string
"
,
},
default_dict
[
key
]);
"
info
"
:
"
(Not part of the schema)
"
root
.
appendChild
(
div
);
},
default_dict
[
key
],
root
)
);
}
}
}
}
}
}
return
root
;
return
queue
;
}
}
function
getFormValuesAsJSONDict
(
g
)
{
function
getFormValuesAsJSONDict
(
g
)
{
...
@@ -286,8 +302,9 @@
...
@@ -286,8 +302,9 @@
function
addSubForm
(
g
,
options
)
{
function
addSubForm
(
g
,
options
)
{
var
element
=
options
.
element
,
var
element
=
options
.
element
,
key
=
element
.
parentNode
.
querySelector
(
"
input[type='text']
"
).
value
,
key
=
options
.
key
||
scope
=
element
.
name
+
"
/
"
+
key
;
element
.
parentNode
.
querySelector
(
"
input[type='text']
"
).
value
,
scope
=
(
options
.
path
||
element
.
name
)
+
"
/
"
+
key
;
if
(
!
key
||
g
.
props
.
subforms
.
hasOwnProperty
(
scope
))
{
if
(
!
key
||
g
.
props
.
subforms
.
hasOwnProperty
(
scope
))
{
return
false
;
return
false
;
...
@@ -302,7 +319,7 @@
...
@@ -302,7 +319,7 @@
div
.
setAttribute
(
"
class
"
,
"
slapos-parameter-dict-key
"
);
div
.
setAttribute
(
"
class
"
,
"
slapos-parameter-dict-key
"
);
div
.
appendChild
(
form_gadget
.
element
);
div
.
appendChild
(
form_gadget
.
element
);
element
.
parentNode
.
parentNode
.
insertBefore
(
div
,
element
.
parentNode
.
parentNode
.
children
[
1
]);
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 @@
...
@@ -446,9 +463,11 @@
while
(
g
.
element
.
firstChild
)
{
while
(
g
.
element
.
firstChild
)
{
g
.
element
.
removeChild
(
g
.
element
.
firstChild
);
g
.
element
.
removeChild
(
g
.
element
.
firstChild
);
}
}
g
.
element
.
appendChild
(
render_field
(
g
,
key
,
""
,
schema
,
default_dict
));
return
render_field
(
g
,
key
,
""
,
schema
,
default_dict
,
g
.
element
)
g
.
listenEvents
();
.
push
(
function
()
{
return
g
.
element
;
g
.
listenEvents
();
return
g
.
element
;
});
})
})
.
declareMethod
(
'
renderFailoverTextArea
'
,
function
(
content
,
error
)
{
.
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