Added "ajax_config" decorator to properties edit form
authorThierry Florac <thierry.florac@onf.fr>
Mon, 27 Aug 2018 09:59:35 +0200
changeset 85 71863b99d12c
parent 84 9fc99ca5c9bc
child 86 264be21e5ae7
Added "ajax_config" decorator to properties edit form
src/pyams_zmi/zmi/site.py
--- a/src/pyams_zmi/zmi/site.py	Fri Jul 20 12:49:02 2018 +0200
+++ b/src/pyams_zmi/zmi/site.py	Mon Aug 27 09:59:35 2018 +0200
@@ -27,7 +27,7 @@
 from pyams_zmi.layer import IAdminLayer
 
 # import packages
-from pyams_form.form import AJAXEditForm
+from pyams_form.form import AJAXEditForm, ajax_config
 from pyams_pagelet.pagelet import pagelet_config
 from pyams_skin.page import DefaultPageHeaderAdapter
 from pyams_skin.viewlet.menu import MenuItem
@@ -69,6 +69,7 @@
 
 
 @pagelet_config(name='properties.html', context=ISiteRoot, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION)
+@ajax_config(name='properties.json', context=ISiteRoot, layer=IPyAMSLayer)
 @implementer(IWidgetForm, IInnerPage, IPropertiesEditForm)
 class PropertiesEditForm(AdminEditForm):
     """Properties edit form"""
@@ -91,12 +92,6 @@
     def getContent(self):
         return IConfiguration(self.context)
 
-
-@view_config(name='properties.json', context=ISiteRoot, request_type=IPyAMSLayer,
-             permission=MANAGE_SYSTEM_PERMISSION, renderer='json', xhr=True)
-class PropertiesAJAXEditForm(AJAXEditForm, PropertiesEditForm):
-    """Properties edit form, AJAX renderer"""
-
     def get_ajax_output(self, changes):
         if changes:
             return {
@@ -106,7 +101,7 @@
                 'smallbox_status': 'success'
             }
         else:
-            return AJAXEditForm.get_ajax_output(self, changes)
+            return super(self.__class__, self).get_ajax_output(changes)
 
 
 @adapter_config(context=(Interface, IPyAMSLayer, PropertiesEditForm), provides=IPageHeader)