Use template to render name cell
authorThierry Florac <thierry.florac@onf.fr>
Fri, 15 Jun 2018 11:04:19 +0200
changeset 687 2a176cd699ac
parent 686 43ebbd99dd62
child 688 22a501f58d06
Use template to render name cell
src/pyams_content/features/menu/zmi/__init__.py
src/pyams_content/features/menu/zmi/templates/menu-name-cell.pt
--- a/src/pyams_content/features/menu/zmi/__init__.py	Fri Jun 15 11:03:40 2018 +0200
+++ b/src/pyams_content/features/menu/zmi/__init__.py	Fri Jun 15 11:04:19 2018 +0200
@@ -28,6 +28,7 @@
 from pyams_skin.layer import IPyAMSLayer
 from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION
 from pyams_viewlet.interfaces import IViewletManager
+from pyams_zmi.interfaces import IPropertiesEditForm
 from z3c.table.interfaces import IValues, IColumn
 
 # import packages
@@ -48,6 +49,7 @@
 from pyams_zmi.zmi.table import InnerTableView
 from pyramid.decorator import reify
 from pyramid.exceptions import NotFound
+from pyramid.renderers import render
 from pyramid.view import view_config
 from z3c.form import field
 from zope.interface import implementer, alsoProvides, Interface
@@ -114,12 +116,15 @@
 
 @pagelet_config(name='properties.html', context=IMenu, layer=IPyAMSLayer, permission=MANAGE_TEMPLATE_PERMISSION)
 @ajax_config(name='properties.json', context=IMenu, layer=IPyAMSLayer)
+@implementer(IPropertiesEditForm)
 class MenuPropertiesEditForm(AdminDialogEditForm):
     """Menu properties edit form"""
 
     legend = _("Edit menu properties")
     icon_css_class = 'fa fa-fw fa-bars'
 
+    dialog_class = 'modal-large'
+
     fields = field.Fields(IMenu).select('title')
     edit_permission = MANAGE_TEMPLATE_PERMISSION
 
@@ -205,17 +210,7 @@
     weight = 10
 
     def renderCell(self, item):
-        return '<span data-ams-stop-propagation="true" ' \
-               '      data-ams-click-handler="MyAMS.skin.switchCellContent" ' \
-               '      data-ams-switch-handler="get-menu-items.json" ' \
-               '      data-ams-switch-target=".menus">' \
-               '    <span class="small hint" title="{hint}" data-ams-hint-gravity="e">' \
-               '        <i class="fa fa-plus-square-o switch"></i>' \
-               '    </span>' \
-               '</span>&nbsp;&nbsp;&nbsp;<span class="title">{title}</span>' \
-               '<div class="inner-table-form menus margin-x-10 margin-bottom-0 padding-left-5"></div>'.format(
-            hint=self.request.localizer.translate(_("Click to see menu items")),
-            title=super(MenusTableNameColumn, self).renderCell(item))
+        return render('templates/menu-name-cell.pt', {'context': item}, request=self.request)
 
 
 @adapter_config(name='trash', context=(IMenusContainerTarget, IPyAMSLayer, MenusTable), provides=IColumn)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/features/menu/zmi/templates/menu-name-cell.pt	Fri Jun 15 11:04:19 2018 +0200
@@ -0,0 +1,13 @@
+<i18n:v domain="pyams_content">
+	<span data-ams-stop-propagation="true"
+		  data-ams-click-handler="MyAMS.skin.switchCellContent"
+		  data-ams-switch-handler="get-menu-items.json"
+		  data-ams-switch-target=".menus">
+		<span class="small hint"
+			  title="Click to see menu items" i18n:attributes="title"
+			  data-ams-hint-gravity="e">
+			<i class="fa fa-plus-square-o switch"></i>
+		</span>
+	</span>&nbsp;&nbsp;&nbsp;<span class="title" tal:content="i18n:context.title">title</span>
+	<div class="inner-table-form menus margin-x-10 margin-bottom-0 padding-left-5"></div>
+</i18n:v>