Commit 09c0b37d authored by Romain Courteaud's avatar Romain Courteaud

Bug fix: make ParallelistField compatible with ListField as sub-field.

Patch Formulator, in order to modify dynamically the size of the
ParallelistField.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@6405 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9b99a054
...@@ -564,6 +564,35 @@ def MultiItemsWidget_render_items(self, field, key, value, REQUEST): ...@@ -564,6 +564,35 @@ def MultiItemsWidget_render_items(self, field, key, value, REQUEST):
MultiItemsWidget.render_items = MultiItemsWidget_render_items MultiItemsWidget.render_items = MultiItemsWidget_render_items
from Products.Formulator.Widget import MultiListWidget
def MultiListWidget_render(self, field, key, value, REQUEST):
rendered_items = self.render_items(field, key, value, REQUEST)
return render_element(
'select',
name=key,
multiple=None,
css_class=field.get_value('css_class', REQUEST=REQUEST),
size=field.get_value('size', REQUEST=REQUEST),
contents=string.join(rendered_items, "\n"),
extra=field.get_value('extra', REQUEST=REQUEST))
MultiListWidget.render = MultiListWidget_render
from Products.Formulator.Widget import ListWidget
def ListWidget_render(self, field, key, value, REQUEST):
rendered_items = self.render_items(field, key, value, REQUEST)
return render_element(
'select',
name=key,
css_class=field.get_value('css_class', REQUEST=REQUEST),
size=field.get_value('size', REQUEST=REQUEST),
contents=string.join(rendered_items, "\n"),
extra=field.get_value('extra', REQUEST=REQUEST))
ListWidget.render = ListWidget_render
# JPS - Subfield handling with listbox requires extension # JPS - Subfield handling with listbox requires extension
from Products.Formulator.StandardFields import DateTimeField from Products.Formulator.StandardFields import DateTimeField
......
...@@ -36,7 +36,8 @@ from zLOG import LOG ...@@ -36,7 +36,8 @@ from zLOG import LOG
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.Formulator.Errors import ValidationError from Products.Formulator.Errors import ValidationError
class ParallelListWidget(Widget.MultiListWidget): class ParallelListWidget(Widget.MultiListWidget,
Widget.ListWidget):
""" """
Make the MultilistField more usable for the user. Make the MultilistField more usable for the user.
...@@ -63,6 +64,7 @@ class ParallelListWidget(Widget.MultiListWidget): ...@@ -63,6 +64,7 @@ class ParallelListWidget(Widget.MultiListWidget):
""" """
property_names = Widget.MultiListWidget.property_names + \ property_names = Widget.MultiListWidget.property_names + \
Widget.ListWidget.property_names + \
['hash_script_id'] ['hash_script_id']
hash_script_id = fields.StringField('hash_script_id', hash_script_id = fields.StringField('hash_script_id',
...@@ -71,6 +73,17 @@ class ParallelListWidget(Widget.MultiListWidget): ...@@ -71,6 +73,17 @@ class ParallelListWidget(Widget.MultiListWidget):
"The method to call to hash items list."), "The method to call to hash items list."),
required=0) required=0)
# delete double in order to keep a usable ZMI...
# XXX need to keep order !
#property_names = dict([(i,0) for i in property_names]).keys()
_v_dict = {}
_v_property_name_list = []
for property_name in property_names:
if not _v_dict.has_key(property_name):
_v_property_name_list.append(property_name)
_v_dict[property_name] = 1
property_names = _v_property_name_list
def __init__(self): def __init__(self):
""" """
Generate some subwidget used for rendering. Generate some subwidget used for rendering.
......
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