Added Javascript caller toolbar menu item
authorThierry Florac <thierry.florac@onf.fr>
Wed, 20 May 2015 12:33:54 +0200
changeset 61 ecc79f7c5957
parent 60 b3d22ddef5cc
child 62 95b8b181c3ad
Added Javascript caller toolbar menu item
src/pyams_skin/viewlet/toolbar/__init__.py
--- a/src/pyams_skin/viewlet/toolbar/__init__.py	Wed May 20 12:33:19 2015 +0200
+++ b/src/pyams_skin/viewlet/toolbar/__init__.py	Wed May 20 12:33:54 2015 +0200
@@ -16,7 +16,7 @@
 # import standard library
 
 # import interfaces
-from pyams_skin.interfaces.container import ITable, ITableWithActions
+from pyams_skin.interfaces.container import ITableWithActions
 from pyams_skin.interfaces.viewlet import IToolbarViewletManager, IToolbarAction, IToolbarMenu, IToolbarMenuItem, \
     IContextActions, IToolbarAddingMenu, ITableItemColumnActionsMenu
 from pyams_skin.layer import IPyAMSLayer
@@ -84,8 +84,8 @@
         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)
+@viewlet_config(name='pyams.addings', view=Interface, layer=IPyAMSLayer, manager=IToolbarViewletManager)
+@viewletmanager_config(name='pyams.addings', view=Interface, layer=IPyAMSLayer, provides=IToolbarAddingMenu)
 @implementer(IToolbarAddingMenu)
 class ToolbarAddingMenu(ToolbarMenu):
     """Toolbar adding menu"""
@@ -120,6 +120,13 @@
         return absolute_url(self.context, self.request, self.url)
 
 
+class JsToolbarMenuItem(ToolbarMenuItem):
+    """Javascript call toolbar menu item"""
+
+    def get_url(self):
+        return self.url
+
+
 @template_config(template='menu-divider.pt', layer=IPyAMSLayer)
 @implementer(IToolbarMenuItem)
 class ToolbarMenuDivider(Viewlet):
@@ -142,7 +149,7 @@
 class ContextActionsExtension(ContextRequestViewAdapter):
     """extension:context_actions(context) TALES extension"""
 
-    def render(self, context):
+    def render(self, context=None):
         if context is None:
             context = self.context
         registry = self.request.registry