Merge pull request #1061 from wazuh/issue-1060

Fix duplicated rows when resizing tables
This commit is contained in:
Jesús Ángel 2018-12-05 13:22:21 +01:00 committed by GitHub
commit f72cb793c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -68,12 +68,16 @@ app.directive('wzTable', function() {
*/
const rowSizes = $scope.rowSizes || [15, 13, 11];
let doit;
// Prevents duplicated rows when resizing
let resizing = false;
$window.onresize = () => {
if(resizing) return;
resizing = true;
clearTimeout(doit);
doit = setTimeout(() => {
$scope.rowsPerPage = calcTableRows($window.innerHeight, rowSizes);
$scope.itemsPerPage = $scope.rowsPerPage;
init();
init().then(() => resizing = false).catch(() => resizing = false);
}, 150);
};
$scope.rowsPerPage = calcTableRows($window.innerHeight, rowSizes);