Commit fff85e8d authored by Nicolas Wavrant's avatar Nicolas Wavrant

[renderjs_ui] Support infinite listbox

See merge request !2034
parents 5d240501 95b9cfca
......@@ -2007,14 +2007,20 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
editable_field_dict[select] = proxy_form.get_field(proxy_field_name, include_disabled=1)
break
# handle the case when list-scripts are ignoring `limit` - paginate for them
if limit is not None:
# handle the case when list-scripts are ignoring `limit` - paginate for them.
# Except when `limit` is explicitely set to 0, meaning no limit.
if limit:
if isinstance(limit, (tuple, list)):
start, num_items = map(int, limit)
elif isinstance(limit, int):
start, num_items = 0, limit
else:
start, num_items = 0, int(limit)
if isinstance(limit, int):
limit_int = limit
else:
limit_int = int(limit)
if limit_int == 0:
start, num_items = 0, len(search_result_iterable)
else:
start, num_items = 0, int(limit_int)
if not (is_rendering_listbox and not has_listbox_a_count_method):
# the limit was most likely taken into account thus we don't need to slice
start, num_items = 0, len(search_result_iterable)
......
......@@ -1214,7 +1214,7 @@
select_list.push("uid");
if (gadget.state.lines === 0) {
limit_options = undefined;
limit_options = 0;
} else {
limit_options = [gadget.state.begin_from, gadget.state.lines + 1];
}
......
......@@ -228,7 +228,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
<value> <unicode>zope</unicode> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -242,7 +242,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>994.13949.44825.36573</string> </value>
<value> <string>1021.46754.58269.53777</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -262,7 +262,7 @@
</tuple>
<state>
<tuple>
<float>1629394496.1</float>
<float>1735631070.51</float>
<string>UTC</string>
</tuple>
</state>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>testInfiniteListbox</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<html xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Test Infinite ListBox</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">A listbox with a "lines" property of "0" should not set a display limit</td></tr>
</thead><tbody>
<tal:block metal:use-macro="here/PTZuite_CommonTemplate/macros/init" />
<tr><td>open</td>
<td>${base_url}/foo_module/ListBoxZuite_reset</td><td></td></tr>
<tr><td>assertTextPresent</td>
<td>Reset Successfully.</td><td></td></tr>
<tr><td>open</td>
<td>${base_url}/foo_module/FooModule_createObjects?start:int=1&amp;num:int=100&amp;create_line:int=0</td><td></td></tr>
<tr><td>assertTextPresent</td>
<td>Created Successfully.</td><td></td></tr>
<tr><td>open</td>
<td>${base_url}/foo_module/FooModule_viewFooList/listbox/ListBox_setPropertyList?field_list_method=FooModule_listAsContext&amp;field_columns=id%7CID%0Aquantity%7CQuantity&amp;field_lines=0</td>
<td></td></tr>
<tr><td>assertTextPresent</td>
<td>Set Successfully.</td><td></td></tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/wait_for_activities" />
<!-- Shortcut for full renderjs url -->
<tr><td>store</td>
<td>${base_url}/web_site_module/renderjs_runner</td>
<td>renderjs_url</td></tr>
<tr><td>open</td>
<td>${renderjs_url}/#/foo_module</td><td></td></tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_listbox_loaded" />
<!-- Check that for the 100th created object, for which the quantity is -90,
we have '-90' displayed
-->
<tr>
<td>assertElementPresent</td>
<td>//a[contains(@href, "jio_key=foo_module%2F100") and text()="-90"]</td>
<td></td>
</tr>
<!-- Check that the listbox header counting the elements displays the correct info -->
<tr>
<td>assertElementPresent</td>
<td>//div[contains(@class, "ui-table-header")]/h1[text()="Foos "]/span[text()="(100)"]</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment