--- a/src/pyams_content/component/illustration/zmi/paragraph.py Wed Apr 11 16:44:46 2018 +0200
+++ b/src/pyams_content/component/illustration/zmi/paragraph.py Wed Apr 11 16:46:31 2018 +0200
@@ -23,7 +23,6 @@
from pyams_content.component.paragraph.zmi.interfaces import IParagraphInnerEditor, IParagraphContainerView
from pyams_content.interfaces import MANAGE_CONTENT_PERMISSION
from pyams_form.interfaces.form import IInnerForm, IEditFormButtons
-from pyams_i18n.interfaces import II18n
from pyams_skin.interfaces.viewlet import IToolbarAddingMenu
from pyams_skin.layer import IPyAMSLayer
from transaction.interfaces import ITransactionManager
@@ -32,10 +31,11 @@
# import packages
from pyams_content.component.illustration.paragraph import Illustration
from pyams_content.component.paragraph.zmi import BaseParagraphAJAXAddForm, BaseParagraphAJAXEditForm, \
- BaseParagraphAddMenu, BaseParagraphPropertiesEditForm
+ BaseParagraphAddMenu, BaseParagraphPropertiesEditForm, get_json_paragraph_refresh_event
from pyams_content.features.renderer.zmi import BaseRenderedContentRenderer
from pyams_content.features.renderer.zmi.widget import RendererFieldWidget
from pyams_pagelet.pagelet import pagelet_config
+from pyams_skin.event import get_json_form_refresh_event
from pyams_utils.adapter import adapter_config
from pyams_viewlet.viewlet import viewlet_config
from pyams_zmi.form import AdminDialogAddForm
@@ -97,6 +97,8 @@
class IllustrationPropertiesEditForm(BaseParagraphPropertiesEditForm):
"""Illustration properties edit form"""
+ prefix = 'illustration_properties.'
+
legend = _("Edit illustration properties")
dialog_class = 'modal-large'
icon_css_class = 'fa fa-fw fa-file-image-o'
@@ -121,15 +123,7 @@
def get_ajax_output(self, changes):
output = super(IllustrationPropertiesAJAXEditForm, self).get_ajax_output(changes)
if 'title' in changes.get(IIllustration, ()):
- output.setdefault('events', []).append({
- 'event': 'myams.refresh',
- 'options': {
- 'handler': 'PyAMS_content.paragraphs.refreshParagraph',
- 'object_name': self.context.__name__,
- 'title': II18n(self.context).query_attribute('title', request=self.request),
- 'visible': self.context.visible
- }
- })
+ output.setdefault('events', []).append(get_json_paragraph_refresh_event(self.context, self.request))
return output
@@ -158,31 +152,13 @@
output = super(IllustrationInnerAJAXEditForm, self).get_ajax_output(changes)
updated = changes.get(IIllustration, ())
if 'title' in updated:
- output.setdefault('events', []).append({
- 'event': 'myams.refresh',
- 'options': {
- 'handler': 'PyAMS_content.paragraphs.refreshParagraph',
- 'object_name': self.context.__name__,
- 'title': II18n(self.context).query_attribute('title', request=self.request),
- 'visible': self.context.visible
- }
- })
+ output.setdefault('events', []).append(get_json_paragraph_refresh_event(self.context, self.request))
updated = changes.get(IIllustrationParagraph, ())
if 'data' in updated:
# we have to commit transaction to be able to handle blobs...
ITransactionManager(self.context).get().commit()
- form = IllustrationInnerEditForm(self.context, self.request)
- form.update()
- output.setdefault('events', []).append({
- 'event': 'myams.refresh',
- 'options': {
- 'object_id': '{0}_{1}_{2}'.format(
- self.context.__class__.__name__,
- getattr(form.getContent(), '__name__', 'noname').replace('++', ''),
- form.id),
- 'content': form.render()
- }
- })
+ output.setdefault('events', []).append(get_json_form_refresh_event(self.context, self.request,
+ IllustrationInnerEditForm))
return output