[Checkins] SVN: zope3org/trunk/src/zorg/multiform/ fixed edit action in gridform

Bernd Dorn bernd.dorn at fhv.at
Tue Apr 11 05:25:29 EDT 2006


Log message for revision 66838:
  fixed edit action in gridform

Changed:
  U   zope3org/trunk/src/zorg/multiform/actions.txt
  U   zope3org/trunk/src/zorg/multiform/gridform.txt
  U   zope3org/trunk/src/zorg/multiform/multiform.py

-=-
Modified: zope3org/trunk/src/zorg/multiform/actions.txt
===================================================================
--- zope3org/trunk/src/zorg/multiform/actions.txt	2006-04-11 09:15:25 UTC (rev 66837)
+++ zope3org/trunk/src/zorg/multiform/actions.txt	2006-04-11 09:25:29 UTC (rev 66838)
@@ -66,12 +66,12 @@
     ...             res += '<div>%s</div>\n' % action.render()
     ...         return res
     ...     
-    ...     @form.action('Edit',condition=multiform.isFormDisplayMode)
+    ...     @form.action('Edit',condition=multiform.allSubFormDisplayMode)
     ...     def handle_edit_action(self, action, data):
     ...         for form in self.subForms.values():
     ...             form.newInputMode = True
     ...         
-    ...     @form.action('Cancel',condition=multiform.isFormInputMode)
+    ...     @form.action('Cancel',condition=multiform.anySubFormInputMode)
     ...     def handle_cancel_action(self, action, data):
     ...         for form in self.subForms.values():
     ...             form.newInputMode = False

Modified: zope3org/trunk/src/zorg/multiform/gridform.txt
===================================================================
--- zope3org/trunk/src/zorg/multiform/gridform.txt	2006-04-11 09:15:25 UTC (rev 66837)
+++ zope3org/trunk/src/zorg/multiform/gridform.txt	2006-04-11 09:25:29 UTC (rev 66838)
@@ -52,10 +52,9 @@
     >>> def isSubFormDisplayMode(form,action):
     ...     return not form.inputMode
 
-    >>> def allSubFormsDisplayMode(form,action):
+    >>> def anySubFormDisplayMode(form,action):
     ...     return not (True in form.parentForm.subFormInputMode.values())
 
-
     >>> class OrderForm(gridform.GridItemFormBase):
     ...     inputMode=False
     ...     forceInput=['selected'] 
@@ -74,7 +73,7 @@
     ...         self.newInputMode = False
     ...         
     ...     @multiform.parentAction('Edit',
-    ...         condition=allSubFormsDisplayMode)
+    ...         condition=anySubFormDisplayMode)
     ...     def handle_edit_action(self, action, data):
     ...         if isSelected(self,action):
     ...             self.newInputMode = True
@@ -178,6 +177,7 @@
 Also the edit action should be disabled now.
 
     >>> print gf.subActionNames
+    [u'form.actions.save']
 
 Now we test the actions which are displayed in each row.
 

Modified: zope3org/trunk/src/zorg/multiform/multiform.py
===================================================================
--- zope3org/trunk/src/zorg/multiform/multiform.py	2006-04-11 09:15:25 UTC (rev 66837)
+++ zope3org/trunk/src/zorg/multiform/multiform.py	2006-04-11 09:25:29 UTC (rev 66838)
@@ -15,14 +15,10 @@
         
 
 def isFormDisplayMode(f,action):
-    return not isFormInputMode(f,action)
+    return not f.inputMode
     
 def isFormInputMode(f,action):
-    return not f.inputMode
-    if len(f.subFormInputMode) == 0:
-        return f.inputMode
-    else:
-        return (True in f.subFormInputMode.values())
+    return f.inputMode
 
 def isParentFormDisplayMode(f,action):
     return not isParentFormInputMode(f,action)
@@ -30,7 +26,17 @@
 def isParentFormInputMode(f,action):
     return (True in f.parentForm.subFormInputMode.values())
 
+def anySubFormInputMode(form,action):
+    if not IMultiForm.providedBy(form):
+        form = form.parentForm
+    return (True in form.subFormInputMode.values())
 
+def allSubFormDisplayMode(form,action):
+    if not IMultiForm.providedBy(form):
+        form = form.parentForm
+    return not (True in form.subFormInputMode.values())
+
+
 class ItemAction(form.Action):
 
     """an action that is rendered in the itemform object and can



More information about the Checkins mailing list