Commit ef3e9913 authored by Jean-Paul Smets's avatar Jean-Paul Smets

Supports reordering of entries

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@10010 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3181ead8
...@@ -48,23 +48,6 @@ SUB_FIELD_ID = 'relation' ...@@ -48,23 +48,6 @@ SUB_FIELD_ID = 'relation'
ITEM_ID = 'item' ITEM_ID = 'item'
NO_VALUE = '??? (No Value)' NO_VALUE = '??? (No Value)'
def checkSameKeys(a , b):
"""
Checks if the two lists contain
the same values
"""
same = 1
for ka in a:
if (not ka in b) and (ka != ''):
same = 0
break
if same:
for kb in b:
if (not kb in a) and (kb != ''):
same = 0
break
return same
class MultiRelationStringFieldWidget(Widget.LinesTextAreaWidget, class MultiRelationStringFieldWidget(Widget.LinesTextAreaWidget,
Widget.TextWidget, Widget.TextWidget,
Widget.ListWidget): Widget.ListWidget):
...@@ -502,7 +485,8 @@ class MultiRelationStringFieldValidator(Validator.LinesValidator): ...@@ -502,7 +485,8 @@ class MultiRelationStringFieldValidator(Validator.LinesValidator):
if isinstance(current_value_list, StringType): if isinstance(current_value_list, StringType):
current_value_list = [current_value_list] current_value_list = [current_value_list]
# Check value list # Check value list
if not (checkSameKeys(value_list, current_value_list)): if value_list != current_value_list: # Changes in the order or in the number of occurences
# must be taken into account
for i in range(len(value_list)): for i in range(len(value_list)):
value = value_list[i] value = value_list[i]
relation_field_id = field.generate_subfield_key("%s_%s" % \ relation_field_id = field.generate_subfield_key("%s_%s" % \
...@@ -530,12 +514,14 @@ class MultiRelationStringFieldValidator(Validator.LinesValidator): ...@@ -530,12 +514,14 @@ class MultiRelationStringFieldValidator(Validator.LinesValidator):
catalog_index = field.get_value('catalog_index') catalog_index = field.get_value('catalog_index')
portal_type_list = [x[0] for x in field.get_value('portal_type')] portal_type_list = [x[0] for x in field.get_value('portal_type')]
portal_catalog = getToolByName(field, 'portal_catalog') portal_catalog = getToolByName(field, 'portal_catalog')
#################################### ####################################
# Check list input # Check list input
#################################### ####################################
relation_field_id = field.generate_subfield_key("%s" % \ relation_field_id = field.generate_subfield_key("%s" % \
SUB_FIELD_ID, key=key) SUB_FIELD_ID, key=key)
relation_uid_list = REQUEST.get(relation_field_id, None) relation_uid_list = REQUEST.get(relation_field_id, None)
#################################### ####################################
# User clicked on the wheel # User clicked on the wheel
#################################### ####################################
...@@ -567,6 +553,7 @@ class MultiRelationStringFieldValidator(Validator.LinesValidator): ...@@ -567,6 +553,7 @@ class MultiRelationStringFieldValidator(Validator.LinesValidator):
display_text = message display_text = message
else: else:
display_text = 'Object has been deleted' display_text = 'Object has been deleted'
################################ ################################
# Modify if user modified his value # Modify if user modified his value
################################ ################################
......
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