Skip to content

Commit

Permalink
VCST-1856: Search by keyword use relevance sorting by default (#432)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
OlegoO authored Sep 24, 2024
1 parent d7439e5 commit d7631b5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</ul>

<div class="form-input" style="flex-grow: 1; flex-grow: 1; max-width: 400px">
<input ng-model="filter.keyword" ng-keyup="$event.which === 13 && filter.criteriaChanged()" placeholder="{{'platform.placeholders.search-keyword' | translate}}">
<input ng-model="filter.keyword" ng-keyup="$event.which === 13 && filter.filterByKeyword()" placeholder="{{'platform.placeholders.search-keyword' | translate}}">
<button class="btn __other" style="position: relative;right: 45px;" ng-click="filter.current=null;filter.change()">
<i class="btn-ico fa fa-remove" title="Clear"></i>
</button>
Expand Down

0 comments on commit d7631b5

Please sign in to comment.