Skip to content

Commit

Permalink
Search ext: When removing a column from SELECT, also remove from ORDE…
Browse files Browse the repository at this point in the history
…R BY
  • Loading branch information
colemanw committed Sep 18, 2020
1 parent 4fea3bf commit 7da9d07
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions ext/search/ang/search/crmSearch.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@
ctrl.params.orderBy = {};
}
ctrl.params.orderBy[col] = dir;
if (ctrl.results) {
ctrl.refreshPage();
}
};

/**
Expand Down Expand Up @@ -233,6 +236,10 @@
};

function onChangeSelect(newSelect, oldSelect) {
// When removing a column from SELECT, also remove from ORDER BY
_.each(_.difference(_.keys(ctrl.params.orderBy), newSelect), function(col) {
delete ctrl.params.orderBy[col];
});
// Re-arranging or removing columns doesn't merit a refresh, only adding columns does
if (!oldSelect || _.difference(newSelect, oldSelect).length) {
if (ctrl.autoSearch) {
Expand All @@ -243,12 +250,6 @@
}
}

function onChangeOrderBy() {
if (ctrl.results) {
ctrl.refreshPage();
}
}

function onChangeFilters() {
ctrl.stale = true;
ctrl.selectedRows.length = 0;
Expand Down Expand Up @@ -480,7 +481,6 @@
format: 'json',
default: {}
});
$scope.$watchCollection('$ctrl.params.orderBy', onChangeOrderBy);

$scope.$bindToRoute({
expr: '$ctrl.params.where',
Expand Down

0 comments on commit 7da9d07

Please sign in to comment.