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
c516bcd7
Commit
c516bcd7
authored
Aug 07, 2018
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add guessing type of schema
parent
1901db39
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
5 deletions
+44
-5
jsonform/gadget_json_generated_form_child.js
jsonform/gadget_json_generated_form_child.js
+44
-5
No files found.
jsonform/gadget_json_generated_form_child.js
View file @
c516bcd7
...
@@ -22,6 +22,48 @@
...
@@ -22,6 +22,48 @@
return
typeof
doc
;
return
typeof
doc
;
}
}
function
guessSchemaType
(
schema
)
{
var
property_name
;
for
(
property_name
in
schema
)
{
if
(
schema
.
hasOwnProperty
(
property_name
))
{
switch
(
property_name
)
{
// case "allOf":
// case "anyOf":
// case "oneOf":
// return false;
case
"
required
"
:
case
"
maxProperties
"
:
case
"
minProperties
"
:
case
"
additionalProperties
"
:
case
"
properties
"
:
case
"
patternProperties
"
:
case
"
dependencies
"
:
case
"
propertyNames
"
:
return
"
object
"
;
case
"
additionalItems
"
:
case
"
items
"
:
case
"
maxItems
"
:
case
"
minItems
"
:
case
"
uniqueItems
"
:
case
"
contains
"
:
return
"
array
"
;
case
"
maxLength
"
:
case
"
minLength
"
:
case
"
pattern
"
:
case
"
contentEncoding
"
:
case
"
contentMediaType
"
:
return
"
string
"
;
case
"
multipleOf
"
:
case
"
maximum
"
:
case
"
exclusiveMaximum
"
:
case
"
minimum
"
:
case
"
exclusiveMinimum
"
:
return
"
number
"
;
}
}
}
}
function
createElement
(
type
,
props
)
{
function
createElement
(
type
,
props
)
{
var
element
=
document
.
createElement
(
type
),
var
element
=
document
.
createElement
(
type
),
key
;
key
;
...
@@ -1484,11 +1526,8 @@
...
@@ -1484,11 +1526,8 @@
options
.
delete_button
=
!
options
.
required
;
options
.
delete_button
=
!
options
.
required
;
}
}
}
}
if
(
options
.
top
&&
!
options
.
type
&&
!
schema
.
type
)
{
if
(
!
options
.
type
&&
schema
&&
!
schema
.
type
)
{
// XXX use "object" as type for support buggy
options
.
type
=
guessSchemaType
(
schema
);
// slapos schemas where some times type absent
// i need remove it in future
options
.
type
=
"
object
"
;
}
}
while
(
root
.
firstChild
)
{
while
(
root
.
firstChild
)
{
root
.
removeChild
(
root
.
firstChild
);
root
.
removeChild
(
root
.
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