Commit 21bcd34a authored by abirembaut's avatar abirembaut Committed by julienmege

fix (cases lists) Case list refresh generate same request twice (#502)

- prevent call to searchForCases when searchSort is cleaned as there is already a watch triggering the search in this case

Covers [BS-19310](https://bonitasoft.atlassian.net/browse/BS-19310)
parent 4c116d12
......@@ -135,9 +135,13 @@
};
vm.reinitCases = function () {
delete $scope.searchOptions.searchSort;
$scope.pagination.currentPage = 1;
vm.searchForCases();
if ($scope.searchOptions.searchSort) {
delete $scope.searchOptions.searchSort;
//that's it because searchForCases() is called by the watch on searchOptions
} else {
vm.searchForCases();
}
};
$scope.$on('caselist:http-error', handleHttpErrorEvent);
......
......@@ -134,9 +134,13 @@
};
vm.reinitCases = function () {
delete $scope.searchOptions.searchSort;
$scope.pagination.currentPage = 1;
vm.searchForCases();
if ($scope.searchOptions.searchSort) {
delete $scope.searchOptions.searchSort;
//that's it because searchForCases() is called by the watch on searchOptions
} else {
vm.searchForCases();
}
};
$scope.$on('caselist:http-error', handleHttpErrorEvent);
......
......@@ -992,6 +992,19 @@
});
scope.searchOptions.searchSort = {};
scope.pagination.currentPage = 10;
casesCtrl.reinitCases();
expect(scope.searchOptions.searchSort).toBeUndefined();
expect(scope.pagination.currentPage).toBe(1);
}));
it('should perform search', inject(function($controller) {
casesCtrl = $controller('ActiveCaseListCtrl', {
'$scope': scope,
'processId': undefined,
'supervisorId': undefined,
'caseStateFilter': ''
});
delete scope.searchOptions.searchSort;
scope.pagination.currentPage = 10;
spyOn(casesCtrl, 'searchForCases');
casesCtrl.reinitCases();
expect(scope.searchOptions.searchSort).toBeUndefined();
......
......@@ -874,6 +874,19 @@
});
scope.searchOptions.searchSort = {};
scope.pagination.currentPage = 10;
casesCtrl.reinitCases();
expect(scope.searchOptions.searchSort).toBeUndefined();
expect(scope.pagination.currentPage).toBe(1);
}));
it('should perform search', inject(function($controller) {
casesCtrl = $controller('ActiveCaseListUserCtrl', {
'$scope': scope,
'processId': undefined,
'supervisorId': undefined,
'caseStateFilter': ''
});
delete scope.searchOptions.searchSort;
scope.pagination.currentPage = 10;
spyOn(casesCtrl, 'searchForCases');
casesCtrl.reinitCases();
expect(scope.searchOptions.searchSort).toBeUndefined();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment