# HG changeset patch # User Thierry Florac # Date 1542700846 -3600 # Node ID 25ce08d3d1774dfa88bf6efe494a0e56d63b8ca9 # Parent d5f9f495dc30561f162e001bbd6e29b737a75761 Added menus to simple header diff -r d5f9f495dc30 -r 25ce08d3d177 src/pyams_default_theme/features/header/__init__.py --- a/src/pyams_default_theme/features/header/__init__.py Mon Nov 19 22:59:24 2018 +0100 +++ b/src/pyams_default_theme/features/header/__init__.py Tue Nov 20 09:00:46 2018 +0100 @@ -19,9 +19,9 @@ from pyams_content.component.association.interfaces import ASSOCIATION_CONTAINER_KEY from pyams_content.features.header.interfaces import IHeaderSettings, IHeaderTarget -from pyams_content.features.menu import Menu -from pyams_content.features.menu.interfaces import IMenuLinksContainer, IMenuLinksContainerTarget -from pyams_default_theme.features.header.interfaces import ISimpleHeaderRendererSettings, ISimpleHeaderTabsMenu +from pyams_content.features.menu import MenusContainer, IMenusContainer +from pyams_content.features.menu.interfaces import IMenusContainerTarget +from pyams_default_theme.features.header.interfaces import ISimpleHeaderRendererSettings, ISimpleHeaderMenusContainer from pyams_default_theme.layer import IPyAMSDefaultLayer from pyams_file.property import FileProperty from pyams_utils.adapter import ContextAdapter, adapter_config, get_annotation_adapter @@ -55,10 +55,10 @@ # Simple header renderer settings # -SIMPLE_HEADER_TABS_KEY = '{0}::tabs'.format(ASSOCIATION_CONTAINER_KEY) +SIMPLE_HEADER_MENUS_KEY = '{0}::menus'.format(ASSOCIATION_CONTAINER_KEY) -@implementer(ISimpleHeaderRendererSettings, IMenuLinksContainerTarget) +@implementer(ISimpleHeaderRendererSettings, IMenusContainerTarget) class SimpleHeaderRendererSettings(Persistent, Location): """Simple header renderer settings""" @@ -66,20 +66,20 @@ logo = FileProperty(ISimpleHeaderRendererSettings['logo']) @property - def tabs(self): - return get_annotation_adapter(self, SIMPLE_HEADER_TABS_KEY, Menu, - markers=ISimpleHeaderTabsMenu, name='++ass++tabs') + def menus(self): + return get_annotation_adapter(self, SIMPLE_HEADER_MENUS_KEY, MenusContainer, + markers=ISimpleHeaderMenusContainer, name='++ass++menus') -@adapter_config(name='tabs', context=ISimpleHeaderRendererSettings, provides=IMenuLinksContainer) -def simple_header_tabs_links_adapter(context): - """Simple header tabs links adapter""" - return context.tabs +@adapter_config(name='menus', context=ISimpleHeaderRendererSettings, provides=IMenusContainer) +def simple_header_menus_adapter(context): + """Simple header menus adapter""" + return context.menus -@adapter_config(name='tabs', context=ISimpleHeaderRendererSettings, provides=ISublocations) +@adapter_config(name='menus', context=ISimpleHeaderRendererSettings, provides=ISublocations) class SimpleHeaderRendererSettingsSublocations(ContextAdapter): """Simple header renderer settings sub-locations adapter""" def sublocations(self): - return self.context.tabs.values() + return self.context.menus.values() diff -r d5f9f495dc30 -r 25ce08d3d177 src/pyams_default_theme/features/header/interfaces.py --- a/src/pyams_default_theme/features/header/interfaces.py Mon Nov 19 22:59:24 2018 +0100 +++ b/src/pyams_default_theme/features/header/interfaces.py Tue Nov 20 09:00:46 2018 +0100 @@ -12,15 +12,10 @@ __docformat__ = 'restructuredtext' +from zope.interface import Interface, Attribute -# import standard library - -# import interfaces from pyams_content.features.header.interfaces import IHeaderRendererSettings - -# import packages from pyams_file.schema import ImageField -from zope.interface import Interface, Attribute from pyams_default_theme import _ @@ -38,6 +33,8 @@ tabs = Attribute("Top tabs list") + menus = Attribute("Top tabs menus list") -class ISimpleHeaderTabsMenu(Interface): - """Simple header menu marker interface""" + +class ISimpleHeaderMenusContainer(Interface): + """Simple header menus marker interface""" diff -r d5f9f495dc30 -r 25ce08d3d177 src/pyams_default_theme/features/header/zmi/__init__.py --- a/src/pyams_default_theme/features/header/zmi/__init__.py Mon Nov 19 22:59:24 2018 +0100 +++ b/src/pyams_default_theme/features/header/zmi/__init__.py Tue Nov 20 09:00:46 2018 +0100 @@ -12,23 +12,18 @@ __docformat__ = 'restructuredtext' - -# import standard library +from transaction.interfaces import ITransactionManager +from z3c.form import field -# import interfaces -from pyams_default_theme.features.header import ISimpleHeaderRendererSettings, ISimpleHeaderTabsMenu +from pyams_content.features.header.zmi import HeaderSettingsRendererSettingsEditForm +from pyams_content.features.menu.zmi import IMenusView, MenusTable, MenusView +from pyams_default_theme.features.header import ISimpleHeaderMenusContainer, ISimpleHeaderRendererSettings from pyams_form.interfaces.form import IInnerSubForm from pyams_portal.interfaces import MANAGE_TEMPLATE_PERMISSION +from pyams_skin.event import get_json_widget_refresh_event from pyams_skin.layer import IPyAMSLayer -from transaction.interfaces import ITransactionManager - -# import packages -from pyams_content.features.header.zmi import HeaderSettingsRendererSettingsEditForm -from pyams_content.features.menu.zmi import LinksTable, IMenuLinksView, MenuLinksView -from pyams_skin.event import get_json_widget_refresh_event from pyams_utils.adapter import adapter_config from pyams_zmi.form import InnerAdminEditForm -from z3c.form import field from pyams_default_theme import _ @@ -62,23 +57,17 @@ # -# Header top tabs table view +# Header menus table view # -class TabsAssociationsTable(LinksTable): - """Simple header tabs associations table""" - - associations_name = 'tabs' - - -@adapter_config(name='simple-header-tabs', +@adapter_config(name='simple-header-menus', context=(ISimpleHeaderRendererSettings, IPyAMSLayer, HeaderSettingsRendererSettingsEditForm), provides=IInnerSubForm) -@adapter_config(name='++ass++tabs', context=(ISimpleHeaderTabsMenu, IPyAMSLayer), provides=IMenuLinksView) -class SimpleHeaderTabsView(MenuLinksView): - """Simple header tabs view""" +@adapter_config(name='++ass++menus', context=(ISimpleHeaderMenusContainer, IPyAMSLayer), provides=IMenusView) +class SimpleHeaderMenusView(MenusView): + """Simple header menus view""" - title = _("Top tabs") + title = _("Top menus") - table_class = TabsAssociationsTable + table_class = MenusTable weight = 10