Added inner table base class
authortflorac@dagon.home
Thu, 05 Apr 2018 23:01:11 +0200
changeset 58 b1d1dd23df30
parent 57 101f3a658b8a
child 59 c16a44de14ac
Added inner table base class
src/pyams_zmi/zmi/table.py
src/pyams_zmi/zmi/templates/inner-table.pt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_zmi/zmi/table.py	Thu Apr 05 23:01:11 2018 +0200
@@ -0,0 +1,42 @@
+#
+# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+
+# import standard library
+
+# import interfaces
+from pyams_zmi.layer import IAdminLayer
+
+# import packages
+from pyams_template.template import template_config
+from pyams_zmi.form import InnerAdminDisplayForm
+from z3c.form import field
+from zope.interface import Interface
+
+
+@template_config(template='templates/inner-table.pt', layer=IAdminLayer)
+class InnerTableView(InnerAdminDisplayForm):
+    """Inner table view"""
+
+    fields = field.Fields(Interface)
+    table_factory = None
+
+    def __init__(self, context, request, view):
+        super(InnerTableView, self).__init__(context, request, view)
+        self.table = self.table_factory(context, request)
+        self.table.view = self
+
+    def update(self):
+        super(InnerTableView, self).update()
+        self.table.update()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_zmi/zmi/templates/inner-table.pt	Thu Apr 05 23:01:11 2018 +0200
@@ -0,0 +1,14 @@
+<div class="form-group" i18n:domain="pyams_zmi">
+	<fieldset class="margin-top-10 padding-top-5 padding-bottom-0">
+		<legend
+			class="inner switcher margin-bottom-5 padding-right-10 no-y-padding pull-left width-auto"
+			tal:attributes="data-ams-switcher-state 'open' if view.table.values else None">
+			<tal:var content="view.title" i18n:translate="">View title</tal:var>
+		</legend>
+		<div class="pull-left persistent">
+			<tal:var content="structure provider:pyams.widget_title" />
+		</div>
+		<div class="clearfix"></div>
+		<tal:var content="structure view.table.render()" />
+	</fieldset>
+</div>