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
e59f79f6
Commit
e59f79f6
authored
Apr 06, 2018
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add schema_path and so fix base_url computation
parent
c4a0f84d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
16 deletions
+54
-16
gadget_json_generated_form.js
gadget_json_generated_form.js
+54
-16
No files found.
gadget_json_generated_form.js
View file @
e59f79f6
...
...
@@ -162,6 +162,7 @@
}
return
form_gadget
.
renderForm
({
schema
:
options
.
schema_part
,
schema_path
:
options
.
schema_path
,
document
:
options
.
default_dict
,
display_label
:
options
.
parent_type
!==
"
array
"
,
scope
:
scope
...
...
@@ -169,7 +170,7 @@
});
}
function
render_array
(
gadget
,
json_field
,
default_array
,
root
,
path
)
{
function
render_array
(
gadget
,
json_field
,
default_array
,
root
,
path
,
schema_path
)
{
var
queue
=
RSVP
.
Queue
(),
div
,
div_input
,
...
...
@@ -206,6 +207,7 @@
gadget
:
gadget
,
parent_type
:
'
array
'
,
element
:
input
,
schema_path
:
schema_path
+
'
/items
'
,
schema_part
:
item_schema
})
.
push
(
element_append
);
...
...
@@ -228,6 +230,7 @@
parent_type
:
'
array
'
,
path
:
path
,
element
:
input
,
schema_path
:
schema_path
+
'
/items
'
,
schema_part
:
item_schema
,
default_dict
:
default_array
[
i
]
})
...
...
@@ -241,7 +244,7 @@
return
queue
;
}
function
render_field
(
gadget
,
key
,
path
,
json_field
,
default_value
,
root
,
editable_label
)
{
function
render_field
(
gadget
,
key
,
path
,
json_field
,
default_value
,
root
,
schema_path
)
{
var
div
,
label
,
div_input
,
...
...
@@ -262,9 +265,9 @@
}
if
(
json_field
.
$ref
!==
undefined
)
{
return
gadget
.
loadJSONSchema
(
json_field
.
$ref
,
first
_path
)
return
gadget
.
loadJSONSchema
(
json_field
.
$ref
,
schema
_path
)
.
push
(
function
(
schema_part
)
{
return
render_field
(
gadget
,
key
,
path
,
schema_part
,
default_value
,
root
);
return
render_field
(
gadget
,
key
,
path
,
schema_part
,
default_value
,
root
,
schema_path
);
});
}
...
...
@@ -340,7 +343,8 @@
json_field
,
default_value
,
div_input
,
first_path
+
'
/
'
first_path
+
'
/
'
,
schema_path
);
div
.
setAttribute
(
"
data-json-path
"
,
first_path
+
'
/
'
);
gadget
.
props
.
arrays
[
first_path
+
'
/
'
]
=
div
;
...
...
@@ -355,7 +359,8 @@
json_field
,
default_value
,
div_input
,
first_path
+
'
/
'
first_path
+
'
/
'
,
schema_path
);
});
div
.
setAttribute
(
"
data-json-path
"
,
first_path
+
'
/
'
);
...
...
@@ -387,10 +392,11 @@
});
}
render_object
=
function
(
g
,
json_field
,
default_dict
,
root
,
path
)
{
render_object
=
function
(
g
,
json_field
,
default_dict
,
root
,
path
,
schema_path
)
{
var
additionalProperties
,
key
,
required
=
json_field
.
required
||
[],
properties
=
json_field
.
properties
,
used_properties
=
{},
queue
=
RSVP
.
Queue
(),
scope
=
"
property_add_
"
+
Math
.
random
().
toString
(
36
).
substr
(
2
,
9
),
...
...
@@ -400,13 +406,27 @@
.
push
(
function
(
z
)
{
return
z
.
getContent
()
.
push
(
function
(
value
)
{
var
property_name
=
value
[
scope
];
var
property_name_array
=
value
[
scope
].
split
(
'
/
'
),
property_name
,
schema
,
schema_path_local
,
anyOfidx
=
property_name_array
[
1
];
property_name
=
decodeJsonPointer
(
property_name_array
[
0
]);
schema_path_local
=
schema_path
+
'
/properties/
'
+
encodeJsonPointer
(
property_name
);
if
(
property_name_array
.
length
>
1
)
{
schema
=
json_field
.
properties
[
property_name
].
anyOf
[
anyOfidx
];
schema_path_local
+=
'
/
'
+
anyOfidx
;
}
else
{
schema
=
json_field
.
properties
[
property_name
];
}
used_properties
[
property_name
]
=
""
;
return
addSubForm
({
gadget
:
g
,
property_name
:
property_name
,
path
:
path
,
schema_part
:
json_field
.
properties
[
property_name
]
schema_path
:
schema_path_local
,
schema_part
:
schema
});
})
.
push
(
function
(
element
)
{
...
...
@@ -419,11 +439,28 @@
return
g
.
getDeclaredGadget
(
scope
)
.
push
(
function
(
g
)
{
var
property_name
,
i
,
anyOf
,
description
,
item_list
=
[[
"
add property
"
,
"
add property
"
]];
for
(
property_name
in
json_field
.
properties
)
{
if
(
json_field
.
properties
.
hasOwnProperty
(
property_name
)
&&
for
(
property_name
in
properties
)
{
if
(
properties
.
hasOwnProperty
(
property_name
)
&&
!
used_properties
.
hasOwnProperty
(
property_name
))
{
item_list
.
push
([
property_name
,
property_name
]);
anyOf
=
properties
[
property_name
].
anyOf
;
if
(
anyOf
)
{
for
(
i
=
0
;
i
<
anyOf
.
length
;
i
+=
1
)
{
description
=
anyOf
[
i
].
$ref
||
anyOf
[
i
].
title
||
anyOf
[
i
].
type
||
anyOf
[
i
].
description
;
item_list
.
push
([
property_name
+
'
/
'
+
description
,
encodeJsonPointer
(
property_name
)
+
'
/
'
+
i
.
toString
()
]);
}
}
else
{
item_list
.
push
([
property_name
,
property_name
]);
}
}
}
return
g
.
render
({
...
...
@@ -484,6 +521,7 @@
return
addSubForm
({
gadget
:
g
,
element
:
input
,
schema_path
:
schema_path
+
'
/additionalProperties
'
,
schema_part
:
schema
})
.
push
(
element_append
);
...
...
@@ -503,6 +541,7 @@
property_name
:
property_name
,
path
:
path
,
element
:
input
,
schema_path
:
schema_path
+
'
/additionalProperties
'
,
schema_part
:
schema
,
default_dict
:
default_dict
[
property_name
]
})
...
...
@@ -538,6 +577,7 @@
gadget
:
g
,
property_name
:
key
,
path
:
path
,
schema_path
:
schema_path
+
'
/properties/
'
+
encodeJsonPointer
(
key
),
schema_part
:
json_field
.
properties
[
key
],
default_dict
:
default_dict
[
key
]
})
...
...
@@ -896,7 +936,7 @@
g
.
props
.
delete_button
=
delete_button
;
root
.
appendChild
(
delete_button
);
}
return
render_field
(
g
,
property_name
,
""
,
schema
,
options
.
document
,
root
)
return
render_field
(
g
,
property_name
,
""
,
schema
,
options
.
document
,
root
,
options
.
schema_path
)
.
push
(
function
()
{
g
.
listenEvents
();
return
g
.
element
;
...
...
@@ -910,9 +950,6 @@
base_url
,
hash
;
if
(
!
g
.
props
.
toplevel
)
{
path
=
g
.
element
.
getAttribute
(
'
data-json-parent
'
)
+
encodeJsonPointer
(
g
.
element
.
getAttribute
(
'
data-json-property-name
'
))
+
path
;
return
g
.
loadJSONSchemaParent
(
url
,
path
);
}
// XXX need use $id
...
...
@@ -980,6 +1017,7 @@
g
.
options
.
schema
=
schema
;
return
g
.
renderForm
({
schema
:
schema
,
schema_path
:
""
,
document
:
options
.
value
});
})
...
...
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