Commit 7d712db5 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Add a new attribute optional into ActionInformation.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3396 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a2443d9f
...@@ -80,6 +80,7 @@ class PatchedActionInformation(ActionInformation.oldActionInformation): ...@@ -80,6 +80,7 @@ class PatchedActionInformation(ActionInformation.oldActionInformation):
, visible=1 , visible=1
, action='' , action=''
, icon='' , icon=''
, optional=0
): ):
""" Set up an instance. """ Set up an instance.
""" """
...@@ -102,6 +103,7 @@ class PatchedActionInformation(ActionInformation.oldActionInformation): ...@@ -102,6 +103,7 @@ class PatchedActionInformation(ActionInformation.oldActionInformation):
self.visible = visible self.visible = visible
self.setActionExpression(action) self.setActionExpression(action)
self.setIconExpression(icon) self.setIconExpression(icon)
self.optional = optional
def getAction( self, ec ): def getAction( self, ec ):
...@@ -122,6 +124,7 @@ class PatchedActionInformation(ActionInformation.oldActionInformation): ...@@ -122,6 +124,7 @@ class PatchedActionInformation(ActionInformation.oldActionInformation):
info['permissions'] = self.getPermissions() info['permissions'] = self.getPermissions()
info['category'] = self.getCategory() info['category'] = self.getCategory()
info['visible'] = self.getVisibility() info['visible'] = self.getVisibility()
info['optional'] = self.getOption()
return info return info
...@@ -156,6 +159,13 @@ class PatchedActionInformation(ActionInformation.oldActionInformation): ...@@ -156,6 +159,13 @@ class PatchedActionInformation(ActionInformation.oldActionInformation):
self.icon = icon self.icon = icon
security.declarePublic( 'getOption' )
def getOption( self ):
""" Return whether the action should be optional in the Business Template.
"""
return getattr( self, 'optional', 0 )
def clone( self ): def clone( self ):
""" Return a newly-created AI just like us. """ Return a newly-created AI just like us.
...@@ -170,6 +180,7 @@ class PatchedActionInformation(ActionInformation.oldActionInformation): ...@@ -170,6 +180,7 @@ class PatchedActionInformation(ActionInformation.oldActionInformation):
, visible=self.visible , visible=self.visible
, action=self.getActionExpression() , action=self.getActionExpression()
, icon=self.getIconExpression() , icon=self.getIconExpression()
, optional=self.optional
) )
ActionInformation.ActionInformation = PatchedActionInformation ActionInformation.ActionInformation = PatchedActionInformation
...@@ -200,6 +211,7 @@ class PatchedActionProviderBase(ActionProviderBase): ...@@ -200,6 +211,7 @@ class PatchedActionProviderBase(ActionProviderBase):
a1['action'] = a.getActionExpression() a1['action'] = a.getActionExpression()
a1['icon'] = a.getIconExpression() a1['icon'] = a.getIconExpression()
a1['condition'] = a.getCondition() a1['condition'] = a.getCondition()
a1['optional'] = a.getOption()
actions.append(a1) actions.append(a1)
# possible_permissions is in AccessControl.Role.RoleManager. # possible_permissions is in AccessControl.Role.RoleManager.
...@@ -222,6 +234,7 @@ class PatchedActionProviderBase(ActionProviderBase): ...@@ -222,6 +234,7 @@ class PatchedActionProviderBase(ActionProviderBase):
, category , category
, icon=None , icon=None
, visible=1 , visible=1
, optional=0
, REQUEST=None , REQUEST=None
): ):
""" Add an action to our list. """ Add an action to our list.
...@@ -246,6 +259,7 @@ class PatchedActionProviderBase(ActionProviderBase): ...@@ -246,6 +259,7 @@ class PatchedActionProviderBase(ActionProviderBase):
, permissions=permission , permissions=permission
, category=str(category) , category=str(category)
, visible=int(visible) , visible=int(visible)
, optional=int(optional)
) )
new_actions.append( new_action ) new_actions.append( new_action )
...@@ -267,6 +281,7 @@ class PatchedActionProviderBase(ActionProviderBase): ...@@ -267,6 +281,7 @@ class PatchedActionProviderBase(ActionProviderBase):
condition = str( properties.get( 'condition_%d' % index, '' ) ) condition = str( properties.get( 'condition_%d' % index, '' ) )
category = str( properties.get( 'category_%d' % index, '' )) category = str( properties.get( 'category_%d' % index, '' ))
visible = properties.get( 'visible_%d' % index, 0 ) visible = properties.get( 'visible_%d' % index, 0 )
optional = properties.get( 'optional_%d' % index, 0 )
permissions = properties.get( 'permission_%d' % index, () ) permissions = properties.get( 'permission_%d' % index, () )
if not name: if not name:
...@@ -290,6 +305,12 @@ class PatchedActionProviderBase(ActionProviderBase): ...@@ -290,6 +305,12 @@ class PatchedActionProviderBase(ActionProviderBase):
except: except:
visible = 0 visible = 0
if type( optional ) is not type( 0 ):
try:
optional = int( optional )
except:
optional = 0
if type( permissions ) is type( '' ): if type( permissions ) is type( '' ):
permissions = ( permissions, ) permissions = ( permissions, )
...@@ -301,6 +322,7 @@ class PatchedActionProviderBase(ActionProviderBase): ...@@ -301,6 +322,7 @@ class PatchedActionProviderBase(ActionProviderBase):
, permissions=permissions , permissions=permissions
, category=category , category=category
, visible=visible , visible=visible
, optional=optional
) )
ActionProviderBase.manage_editActionsForm = PatchedActionProviderBase.manage_editActionsForm ActionProviderBase.manage_editActionsForm = PatchedActionProviderBase.manage_editActionsForm
......
...@@ -151,6 +151,25 @@ ...@@ -151,6 +151,25 @@
</td> </td>
</tr> </tr>
<tr>
<td></td>
<td>
<div class="form-label">
Optional?
</div>
</td>
<td>
<div class="form-element">
<input type="hidden" name="optional_&dtml-index;:int:default"
value="0" />
<dtml-let chk="optional and 'checked' or ''">
<input type="checkbox" name="optional_&dtml-index;:boolean"
&dtml-chk; value="1" />
</dtml-let>
</div>
</td>
</tr>
</dtml-let> </dtml-let>
<tr><td colspan="3"> <tr><td colspan="3">
...@@ -295,6 +314,21 @@ Add an action ...@@ -295,6 +314,21 @@ Add an action
</td> </td>
</tr> </tr>
<td></td>
<td>
<div class="form-label">
Optional?
</div>
</td>
<td>
<div class="form-element">
<input type="hidden" name="optional:int:default"
value="0" />
<input type="checkbox" name="optional:boolean" value="0"/>
</div>
</td>
</tr>
</table> </table>
<div class="form-element"> <div class="form-element">
......
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