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
cbf9ccf6
Commit
cbf9ccf6
authored
Mar 08, 2018
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
button for remove additionalProperties/arrayItems/paternProperties added
parent
0df2f3ed
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
11 deletions
+39
-11
README.md
README.md
+1
-1
gadget_json_generated_form.js
gadget_json_generated_form.js
+38
-10
No files found.
README.md
View file @
cbf9ccf6
...
...
@@ -79,7 +79,7 @@ Below is the list of JSON Schema validation properties and current supported sta
-
rendering is not supported
*
`patternProperties`
-
**fixed**
values can be only
`object`
types
-
add buttons for remove existed
`patternProperties`
-
**done**
add buttons for remove existed
`patternProperties`
-
**fixed**
can not be mixed with
`properties`
-
only regex .
*
in keys is supported
*
`properties`
...
...
gadget_json_generated_form.js
View file @
cbf9ccf6
...
...
@@ -435,22 +435,14 @@
return
g
.
declareGadget
(
'
gadget_json_generated_form.html
'
,
{
scope
:
scope
})
.
push
(
function
(
form_gadget
)
{
var
div
=
document
.
createElement
(
"
div
"
);
form_gadget
.
element
.
setAttribute
(
"
data-json-parent
"
,
parent_path
);
if
(
options
.
parent_type
===
"
array
"
)
{
g
.
props
.
arrays
[
parent_path
]
=
1
;
}
else
{
g
.
props
.
subforms
[
scope
]
=
form_gadget
;
}
div
.
setAttribute
(
"
class
"
,
"
slapos-parameter-dict-key
"
);
div
.
appendChild
(
form_gadget
.
element
);
// add after button
// element.parentNode.parentNode.insertBefore(div, element.parentNode.parentNode.children[1]);
// add to end of list
element
.
parentNode
.
appendChild
(
div
);
element
.
parentNode
.
appendChild
(
form_gadget
.
element
);
return
form_gadget
.
renderForm
({
schema
:
options
.
schema_part
,
document
:
options
.
default_dict
,
...
...
@@ -476,6 +468,23 @@
});
})
.
declareAcquiredMethod
(
"
deleteChildrenParent
"
,
"
deleteChildren
"
)
.
allowPublicAcquisition
(
"
deleteChildren
"
,
function
(
scope
)
{
var
arrays
=
this
.
props
.
arrays
,
subforms
=
this
.
props
.
subforms
,
element
=
this
.
element
.
querySelector
(
"
div[data-gadget-scope='
"
+
scope
+
"
']
"
);
if
(
!
arrays
.
hasOwnProperty
(
element
.
getAttribute
(
'
data-json-parent
'
)))
{
if
(
subforms
.
hasOwnProperty
(
scope
))
{
delete
subforms
[
scope
].
element
;
delete
subforms
[
scope
];
}
}
element
.
parentNode
.
removeChild
(
element
);
})
.
declareMethod
(
"
selfRemove
"
,
function
()
{
return
this
.
deleteChildrenParent
(
this
.
element
.
getAttribute
(
'
data-gadget-scope
'
));
})
.
declareAcquiredMethod
(
"
processValidationParent
"
,
"
processValidation
"
)
.
allowPublicAcquisition
(
"
processValidation
"
,
function
(
json_dict
)
{
return
this
.
processValidation
(
undefined
,
json_dict
);
...
...
@@ -548,7 +557,8 @@
.
declareMethod
(
'
renderForm
'
,
function
(
options
)
{
var
g
=
this
,
key
=
options
.
key
,
schema
=
options
.
schema
;
schema
=
options
.
schema
,
delete_button
;
g
.
props
.
inputs
=
[];
g
.
props
.
add_buttons
=
[];
g
.
props
.
arrays
=
{};
...
...
@@ -566,6 +576,14 @@
while
(
g
.
element
.
firstChild
)
{
g
.
element
.
removeChild
(
g
.
element
.
firstChild
);
}
if
(
!
g
.
props
.
toplevel
)
{
delete_button
=
document
.
createElement
(
"
button
"
);
delete_button
.
type
=
"
button
"
;
delete_button
.
name
=
options
.
path
;
delete_button
.
textContent
=
"
Delete
"
;
g
.
props
.
delete_button
=
delete_button
;
g
.
element
.
appendChild
(
delete_button
);
}
return
render_field
(
g
,
key
,
""
,
schema
,
options
.
document
,
g
.
element
)
.
push
(
function
()
{
g
.
listenEvents
();
...
...
@@ -576,6 +594,7 @@
.
declareMethod
(
'
render
'
,
function
(
options
)
{
var
g
=
this
,
queue
;
g
.
props
.
toplevel
=
true
;
g
.
options
=
options
;
if
(
!
options
.
value
)
{
options
.
value
=
{};
...
...
@@ -610,6 +629,15 @@
i
,
promise_list
=
[];
if
(
g
.
props
.
delete_button
)
{
promise_list
.
push
(
loopEventListener
(
g
.
props
.
delete_button
,
'
click
'
,
false
,
g
.
selfRemove
.
bind
(
g
)
));
}
for
(
i
=
0
;
i
<
field_list
.
length
;
i
=
i
+
1
)
{
promise_list
.
push
(
loopEventListener
(
field_list
[
i
],
...
...
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