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
f2c8b82e
Commit
f2c8b82e
authored
Apr 15, 2018
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add expandProperties()
parent
6d65e3c3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
4 deletions
+44
-4
gadget_json_generated_form.js
gadget_json_generated_form.js
+44
-4
No files found.
gadget_json_generated_form.js
View file @
f2c8b82e
...
...
@@ -266,7 +266,7 @@
});
}
expandSchema
=
function
(
g
,
schema
,
schema_path
)
{
expandSchema
=
function
(
g
,
schema
,
schema_path
,
ref
)
{
if
(
schema
===
undefined
)
{
schema
=
true
;
}
...
...
@@ -279,18 +279,57 @@
if
(
schema
.
$ref
)
{
return
g
.
loadJSONSchema
(
schema
.
$ref
,
schema_path
)
.
push
(
function
(
schema_part
)
{
return
expandSchema
(
g
,
schema_part
,
schema_path
);
return
expandSchema
(
g
,
schema_part
,
schema_path
,
schema
.
$ref
);
});
}
return
RSVP
.
Queue
()
.
push
(
function
()
{
return
[{
title
:
ref
||
schema
.
title
,
schema
:
schema
,
schema_path
:
schema_path
}];
});
};
function
expandProperties
(
g
,
properties
,
schema_path
)
{
return
RSVP
.
Queue
()
.
push
(
function
()
{
var
property_name
,
arr
=
[];
function
addPropertyName
(
p_name
)
{
return
function
(
schema_array
)
{
var
i
;
for
(
i
=
0
;
i
<
schema_array
.
length
;
i
+=
1
)
{
// add propertyName to title
schema_array
[
i
].
title
=
p_name
+
'
/
'
+
schema_array
[
i
].
title
;
// add propertyName to schemaItem
schema_array
[
i
].
property_name
=
property_name
;
}
return
schema_array
;
};
}
for
(
property_name
in
properties
)
{
if
(
properties
.
hasOwnProperty
(
property_name
))
{
arr
.
push
(
expandSchema
(
g
,
properties
[
property_name
],
schema_path
+
'
/properties/
'
+
encodeJsonPointer
(
property_name
))
.
push
(
addPropertyName
(
property_name
))
);
}
}
return
RSVP
.
all
(
arr
);
})
.
push
(
function
(
arr
)
{
var
i
,
schema_arr
=
[];
for
(
i
=
0
;
i
<
arr
.
length
;
i
+=
1
)
{
schema_arr
.
concat
(
arr
[
i
]);
}
return
schema_arr
;
});
}
function
render_select_type
(
gadget
,
title
,
schema_arr
,
event
)
{
var
scope
=
Math
.
random
().
toString
(
36
).
substr
(
2
,
9
),
type_arr
=
[],
...
...
@@ -313,7 +352,7 @@
}
else
{
for
(
i
=
0
;
i
<
schema_arr
.
length
;
i
+=
1
)
{
schema_item
=
schema_arr
[
i
];
description
=
schema_item
.
schema
.
$ref
||
schema_item
.
schema
.
title
;
description
=
schema_item
.
title
;
if
(
getDocumentType
(
schema_item
.
schema
.
type
)
===
"
array
"
)
{
description
=
description
||
schema_item
.
schema
.
description
;
for
(
z
=
0
;
z
<
schema_item
.
schema
.
type
.
length
;
z
+=
1
)
{
...
...
@@ -322,6 +361,7 @@
title
:
description
+
'
#
'
+
type
,
value
:
{
type
:
type
,
property_name
:
schema_item
.
property_name
,
schema_path
:
schema_item
.
schema_path
,
schema
:
schema_item
.
schema
}
...
...
@@ -334,7 +374,7 @@
type_arr
.
push
({
title
:
description
,
value
:
{
type
:
undefined
,
property_name
:
schema_item
.
property_name
,
schema_path
:
schema_item
.
schema_path
,
schema
:
schema_item
.
schema
}
...
...
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