# HG changeset patch # User Thierry Florac # Date 1507877058 -7200 # Node ID fbca11f0c1f4738b20cae05e1df470a083bfec3a # Parent dabf155776a9530c01cfbc213669b83bd6f417bb Added imagemap preview in paragraph diff -r dabf155776a9 -r fbca11f0c1f4 src/pyams_content/shared/imagemap/zmi/paragraph.py --- a/src/pyams_content/shared/imagemap/zmi/paragraph.py Fri Oct 13 08:41:15 2017 +0200 +++ b/src/pyams_content/shared/imagemap/zmi/paragraph.py Fri Oct 13 08:44:18 2017 +0200 @@ -23,7 +23,7 @@ from pyams_content.interfaces import MANAGE_CONTENT_PERMISSION from pyams_content.shared.common.interfaces import IWfSharedContent from pyams_content.shared.imagemap.interfaces import IImageMapParagraph -from pyams_form.interfaces.form import IInnerForm, IEditFormButtons +from pyams_form.interfaces.form import IInnerForm, IEditFormButtons, IWidgetsSuffixViewletsManager from pyams_i18n.interfaces import II18n from pyams_skin.interfaces.viewlet import IToolbarAddingMenu from pyams_skin.layer import IPyAMSLayer @@ -38,7 +38,7 @@ from pyams_template.template import template_config from pyams_utils.adapter import adapter_config from pyams_utils.traversing import get_parent -from pyams_viewlet.viewlet import viewlet_config, BaseContentProvider +from pyams_viewlet.viewlet import viewlet_config, BaseContentProvider, Viewlet from pyams_zmi.form import AdminDialogAddForm, AdminDialogEditForm from pyramid.view import view_config from z3c.form import field, button @@ -128,6 +128,30 @@ class ImagemapParagraphInnerAJAXEditForm(BaseParagraphAJAXEditForm, ImagemapParagraphInnerEditForm): """Image map paragraph properties inner edit form, JSON rendener""" + def get_ajax_output(self, changes): + output = super(ImagemapParagraphInnerAJAXEditForm, self).get_ajax_output(changes) + if 'reference' in changes.get(IImageMapParagraph, ()): + form = ImagemapParagraphInnerEditForm(self.context, self.request) + form.update() + content = form.getContent() + output.setdefault('events', []).append({ + 'event': 'PyAMS_content.changed_item', + 'options': {'handler': 'PyAMS_content.refreshForm', + 'object_name': '{0}_{1}_{2}'.format( + content.__class__.__name__, + getattr(content, '__name__', 'noname').replace('++', ''), + form.id), + 'form': form.render()} + }) + return output + + +@viewlet_config(name='imagemap-preview', context=IImageMapParagraph, request=IPyAMSLayer, + view=ImagemapParagraphInnerEditForm, manager=IWidgetsSuffixViewletsManager, weight=1) +@template_config(template='templates/imagemap-preview.pt', layer=IPyAMSLayer) +class ImagemapParagraphPreviewWidgetsSuffix(Viewlet): + """Image map paragraph preview widgets suffix""" + # # Image map paragraph summary diff -r dabf155776a9 -r fbca11f0c1f4 src/pyams_content/shared/imagemap/zmi/templates/imagemap-preview.pt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_content/shared/imagemap/zmi/templates/imagemap-preview.pt Fri Oct 13 08:44:18 2017 +0200 @@ -0,0 +1,8 @@ +
+
+
+ +
+