Updated search results sort order
authorThierry Florac <thierry.florac@onf.fr>
Thu, 20 Dec 2018 14:22:24 +0100
changeset 1189 26b86361e20b
parent 1188 a3765dd8cbb8
child 1190 d4510a0252b0
Updated search results sort order
src/pyams_content/root/zmi/search.py
src/pyams_content/shared/common/zmi/search.py
--- a/src/pyams_content/root/zmi/search.py	Wed Dec 19 11:02:20 2018 +0100
+++ b/src/pyams_content/root/zmi/search.py	Thu Dec 20 14:22:24 2018 +0100
@@ -279,6 +279,7 @@
     search_form_factory = SiteRootAdvancedSearchForm
 
     sortOn = None
+    dt_sort_order = 'desc'
 
     def __init__(self, context, request):
         super(SiteRootAdvancedSearchResultsView, self).__init__(context, request)
@@ -288,7 +289,7 @@
     def data_attributes(self):
         attributes = super(SiteRootAdvancedSearchResultsView, self).data_attributes
         attributes['table'] = {
-            'data-ams-datatable-sorting': '[]',
+            'data-ams-datatable-sorting': "{0},{1}".format(len(self.columns) - 1, self.dt_sort_order),
             'data-ams-datatable-display-length': IAdminProfile(self.request.principal).table_page_length
         }
         return attributes
--- a/src/pyams_content/shared/common/zmi/search.py	Wed Dec 19 11:02:20 2018 +0100
+++ b/src/pyams_content/shared/common/zmi/search.py	Thu Dec 20 14:22:24 2018 +0100
@@ -9,6 +9,8 @@
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
 #
+from pyams_skin.interfaces.viewlet import IToolbarViewletManager
+from pyams_skin.viewlet.toolbar import ToolbarAction
 
 __docformat__ = 'restructuredtext'
 
@@ -332,6 +334,7 @@
     search_form_factory = SharedToolAdvancedSearchForm
 
     sortOn = None
+    dt_sort_order = 'desc'
 
     def __init__(self, context, request):
         super(SharedToolAdvancedSearchResultsView, self).__init__(context, request)
@@ -341,7 +344,7 @@
     def data_attributes(self):
         attributes = super(SharedToolAdvancedSearchResultsView, self).data_attributes
         attributes['table'] = {
-            'data-ams-datatable-sorting': '[]',
+            'data-ams-datatable-sorting': "{0},{1}".format(len(self.columns) - 1, self.dt_sort_order),
             'data-ams-datatable-display-length': IAdminProfile(self.request.principal).table_page_length
         }
         return attributes