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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tomáš Peterka
erp5
Commits
45641950
Commit
45641950
authored
Nov 29, 2017
by
Tomáš Peterka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Functional stats line in ListBox
parent
a26aa2dd
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
168 additions
and
120 deletions
+168
-120
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
...rtal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
+47
-23
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_jio_js.js
...athTemplateItem/web_page_module/rjs_gadget_erp5_jio_js.js
+7
-3
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_jio_js.xml
...thTemplateItem/web_page_module/rjs_gadget_erp5_jio_js.xml
+2
-2
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_listbox_html.html
...ateItem/web_page_module/rjs_gadget_erp5_listbox_html.html
+26
-43
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_listbox_html.xml
...lateItem/web_page_module/rjs_gadget_erp5_listbox_html.xml
+2
-2
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_listbox_js.js
...emplateItem/web_page_module/rjs_gadget_erp5_listbox_js.js
+82
-45
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_listbox_js.xml
...mplateItem/web_page_module/rjs_gadget_erp5_listbox_js.xml
+2
-2
No files found.
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
View file @
45641950
...
@@ -676,8 +676,8 @@ def renderField(traversed_document, field, form, value=None, meta_type=None, key
...
@@ -676,8 +676,8 @@ def renderField(traversed_document, field, form, value=None, meta_type=None, key
"lines"
:
field
.
get_value
(
'lines'
),
"lines"
:
field
.
get_value
(
'lines'
),
"default_params"
:
ensure_serializable
(
default_params
),
"default_params"
:
ensure_serializable
(
default_params
),
"list_method"
:
list_method_name
,
"list_method"
:
list_method_name
,
"s
tat_method"
:
field
.
get_value
(
'stat_method'
).
getMethodName
()
if
field
.
get_value
(
'stat_method'
)
!=
""
else
""
,
"s
how_stat"
:
field
.
get_value
(
'stat_method'
)
!=
""
or
len
(
field
.
get_value
(
'stat_columns'
))
>
0
,
"
count_method"
:
field
.
get_value
(
'count_method'
).
getMethodName
()
if
field
.
get_value
(
'count_method'
)
!=
""
else
""
,
"
show_count"
:
field
.
get_value
(
'count_method'
)
!=
""
,
"query"
:
url_template_dict
[
"jio_search_template"
]
%
{
"query"
:
url_template_dict
[
"jio_search_template"
]
%
{
"query"
:
make_query
({
"query"
:
make_query
({
"query"
:
sql_catalog
.
buildQuery
(
"query"
:
sql_catalog
.
buildQuery
(
...
@@ -1430,8 +1430,11 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
...
@@ -1430,8 +1430,11 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
editable_field_dict
=
{}
editable_field_dict
=
{}
listbox_form
=
None
listbox_form
=
None
listbox_field_id
=
None
listbox_field_id
=
None
source_field_meta_type
=
source_field
.
meta_type
if
source_field
is
not
None
else
""
if
source_field_meta_type
==
"ProxyField"
:
source_field_meta_type
=
source_field
.
getRecursiveTemplateField
().
meta_type
if
source_field
is
not
None
and
source_field
.
meta_type
==
"ListBox"
:
if
source_field
is
not
None
and
source_field
_
meta_type
==
"ListBox"
:
listbox_field_id
=
source_field
.
id
listbox_field_id
=
source_field
.
id
# XXX Proxy field are not correctly handled in traversed_document of web site
# XXX Proxy field are not correctly handled in traversed_document of web site
listbox_form
=
getattr
(
traversed_document
,
source_field
.
aq_parent
.
id
)
listbox_form
=
getattr
(
traversed_document
,
source_field
.
aq_parent
.
id
)
...
@@ -1454,7 +1457,13 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
...
@@ -1454,7 +1457,13 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
start
,
num_items
=
0
,
len
(
search_result_iterable
)
start
,
num_items
=
0
,
len
(
search_result_iterable
)
contents_list
=
[]
# resolved fields from the search result
contents_list
=
[]
# resolved fields from the search result
result_dict
.
update
({
'_query'
:
query
,
'_local_roles'
:
local_roles
,
'_limit'
:
limit
,
'_select_list'
:
select_list
,
'_embedded'
:
{}
})
# now fill in `contents_list` with actual information
# now fill in `contents_list` with actual information
# beware that search_result_iterable can hide anything inside!
# beware that search_result_iterable can hide anything inside!
for
result_index
,
search_result
in
enumerate
(
search_result_iterable
):
for
result_index
,
search_result
in
enumerate
(
search_result_iterable
):
...
@@ -1514,45 +1523,60 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
...
@@ -1514,45 +1523,60 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
# given search_result. This name can unfortunately mean almost anything from
# given search_result. This name can unfortunately mean almost anything from
# a key name to Python Script with variable number of input parameters.
# a key name to Python Script with variable number of input parameters.
contents_item
[
select
]
=
resolve_field
(
search_result
,
select
,
property_getter
,
property_hasser
)
contents_item
[
select
]
=
resolve_field
(
search_result
,
select
,
property_getter
,
property_hasser
)
# endfor select
# endfor select
contents_list
.
append
(
contents_item
)
contents_list
.
append
(
contents_item
)
result_dict
.
update
({
result_dict
[
'_embedded'
].
update
({
'_query'
:
query
,
'contents'
:
contents_list
'_local_roles'
:
local_roles
,
'_limit'
:
limit
,
'_select_list'
:
select_list
,
'_embedded'
:
{
'contents'
:
contents_list
}
})
})
# Compute statistics if the search issuer was ListBox
# Compute statistics if the search issuer was ListBox
# or in future if the stats (SUM) are required by JIO call
# or in future if the stats (SUM) are required by JIO call
contents_stat_list
=
[]
source_field_meta_type
=
source_field
.
meta_type
if
source_field
is
not
None
else
""
if
source_field
is
not
None
and
source_field
.
meta_type
==
"ListBox"
:
if
source_field_meta_type
==
"ProxyField"
:
source_field_meta_type
=
source_field
.
getRecursiveTemplateField
().
meta_type
context
.
log
(
'source_field "{!s}", source_field_meta_type {!s}'
.
format
(
source_field
,
source_field_meta_type
))
if
source_field
is
not
None
and
source_field_meta_type
==
"ListBox"
:
contents_stat_list
=
[]
# in case the search was issued by listbox we can provide results of
# in case the search was issued by listbox we can provide results of
# stat_method and count_method back to the caller
# stat_method and count_method back to the caller
# XXX: we should check whether they asked for it
# XXX: we should check whether they asked for it
stat_method
=
source_field
.
get_value
(
'stat_method'
)
stat_method
=
source_field
.
get_value
(
'stat_method'
)
stat_columns
=
source_field
.
get_value
(
'stat_columns'
)
stat_columns
=
source_field
.
get_value
(
'stat_columns'
)
context
.
log
(
'stat_method "{!s}", stat_columns {!s}'
.
format
(
stat_method
,
stat_columns
))
# Selection is unfortunatelly required fot stat methods
selection_name
=
source_field
.
get_value
(
'selection_name'
)
selection
=
None
if
selection_name
:
selection_tool
=
context
.
getPortalObject
().
portal_selections
selection
=
selection_tool
.
getSelectionFor
(
selection_name
,
REQUEST
)
contents_stat
=
{}
contents_stat
=
{}
if
len
(
stat_columns
)
>
0
:
if
len
(
stat_columns
)
>
0
:
# prefer stat per columns as it is in ListBox
# prefer stat per columns as it is in ListBox
# always called on current context
# always called on current context
for
stat_name
,
stat_script
in
stat_columns
:
for
stat_name
,
stat_script
in
stat_columns
:
contents_stat
[
stat_name
]
=
getattr
(
traversed_document
,
stat_script
)(
**
catalog_kw
)
contents_stat
[
stat_name
]
=
getattr
(
traversed_document
,
stat_script
)(
selection
=
selection
,
selection_name
=
selection_name
,
**
catalog_kw
)
contents_stat_list
.
append
(
contents_stat
)
contents_stat_list
.
append
(
contents_stat
)
elif
stat_method
!=
""
and
stat_method
.
getMethodName
()
!=
list_method
_name
:
elif
stat_method
!=
""
and
stat_method
.
getMethodName
()
!=
list_method
:
# g
lob
al stat_method is second - should return dictionary or list of dictionaries
# g
ener
al stat_method is second - should return dictionary or list of dictionaries
# where all "fields" should be accessible by
its
"select" name
# where all "fields" should be accessible by
their
"select" name
contents_stat_list
=
getattr
(
traversed_document
,
stat_method
.
getMethodName
())(
**
catalog_kw
)
contents_stat_list
=
getattr
(
traversed_document
,
stat_method
.
getMethodName
())(
**
catalog_kw
)
if
len
(
contents_stat_list
)
>
0
:
for
contents_stat
in
contents_stat_list
:
result_dict
[
'_embedded'
].
update
({
for
key
,
value
in
contents_stat
.
items
():
'contents'
:
contents_list
if
key
in
editable_field_dict
:
})
contents_stat
[
key
]
=
renderField
(
traversed_document
,
editable_field_dict
[
key
],
listbox_form
,
value
,
key
=
editable_field_dict
[
key
].
id
+
'__sum'
)
context
.
log
(
'contents_stat_list {!s}'
.
format
(
contents_stat_list
))
if
len
(
contents_stat_list
)
>
0
:
result_dict
[
'_embedded'
].
update
({
'sum'
:
contents_stat_list
})
# We should cleanup the selection if it exists in catalog params BUT
# We should cleanup the selection if it exists in catalog params BUT
# we cannot because it requires escalated Permission.'modifyPortal' so
# we cannot because it requires escalated Permission.'modifyPortal' so
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_jio_js.js
View file @
45641950
...
@@ -179,12 +179,14 @@
...
@@ -179,12 +179,14 @@
)
)
.
push
(
function
(
catalog_json
)
{
.
push
(
function
(
catalog_json
)
{
var
data
=
catalog_json
.
_embedded
.
contents
,
var
data
=
catalog_json
.
_embedded
.
contents
,
count
=
data
.
length
,
summary
=
catalog_json
.
_embedded
.
sum
,
count
=
catalog_json
.
_embedded
.
count
,
length
=
data
.
length
,
k
,
k
,
uri
,
uri
,
item
,
item
,
result
=
[];
result
=
[];
for
(
k
=
0
;
k
<
count
;
k
+=
1
)
{
for
(
k
=
0
;
k
<
length
;
k
+=
1
)
{
item
=
data
[
k
];
item
=
data
[
k
];
uri
=
new
URI
(
item
.
_links
.
self
.
href
);
uri
=
new
URI
(
item
.
_links
.
self
.
href
);
delete
item
.
_links
;
delete
item
.
_links
;
...
@@ -198,7 +200,9 @@
...
@@ -198,7 +200,9 @@
data
:
{
data
:
{
rows
:
result
,
rows
:
result
,
total_rows
:
result
.
length
total_rows
:
result
.
length
}
},
sum
:
summary
,
count
:
count
};
};
});
});
})
})
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_jio_js.xml
View file @
45641950
...
@@ -230,7 +230,7 @@
...
@@ -230,7 +230,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
9
47.45414.13002.10052
</string>
</value>
<value>
<string>
9
63.50499.50100.12458
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -248,7 +248,7 @@
...
@@ -248,7 +248,7 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
1
449753994.81
</float>
<float>
1
511939345.58
</float>
<string>
UTC
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</state>
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_listbox_html.html
View file @
45641950
...
@@ -118,55 +118,37 @@
...
@@ -118,55 +118,37 @@
<
/table
>
<
/table
>
</script>
</script>
<script
id=
"listbox-tfoot-
sum-
template"
type=
"text/x-handlebars-template"
>
<script
id=
"listbox-tfoot-template"
type=
"text/x-handlebars-template"
>
<
table
>
<
table
>
<
tfoot
class
=
"
ui-bar-inherit tfoot
summary
"
>
<
tfoot
class
=
"
ui-bar-inherit tfoot
"
>
{{
#
each
row_list
}}
{{
#
each
row_list
}}
<
tr
>
<
tr
>
{{
#
each
cell_list
}}
{{
#
if
..
/
show_anchor
}}
<
td
>
<
td
><
/td
>
{{
#
if
type
}}
{{
/
if
}}
{{
#
if
editable
}}
{{
#
each
cell_list
}}
<
div
class
=
"
editable_div
"
data
-
column
=
"
{{column}}
"
data
-
line
=
"
{{line}}
"
><
/div
>
<
td
>
{{
else
}}
{{
#
if
type
}}
<
a
href
=
"
{{href}}
"
class
=
"
ui-link
"
>
<
div
class
=
"
editable_div
"
data
-
column
=
"
{{column}}
"
data
-
line
=
"
{{line}}
"
><
/div
>
<
div
class
=
"
editable_div
"
data
-
column
=
"
{{column}}
"
data
-
line
=
"
{{line}}
"
><
/div
>
{{
else
}}
<
/a
>
{{
text
}}
{{
/
if
}}
{{
/if}
}
{{
else
}}
<
/td
>
<
a
href
=
"
{{href}}
"
class
=
"
ui-link
"
>
{{
text
}}
<
/a
>
{{
/
each
}}
{{
/
if
}}
<
/tr
>
<
/td
>
{{
/
each
}}
{{
/
each
}}
<
/tr
>
{{
/
each
}}
<
th
colspan
=
"
{{colspan}}
"
>
<
div
class
=
"
ui-controlgroup ui-controlgroup-horizontal ui-corner-all ui-paging-menu
"
>
<
div
class
=
"
ui-controlgroup-controls
"
>
<
a
class
=
"
{{previous_classname}}
"
data
-
i18n
=
"
Previous
"
href
=
"
{{previous_url}}
"
>
Previous
<
/a
>
<
a
class
=
"
{{next_classname}}
"
data
-
i18n
=
"
Next
"
href
=
"
{{next_url}}
"
>
Next
<
/a
>
<
span
class
=
"
ui-btn ui-disabled
"
data
-
i18n
=
"
{{record}}
"
>
{{
record
}}
<
/span
>
<
/div
>
<
/div
>
<
/th
>
<
/tfoot
>
<
/tfoot
>
<
/table
>
<
/table
>
</script>
</script>
<script
id=
"listbox-tfoot-count-template"
type=
"text/x-handlebars-template"
>
<script
id=
"listbox-nav-template"
type=
"text/x-handlebars-template"
>
<
table
>
<
nav
class
=
"
ui-bar-inherit ui-controlgroup ui-controlgroup-horizontal ui-corner-all ui-paging-menu
"
>
<
tfoot
class
=
"
ui-bar-inherit tfoot
"
>
<
div
class
=
"
ui-controlgroup-controls
"
>
<
th
colspan
=
"
{{colspan}}
"
>
<
a
class
=
"
{{previous_classname}}
"
data
-
i18n
=
"
Previous
"
href
=
"
{{previous_url}}
"
>
Previous
<
/a
>
<
div
class
=
"
ui-controlgroup ui-controlgroup-horizontal ui-corner-all ui-paging-menu
"
>
<
a
class
=
"
{{next_classname}}
"
data
-
i18n
=
"
Next
"
href
=
"
{{next_url}}
"
>
Next
<
/a
>
<
div
class
=
"
ui-controlgroup-controls
"
>
<
span
class
=
"
ui-btn ui-disabled
"
data
-
i18n
=
"
{{record}}
"
>
{{
record
}}
<
/span
>
<
a
class
=
"
{{previous_classname}}
"
data
-
i18n
=
"
Previous
"
href
=
"
{{previous_url}}
"
>
Previous
<
/a
>
<
/div
>
<
a
class
=
"
{{next_classname}}
"
data
-
i18n
=
"
Next
"
href
=
"
{{next_url}}
"
>
Next
<
/a
>
<
/nav
>
<
span
class
=
"
ui-btn ui-disabled
"
data
-
i18n
=
"
{{record}}
"
>
{{
record
}}
<
/span
>
<
/div
>
<
/div
>
<
/th
>
<
/tfoot
>
<
/table
>
</script>
</script>
<script
id=
"listbox-template"
type=
"text/x-handlebars-template"
>
<script
id=
"listbox-template"
type=
"text/x-handlebars-template"
>
...
@@ -188,6 +170,7 @@
...
@@ -188,6 +170,7 @@
<
tbody
><
/tbody
>
<
tbody
><
/tbody
>
<
tfoot
class
=
"
ui-bar-inherit tfoot
"
><
/tfoot
>
<
tfoot
class
=
"
ui-bar-inherit tfoot
"
><
/tfoot
>
<
/table
>
<
/table
>
<
nav
><
/nav
>
<
/div
>
<
/div
>
</script>
</script>
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_listbox_html.xml
View file @
45641950
...
@@ -234,7 +234,7 @@
...
@@ -234,7 +234,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
963.
47536.5989.57173
</string>
</value>
<value>
<string>
963.
50750.47688.32426
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -252,7 +252,7 @@
...
@@ -252,7 +252,7 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
1511
764805.38
</float>
<float>
1511
952124.83
</float>
<string>
UTC
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</state>
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_listbox_js.js
View file @
45641950
This diff is collapsed.
Click to expand it.
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_listbox_js.xml
View file @
45641950
...
@@ -236,7 +236,7 @@
...
@@ -236,7 +236,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
963.
47634.31999.4898
</string>
</value>
<value>
<string>
963.
50757.35572.58794
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -254,7 +254,7 @@
...
@@ -254,7 +254,7 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
1511
765129.91
</float>
<float>
1511
952430.52
</float>
<string>
UTC
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</state>
...
...
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