Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
erp5
Commits
dd8d76f4
Commit
dd8d76f4
authored
Oct 12, 2018
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_json_form: update version from
https://lab.nexedi.com/bk/rjs_json_form
parent
420c2a32
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
94 additions
and
54 deletions
+94
-54
bt5/erp5_json_form/SkinTemplateItem/portal_skins/erp5_json_form/jsonform.gadget.js.js
...ateItem/portal_skins/erp5_json_form/jsonform.gadget.js.js
+20
-3
bt5/erp5_json_form/SkinTemplateItem/portal_skins/erp5_json_form/jsonform/gadget_json_generated_form_child.js.js
...json_form/jsonform/gadget_json_generated_form_child.js.js
+74
-51
No files found.
bt5/erp5_json_form/SkinTemplateItem/portal_skins/erp5_json_form/jsonform.gadget.js.js
View file @
dd8d76f4
...
...
@@ -342,10 +342,27 @@
}
var
key
,
p
;
if
(
x
.
hasOwnProperty
(
"
$ref
"
)
||
y
.
hasOwnProperty
(
"
$ref
"
))
{
if
(
doesntcopy
)
{
// we need reference resolve before merging
// so allOf schema returned and array item or object field
// run merging on next iteration.
return
{
allOf
:
[
x
,
y
]
};
}
else
{
throw
new
Error
(
"
all reference must be resolved before merge run on first recursion level
"
);
}
}
if
(
x
===
true
)
{
x
=
{};
}
else
if
(
!
doesntcopy
)
{
x
=
JSON
.
parse
(
JSON
.
stringify
(
x
));
// cleanup already walked schema variations
if
(
x
.
anyOf
)
{
delete
x
.
anyOf
;
}
...
...
@@ -385,11 +402,11 @@
case
"
additionalItems
"
:
case
"
contains
"
:
case
"
propertyNames
"
:
mergeSchemas
(
x
[
key
],
y
[
key
],
true
);
x
[
key
]
=
mergeSchemas
(
x
[
key
],
y
[
key
],
true
);
break
;
case
"
items
"
:
// XXX items can be array
mergeSchemas
(
x
[
key
],
y
[
key
],
true
);
x
[
key
]
=
mergeSchemas
(
x
[
key
],
y
[
key
],
true
);
break
;
case
"
contentEncoding
"
:
case
"
contentMediaType
"
:
...
...
@@ -427,7 +444,7 @@
for
(
p
in
y
[
key
])
{
if
(
y
[
key
].
hasOwnProperty
(
p
))
{
if
(
x
[
key
].
hasOwnProperty
(
p
))
{
mergeSchemas
(
x
[
key
][
p
],
y
[
key
][
p
],
true
);
x
[
key
][
p
]
=
mergeSchemas
(
x
[
key
][
p
],
y
[
key
][
p
],
true
);
}
else
{
x
[
key
][
p
]
=
y
[
key
][
p
];
}
...
...
bt5/erp5_json_form/SkinTemplateItem/portal_skins/erp5_json_form/jsonform/gadget_json_generated_form_child.js.js
View file @
dd8d76f4
...
...
@@ -921,56 +921,8 @@
typeof
json_document
!==
type
;
}
div
=
document
.
createElement
(
"
div
"
);
div
.
setAttribute
(
"
class
"
,
"
jsonformfield ui-field-contain
"
);
if
(
schema
.
description
)
{
div
.
title
=
schema
.
description
;
}
// if (property_name && !first_path) {
if
(
options
.
delete_button
===
true
)
{
delete_button
=
createElement
(
"
span
"
,
{
"
class
"
:
"
ui-btn-icon-top ui-icon-trash-o
"
}
);
gadget
.
props
.
delete_button
=
delete_button
;
div
.
appendChild
(
delete_button
);
}
else
if
(
options
.
top
!==
true
)
{
if
(
options
.
required
)
{
delete_button
=
createElement
(
"
span
"
,
{
"
class
"
:
"
ui-btn-icon-top ui-icon-circle
"
}
);
div
.
appendChild
(
delete_button
);
}
else
{
delete_button
=
createElement
(
"
span
"
);
delete_button
.
innerHTML
=
"
 
"
;
div
.
appendChild
(
delete_button
);
}
}
label_text
=
[
property_name
,
schema_ob
.
title
]
.
filter
(
function
(
v
)
{
return
v
;
})
.
join
(
"
"
)
// use non-breaking hyphen
.
replace
(
/-/g
,
"
‑
"
);
if
(
property_name
||
options
.
top
)
{
if
(
options
.
top
)
{
label
=
document
.
createElement
(
"
span
"
);
label
.
textContent
=
label_text
;
root
.
appendChild
(
label
);
}
else
{
label
=
document
.
createElement
(
"
label
"
);
label
.
textContent
=
label_text
;
div
.
appendChild
(
label
);
}
}
div_input
=
document
.
createElement
(
"
div
"
);
div_input
.
setAttribute
(
"
id
"
,
gadget
.
element
.
getAttribute
(
"
data-gadget-scope
"
)
+
first_path
+
'
/
'
);
div_input
.
setAttribute
(
"
class
"
,
"
input
"
);
// render input begin
if
(
!
input
&&
schema_arr
[
0
].
is_arr_of_const
)
{
if
(
!
input
&&
schema_arr
[
0
].
is_arr_of_const
&&
schema_arr
.
length
>
1
)
{
input
=
render_enum_with_title
(
gadget
,
schema_arr
,
json_document
,
options
.
selected_schema
);
}
if
(
!
input
&&
schema
.
const
!==
undefined
)
{
...
...
@@ -1060,7 +1012,59 @@
}
}
}
if
(
schema
.
default
!==
undefined
)
{
input
.
setAttribute
(
'
data-default-value
'
,
JSON
.
stringify
(
schema
.
default
));
input
.
placeholder
=
schema
.
default
;
}
}
// render input end
// html layout render begin
div
=
document
.
createElement
(
"
div
"
);
div
.
setAttribute
(
"
class
"
,
"
jsonformfield ui-field-contain
"
);
if
(
schema
.
description
)
{
div
.
title
=
schema
.
description
;
}
// if (property_name && !first_path) {
if
(
options
.
delete_button
===
true
)
{
delete_button
=
createElement
(
"
span
"
,
{
"
class
"
:
"
ui-btn-icon-top ui-icon-trash-o
"
}
);
gadget
.
props
.
delete_button
=
delete_button
;
div
.
appendChild
(
delete_button
);
}
else
if
(
options
.
top
!==
true
)
{
if
(
options
.
required
)
{
delete_button
=
createElement
(
"
span
"
,
{
"
class
"
:
"
ui-btn-icon-top ui-icon-circle
"
}
);
div
.
appendChild
(
delete_button
);
}
else
{
delete_button
=
createElement
(
"
span
"
);
delete_button
.
innerHTML
=
"
 
"
;
div
.
appendChild
(
delete_button
);
}
}
label_text
=
[
property_name
,
schema_ob
.
title
]
.
filter
(
function
(
v
)
{
return
v
;
})
.
join
(
"
"
)
// use non-breaking hyphen
.
replace
(
/-/g
,
"
‑
"
);
if
(
property_name
||
options
.
top
)
{
if
(
options
.
top
)
{
label
=
document
.
createElement
(
"
span
"
);
label
.
textContent
=
label_text
;
root
.
appendChild
(
label
);
}
else
{
label
=
document
.
createElement
(
"
label
"
);
label
.
textContent
=
label_text
;
div
.
appendChild
(
label
);
}
}
div_input
=
document
.
createElement
(
"
div
"
);
div_input
.
setAttribute
(
"
id
"
,
gadget
.
element
.
getAttribute
(
"
data-gadget-scope
"
)
+
first_path
+
'
/
'
);
div_input
.
setAttribute
(
"
class
"
,
"
input
"
);
if
(
!
input
&&
type
===
"
array
"
)
{
queue
=
render_array
(
...
...
@@ -1100,12 +1104,11 @@
//input.setAttribute("class", "slapos-parameter");
div_input
.
appendChild
(
input
);
}
else
{
div
.
setAttribute
(
"
data-parent-scope
"
,
gadget
.
element
.
getAttribute
(
"
data-gadget-scope
"
));
div
.
setAttribute
(
"
data-json-path
"
,
first_path
+
'
/
'
);
div
.
setAttribute
(
"
data-json-type
"
,
type
);
}
// render input end
if
(
schema
.
info
!==
undefined
)
{
span_info
=
document
.
createElement
(
"
span
"
);
span_info
.
textContent
=
schema
.
info
;
...
...
@@ -1116,6 +1119,7 @@
error_message
.
hidden
=
true
;
div_input
.
appendChild
(
error_message
);
div
.
appendChild
(
div_input
);
// html layout render end
return
queue
.
push
(
function
()
{
...
...
@@ -1322,6 +1326,11 @@
root
.
appendChild
(
child
);
}
if
(
JSON
.
stringify
(
schema
.
default
)
===
'
{}
'
)
{
// save default value as attribute only for empty values
root
.
parentElement
.
setAttribute
(
"
data-default-value
"
,
'
{}
'
);
}
if
(
json_document
===
undefined
)
{
if
(
schema
.
hasOwnProperty
(
'
default
'
))
{
json_document
=
schema
.
default
;
...
...
@@ -1585,6 +1594,18 @@
});
}
// set empty object if default value require this
array
=
g
.
element
.
querySelectorAll
(
"
div[data-parent-scope='
"
+
g
.
element
.
getAttribute
(
"
data-gadget-scope
"
)
+
"
']
"
);
for
(
i
=
0
;
i
<
array
.
length
;
i
+=
1
)
{
path
=
array
[
i
].
getAttribute
(
"
data-json-path
"
).
slice
(
0
,
-
1
);
if
(
array
[
i
].
getAttribute
(
"
data-default-value
"
)
===
"
{}
"
)
{
convertOnMultiLevel
(
multi_level_dict
,
path
,
{});
}
}
for
(
path
in
options
.
arrays
)
{
if
(
options
.
arrays
.
hasOwnProperty
(
path
))
{
array
=
options
.
arrays
[
path
]
...
...
@@ -1649,6 +1670,8 @@
}
else
{
json_dict
[
input
.
name
]
=
input
.
value
;
}
}
else
if
(
input
.
hasAttribute
(
'
data-default-value
'
))
{
json_dict
[
input
.
name
]
=
JSON
.
parse
(
input
.
getAttribute
(
'
data-default-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