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 @@
</td>
</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>
<tr><td colspan="3">
......@@ -329,6 +343,21 @@ Add an action
</td>
</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>
<div class="form-element">
......
......@@ -30,7 +30,7 @@ class PatchedActionInformation(ActionInformation.oldActionInformation):
, category='object'
, condition=''
, permissions=()
, priority=10
, priority=1.0
, visible=1
, action=''
, icon=''
......@@ -79,6 +79,7 @@ class PatchedActionInformation(ActionInformation.oldActionInformation):
info['category'] = self.getCategory()
info['visible'] = self.getVisibility()
info['optional'] = self.getOption()
info['priority'] = self.getPriority()
return info
......@@ -120,6 +121,12 @@ class PatchedActionInformation(ActionInformation.oldActionInformation):
"""
return getattr( self, 'optional', 0 )
def getPriority( self ):
"""
Return the priority of the action
"""
return getattr(self, 'priority', 1.0)
def clone( self ):
""" Return a newly-created AI just like us.
......
......@@ -36,6 +36,7 @@ def ActionProviderBase_manage_editActionsForm( self, REQUEST, manage_tabs_messag
a1['visible'] = a.getVisibility()
a1['action'] = a.getActionExpression()
a1['condition'] = a.getCondition()
a1['priority'] = a.getPriority()
if hasattr(a, 'getIconExpression') :
a1['icon'] = a.getIconExpression()
if hasattr(a, 'getOption') :
......@@ -63,6 +64,7 @@ def ActionProviderBase_addAction( self
, icon=None
, visible=1
, optional=0
, priority=1.0
, REQUEST=None
):
""" Add an action to our list.
......@@ -88,6 +90,7 @@ def ActionProviderBase_addAction( self
, category=str(category)
, visible=int(visible)
, optional=int(optional)
, priority=float(priority)
)
new_actions.append( new_action )
......@@ -111,6 +114,7 @@ def ActionProviderBase_extractAction( self, properties, index ):
visible = properties.get( 'visible_%d' % index, 0 )
optional = properties.get( 'optional_%d' % index, 0 )
permissions = properties.get( 'permission_%d' % index, () )
priority = float( properties.get( 'priority_%d' % index, 1.0 ))
if not name:
raise ValueError('A name is required.')
......@@ -142,6 +146,9 @@ def ActionProviderBase_extractAction( self, properties, index ):
if type( permissions ) is type( '' ):
permissions = ( permissions, )
if type( priority ) is not type(1.0):
priority = float(priority)
return ActionInformation( id=id
, title=name
, action=action
......@@ -151,6 +158,7 @@ def ActionProviderBase_extractAction( self, properties, index ):
, category=category
, visible=visible
, optional=optional
, priority=priority
)
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