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
73ed449e
Commit
73ed449e
authored
Apr 07, 2018
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
begin allOf support
parent
15ad8951
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
0 deletions
+52
-0
gadget_json_generated_form.js
gadget_json_generated_form.js
+52
-0
No files found.
gadget_json_generated_form.js
View file @
73ed449e
...
...
@@ -244,6 +244,51 @@
return
queue
;
}
function
expandSchema
(
g
,
schema
,
schema_path
)
{
if
(
schema
.
$ref
)
{
return
g
.
loadJSONSchema
(
schema
.
$ref
,
schema_path
)
.
push
(
function
(
schema_part
)
{
return
schema_part
;
});
}
return
RSVP
.
Queue
()
.
push
(
function
()
{
return
schema
;
});
}
function
allOf
(
g
,
schema_array
,
schema_path
)
{
return
RSVP
.
Queue
()
.
push
(
function
()
{
var
i
,
arr
=
[];
for
(
i
=
0
;
i
<
schema_array
.
length
;
i
+=
1
)
{
arr
.
push
(
expandSchema
(
g
,
schema_array
[
i
],
schema_path
));
}
return
RSVP
.
all
(
arr
);
})
.
push
(
function
(
arr
)
{
var
i
,
key
,
next_schema
,
schema
=
arr
[
0
];
for
(
i
=
1
;
i
<
arr
.
length
;
i
+=
1
)
{
next_schema
=
arr
[
i
];
for
(
key
in
next_schema
)
{
if
(
next_schema
.
hasOwnProperty
(
key
))
{
if
(
schema
.
hasOwnProperty
(
key
))
{
// XXX need use many many rules for merging
schema
[
key
]
=
next_schema
[
key
];
}
else
{
schema
[
key
]
=
next_schema
[
key
];
}
}
}
}
return
schema
;
});
}
function
render_field
(
gadget
,
key
,
path
,
json_field
,
default_value
,
root
,
schema_path
)
{
var
div
,
label
,
...
...
@@ -264,6 +309,13 @@
json_field
=
getDocumentSchema
(
default_value
);
}
if
(
json_field
.
allOf
!==
undefined
)
{
return
allOf
(
gadget
,
json_field
.
allOf
,
schema_path
)
.
push
(
function
(
schema_part
)
{
return
render_field
(
gadget
,
key
,
path
,
schema_part
,
default_value
,
root
,
schema_path
);
});
}
if
(
json_field
.
$ref
!==
undefined
)
{
return
gadget
.
loadJSONSchema
(
json_field
.
$ref
,
schema_path
)
.
push
(
function
(
schema_part
)
{
...
...
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