Commit c41dd218 authored by Aurel's avatar Aurel

allow to define priority on actions


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4851 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7c7bb340
...@@ -170,6 +170,20 @@ ...@@ -170,6 +170,20 @@
</td> </td>
</tr> </tr>
<tr>
<td></td>
<td>
<div class="form-label">
Priority
</div>
</td>
<td>
<div class="form-element">
<input type="text" name="priority_&dtml-index;:float" value="&dtml-priority;" />
</div>
</td>
</tr>
</dtml-let> </dtml-let>
<tr><td colspan="3"> <tr><td colspan="3">
...@@ -329,6 +343,21 @@ Add an action ...@@ -329,6 +343,21 @@ Add an action
</td> </td>
</tr> </tr>
<tr>
<td></td>
<td>
<div class="form-label">
Priority
</div>
</td>
<td>
<div class="form-element">
<input type="text" name="priority:float" value="1.0" />
</div>
</td>
</tr>
</table> </table>
<div class="form-element"> <div class="form-element">
......
...@@ -30,7 +30,7 @@ class PatchedActionInformation(ActionInformation.oldActionInformation): ...@@ -30,7 +30,7 @@ class PatchedActionInformation(ActionInformation.oldActionInformation):
, category='object' , category='object'
, condition='' , condition=''
, permissions=() , permissions=()
, priority=10 , priority=1.0
, visible=1 , visible=1
, action='' , action=''
, icon='' , icon=''
...@@ -57,7 +57,7 @@ class PatchedActionInformation(ActionInformation.oldActionInformation): ...@@ -57,7 +57,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 self.optional = optional
def getAction( self, ec ): def getAction( self, ec ):
...@@ -79,6 +79,7 @@ class PatchedActionInformation(ActionInformation.oldActionInformation): ...@@ -79,6 +79,7 @@ class PatchedActionInformation(ActionInformation.oldActionInformation):
info['category'] = self.getCategory() info['category'] = self.getCategory()
info['visible'] = self.getVisibility() info['visible'] = self.getVisibility()
info['optional'] = self.getOption() info['optional'] = self.getOption()
info['priority'] = self.getPriority()
return info return info
...@@ -120,6 +121,12 @@ class PatchedActionInformation(ActionInformation.oldActionInformation): ...@@ -120,6 +121,12 @@ class PatchedActionInformation(ActionInformation.oldActionInformation):
""" """
return getattr( self, 'optional', 0 ) return getattr( self, 'optional', 0 )
def getPriority( self ):
"""
Return the priority of the action
"""
return getattr(self, 'priority', 1.0)
def clone( self ): def clone( self ):
""" Return a newly-created AI just like us. """ Return a newly-created AI just like us.
......
...@@ -36,6 +36,7 @@ def ActionProviderBase_manage_editActionsForm( self, REQUEST, manage_tabs_messag ...@@ -36,6 +36,7 @@ def ActionProviderBase_manage_editActionsForm( self, REQUEST, manage_tabs_messag
a1['visible'] = a.getVisibility() a1['visible'] = a.getVisibility()
a1['action'] = a.getActionExpression() a1['action'] = a.getActionExpression()
a1['condition'] = a.getCondition() a1['condition'] = a.getCondition()
a1['priority'] = a.getPriority()
if hasattr(a, 'getIconExpression') : if hasattr(a, 'getIconExpression') :
a1['icon'] = a.getIconExpression() a1['icon'] = a.getIconExpression()
if hasattr(a, 'getOption') : if hasattr(a, 'getOption') :
...@@ -63,6 +64,7 @@ def ActionProviderBase_addAction( self ...@@ -63,6 +64,7 @@ def ActionProviderBase_addAction( self
, icon=None , icon=None
, visible=1 , visible=1
, optional=0 , optional=0
, priority=1.0
, REQUEST=None , REQUEST=None
): ):
""" Add an action to our list. """ Add an action to our list.
...@@ -88,6 +90,7 @@ def ActionProviderBase_addAction( self ...@@ -88,6 +90,7 @@ def ActionProviderBase_addAction( self
, category=str(category) , category=str(category)
, visible=int(visible) , visible=int(visible)
, optional=int(optional) , optional=int(optional)
, priority=float(priority)
) )
new_actions.append( new_action ) new_actions.append( new_action )
...@@ -111,6 +114,7 @@ def ActionProviderBase_extractAction( self, properties, index ): ...@@ -111,6 +114,7 @@ def ActionProviderBase_extractAction( self, properties, index ):
visible = properties.get( 'visible_%d' % index, 0 ) visible = properties.get( 'visible_%d' % index, 0 )
optional = properties.get( 'optional_%d' % index, 0 ) optional = properties.get( 'optional_%d' % index, 0 )
permissions = properties.get( 'permission_%d' % index, () ) permissions = properties.get( 'permission_%d' % index, () )
priority = float( properties.get( 'priority_%d' % index, 1.0 ))
if not name: if not name:
raise ValueError('A name is required.') raise ValueError('A name is required.')
...@@ -142,6 +146,9 @@ def ActionProviderBase_extractAction( self, properties, index ): ...@@ -142,6 +146,9 @@ def ActionProviderBase_extractAction( self, properties, index ):
if type( permissions ) is type( '' ): if type( permissions ) is type( '' ):
permissions = ( permissions, ) permissions = ( permissions, )
if type( priority ) is not type(1.0):
priority = float(priority)
return ActionInformation( id=id return ActionInformation( id=id
, title=name , title=name
, action=action , action=action
...@@ -151,6 +158,7 @@ def ActionProviderBase_extractAction( self, properties, index ): ...@@ -151,6 +158,7 @@ def ActionProviderBase_extractAction( self, properties, index ):
, category=category , category=category
, visible=visible , visible=visible
, optional=optional , optional=optional
, priority=priority
) )
ActionProviderBase.manage_editActionsForm = ActionProviderBase_manage_editActionsForm ActionProviderBase.manage_editActionsForm = ActionProviderBase_manage_editActionsForm
......
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