Skip to content

Commit

Permalink
Restore column filters when unpinning (#4473)
Browse files Browse the repository at this point in the history
Fixes column filters when unpinning
  • Loading branch information
axelstudios authored Jan 10, 2024
1 parent 2f24661 commit e500512
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
24 changes: 22 additions & 2 deletions seed/static/seed/js/controllers/inventory_list_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ angular.module('BE.seed.controller.inventory_list', []).controller('inventory_li
'$state',
'$stateParams',
'$q',
'$timeout',
'inventory_service',
'label_service',
'data_quality_service',
Expand Down Expand Up @@ -45,6 +46,7 @@ angular.module('BE.seed.controller.inventory_list', []).controller('inventory_li
$state,
$stateParams,
$q,
$timeout,
inventory_service,
label_service,
data_quality_service,
Expand Down Expand Up @@ -1829,7 +1831,7 @@ angular.module('BE.seed.controller.inventory_list', []).controller('inventory_li
fastWatch: true,
flatEntityAccess: true,
gridMenuShowHideColumns: false,
showTreeExpandNoChildren: false,
hidePinRight: true,
saveFocus: false,
saveGrouping: false,
saveGroupingExpandedStates: false,
Expand All @@ -1840,6 +1842,7 @@ angular.module('BE.seed.controller.inventory_list', []).controller('inventory_li
saveTreeView: false,
saveVisible: false,
saveWidths: false,
showTreeExpandNoChildren: false,
useExternalFiltering: true,
useExternalSorting: true,
columnDefs: $scope.columns,
Expand Down Expand Up @@ -1903,7 +1906,24 @@ angular.module('BE.seed.controller.inventory_list', []).controller('inventory_li
}
}, 1000)
);
gridApi.pinning.on.columnPinned($scope, saveSettings);
gridApi.pinning.on.columnPinned($scope, (colDef, container) => {
if (container) {
saveSettings();
} else {
// Hack to fix disappearing filter after unpinning a column
const gridCol = gridApi.grid.columns.find(({ colDef: { name } }) => name === colDef.name);
if (gridCol) {
gridCol.colDef.visible = false;
gridApi.grid.refresh();

$timeout(() => {
gridCol.colDef.visible = true;
gridApi.grid.refresh();
saveSettings();
}, 0);
}
}
});

const selectionChanged = () => {
const selected = gridApi.selection.getSelectedRows();
Expand Down
8 changes: 4 additions & 4 deletions vendors/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"angular-translate-interpolation-messageformat": "^2.19.0",
"angular-translate-loader-static-files": "^2.19.0",
"angular-ui-bootstrap": "^2.5.6",
"angular-ui-grid": "^4.12.2",
"angular-ui-grid": "^4.12.4",
"angular-ui-notification": "^0.3.6",
"angular-ui-router": "^1.0.30",
"angular-ui-router.statehelper": "^1.3.1",
Expand Down

0 comments on commit e500512

Please sign in to comment.