Updated paragraphs container management
authorThierry Florac <thierry.florac@onf.fr>
Tue, 03 Oct 2017 15:48:44 +0200
changeset 194 6a26b2b0cb47
parent 193 595d2965fc4d
child 195 e689a4341d47
Updated paragraphs container management
src/pyams_content/component/paragraph/interfaces/__init__.py
src/pyams_content/component/paragraph/zmi/container.py
--- a/src/pyams_content/component/paragraph/interfaces/__init__.py	Tue Oct 03 14:44:04 2017 +0200
+++ b/src/pyams_content/component/paragraph/interfaces/__init__.py	Tue Oct 03 15:48:44 2017 +0200
@@ -46,7 +46,6 @@
                    default=True)
 
     title = I18nTextLineField(title=_("ยง Title"),
-                              description=_("Paragraph title"),
                               required=False)
 
 
--- a/src/pyams_content/component/paragraph/zmi/container.py	Tue Oct 03 14:44:04 2017 +0200
+++ b/src/pyams_content/component/paragraph/zmi/container.py	Tue Oct 03 15:48:44 2017 +0200
@@ -9,6 +9,7 @@
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
 #
+from pyams_skin.interfaces.container import ITableElementEditor
 
 __docformat__ = 'restructuredtext'
 
@@ -108,6 +109,14 @@
         return super(ParagraphContainerTable, self).render()
 
 
+@adapter_config(context=(IBaseParagraph, IPyAMSLayer, ParagraphContainerTable), provides=ITableElementEditor)
+class BaseParagraphTableElementEditor(ContextRequestViewAdapter):
+    """Base paragraph table element editor"""
+
+    def __new__(cls, *args, **kwargs):
+        return None
+
+
 @adapter_config(name='sorter', context=(IParagraphContainerTarget, IPyAMSLayer, ParagraphContainerTable),
                 provides=IColumn)
 class ParagraphContainerSorterColumn(ProtectedFormObjectMixin, SorterColumn):
@@ -200,25 +209,27 @@
     weight = 50
 
     def renderHeadCell(self):
-        return '<span class="small hint" title="{title}" data-ams-hint-gravity="e"' \
-               '      data-ams-stop-propagation="true"' \
+        return '<span data-ams-stop-propagation="true"' \
                '      data-ams-click-handler="PyAMS_content.paragraphs.switchAllEditors">' \
-               '    <i class="fa fa-plus-square-o"></i>' \
-               '</span>&nbsp;&nbsp;&nbsp;'.format(
-                    title=self.request.localizer.translate(_("Click to open/close all paragraphs editors"))) + \
-               super(ParagraphContainerTitleColumn, self).renderHeadCell()
+               '    <span class="small hint" title="{hint}" data-ams-hint-gravity="e">' \
+               '        <i class="fa fa-plus-square-o switch"></i>' \
+               '    </span>&nbsp;&nbsp;&nbsp;{title}' \
+               '</span>'.format(
+                    hint=self.request.localizer.translate(_("Click to open/close all paragraphs editors")),
+                    title=super(ParagraphContainerTitleColumn, self).renderHeadCell())
 
     def renderCell(self, item):
         provider = getParagraphTitleHints(item, self.request, self.table) or ''
-        return '<div>{provider}<span class="small hint" title="{title}" data-ams-hint-gravity="e"' \
-               '      data-ams-stop-propagation="true" ' \
-               '      data-ams-click-handler="PyAMS_content.paragraphs.switchEditor">' \
-               '    <i class="fa fa-plus-square-o"></i>' \
-               '</span>&nbsp;&nbsp;&nbsp;'.format(
+        return '<div data-ams-stop-propagation="true" ' \
+               '     data-ams-click-handler="PyAMS_content.paragraphs.switchEditor">{provider}' \
+               '    <span class="small hint" title="{hint}" data-ams-hint-gravity="e">' \
+               '        <i class="fa fa-plus-square-o switch"></i>' \
+               '    </span>&nbsp;&nbsp;&nbsp;<span class="title">{title}</span>' \
+               '</div>'.format(
                     provider=provider,
-                    title=self.request.localizer.translate(_("Click to open/close paragraph editor"))) + \
-               '<span class="title">{0}</span>'.format(super(ParagraphContainerTitleColumn, self).renderCell(item)) + \
-               '</div><div class="inner-table-form editor margin-x-10 margin-bottom-0"></div>'
+                    hint=self.request.localizer.translate(_("Click to open/close paragraph editor")),
+                    title=super(ParagraphContainerTitleColumn, self).renderCell(item)) + \
+               '<div class="inner-table-form editor margin-x-10 margin-bottom-0"></div>'
 
     def getValue(self, obj):
         return II18n(obj).query_attribute('title', request=self.request) or ' - - - - - - - -'