src/pyams_skin/viewlet/toolbar/__init__.py
changeset 191 03aae24b8ea6
parent 69 a361355b55c7
child 196 1ec15633d058
equal deleted inserted replaced
190:4945c9b1202e 191:03aae24b8ea6
    16 # import standard library
    16 # import standard library
    17 
    17 
    18 # import interfaces
    18 # import interfaces
    19 from pyams_skin.interfaces.container import ITableWithActions
    19 from pyams_skin.interfaces.container import ITableWithActions
    20 from pyams_skin.interfaces.viewlet import IToolbarViewletManager, IToolbarAction, IToolbarMenu, IToolbarMenuItem, \
    20 from pyams_skin.interfaces.viewlet import IToolbarViewletManager, IToolbarAction, IToolbarMenu, IToolbarMenuItem, \
    21     IContextActions, IToolbarAddingMenu, ITableItemColumnActionsMenu, IWidgetTitleViewletManager
    21     IContextActions, IToolbarAddingMenu, ITableItemColumnActionsMenu, IWidgetTitleViewletManager, IToolbarActionItem
    22 from pyams_skin.layer import IPyAMSLayer
    22 from pyams_skin.layer import IPyAMSLayer
    23 from pyams_utils.interfaces.tales import ITALESExtension
    23 from pyams_utils.interfaces.tales import ITALESExtension
    24 from zope.contentprovider.interfaces import IContentProvider
    24 from zope.contentprovider.interfaces import IContentProvider
    25 
    25 
    26 # import packages
    26 # import packages
   108 
   108 
   109     label = _("Actions...")
   109     label = _("Actions...")
   110     css_class = 'btn btn-xs btn-info dropdown-toggle'
   110     css_class = 'btn btn-xs btn-info dropdown-toggle'
   111 
   111 
   112 
   112 
   113 @template_config(template='menu-item.pt', layer=IPyAMSLayer)
   113 @template_config(template='toolbar-item.pt', layer=IPyAMSLayer)
   114 @implementer(IToolbarMenuItem)
   114 @implementer(IToolbarActionItem)
   115 class ToolbarMenuItem(Viewlet):
   115 class ToolbarActionItem(Viewlet):
   116     """Toolbar menu item class"""
   116     """Toolbar action item class"""
   117 
   117 
   118     label = FieldProperty(IToolbarMenuItem['label'])
   118     label = FieldProperty(IToolbarMenuItem['label'])
   119     label_css_class = FieldProperty(IToolbarMenuItem['label_css_class'])
   119     label_css_class = FieldProperty(IToolbarMenuItem['label_css_class'])
   120     css_class = FieldProperty(IToolbarMenuItem['css_class'])
   120     css_class = FieldProperty(IToolbarMenuItem['css_class'])
   121     click_handler = FieldProperty(IToolbarMenuItem['click_handler'])
   121     click_handler = FieldProperty(IToolbarMenuItem['click_handler'])
   123     modal_target = FieldProperty(IToolbarMenuItem['modal_target'])
   123     modal_target = FieldProperty(IToolbarMenuItem['modal_target'])
   124     stop_propagation = FieldProperty(IToolbarMenuItem['stop_propagation'])
   124     stop_propagation = FieldProperty(IToolbarMenuItem['stop_propagation'])
   125 
   125 
   126     def get_url(self):
   126     def get_url(self):
   127         return absolute_url(self.context, self.request, self.url)
   127         return absolute_url(self.context, self.request, self.url)
       
   128 
       
   129 
       
   130 @template_config(template='menu-item.pt', layer=IPyAMSLayer)
       
   131 @implementer(IToolbarMenuItem)
       
   132 class ToolbarMenuItem(ToolbarActionItem):
       
   133     """Toolbar menu item class"""
   128 
   134 
   129 
   135 
   130 class JsToolbarMenuItem(ToolbarMenuItem):
   136 class JsToolbarMenuItem(ToolbarMenuItem):
   131     """Javascript call toolbar menu item"""
   137     """Javascript call toolbar menu item"""
   132 
   138 
   149 @implementer(IContextActions)
   155 @implementer(IContextActions)
   150 class ContextActionsViewletManager(ToolbarMenu):
   156 class ContextActionsViewletManager(ToolbarMenu):
   151     """Context actions viewlet manager"""
   157     """Context actions viewlet manager"""
   152 
   158 
   153     label = _("Other actions...")
   159     label = _("Other actions...")
       
   160     label_css_class = ''
   154     css_class = FieldProperty(IContextActions['css_class'])
   161     css_class = FieldProperty(IContextActions['css_class'])
   155 
   162 
   156 
   163 
   157 @adapter_config(name='context_actions', context=(Interface, Interface, Interface), provides=ITALESExtension)
   164 @adapter_config(name='context_actions', context=(Interface, Interface, Interface), provides=ITALESExtension)
   158 class ContextActionsExtension(ContextRequestViewAdapter):
   165 class ContextActionsExtension(ContextRequestViewAdapter):