Added generic toolbar adding menu interface
authorThierry Florac <thierry.florac@onf.fr>
Tue, 03 Mar 2015 16:33:51 +0100
changeset 20 0bd30fe2beab
parent 19 7d4bd86b3f30
child 21 012fda888a1c
Added generic toolbar adding menu interface
src/pyams_skin/viewlet/toolbar/__init__.py
--- a/src/pyams_skin/viewlet/toolbar/__init__.py	Tue Mar 03 16:33:19 2015 +0100
+++ b/src/pyams_skin/viewlet/toolbar/__init__.py	Tue Mar 03 16:33:51 2015 +0100
@@ -16,8 +16,9 @@
 # import standard library
 
 # import interfaces
+from pyams_skin.interfaces.container import ITable
 from pyams_skin.interfaces.viewlet import IToolbarViewletManager, IToolbarAction, IToolbarMenu, IToolbarMenuItem, \
-    IContextActions
+    IContextActions, IToolbarAddingMenu
 from pyams_skin.layer import IPyAMSLayer
 from pyams_utils.interfaces.tales import ITALESExtension
 from zope.contentprovider.interfaces import IContentProvider
@@ -27,10 +28,12 @@
 from pyams_utils.adapter import ContextRequestViewAdapter, adapter_config
 from pyams_utils.url import absolute_url
 from pyams_viewlet.manager import TemplateBasedViewletManager, WeightOrderedViewletManager, viewletmanager_config
-from pyams_viewlet.viewlet import Viewlet
+from pyams_viewlet.viewlet import Viewlet, viewlet_config
 from zope.interface import implementer, Interface
 from zope.schema.fieldproperty import FieldProperty
 
+from pyams_skin import _
+
 
 @viewletmanager_config(name='pyams.toolbar', view=Interface, layer=IPyAMSLayer, provides=IToolbarViewletManager)
 @template_config(template='manager.pt', layer=IPyAMSLayer)
@@ -80,6 +83,15 @@
         return Viewlet.render(self)
 
 
+@viewlet_config(name='pyams.addings', view=ITable, layer=IPyAMSLayer, manager=IToolbarViewletManager)
+@viewletmanager_config(name='pyams.addings', view=ITable, layer=IPyAMSLayer, provides=IToolbarAddingMenu)
+@implementer(IToolbarAddingMenu)
+class ToolbarAddingMenu(ToolbarMenu):
+    """Toolbar adding menu"""
+
+    label = _("Add...")
+
+
 @template_config(template='menu-item.pt', layer=IPyAMSLayer)
 @implementer(IToolbarMenuItem)
 class ToolbarMenuItem(Viewlet):