Updated JSON response in images edit forms
authorThierry Florac <thierry.florac@onf.fr>
Wed, 11 Apr 2018 10:59:26 +0200 (2018-04-11)
changeset 93 da8b061840c8
parent 92 4568b89a1a58
child 94 015fe46dfa2a
Updated JSON response in images edit forms
src/pyams_file/zmi/image.py
--- a/src/pyams_file/zmi/image.py	Fri Mar 30 15:36:35 2018 +0200
+++ b/src/pyams_file/zmi/image.py	Wed Apr 11 10:59:26 2018 +0200
@@ -78,6 +78,8 @@
 class ImageCropForm(AdminDialogEditForm):
     """Image crop form"""
 
+    prefix = 'image_crop.'
+
     legend = _("Crop image")
     icon_css_class = 'fa fa-fw fa-crop'
     dialog_class = 'modal-large'
@@ -111,9 +113,10 @@
         self.context.crop(x1, y1, x2, y2)
 
     def get_ajax_output(self, changes):
-        return {'status': 'reload',
-                'smallbox': self.request.localizer.translate(self.successMessage),
-                'smallbox_status': 'success'}
+        return {
+            'status': 'reload',
+            'message': self.request.localizer.translate(self.successMessage)
+        }
 
 
 @viewlet_config(name='crop.widgets-prefix', context=IImage, layer=IAdminLayer, view=ImageCropForm,
@@ -176,6 +179,8 @@
 class ImageSquareThumbnailEditForm(AdminDialogEditForm):
     """Image square thumbnail edit form"""
 
+    prefix = 'image_square.'
+
     legend = _("Select square thumbnail")
     icon_css_class = 'fa fa-fw fa-instagram'
     dialog_class = 'modal-large'
@@ -209,9 +214,10 @@
         IThumbnail(self.context).set_geometry('square', geometry)
 
     def get_ajax_output(self, changes):
-        return {'status': 'success',
-                'smallbox': self.request.localizer.translate(self.successMessage),
-                'smallbox_status': 'success'}
+        return {
+            'status': 'success',
+            'message': self.request.localizer.translate(self.successMessage)
+        }
 
 
 @viewlet_config(name='square-thumbnail.widgets-prefix', context=IImage, layer=IAdminLayer,
@@ -259,6 +265,8 @@
 class ImagePanoThumbnailEditForm(AdminDialogEditForm):
     """Image panoramic thumbnail edit form"""
 
+    prefix = 'image_pano.'
+
     legend = _("Select panoramic thumbnail")
     icon_css_class = 'fa fa-fw fa-youtube-play'
     dialog_class = 'modal-large'
@@ -292,9 +300,10 @@
         IThumbnail(self.context).set_geometry('pano', geometry)
 
     def get_ajax_output(self, changes):
-        return {'status': 'success',
-                'smallbox': self.request.localizer.translate(self.successMessage),
-                'smallbox_status': 'success'}
+        return {
+            'status': 'success',
+            'message': self.request.localizer.translate(self.successMessage)
+        }
 
 
 @viewlet_config(name='pano-thumbnail.widgets-prefix', context=IImage, layer=IAdminLayer,
@@ -329,6 +338,8 @@
 class ResponsiveImageSelectionForm(AdminDialogEditForm):
     """Base responsive image selection edit form"""
 
+    prefix = 'image_responsive.'
+
     dialog_class = 'modal-large'
 
     fields = field.Fields(Interface)
@@ -357,9 +368,10 @@
         IThumbnail(self.context).set_geometry(self.selection_size, geometry)
 
     def get_ajax_output(self, changes):
-        return {'status': 'success',
-                'smallbox': self.request.localizer.translate(self.successMessage),
-                'smallbox_status': 'success'}
+        return {
+            'status': 'success',
+            'message': self.request.localizer.translate(self.successMessage)
+        }
 
 
 @viewlet_config(name='responsive-image.selection.widgets-prefix', context=IResponsiveImage, layer=IAdminLayer,
@@ -655,6 +667,8 @@
 class ImageResizeForm(AdminDialogEditForm):
     """Image resize form"""
 
+    prefix = 'image_resize.'
+
     legend = _("Resize image")
     icon_css_class = 'fa fa-fw fa-compress'
 
@@ -683,9 +697,10 @@
         self.context.resize(data.get('width'), data.get('height'), data.get('keep_ratio'))
 
     def get_ajax_output(self, changes):
-        return {'status': 'reload',
-                'smallbox': self.request.localizer.translate(self.successMessage),
-                'smallbox_status': 'success'}
+        return {
+            'status': 'reload',
+            'message': self.request.localizer.translate(self.successMessage)
+        }
 
 
 @adapter_config(context=(IImage, IAdminLayer, ImageResizeForm), provides=IFormHelp)