Commit 56e1f85d authored by Vincent Pelletier's avatar Vincent Pelletier

ERP5Type.patched.DCWorkflow: Make transition id available.

Finally removes the need to hardcode transition id when it's the same as
current transition (which should be the case in the overwhelming majority
of transitions).
parent 91183a1d
...@@ -211,6 +211,7 @@ DCWorkflowDefinition.listGlobalActions = DCWorkflowDefinition_listGlobalActions ...@@ -211,6 +211,7 @@ DCWorkflowDefinition.listGlobalActions = DCWorkflowDefinition_listGlobalActions
# Patches over original listObjectActions: # Patches over original listObjectActions:
# - Factorise consecutive tests. # - Factorise consecutive tests.
# - Add "transition_id" when rendering name, url and icon properties.
def DCWorkflowDefinition_listObjectActions(self, info): def DCWorkflowDefinition_listObjectActions(self, info):
''' '''
Allows this workflow to Allows this workflow to
...@@ -219,6 +220,7 @@ def DCWorkflowDefinition_listObjectActions(self, info): ...@@ -219,6 +220,7 @@ def DCWorkflowDefinition_listObjectActions(self, info):
info.object. info.object.
Returns the actions to be displayed to the user. Returns the actions to be displayed to the user.
''' '''
fmt_data = None
ob = info.object ob = info.object
sdef = self._getWorkflowStateOf(ob) sdef = self._getWorkflowStateOf(ob)
if sdef is None: if sdef is None:
...@@ -228,14 +230,19 @@ def DCWorkflowDefinition_listObjectActions(self, info): ...@@ -228,14 +230,19 @@ def DCWorkflowDefinition_listObjectActions(self, info):
tdef = self.transitions.get(tid, None) tdef = self.transitions.get(tid, None)
if tdef is not None and tdef.trigger_type == TRIGGER_USER_ACTION and \ if tdef is not None and tdef.trigger_type == TRIGGER_USER_ACTION and \
tdef.actbox_name and self._checkTransitionGuard(tdef, ob): tdef.actbox_name and self._checkTransitionGuard(tdef, ob):
if fmt_data is None:
fmt_data = TemplateDict()
fmt_data._push(info)
fmt_data._push({'transition_id': tid})
res.append((tid, { res.append((tid, {
'id': tid, 'id': tid,
'name': tdef.actbox_name % info, 'name': tdef.actbox_name % fmt_data,
'url': tdef.actbox_url % info, 'url': tdef.actbox_url % fmt_data,
'icon': tdef.actbox_icon % info, 'icon': tdef.actbox_icon % fmt_data,
'permissions': (), # Predetermined. 'permissions': (), # Predetermined.
'category': tdef.actbox_category, 'category': tdef.actbox_category,
'transition': tdef})) 'transition': tdef}))
fmt_data._pop()
res.sort() res.sort()
return [ result[1] for result in res ] return [ result[1] for result in res ]
DCWorkflowDefinition.listObjectActions = DCWorkflowDefinition_listObjectActions DCWorkflowDefinition.listObjectActions = DCWorkflowDefinition_listObjectActions
......
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