Skip to content

Commit

Permalink
Fix inventory loading if no previous sort settings exist in localStor…
Browse files Browse the repository at this point in the history
…age (#4497)
  • Loading branch information
axelstudios authored Jan 22, 2024
1 parent 1003ef9 commit a3a7e46
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions seed/static/seed/js/controllers/inventory_list_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -1800,8 +1800,8 @@ angular.module('BE.seed.controller.inventory_list', []).controller('inventory_li
$scope.restore_status = RESTORE_SETTINGS;
let state = inventory_service.loadGridSettings(`${localStorageKey}.sort`);
// If save state has filters or sorts, ignore the grids first attempt to run filterChanged or sortChanged
const columns = JSON.parse(state).columns
$scope.ignore_filter_or_sort = !_.isEmpty(columns)
const { columns } = JSON.parse(state) ?? {};
$scope.ignore_filter_or_sort = !_.isEmpty(columns);
if (!_.isNull(state)) {
state = JSON.parse(state);
$scope.gridApi.saveState.restore($scope, state).then(() => {
Expand All @@ -1826,14 +1826,13 @@ angular.module('BE.seed.controller.inventory_list', []).controller('inventory_li
};

const filterOrSortChanged = _.debounce(() => {
if ($scope.ignore_filter_or_sort) {
$scope.ignore_filter_or_sort = false;
} else if ($scope.restore_status === RESTORE_COMPLETE) {
updateColumnFilterSort();
$scope.load_inventory(1);
}
}, 1000)

if ($scope.ignore_filter_or_sort) {
$scope.ignore_filter_or_sort = false;
} else if ($scope.restore_status === RESTORE_COMPLETE) {
updateColumnFilterSort();
$scope.load_inventory(1);
}
}, 1000);

$scope.gridOptions = {
data: 'data',
Expand Down Expand Up @@ -1903,7 +1902,7 @@ angular.module('BE.seed.controller.inventory_list', []).controller('inventory_li
saveSettings();
});
gridApi.core.on.columnVisibilityChanged($scope, saveSettings);
gridApi.core.on.filterChanged($scope, filterOrSortChanged)
gridApi.core.on.filterChanged($scope, filterOrSortChanged);
gridApi.core.on.sortChanged($scope, filterOrSortChanged);
gridApi.pinning.on.columnPinned($scope, (colDef, container) => {
if (container) {
Expand Down

0 comments on commit a3a7e46

Please sign in to comment.