Commit 5ad4a202 authored by Ivan Tyagov's avatar Ivan Tyagov

erp5_wendelin: fix array preview for new UI and show data in reversed order

See merge request nexedi/wendelin!48
parents 6549645f d631b4f7
...@@ -2,10 +2,6 @@ from Products.ERP5Type.Document import newTempBase ...@@ -2,10 +2,6 @@ from Products.ERP5Type.Document import newTempBase
if context.getArray() is None: if context.getArray() is None:
return [] return []
length = context.getArrayShape()[0]
if length == 0:
return []
class SequenceSliceMap(): class SequenceSliceMap():
def __init__(self, sequence_slice, usual_slice_length, total_length): def __init__(self, sequence_slice, usual_slice_length, total_length):
...@@ -41,22 +37,32 @@ def createTempBase(nr, row): ...@@ -41,22 +37,32 @@ def createTempBase(nr, row):
**{col[0]: str(getElement(row, i)) for i, col in column_iterator}) **{col[0]: str(getElement(row, i)) for i, col in column_iterator})
length = context.getArrayShape()[0]
# never access more than 1000 lines at once # never access more than 1000 lines at once
list_lines = min(list_lines, limit, 1000) list_lines = min(list_lines, limit, 1000)
list_end = list_start + list_lines
if list_end > length: if context.REQUEST.has_key("limit"):
list_end = length list_start = limit[0]
list_start = list_end - (list_end % list_lines) list_lines = limit[1] - limit[0]
orig_list_start = list_start
if orig_list_start + list_lines > length:
orig_list_start = length - length - (length % list_lines)
list_start = max(length - list_start - list_lines, 0)
if abs(orig_list_start) < list_lines and orig_list_start != 0:
list_end = abs(orig_list_start)
else:
list_end = max(list_start + list_lines, 0)
#list_end = max(list_start + list_lines, 0)
if list_start == list_end: if list_start == list_end:
array_slice = [context.getArrayIndex(list_start)] array_slice = [context.getArrayIndex(list_start)]
else: else:
array_slice = context.getArraySlice(list_start, list_end) array_slice = context.getArraySlice(list_start, list_end)
temp_base_list = [createTempBase(nr + list_start, row) for nr, row in enumerate(array_slice)] temp_base_list = list(reversed([createTempBase(nr + list_start, row) for nr, row in enumerate(array_slice)]))
# return lazy sequence of temp objects # return lazy sequence of temp objects
return SequenceSliceMap(temp_base_list, list_lines, length) return SequenceSliceMap(temp_base_list, list_lines, length)
...@@ -95,9 +95,7 @@ ...@@ -95,9 +95,7 @@
</item> </item>
<item> <item>
<key> <string>url_columns</string> </key> <key> <string>url_columns</string> </key>
<value> <value> <string></string> </value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item> </item>
</dictionary> </dictionary>
</value> </value>
...@@ -136,7 +134,7 @@ ...@@ -136,7 +134,7 @@
<item> <item>
<key> <string>list_method</string> </key> <key> <string>list_method</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value> </value>
</item> </item>
<item> <item>
...@@ -186,19 +184,6 @@ ...@@ -186,19 +184,6 @@
</pickle> </pickle>
</record> </record>
<record id="4" aka="AAAAAAAAAAQ="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: [(col[0], None) for col in here.DataArray_getArrayColumnList()]</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle> <pickle>
<global name="Method" module="Products.Formulator.MethodField"/> <global name="Method" module="Products.Formulator.MethodField"/>
</pickle> </pickle>
......
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