Update link refresh after reference update
authorThierry Florac <tflorac@ulthar.net>
Thu, 08 Feb 2018 15:51:58 +0100
changeset 383 8409f13da5d0
parent 382 f6b688877716
child 384 d433c8c46ec9
Update link refresh after reference update
src/pyams_content/shared/site/zmi/link.py
--- a/src/pyams_content/shared/site/zmi/link.py	Thu Feb 08 15:15:30 2018 +0100
+++ b/src/pyams_content/shared/site/zmi/link.py	Thu Feb 08 15:51:58 2018 +0100
@@ -10,7 +10,6 @@
 # FOR A PARTICULAR PURPOSE.
 #
 
-
 __docformat__ = 'restructuredtext'
 
 
@@ -22,6 +21,7 @@
 from pyams_content.shared.site.interfaces import ISiteContainer, IContentLink
 from pyams_content.skin.zmi.interfaces import ISiteTreeTable
 from pyams_i18n.interfaces import II18n
+from pyams_sequence.interfaces import IInternalReference
 from pyams_skin.interfaces.container import ITableElementName
 from pyams_skin.interfaces.viewlet import IToolbarAddingMenu
 from pyams_skin.layer import IPyAMSLayer
@@ -152,7 +152,19 @@
     def get_ajax_output(self, changes):
         output = super(ContentLinkPropertiesAJAXEditForm, self).get_ajax_output(changes)
         intids = get_utility(IIntIds)
-        if 'alt_title' in changes.get(IContentLink, ()):
+        if 'reference' in changes.get(IInternalReference, ()):
+            table = SiteContainerTreeTable(self.context.__parent__, self.request)
+            table.update()
+            row = table.setUpRow(self.context)
+            output.setdefault('events', []).append({
+                'event': 'myams.refresh',
+                'options': {
+                    'handler': 'MyAMS.skin.refreshRow',
+                    'object_id': '{0}::{1}'.format(SiteContainerTreeTable.id, intids.queryId(self.context)),
+                    'row': table.renderRow(row)
+                }
+            })
+        elif 'alt_title' in changes.get(IContentLink, ()):
             adapter = ContentLinkTableElementName(self.context, self.request, None)
             column = SiteContainerTreeNameColumn(self.context, self.request, None)
             output.setdefault('events', []).append({
@@ -164,15 +176,4 @@
                     'cell': column.renderCell(self.context, name=adapter.name)
                 }
             })
-        if 'reference' in changes.get(IContentLink, ()):
-            column = SiteContainerTreeSequenceColumn(self.context, self.request, None)
-            output.setdefault('events', []).append({
-                'event': 'myams.refresh',
-                'options': {
-                    'handler': 'MyAMS.skin.refreshRowCell',
-                    'object_id': '{0}::{1}'.format(SiteContainerTreeTable.id, intids.queryId(self.context)),
-                    'col_name': 'sequence',
-                    'cell': column.renderCell(self.context)
-                }
-            })
         return output