--- a/src/pyams_workflow/zmi/workflow.py Wed May 20 12:46:23 2015 +0200
+++ b/src/pyams_workflow/zmi/workflow.py Wed May 20 12:47:00 2015 +0200
@@ -16,41 +16,46 @@
# import standard library
# import interfaces
-from pyams_skin.interfaces.viewlet import IMainMenusViewletManager
-from pyams_workflow.interfaces import IWorkflow, IWorkflowInfo, IWorkflowVersion, IWorkflowManagedContent
+from pyams_skin.interfaces.viewlet import IToolbarViewletManager
+from pyams_workflow.interfaces import IWorkflow, IWorkflowInfo, IWorkflowVersion, IWorkflowManagedContent, \
+ IWorkflowVersions
from pyams_workflow.zmi.interfaces import IWorkflowMenu
from pyams_zmi.layer import IAdminLayer
# import packages
-from pyams_skin.viewlet.menu import Menu, MenuItem
+from pyams_skin.table import NameColumn
+from pyams_skin.viewlet.toolbar import ToolbarMenu, ToolbarMenuItem
from pyams_utils.registry import query_utility
from pyams_utils.traversing import get_parent
from pyams_viewlet.manager import viewletmanager_config
from pyams_viewlet.viewlet import viewlet_config
-from zope.interface import implementer
+from zope.interface import implementer, Interface
from pyams_workflow import _
-class WorkflowMenuItem(MenuItem):
+class WorkflowMenuItem(ToolbarMenuItem):
"""Workflow menu item"""
def __init__(self, context, request, view, manager, transition):
super(WorkflowMenuItem, self).__init__(context, request, view, manager)
self.label = transition.title
- self.url = transition.user_data.get('view_name')
+ self.label_css_class = transition.user_data.get('menu_css_class') or 'fa fa-fw'
+ self.url = '{url}?transition_id={transition}'.format(url=transition.user_data.get('view_name'),
+ transition=transition.transition_id)
self.weight = transition.order
self.modal_target = True
-@viewlet_config(name='workflow.menu', layer=IAdminLayer, context=IWorkflowVersion,
- manager=IMainMenusViewletManager, permission='system.view', weight=200)
+@viewlet_config(name='workflow.menu', view=Interface, layer=IAdminLayer, context=IWorkflowVersion,
+ manager=IToolbarViewletManager, permission='portal.templates.manage', weight=200)
@viewletmanager_config(name='workflow.menu', layer=IAdminLayer, provides=IWorkflowMenu)
@implementer(IWorkflowMenu)
-class WorkflowMenu(Menu):
+class WorkflowMenu(ToolbarMenu):
"""Workflow menu"""
- header = _("Workflow")
+ label = _("Change status...")
+ css_class = 'btn btn-xs btn-danger dropdown-toggle'
def _get_viewlets(self):
viewlets = []
@@ -65,3 +70,16 @@
viewlets.append((transition_id, menu))
viewlets.sort(key=lambda x: x[1].weight)
return viewlets
+
+
+class WorkflowContentNameColumn(NameColumn):
+ """Workflow content name column"""
+
+ def getValue(self, obj):
+ wf_versions = IWorkflowVersions(obj, None)
+ if wf_versions is None:
+ return super(WorkflowContentNameColumn, self).getValue(obj)
+ versions = wf_versions.get_last_versions(count=1)
+ if len(versions) > 0:
+ version = versions[0]
+ return super(WorkflowContentNameColumn, self).getValue(version)