From d7631b5174596ea2b3ef3d1f293df35bafe9c83c Mon Sep 17 00:00:00 2001 From: Oleg Zhuk Date: Tue, 24 Sep 2024 13:47:58 +0200 Subject: [PATCH] VCST-1856: Search by keyword use relevance sorting by default (#432) feat: Implemented default relevance sorting for keyword searches. This enhancement ensures that search results are more relevant to the user's query. The next click in the grid enables custom sorting for the search results. --- .../Scripts/blades/customerOrder-list.js | 13 ++++++++++--- .../Scripts/blades/customerOrder-list.tpl.html | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/VirtoCommerce.OrdersModule.Web/Scripts/blades/customerOrder-list.js b/src/VirtoCommerce.OrdersModule.Web/Scripts/blades/customerOrder-list.js index 1c139e73..4244828e 100644 --- a/src/VirtoCommerce.OrdersModule.Web/Scripts/blades/customerOrder-list.js +++ b/src/VirtoCommerce.OrdersModule.Web/Scripts/blades/customerOrder-list.js @@ -34,10 +34,12 @@ angular.module('virtoCommerce.orderModule') }); blade.refresh = function () { + var sortCriteria = uiGridHelper.getSortExpression($scope); + var criteria = { responseGroup: "WithPrices", keyword: filter.keyword, - sort: uiGridHelper.getSortExpression($scope), + sort: filter.keyword && filter.ignoreSortingForRelevance == sortCriteria ? '' : sortCriteria, skip: ($scope.pageSettings.currentPage - 1) * $scope.pageSettings.itemsPerPageCount, take: $scope.pageSettings.itemsPerPageCount }; @@ -121,7 +123,7 @@ angular.module('virtoCommerce.orderModule') $scope.filterBy = function(field, value) { filter.keyword = `${field}:"${value}"`; - blade.refresh(); + filter.criteriaChanged(); }; $scope.deleteList = function (list) { @@ -218,7 +220,12 @@ angular.module('virtoCommerce.orderModule') }; angular.extend(newBlade, bladeData); bladeNavigationService.showBlade(newBlade, blade); - } + } + + filter.filterByKeyword = function () { + filter.ignoreSortingForRelevance = uiGridHelper.getSortExpression($scope); + filter.criteriaChanged(); + }; filter.criteriaChanged = function () { if ($scope.pageSettings.currentPage > 1) { diff --git a/src/VirtoCommerce.OrdersModule.Web/Scripts/blades/customerOrder-list.tpl.html b/src/VirtoCommerce.OrdersModule.Web/Scripts/blades/customerOrder-list.tpl.html index f5e07091..4561312a 100644 --- a/src/VirtoCommerce.OrdersModule.Web/Scripts/blades/customerOrder-list.tpl.html +++ b/src/VirtoCommerce.OrdersModule.Web/Scripts/blades/customerOrder-list.tpl.html @@ -10,7 +10,7 @@
- +