Commit d631b4f7 authored by Eteri's avatar Eteri

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

parent 98c8e221
......@@ -2,10 +2,6 @@ from Products.ERP5Type.Document import newTempBase
if context.getArray() is None:
return []
length = context.getArrayShape()[0]
if length == 0:
return []
class SequenceSliceMap():
def __init__(self, sequence_slice, usual_slice_length, total_length):
......@@ -41,22 +37,32 @@ def createTempBase(nr, row):
**{col[0]: str(getElement(row, i)) for i, col in column_iterator})
length = context.getArrayShape()[0]
# never access more than 1000 lines at once
list_lines = min(list_lines, limit, 1000)
list_end = list_start + list_lines
if list_end > length:
list_end = length
list_start = list_end - (list_end % list_lines)
if context.REQUEST.has_key("limit"):
list_start = limit[0]
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:
array_slice = [context.getArrayIndex(list_start)]
else:
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 SequenceSliceMap(temp_base_list, list_lines, length)
......@@ -95,9 +95,7 @@
</item>
<item>
<key> <string>url_columns</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
<value> <string></string> </value>
</item>
</dictionary>
</value>
......@@ -136,7 +134,7 @@
<item>
<key> <string>list_method</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
......@@ -186,19 +184,6 @@
</pickle>
</record>
<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>
<global name="Method" module="Products.Formulator.MethodField"/>
</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