# HG changeset patch # User Thierry Florac # Date 1595241049 -7200 # Node ID 916c81459d6beb28dfb786bceb30b0a11f6544e4 # Parent 85e615286c7af2a883b0890c45a8fa6f87dab1a6 Disable sorting in advanced search if search adapter is using it's own sort algorithm diff -r 85e615286c7a -r 916c81459d6b src/pyams_content/root/zmi/search.py --- a/src/pyams_content/root/zmi/search.py Sun Jul 19 02:10:25 2020 +0200 +++ b/src/pyams_content/root/zmi/search.py Mon Jul 20 12:30:49 2020 +0200 @@ -195,13 +195,17 @@ legend = _("Advanced search") + fields_interface = ISiteRootAdvancedSearchFields + sort_results = True + + prefix = 'search_form.' + ajax_handler = 'advanced-search-results.html' + def __init__(self, context, request): super(SiteRootAdvancedSearchForm, self).__init__(context, request) request.registry.notify(PageletCreatedEvent(self)) apply_skin(self.request, 'PyAMS admin skin') - fields_interface = ISiteRootAdvancedSearchFields - @property def fields(self): fields = field.Fields(self.fields_interface) @@ -209,8 +213,6 @@ fields['collections'].widgetFactory = ThesaurusTermsTreeFieldWidget return fields - ajax_handler = 'advanced-search-results.html' - def updateWidgets(self, prefix=None): super(SiteRootAdvancedSearchForm, self).updateWidgets(prefix) if 'tags' in self.widgets: @@ -328,11 +330,14 @@ def data_attributes(self): attributes = super(SiteRootAdvancedSearchResultsView, self).data_attributes attributes['table'] = { - '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 } + if self.search_form.sort_results: + attributes['table']['data-ams-datatable-sorting'] = \ + "{0},{1}".format(len(self.columns) - 1, self.dt_sort_order) + else: + attributes['table']['data-ams-datatable-sorting'] = '[]' return attributes diff -r 85e615286c7a -r 916c81459d6b src/pyams_content/shared/common/zmi/search.py --- a/src/pyams_content/shared/common/zmi/search.py Sun Jul 19 02:10:25 2020 +0200 +++ b/src/pyams_content/shared/common/zmi/search.py Mon Jul 20 12:30:49 2020 +0200 @@ -215,6 +215,10 @@ legend = _("Advanced search") + fields_interface = ISharedToolAdvancedSearchFields + sort_results = True + + prefix = 'search_form.' ajax_handler = 'advanced-search-results.html' def __init__(self, context, request): @@ -222,8 +226,6 @@ request.registry.notify(PageletCreatedEvent(self)) apply_skin(self.request, 'PyAMS admin skin') - fields_interface = ISharedToolAdvancedSearchFields - @property def fields(self): workflow = IWorkflow(self.context) @@ -371,11 +373,14 @@ def data_attributes(self): attributes = super(SharedToolAdvancedSearchResultsView, self).data_attributes attributes['table'] = { - '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 } + if self.search_form.sort_results: + attributes['table']['data-ams-datatable-sorting'] = \ + "{0},{1}".format(len(self.columns) - 1, self.dt_sort_order) + else: + attributes['table']['data-ams-datatable-sorting'] = '[]' return attributes