[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/form/browser/ Bug
fix in SequenceWidget. Make shure we just delete selected
items if we push the "Delete selected items" button. Before
this cleanup,
we delete also the items if we select the item and push the "Change"
button.
Roger Ineichen
roger at projekt01.ch
Sat May 29 19:03:45 EDT 2004
Log message for revision 25131:
Bug fix in SequenceWidget. Make shure we just delete selected items if we push the "Delete selected items" button. Before this cleanup, we delete also the items if we select the item and push the "Change" button.
-=-
Modified: Zope3/trunk/src/zope/app/form/browser/sequencewidget.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/sequencewidget.py 2004-05-29 17:15:59 UTC (rev 25130)
+++ Zope3/trunk/src/zope/app/form/browser/sequencewidget.py 2004-05-29 23:03:45 UTC (rev 25131)
@@ -80,10 +80,12 @@
# possibly generate the "remove" and "add" buttons
buttons = ''
if render and num_items > min_length:
+ remove_botton_name = 'remove-selected-items-of-seq-' + self.name
button_label = _('remove-selected-items', "Remove selected items")
button_label = translate(self.context, button_label,
context=self.request, default=button_label)
- buttons += '<input type="submit" value="%s" />' % button_label
+ buttons += '<input type="submit" value="%s" name="%s"/>' % (
+ button_label, remove_botton_name)
if max_length is None or num_items < max_length:
field = self.context.value_type
button_label = _('Add %s')
@@ -179,6 +181,7 @@
adding = False
removing = []
subprefix = re.compile(r'(\d+)\.(.*)$')
+ remove_botton_name = 'remove-selected-items-of-seq-' + self.name
if self.context.value_type is None:
return []
@@ -195,8 +198,12 @@
if token == 'add':
# append a new blank field to the sequence
adding = True
- elif token.startswith('remove_'):
- # remove the index indicated
+ elif token.startswith('remove_') and \
+ remove_botton_name in self.request:
+ # remove the index indicated if we press
+ # the "Remove selected items" button.
+ # Otherwise we delete the items if we check
+ # the box and push the "Change" button.
removing.append(int(token[7:]))
else:
match = subprefix.match(token)
Modified: Zope3/trunk/src/zope/app/form/browser/tests/test_sequencewidget.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/tests/test_sequencewidget.py 2004-05-29 17:15:59 UTC (rev 25130)
+++ Zope3/trunk/src/zope/app/form/browser/tests/test_sequencewidget.py 2004-05-29 23:03:45 UTC (rev 25131)
@@ -153,7 +153,8 @@
def test_remove(self):
request = TestRequest(form={'field.foo.remove_0': u'Hello world!',
- 'field.foo.0.bar': u'existing', 'field.foo.1.bar': u'second'})
+ 'field.foo.0.bar': u'existing', 'field.foo.1.bar': u'second',
+ 'remove-selected-items-of-seq-field.foo': u'Remove selected items'})
widget = TupleSequenceWidget(self.field, TextLine(), request)
widget.setRenderedValue((u'existing', u'second'))
self.assertEquals(widget.getInputValue(), (u'second',))
More information about the Zope3-Checkins
mailing list