Added form toolbar viewlet
authorThierry Florac <thierry.florac@onf.fr>
Mon, 18 Jan 2016 17:48:30 +0100
changeset 34 e1260ddb493e
parent 33 31516d8ac04f
child 35 b7e425948ce2
Added form toolbar viewlet
src/pyams_form/interfaces/form.py
src/pyams_form/templates/toolbar.pt
src/pyams_form/viewlet.py
--- a/src/pyams_form/interfaces/form.py	Thu Oct 08 09:19:03 2015 +0200
+++ b/src/pyams_form/interfaces/form.py	Mon Jan 18 17:48:30 2016 +0100
@@ -220,6 +220,13 @@
                              required=False,
                              readonly=True)
 
+    checkbox_mode = Choice(title="Checkbox mode",
+                           description="""To indicate if fieldset content should be hidden or disabled """
+                                       """when the checkbox if not checked""",
+                           required=True,
+                           values=('disable', 'hide'),
+                           default='hide')
+
     hide_if_empty = Bool(title="Hide group if empty?",
                          description="""If 'Yes', a switchable group containing only """
                                      """widgets with default values is hidden""",
@@ -378,6 +385,10 @@
     """Form header viewlets manager interface"""
 
 
+class IFormToolbarViewletsManager(IFormViewletsManager):
+    """Form toolbar viewlets manager interface"""
+
+
 class IFormPrefixViewletsManager(IFormViewletsManager):
     """Form prefix viewlets manager interface"""
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_form/templates/toolbar.pt	Mon Jan 18 17:48:30 2016 +0100
@@ -0,0 +1,4 @@
+<div class="toolbar">
+	<tal:loop repeat="viewlet view.viewlets"
+	          content="structure viewlet.render()" />
+</div>
\ No newline at end of file
--- a/src/pyams_form/viewlet.py	Thu Oct 08 09:19:03 2015 +0200
+++ b/src/pyams_form/viewlet.py	Mon Jan 18 17:48:30 2016 +0100
@@ -17,9 +17,11 @@
 
 # import interfaces
 from pyams_form.interfaces.form import IFormViewletsManager, IFormPrefixViewletsManager, IWidgetsPrefixViewletsManager, \
-    IWidgetsSuffixViewletsManager, IFormSuffixViewletsManager, IFormLayer, IFormHeaderViewletsManager
+    IWidgetsSuffixViewletsManager, IFormSuffixViewletsManager, IFormLayer, IFormHeaderViewletsManager, \
+    IFormToolbarViewletsManager
 
 # import packages
+from pyams_template.template import template_config, get_view_template
 from pyams_viewlet.manager import WeightOrderedViewletManager, viewletmanager_config
 from zope.interface import implementer
 
@@ -35,6 +37,15 @@
     """Form header viewlet manager, display in modal's form dialog header"""
 
 
+@viewletmanager_config(name='form_toolbar', layer=IFormLayer)
+@template_config(template='templates/toolbar.pt', layer=IFormLayer)
+@implementer(IFormToolbarViewletsManager)
+class FormToolbarViewletsManager(FormViewletManager):
+    """Form toolbar viewlet manager, displayed inside default form header"""
+
+    template = get_view_template()
+
+
 @viewletmanager_config(name='form_prefix', layer=IFormLayer)
 @implementer(IFormPrefixViewletsManager)
 class FormPrefixViewletManager(FormViewletManager):