diff -r 4fafaf94701d -r b694d5667d17 src/pyams_content/component/paragraph/zmi/audio.py --- a/src/pyams_content/component/paragraph/zmi/audio.py Wed Jun 06 13:32:14 2018 +0200 +++ b/src/pyams_content/component/paragraph/zmi/audio.py Fri Jun 08 10:33:23 2018 +0200 @@ -33,13 +33,13 @@ from pyams_content.component.paragraph.zmi import BaseParagraphAJAXAddForm, BaseParagraphAJAXEditForm, \ BaseParagraphAddMenu, BaseParagraphPropertiesEditForm, IParagraphEditFormButtons from pyams_content.features.renderer.zmi.widget import RendererFieldWidget +from pyams_form.form import ajax_config from pyams_form.group import NamedWidgetsGroup from pyams_pagelet.pagelet import pagelet_config from pyams_skin.event import get_json_form_refresh_event, get_json_widget_refresh_event from pyams_utils.adapter import adapter_config from pyams_viewlet.viewlet import viewlet_config from pyams_zmi.form import AdminDialogAddForm -from pyramid.view import view_config from z3c.form import field, button from zope.interface import implementer @@ -59,6 +59,8 @@ @pagelet_config(name='add-audio-paragraph.html', context=IParagraphContainerTarget, layer=IPyAMSLayer, permission=MANAGE_CONTENT_PERMISSION) +@ajax_config(name='add-audio-paragraph.json', context=IParagraphContainerTarget, layer=IPyAMSLayer, + base=BaseParagraphAJAXAddForm) class AudioParagraphAddForm(AdminDialogAddForm): """Audio paragraph add form""" @@ -67,7 +69,6 @@ icon_css_class = 'fa fa-fw fa-volume-up' fields = field.Fields(IAudioParagraph).omit('__parent__', '__name__', 'visible') - ajax_handler = 'add-audio-paragraph.json' edit_permission = MANAGE_CONTENT_PERMISSION def updateWidgets(self, prefix=None): @@ -96,14 +97,9 @@ IParagraphContainer(self.context).append(object) -@view_config(name='add-audio-paragraph.json', context=IParagraphContainerTarget, request_type=IPyAMSLayer, - permission=MANAGE_CONTENT_PERMISSION, renderer='json', xhr=True) -class AudioParagraphAJAXAddForm(BaseParagraphAJAXAddForm, AudioParagraphAddForm): - """Audio paragraph add form, JSON renderer""" - - @pagelet_config(name='properties.html', context=IAudioParagraph, layer=IPyAMSLayer, permission=MANAGE_CONTENT_PERMISSION) +@ajax_config(name='properties.json', context=IAudioParagraph, layer=IPyAMSLayer, base=BaseParagraphAJAXEditForm) class AudioParagraphPropertiesEditForm(BaseParagraphPropertiesEditForm): """Audio paragraph properties edit form""" @@ -116,7 +112,6 @@ fields = field.Fields(IAudioParagraph).omit('__parent__', '__name__', 'visible') fields['renderer'].widgetFactory = RendererFieldWidget - ajax_handler = 'properties.json' edit_permission = MANAGE_CONTENT_PERMISSION def updateWidgets(self, prefix=None): @@ -140,19 +135,14 @@ super(AudioParagraphPropertiesEditForm, self).updateGroups() -@view_config(name='properties.json', context=IAudioParagraph, request_type=IPyAMSLayer, - permission=MANAGE_CONTENT_PERMISSION, renderer='json', xhr=True) -class AudioParagraphPropertiesAJAXEditForm(BaseParagraphAJAXEditForm, AudioParagraphPropertiesEditForm): - """Audio paragraph properties edit form, JSON renderer""" - - @adapter_config(context=(IAudioParagraph, IPyAMSLayer), provides=IParagraphInnerEditor) +@ajax_config(name='inner-properties.json', context=IAudioParagraph, layer=IPyAMSLayer, + base=BaseParagraphAJAXEditForm) @implementer(IInnerForm, IPropertiesEditForm, IAssociationsParentForm) class AudioParagraphPropertiesInnerEditForm(AudioParagraphPropertiesEditForm): """Audio paragraph properties inner edit form""" legend = None - ajax_handler = 'inner-properties.json' @property def buttons(self): @@ -161,14 +151,8 @@ else: return button.Buttons() - -@view_config(name='inner-properties.json', context=IAudioParagraph, request_type=IPyAMSLayer, - permission=MANAGE_CONTENT_PERMISSION, renderer='json', xhr=True) -class AudioParagraphPropertiesInnerAJAXEditForm(BaseParagraphAJAXEditForm, AudioParagraphPropertiesInnerEditForm): - """Audio paragraph properties inner deit form, JSON renderer""" - def get_ajax_output(self, changes): - output = super(AudioParagraphPropertiesInnerAJAXEditForm, self).get_ajax_output(changes) + output = super(self.__class__, self).get_ajax_output(changes) updated = changes.get(IAudioParagraph, ()) if 'data' in updated: # we have to commit transaction to be able to handle blobs...