Updated ImageMap refresh row doc-dc
authorDamien Correia
Wed, 13 Jun 2018 16:17:57 +0200
branchdoc-dc
changeset 668 a63bc2aa60bb
parent 667 9832d24a17c6
child 670 fecfd4969c4f
child 696 575e1e8341c3
Updated ImageMap refresh row
src/pyams_content/shared/imagemap/zmi/area.py
src/pyams_content/shared/imagemap/zmi/container.py
--- a/src/pyams_content/shared/imagemap/zmi/area.py	Wed Jun 13 15:38:26 2018 +0200
+++ b/src/pyams_content/shared/imagemap/zmi/area.py	Wed Jun 13 16:17:57 2018 +0200
@@ -9,6 +9,8 @@
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
 #
+from pyams_skin.event import get_json_table_row_refresh_event
+from pyams_utils.traversing import get_parent
 
 __docformat__ = 'restructuredtext'
 
@@ -24,7 +26,7 @@
 
 # import packages
 from pyams_content.shared.imagemap import ImageMapArea
-from pyams_content.shared.imagemap.zmi.container import ImagemapAreasContainerView
+from pyams_content.shared.imagemap.zmi.container import ImagemapAreasContainerView, ImagemapAreasTable
 from pyams_content.shared.imagemap.zmi.widget import ImgareaInputFieldWidget
 from pyams_form.form import AJAXAddForm, ajax_config
 from pyams_pagelet.pagelet import pagelet_config
@@ -125,3 +127,11 @@
     fields['area'].widgetFactory = ImgareaInputFieldWidget
 
     edit_permission = MANAGE_CONTENT_PERMISSION
+
+    def get_ajax_output(self, changes):
+        output = super(self.__class__, self).get_ajax_output(changes)
+        if changes:
+            container = get_parent(self.context, IWfImageMap)
+            output.setdefault('events', []).append(
+                get_json_table_row_refresh_event(container, self.request, ImagemapAreasTable, self.context))
+        return output
--- a/src/pyams_content/shared/imagemap/zmi/container.py	Wed Jun 13 15:38:26 2018 +0200
+++ b/src/pyams_content/shared/imagemap/zmi/container.py	Wed Jun 13 16:17:57 2018 +0200
@@ -89,11 +89,12 @@
     @property
     def data_attributes(self):
         attributes = super(ImagemapAreasTable, self).data_attributes
-        attributes['table'] = {
+        attributes.setdefault('table', {}).update({
+            'id': self.id,
             'data-ams-location': absolute_url(self.context, self.request),
             'data-ams-datatable-sort': 'false',
             'data-ams-datatable-pagination': 'false'
-        }
+        })
         return attributes
 
     @reify