Added method and template to render an empty table
authorThierry Florac <thierry.florac@onf.fr>
Wed, 13 Jun 2018 15:34:27 +0200
changeset 343 bff947c6b227
parent 342 1aa6dded00ac
child 344 f1dc3da37393
Added method and template to render an empty table
src/pyams_skin/table.py
src/pyams_skin/templates/table-empty.pt
--- a/src/pyams_skin/table.py	Wed Jun 13 11:26:34 2018 +0200
+++ b/src/pyams_skin/table.py	Wed Jun 13 15:34:27 2018 +0200
@@ -9,6 +9,7 @@
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
 #
+from pyramid.renderers import render
 
 __docformat__ = 'restructuredtext'
 
@@ -155,6 +156,13 @@
         return super(BaseTable, self).renderTable() \
             .replace('<table', '<table %s' % self.get_data_attributes('table', self))
 
+    def renderEmptyTable(self, message=''):
+        return render('templates/table-empty.pt',
+                      {'view': self,
+                       'context': self.context,
+                       'message': message},
+                      request=self.request)
+
     def renderRow(self, row, cssClass=None):
         return super(BaseTable, self).renderRow(row, cssClass) \
             .replace('<tr', '<tr %s' % self.get_data_attributes('tr', row[0][0]))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_skin/templates/table-empty.pt	Wed Jun 13 15:34:27 2018 +0200
@@ -0,0 +1,22 @@
+<div class="ams-widget"
+	 tal:attributes="class view.widget_class | default;
+					 data-ams-data extension:object_data(view);">
+	<header tal:condition="not:getattr(view,'hide_header',False)">
+		<span tal:condition="view.widget_icon_class | nothing"
+			  class="widget-icon"><i tal:attributes="class view.widget_icon_class"></i>
+		</span>
+		<h2 tal:content="view.title"></h2>
+		<tal:if condition="not:getattr(view,'hide_toolbar',False)">
+			<tal:var content="structure provider:pyams.widget_title" />
+			<tal:var content="structure provider:pyams.toolbar" />
+		</tal:if>
+	</header>
+	<div class="widget-body no-padding"
+		 tal:define="hide_toolbar getattr(view, 'hide_body_toolbar', False)"
+		 tal:attributes="id string:${view.id}_body;
+						 class python:'widget-body no-padding {0}'.format('no-widget-toolbar' if hide_toolbar else '');">
+		<div class="widget-body-toolbar"></div>
+		<div tal:attributes="id view.id" class="noborder padding-10"
+			 tal:content="structure message">ID</div>
+	</div>
+</div>