Created custom editor for contact card
authorThierry Florac <thierry.florac@onf.fr>
Mon, 19 Nov 2018 15:15:37 +0100
changeset 229 be5bc85fd442
parent 228 44ac5e31ce87
child 230 951d11442e0b
Created custom editor for contact card
src/pyams_default_theme/component/paragraph/zmi/contact.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_default_theme/component/paragraph/zmi/contact.py	Mon Nov 19 15:15:37 2018 +0100
@@ -0,0 +1,38 @@
+#
+# 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'
+
+from pyramid.decorator import reify
+
+from pyams_content.component.paragraph.interfaces.contact import IContactParagraph, have_gis
+from pyams_content.features.renderer.zmi import RendererPropertiesEditForm
+from pyams_content.interfaces import MANAGE_CONTENT_PERMISSION
+from pyams_form.form import ajax_config
+from pyams_pagelet.pagelet import pagelet_config
+from pyams_skin.layer import IPyAMSLayer
+
+
+@pagelet_config(name='renderer-properties.html', context=IContactParagraph, layer=IPyAMSLayer,
+                permission=MANAGE_CONTENT_PERMISSION)
+@ajax_config(name='renderer-properties.json', context=IContactParagraph, layer=IPyAMSLayer)
+class ContactParagraphRendererPropertiesEditForm(RendererPropertiesEditForm):
+    """Contact paragraph renderer properties edit form"""
+
+    dialog_class = 'modal-large'
+
+    @reify
+    def fields(self):
+        fields = super(ContactParagraphRendererPropertiesEditForm, self).fields
+        if not have_gis:
+            fields = fields.omit('display_map', 'map_position')
+        return fields