Updated preview management
authorThierry Florac <thierry.florac@onf.fr>
Fri, 13 Oct 2017 08:45:58 +0200
changeset 232 f08f65ad0818
parent 231 fbca11f0c1f4
child 233 200b656d851d
Updated preview management
src/pyams_content/shared/view/zmi/preview.py
src/pyams_content/shared/view/zmi/summary.py
src/pyams_content/shared/view/zmi/templates/preview.pt
src/pyams_content/shared/view/zmi/templates/summary.pt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/shared/view/zmi/preview.py	Fri Oct 13 08:45:58 2017 +0200
@@ -0,0 +1,39 @@
+#
+# 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_content.shared.common.interfaces.zmi import IPreviewForm
+from pyams_content.shared.view.interfaces import IWfView
+from pyams_form.interfaces.form import IWidgetsSuffixViewletsManager
+from pyams_skin.layer import IPyAMSLayer
+from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION
+
+# import packages
+from pyams_template.template import template_config
+from pyams_viewlet.viewlet import viewlet_config
+
+
+@viewlet_config(name='view-preview', context=IWfView, layer=IPyAMSLayer,
+                view=IPreviewForm, manager=IWidgetsSuffixViewletsManager,
+                permission=VIEW_SYSTEM_PERMISSION, weight=100)
+@template_config(template='templates/preview.pt', layer=IPyAMSLayer)
+class SharedViewPreview(object):
+    """Shared view preview"""
+
+    @property
+    def items(self):
+        return self.context.get_results(self.context)
--- a/src/pyams_content/shared/view/zmi/summary.py	Fri Oct 13 08:44:18 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-#
-# 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_content.shared.common.interfaces.zmi import IInnerSummaryView
-from pyams_content.shared.view.interfaces import IWfView
-from pyams_form.interfaces.form import IInnerTabForm
-from pyams_skin.layer import IPyAMSLayer
-from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION
-
-# import packages
-from pyams_content.shared.common.zmi.summary import SharedContentSummaryForm
-from pyams_pagelet.pagelet import pagelet_config
-from pyams_template.template import template_config
-from pyams_utils.adapter import adapter_config
-from pyams_zmi.form import InnerAdminDisplayForm
-from z3c.form import field
-from zope.interface import implementer, Interface
-
-from pyams_content import _
-
-
-@adapter_config(name='view-summary',
-                context=(IWfView, IPyAMSLayer, SharedContentSummaryForm),
-                provides=IInnerTabForm)
-class SharedViewSummaryForm(InnerAdminDisplayForm):
-    """Shared view summary"""
-
-    weight = 20
-    tab_label = _("Quick preview")
-    tab_target = 'view-summary.html'
-
-    fields = field.Fields(Interface)
-
-
-@pagelet_config(name='view-summary.html', context=IWfView, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION)
-@template_config(template='templates/summary.pt', layer=IPyAMSLayer)
-@implementer(IInnerSummaryView)
-class SharedViewSummaryView(object):
-    """Shared view summary view"""
-
-    def __init__(self, context, request):
-        super(SharedViewSummaryView, self).__init__(context, request)
-
-    @property
-    def items(self):
-        return self.context.get_results(self.context)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/shared/view/zmi/templates/preview.pt	Fri Oct 13 08:45:58 2017 +0200
@@ -0,0 +1,9 @@
+<fieldset i18n:domain="pyams_content">
+	<legend class="inner" i18n:translate="">View result items</legend>
+	<div class="alert alert-info padding-5" i18n:translate="">
+		WARNING: items displayed in this preview are out of context!!
+	</div>
+	<tal:loop repeat="item view.items">
+		<span tal:content="i18n:item.title" /><br />
+	</tal:loop>
+</fieldset>
--- a/src/pyams_content/shared/view/zmi/templates/summary.pt	Fri Oct 13 08:44:18 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-<fieldset i18n:domain="pyams_content">
-	<legend class="inner" i18n:translate="">View result items</legend>
-	<tal:loop repeat="item view.items">
-		<span tal:content="i18n:item.title" /><br />
-	</tal:loop>
-</fieldset>