Added toolbar action item viewlet
authorThierry Florac <thierry.florac@onf.fr>
Wed, 12 Jul 2017 13:47:53 +0200
changeset 191 03aae24b8ea6
parent 190 4945c9b1202e
child 192 b92cfa6a598d
Added toolbar action item viewlet
src/pyams_skin/viewlet/toolbar/__init__.py
src/pyams_skin/viewlet/toolbar/action.pt
src/pyams_skin/viewlet/toolbar/menu.pt
src/pyams_skin/viewlet/toolbar/toolbar-item.pt
--- a/src/pyams_skin/viewlet/toolbar/__init__.py	Wed Jul 12 13:47:25 2017 +0200
+++ b/src/pyams_skin/viewlet/toolbar/__init__.py	Wed Jul 12 13:47:53 2017 +0200
@@ -18,7 +18,7 @@
 # import interfaces
 from pyams_skin.interfaces.container import ITableWithActions
 from pyams_skin.interfaces.viewlet import IToolbarViewletManager, IToolbarAction, IToolbarMenu, IToolbarMenuItem, \
-    IContextActions, IToolbarAddingMenu, ITableItemColumnActionsMenu, IWidgetTitleViewletManager
+    IContextActions, IToolbarAddingMenu, ITableItemColumnActionsMenu, IWidgetTitleViewletManager, IToolbarActionItem
 from pyams_skin.layer import IPyAMSLayer
 from pyams_utils.interfaces.tales import ITALESExtension
 from zope.contentprovider.interfaces import IContentProvider
@@ -110,10 +110,10 @@
     css_class = 'btn btn-xs btn-info dropdown-toggle'
 
 
-@template_config(template='menu-item.pt', layer=IPyAMSLayer)
-@implementer(IToolbarMenuItem)
-class ToolbarMenuItem(Viewlet):
-    """Toolbar menu item class"""
+@template_config(template='toolbar-item.pt', layer=IPyAMSLayer)
+@implementer(IToolbarActionItem)
+class ToolbarActionItem(Viewlet):
+    """Toolbar action item class"""
 
     label = FieldProperty(IToolbarMenuItem['label'])
     label_css_class = FieldProperty(IToolbarMenuItem['label_css_class'])
@@ -127,6 +127,12 @@
         return absolute_url(self.context, self.request, self.url)
 
 
+@template_config(template='menu-item.pt', layer=IPyAMSLayer)
+@implementer(IToolbarMenuItem)
+class ToolbarMenuItem(ToolbarActionItem):
+    """Toolbar menu item class"""
+
+
 class JsToolbarMenuItem(ToolbarMenuItem):
     """Javascript call toolbar menu item"""
 
@@ -151,6 +157,7 @@
     """Context actions viewlet manager"""
 
     label = _("Other actions...")
+    label_css_class = ''
     css_class = FieldProperty(IContextActions['css_class'])
 
 
--- a/src/pyams_skin/viewlet/toolbar/action.pt	Wed Jul 12 13:47:25 2017 +0200
+++ b/src/pyams_skin/viewlet/toolbar/action.pt	Wed Jul 12 13:47:53 2017 +0200
@@ -1,9 +1,8 @@
 <div class="btn-group">
 	<button tal:attributes="class view.css_class;
 							data-toggle 'modal' if view.modal_target else '';
-							data-ams-url view.get_url()"
-			data-toggle="dropdown">
+							data-ams-url view.get_url()">
+		<i tal:attributes="class view.label_css_class"></i>&nbsp;
 		<tal:var content="view.label" />
-		&nbsp;<i tal:attributes="class view.label_css_class"></i>
 	</button>
-</div>
\ No newline at end of file
+</div>
--- a/src/pyams_skin/viewlet/toolbar/menu.pt	Wed Jul 12 13:47:25 2017 +0200
+++ b/src/pyams_skin/viewlet/toolbar/menu.pt	Wed Jul 12 13:47:53 2017 +0200
@@ -1,11 +1,12 @@
 <div class="btn-group margin-right-2" tal:condition="view.viewlets">
 	<button tal:attributes="class view.css_class"
 			data-toggle="dropdown">
-		<tal:var content="view.label" />
-		&nbsp;<i tal:attributes="class view.label_css_class"></i>
+		<i tal:attributes="class view.label_css_class"></i>&nbsp;
+		<tal:var content="view.label" />&nbsp;
+		<i class="fa fa-fw fa-caret-down"></i>
 	</button>
 	<ul tal:attributes="class view.menu_css_class">
 		<tal:loop repeat="viewlet view.viewlets"
 				  content="structure viewlet.render()" />
 	</ul>
-</div>
\ No newline at end of file
+</div>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_skin/viewlet/toolbar/toolbar-item.pt	Wed Jul 12 13:47:53 2017 +0200
@@ -0,0 +1,11 @@
+<a class="btn btn-xs btn-default"
+   tal:attributes="data-ams-click-handler view.click_handler;
+				   data-ams-url view.get_url();
+				   data-ams-target view.target | nothing;
+				   data-ams-stop-propagation 'true' if view.stop_propagation else None;
+				   data-toggle 'modal' if view.modal_target else None;">
+	<i tal:attributes="class string:${view.label_css_class} hint opaque align-base;
+					   title view.label"
+	   i18n:attributes="title"
+	   data-ams-hint-offset="5"></i>
+</a>