Added renderer for double navigation list
authorThierry Florac <thierry.florac@onf.fr>
Wed, 20 Jun 2018 18:14:46 +0200
changeset 57 fc86c86eb416
parent 56 5f1c114f4464
child 58 c7197827a864
Added renderer for double navigation list
src/pyams_default_theme/features/menu/portlet/navigation/__init__.py
src/pyams_default_theme/features/menu/portlet/navigation/interfaces.py
src/pyams_default_theme/features/menu/portlet/navigation/templates/double-select.pt
--- a/src/pyams_default_theme/features/menu/portlet/navigation/__init__.py	Tue Jun 19 17:10:57 2018 +0200
+++ b/src/pyams_default_theme/features/menu/portlet/navigation/__init__.py	Wed Jun 20 18:14:46 2018 +0200
@@ -18,14 +18,20 @@
 # import interfaces
 from pyams_content.features.menu.portlet.navigation.interfaces.double import IDoubleNavigationPortletSettings
 from pyams_content.features.menu.portlet.navigation.interfaces.simple import ISimpleNavigationPortletSettings
-from pyams_portal.interfaces import IPortalContext, IPortletRenderer
+from pyams_default_theme.features.menu.portlet.navigation.interfaces import \
+    IDoubleNavigationPortletSelectMenusRendererSettings
+from pyams_portal.interfaces import IPortalContext, IPortletRenderer, PORTLET_RENDERER_SETTINGS_KEY
 from pyams_skin.layer import IPyAMSLayer
 
 # import packages
+from persistent import Persistent
 from pyams_portal.portlet import PortletRenderer
 from pyams_template.template import template_config
 from pyams_utils.adapter import adapter_config
+from pyams_utils.factory import factory_config
 from zope.interface import implementer, Interface
+from zope.location.location import Location
+from zope.schema.fieldproperty import FieldProperty
 
 from pyams_default_theme import _
 
@@ -54,13 +60,38 @@
 
 
 #
-# Double navigation portlet renderers
+# Double navigation portlet default renderer
 #
 
 @adapter_config(context=(IPortalContext, IPyAMSLayer, Interface, IDoubleNavigationPortletSettings),
                 provides=IPortletRenderer)
 @template_config(template='templates/double-vertical.pt', layer=IPyAMSLayer)
-class DoubleNavigationDefaultPortletRenderer(PortletRenderer):
-    """Double navigation default portlet renderer"""
+class DoubleNavigationPortletDefaultRenderer(PortletRenderer):
+    """Double navigation portlet default renderer"""
 
     label = _("Vertical list with small horizontal menus illustrations")
+
+
+#
+# Double navigation portlet "double-select" renderer
+#
+
+@implementer(IDoubleNavigationPortletSelectMenusRendererSettings)
+@factory_config(provided=IDoubleNavigationPortletSelectMenusRendererSettings)
+class DoubleNavigationPortletSelectMenusRendererSettings(Persistent, Location):
+    """Double navigation portlet select menus renderer settings"""
+
+    first_level_label = FieldProperty(IDoubleNavigationPortletSelectMenusRendererSettings['first_level_label'])
+    second_level_label = FieldProperty(IDoubleNavigationPortletSelectMenusRendererSettings['second_level_label'])
+
+
+@adapter_config(name='double-select',
+                context=(IPortalContext, IPyAMSLayer, Interface, IDoubleNavigationPortletSettings),
+                provides=IPortletRenderer)
+@template_config(template='templates/double-select.pt', layer=IPyAMSLayer)
+class DoubleNavigationPortletSelectMenusRenderer(PortletRenderer):
+    """Double navigation portlet menus renderer"""
+
+    label = _("Double-level selection navigation")
+
+    settings_interface = IDoubleNavigationPortletSelectMenusRendererSettings
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_default_theme/features/menu/portlet/navigation/interfaces.py	Wed Jun 20 18:14:46 2018 +0200
@@ -0,0 +1,36 @@
+#
+# Copyright (c) 2008-2018 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+
+# import standard library
+
+# import interfaces
+
+# import packages
+from pyams_i18n.schema import I18nTextLineField
+from zope.interface import Interface
+
+from pyams_default_theme import _
+
+
+class IDoubleNavigationPortletSelectMenusRendererSettings(Interface):
+    """Double navigation portlet select menus renderer settings interface"""
+
+    first_level_label = I18nTextLineField(title=_("First menu label"),
+                                          description=_("Label associated with first level options menu"),
+                                          required=True)
+
+    second_level_label = I18nTextLineField(title=_("Second menu label"),
+                                           description=_("Label associated with second level options menu"),
+                                           required=True)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_default_theme/features/menu/portlet/navigation/templates/double-select.pt	Wed Jun 20 18:14:46 2018 +0200
@@ -0,0 +1,3 @@
+<tal:var define="settings view.settings">
+	<strong tal:content="i18n:settings.title" />
+</tal:var>