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
38410e04
Commit
38410e04
authored
May 03, 2019
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp5_json_form] update from
https://lab.nexedi.com/bk/rjs_json_form
parent
af39d338
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
131 additions
and
112 deletions
+131
-112
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
+131
-112
No files found.
bt5/erp5_json_form/SkinTemplateItem/portal_skins/erp5_json_form/jsonform/gadget_json_generated_form_child.js.js
View file @
38410e04
...
@@ -940,22 +940,112 @@
...
@@ -940,22 +940,112 @@
});
});
}
}
function
create_layout
(
gadget
,
options
,
create_field
)
{
var
div
,
div_input
;
return
RSVP
.
Queue
()
.
push
(
function
()
{
var
delete_button
,
label
,
label_text
;
div
=
document
.
createElement
(
"
div
"
);
div
.
setAttribute
(
"
class
"
,
"
jsonformfield ui-field-contain
"
);
if
(
options
.
schema
.
description
)
{
div
.
title
=
options
.
schema
.
description
;
}
// if (property_name && !options.json_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
=
[
options
.
property_name
,
options
.
schema_ob
.
title
]
.
filter
(
function
(
v
)
{
return
v
;
})
.
join
(
"
"
)
// use non-breaking hyphen
.
replace
(
/-/g
,
"
‑
"
);
if
(
options
.
property_name
||
options
.
top
)
{
if
(
options
.
top
)
{
label
=
document
.
createElement
(
"
span
"
);
label
.
textContent
=
label_text
;
options
.
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
"
)
+
options
.
json_path
+
'
/
'
);
div_input
.
setAttribute
(
"
class
"
,
"
input
"
);
return
div_input
;
})
.
push
(
function
(
div_input
)
{
return
create_field
(
div_input
);
})
.
push
(
function
(
input
)
{
var
span_info
,
error_message
;
if
(
input
)
{
// object and array excluded from
// gadget.props.inputs not contain values
gadget
.
props
.
inputs
.
push
(
input
);
input
.
name
=
options
.
json_path
;
input
.
required
=
options
.
required
;
if
(
options
.
type_changed
)
{
input
.
setAttribute
(
'
data-origin-value
'
,
JSON
.
stringify
(
options
.
json_document
));
}
// XXX for gui
//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
"
,
options
.
json_path
+
'
/
'
);
div
.
setAttribute
(
"
data-json-type
"
,
options
.
type
);
if
(
options
.
required
)
{
div
.
setAttribute
(
"
data-json-required
"
,
"
true
"
);
}
}
if
(
options
.
schema
.
info
!==
undefined
)
{
span_info
=
document
.
createElement
(
"
span
"
);
span_info
.
textContent
=
options
.
schema
.
info
;
div_input
.
appendChild
(
span_info
);
}
error_message
=
document
.
createElement
(
"
span
"
);
error_message
.
setAttribute
(
"
class
"
,
"
error
"
);
error_message
.
hidden
=
true
;
div_input
.
appendChild
(
error_message
);
div
.
appendChild
(
div_input
);
return
div
;
});
}
function
render_field
(
gadget
,
property_name
,
path
,
schema_arr
,
json_document
,
root
,
options
)
{
function
render_field
(
gadget
,
property_name
,
path
,
schema_arr
,
json_document
,
root
,
options
)
{
var
type
,
var
type
,
div
,
delete_button
,
label
,
label_text
,
div_input
,
span_info
,
error_message
,
input
,
input
,
schema
,
schema
,
schema_path
,
schema_path
,
schema_ob
,
schema_ob
,
first_path
,
first_path
,
type_changed
,
type_changed
;
queue
=
RSVP
.
Queue
();
if
(
options
.
selected_schema
)
{
if
(
options
.
selected_schema
)
{
schema_ob
=
options
.
selected_schema
;
schema_ob
=
options
.
selected_schema
;
...
@@ -1101,112 +1191,41 @@
...
@@ -1101,112 +1191,41 @@
// render input end
// render input end
// html layout render begin
// html layout render begin
div
=
document
.
createElement
(
"
div
"
);
options
.
schema
=
schema
;
div
.
setAttribute
(
"
class
"
,
"
jsonformfield ui-field-contain
"
);
options
.
schema_ob
=
schema_ob
;
if
(
schema
.
description
)
{
options
.
json_path
=
first_path
;
div
.
title
=
schema
.
description
;
options
.
json_document
=
json_document
;
}
options
.
root
=
root
;
// if (property_name && !first_path) {
options
.
property_name
=
property_name
;
if
(
options
.
delete_button
===
true
)
{
options
.
type_changed
=
type_changed
;
delete_button
=
createElement
(
"
span
"
,
return
create_layout
(
gadget
,
options
,
function
(
div_input
)
{
{
"
class
"
:
"
ui-btn-icon-top ui-icon-trash-o
"
}
var
q
;
if
(
input
)
{
return
input
;
}
if
(
type
===
"
array
"
)
{
q
=
render_array
(
gadget
,
schema
,
json_document
,
div_input
,
first_path
+
'
/
'
,
schema_path
);
);
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
);
}
}
}
if
(
type
===
"
object
"
)
{
q
=
render_object
(
div_input
=
document
.
createElement
(
"
div
"
);
gadget
,
div_input
.
setAttribute
(
"
id
"
,
gadget
.
element
.
getAttribute
(
"
data-gadget-scope
"
)
+
first_path
+
'
/
'
);
schema
,
div_input
.
setAttribute
(
"
class
"
,
"
input
"
);
json_document
,
div_input
,
if
(
!
input
&&
type
===
"
array
"
)
{
first_path
+
'
/
'
,
queue
=
render_array
(
schema_path
gadget
,
);
schema
,
json_document
,
div_input
,
first_path
+
'
/
'
,
schema_path
);
}
if
(
!
input
&&
type
===
"
object
"
)
{
queue
.
push
(
function
()
{
return
render_object
(
gadget
,
schema
,
json_document
,
div_input
,
first_path
+
'
/
'
,
schema_path
);
});
}
if
(
input
)
{
// object and array excluded from
// gadget.props.inputs not contain values
gadget
.
props
.
inputs
.
push
(
input
);
input
.
name
=
first_path
;
input
.
required
=
options
.
required
;
if
(
type_changed
)
{
input
.
setAttribute
(
'
data-origin-value
'
,
JSON
.
stringify
(
json_document
));
}
// XXX for gui
//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
);
if
(
options
.
required
)
{
div
.
setAttribute
(
"
data-json-required
"
,
"
true
"
);
}
}
}
return
q
;
})
if
(
schema
.
info
!==
undefined
)
{
.
push
(
function
(
div
)
{
span_info
=
document
.
createElement
(
"
span
"
);
span_info
.
textContent
=
schema
.
info
;
div_input
.
appendChild
(
span_info
);
}
error_message
=
document
.
createElement
(
"
span
"
);
error_message
.
setAttribute
(
"
class
"
,
"
error
"
);
error_message
.
hidden
=
true
;
div_input
.
appendChild
(
error_message
);
div
.
appendChild
(
div_input
);
// html layout render end
return
queue
.
push
(
function
()
{
root
.
appendChild
(
div
);
root
.
appendChild
(
div
);
return
div
;
return
div
;
});
});
...
...
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