# HG changeset patch # User Thierry Florac # Date 1461255078 -7200 # Node ID c270ea8f041eb8b96b012c2c16215c3426ca55df # Parent dc45cba8c8f85613b1470ab90636d7700fcdb6d5 Updated paragraphs management interface diff -r dc45cba8c8f8 -r c270ea8f041e src/pyams_content/component/paragraph/zmi/container.py --- a/src/pyams_content/component/paragraph/zmi/container.py Thu Apr 21 18:10:03 2016 +0200 +++ b/src/pyams_content/component/paragraph/zmi/container.py Thu Apr 21 18:11:18 2016 +0200 @@ -9,7 +9,11 @@ # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # +from zope.contentprovider.interfaces import IContentProvider + from pyams_form.interfaces.form import IFormSecurityContext +from pyams_viewlet.interfaces import IViewletManager +from pyams_viewlet.manager import viewletmanager_config, WeightOrderedViewletManager, TemplateBasedViewletManager __docformat__ = 'restructuredtext' @@ -23,7 +27,7 @@ from pyams_content.component.gallery.interfaces import IGalleryLinksContainerTarget, IGalleryLinksContainer from pyams_content.component.links.interfaces import ILinkLinksContainerTarget, ILinkLinksContainer from pyams_content.component.paragraph.interfaces import IParagraphContainerTarget, IParagraphContainer, IBaseParagraph -from pyams_content.component.paragraph.zmi.interfaces import IParagraphInnerEditor +from pyams_content.component.paragraph.zmi.interfaces import IParagraphInnerEditor, IParagraphTitleToolbar from pyams_i18n.interfaces import II18n from pyams_skin.interfaces import IInnerPage, IPageHeader from pyams_skin.layer import IPyAMSLayer @@ -44,7 +48,7 @@ from pyams_utils.url import absolute_url from pyramid.exceptions import NotFound from pyramid.view import view_config -from pyams_viewlet.viewlet import viewlet_config +from pyams_viewlet.viewlet import viewlet_config, Viewlet from pyams_zmi.view import AdminView from pyramid.decorator import reify from z3c.table.column import GetAttrColumn @@ -180,88 +184,66 @@ return column.table.context -@adapter_config(name='files', context=(IParagraphContainerTarget, IPyAMSLayer, ParagraphContainerTable), - provides=IColumn) -class ParagraphContainerExtFileLinksColumn(ActionColumn): - """Paragraphs container external files links column""" +@viewletmanager_config(name='pyams_paragraph.title_toolbar', context=IBaseParagraph, layer=IPyAMSLayer, + view=ParagraphContainerTable, provides=IParagraphTitleToolbar) +@template_config(template='templates/paragraph-title-toolbar.pt', layer=IPyAMSLayer) +@implementer(IParagraphTitleToolbar) +class ParagraphTitleToolbarViewletManager(TemplateBasedViewletManager, WeightOrderedViewletManager): + """Paragraph title toolbar viewlet manager""" + +@viewlet_config(name='files', context=IExtFileLinksContainerTarget, layer=IPyAMSLayer, view=ParagraphContainerTable, + manager=IParagraphTitleToolbar, permission=VIEW_SYSTEM_PERMISSION, weight=10) +@template_config(template='templates/paragraph-title-icon.pt', layer=IPyAMSLayer) +class ParagraphContainerExtFileLinksAction(Viewlet): + """Paragraph container external files links column""" + + action_class = 'action extfiles nowrap width-40' icon_class = 'fa fa-fw fa-file-text-o' icon_hint = _("External files") - cssClasses = {'td': 'action extfiles nowrap'} - url = 'extfile-links.html' modal_target = True - weight = 10 - - def renderCell(self, item): - if not IExtFileLinksContainerTarget.providedBy(item): - return '' - action = '{action} {{count}}'.format( - action=super(ParagraphContainerExtFileLinksColumn, self).renderCell(item)) - length = len(IExtFileLinksContainer(item).files or ()) - if length: - action = action.format(count='({0})'.format(length)) - else: - action = action.format(count='') - return action + @property + def count(self): + return len(IExtFileLinksContainer(self.context).files or ()) -@adapter_config(name='links', context=(IParagraphContainerTarget, IPyAMSLayer, ParagraphContainerTable), - provides=IColumn) -class ParagraphContainerLinkLinksColumn(ActionColumn): - """Paragraphs container links links column""" +@viewlet_config(name='links', context=ILinkLinksContainerTarget, layer=IPyAMSLayer, view=ParagraphContainerTable, + manager=IParagraphTitleToolbar, permission=VIEW_SYSTEM_PERMISSION, weight=20) +@template_config(template='templates/paragraph-title-icon.pt', layer=IPyAMSLayer) +class ParagraphContainerLinkLinksAction(Viewlet): + """Paragraph container links links column""" + action_class = 'action links nowrap width-40' icon_class = 'fa fa-fw fa-link' icon_hint = _("Useful links") - cssClasses = {'td': 'action links nowrap'} - url = 'link-links.html' modal_target = True - weight = 15 - - def renderCell(self, item): - if not ILinkLinksContainerTarget.providedBy(item): - return '' - action = '{action} {{count}}'.format( - action=super(ParagraphContainerLinkLinksColumn, self).renderCell(item)) - length = len(ILinkLinksContainer(item).links or ()) - if length: - action = action.format(count='({0})'.format(length)) - else: - action = action.format(count='') - return action + @property + def count(self): + return len(ILinkLinksContainer(self.context).links or ()) -@adapter_config(name='gallery', context=(IParagraphContainerTarget, IPyAMSLayer, ParagraphContainerTable), - provides=IColumn) -class ParagraphContainerGalleryLinksColumn(ActionColumn): - """Paragraphs container gallery links column""" +@viewlet_config(name='gallery', context=IGalleryLinksContainerTarget, layer=IPyAMSLayer, view=ParagraphContainerTable, + manager=IParagraphTitleToolbar, permission=VIEW_SYSTEM_PERMISSION, weight=30) +@template_config(template='templates/paragraph-title-icon.pt', layer=IPyAMSLayer) +class ParagraphContainerGalleryLinksAction(Viewlet): + """Paragraph container gallery links column""" + action_class = 'action galleries nowrap width-40' icon_class = 'fa fa-fw fa-picture-o' icon_hint = _("Images galleries") - cssClasses = {'td': 'action galleries nowrap'} - url = 'gallery-links.html' modal_target = True - weight = 20 - - def renderCell(self, item): - if not IGalleryLinksContainerTarget.providedBy(item): - return '' - action = '{action} {{count}}'.format( - action=super(ParagraphContainerGalleryLinksColumn, self).renderCell(item)) - length = len(IGalleryLinksContainer(item).galleries or ()) - if length: - action = action.format(count='({0})'.format(length)) - else: - action = action.format(count='') - return action + @property + def count(self): + return len(IGalleryLinksContainer(self.context).galleries or ()) @adapter_config(name='name', context=(IParagraphContainerTarget, IPyAMSLayer, ParagraphContainerTable), @@ -283,12 +265,20 @@ super(ParagraphContainerTitleColumn, self).renderHeadCell() def renderCell(self, item): - return '
{provider}' \ ' ' \ - ' '.format( - title=self.request.localizer.translate(_("Click to open/close paragraph editor"))) + \ + ' '.format(provider=provider, + title=self.request.localizer.translate(_("Click to open/close paragraph editor"))) + \ '{0}'.format(super(ParagraphContainerTitleColumn, self).renderCell(item)) + \ '
' diff -r dc45cba8c8f8 -r c270ea8f041e src/pyams_content/component/paragraph/zmi/html.py --- a/src/pyams_content/component/paragraph/zmi/html.py Thu Apr 21 18:10:03 2016 +0200 +++ b/src/pyams_content/component/paragraph/zmi/html.py Thu Apr 21 18:11:18 2016 +0200 @@ -108,7 +108,7 @@ content = get_parent(self.context, IWfSharedContent) return II18n(content).query_attribute('title', request=self.request) - legend = _("Edit paragraph properties") + legend = _("Edit HTML paragraph properties") dialog_class = 'modal-max' icon_css_class = 'fa fa-fw fa-html5' label_css_class = 'control-label col-md-2' @@ -132,7 +132,7 @@ """HTML paragraph inner edit form""" legend = None - main_group_legend = _("HTML paragraph properties") + main_group_legend = _("HTML paragraph") main_group_class = 'inner' @property diff -r dc45cba8c8f8 -r c270ea8f041e src/pyams_content/component/paragraph/zmi/illustration.py --- a/src/pyams_content/component/paragraph/zmi/illustration.py Thu Apr 21 18:10:03 2016 +0200 +++ b/src/pyams_content/component/paragraph/zmi/illustration.py Thu Apr 21 18:11:18 2016 +0200 @@ -117,7 +117,7 @@ """Illustration inner edit form""" legend = None - main_group_legend = _("Illustration properties") + main_group_legend = _("Illustration") main_group_class = 'inner' @property diff -r dc45cba8c8f8 -r c270ea8f041e src/pyams_content/component/paragraph/zmi/interfaces.py --- a/src/pyams_content/component/paragraph/zmi/interfaces.py Thu Apr 21 18:10:03 2016 +0200 +++ b/src/pyams_content/component/paragraph/zmi/interfaces.py Thu Apr 21 18:11:18 2016 +0200 @@ -17,9 +17,14 @@ # import interfaces from pyams_form.interfaces.form import IInnerForm +from pyams_viewlet.interfaces import IViewletManager # import packages +class IParagraphTitleToolbar(IViewletManager): + """Paragraph title toolbar viewlet manager""" + + class IParagraphInnerEditor(IInnerForm): """Paragraph inner editor form interface""" diff -r dc45cba8c8f8 -r c270ea8f041e src/pyams_content/component/paragraph/zmi/summary.py --- a/src/pyams_content/component/paragraph/zmi/summary.py Thu Apr 21 18:10:03 2016 +0200 +++ b/src/pyams_content/component/paragraph/zmi/summary.py Thu Apr 21 18:11:18 2016 +0200 @@ -43,7 +43,7 @@ """Paragraphs container summary""" weight = 20 - tab_label = _("Paragraphs") + tab_label = _("Quick preview") tab_target = 'paragraphs-summary.html' fields = field.Fields(Interface) diff -r dc45cba8c8f8 -r c270ea8f041e src/pyams_content/component/paragraph/zmi/templates/paragraph-title-icon.pt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_content/component/paragraph/zmi/templates/paragraph-title-icon.pt Thu Apr 21 18:11:18 2016 +0200 @@ -0,0 +1,14 @@ +
+ + + + + + () + + +
diff -r dc45cba8c8f8 -r c270ea8f041e src/pyams_content/component/paragraph/zmi/templates/paragraph-title-toolbar.pt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_content/component/paragraph/zmi/templates/paragraph-title-toolbar.pt Thu Apr 21 18:11:18 2016 +0200 @@ -0,0 +1,4 @@ +
+ +