Use TableViewlet base class to display catalog indexes
authorThierry Florac <thierry.florac@onf.fr>
Fri, 26 Jan 2018 16:37:35 +0100
changeset 32 190213c865a2
parent 31 dddb3b9cd406
child 33 ab440460b11b
Use TableViewlet base class to display catalog indexes
src/pyams_catalog/zmi/catalog.py
src/pyams_catalog/zmi/templates/catalog-indexes.pt
--- a/src/pyams_catalog/zmi/catalog.py	Mon Dec 11 15:26:54 2017 +0100
+++ b/src/pyams_catalog/zmi/catalog.py	Fri Jan 26 16:37:35 2018 +0100
@@ -26,12 +26,11 @@
 # import packages
 from pyams_catalog.index import InterfaceSupportIndexMixin
 from pyams_pagelet.pagelet import pagelet_config
-from pyams_skin.table import BaseTable, I18nColumn, TrashColumn
-from pyams_template.template import template_config
+from pyams_skin.table import BaseTable, I18nColumn, TrashColumn, TableViewlet
 from pyams_utils.adapter import adapter_config, ContextRequestViewAdapter
 from pyams_utils.text import text_to_html
 from pyams_utils.url import absolute_url
-from pyams_viewlet.viewlet import viewlet_config, Viewlet
+from pyams_viewlet.viewlet import viewlet_config
 from pyams_zmi.form import AdminDialogDisplayForm
 from pyramid.view import view_config
 from z3c.form import field
@@ -212,19 +211,10 @@
 
 @viewlet_config(name='catalog-indexes', view=CatalogPropertiesDisplayForm, layer=IAdminLayer,
                 manager=IWidgetsSuffixViewletsManager)
-@template_config(template='templates/catalog-indexes.pt')
-class CatalogIndexesViewlet(Viewlet):
+class CatalogIndexesViewlet(TableViewlet):
     """Catalog indexes viewlet"""
 
-    table = None
-
-    def __init__(self, context, request, view, manager):
-        super(CatalogIndexesViewlet, self).__init__(context, request, view, manager)
-        self.table = CatalogIndexesTable(context, request)
-
-    def update(self):
-        super(CatalogIndexesViewlet, self).update()
-        self.table.update()
+    table_class = CatalogIndexesTable
 
 
 @view_config(name='delete-index.json', context=ICatalog, request_type=IPyAMSLayer,
--- a/src/pyams_catalog/zmi/templates/catalog-indexes.pt	Mon Dec 11 15:26:54 2017 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-<div class="no-widget-toolbar">
-	<tal:var replace="structure view.table.render()" />
-</div>