Merge pull request #1135 from vankessel/open1117

[Search] 'All' checked upon no filters. Fixes #1117
This commit is contained in:
Andrew Henry 2016-08-29 14:17:07 +01:00 committed by GitHub
commit 597d66782e
2 changed files with 13 additions and 12 deletions

View File

@ -80,7 +80,7 @@ define(function () {
// If there's still nothing in the filters string, there are no
// filters selected
if ($scope.ngModel.filtersString === '') {
$scope.ngModel.filtersString = 'NONE';
$scope.ngModel.checkAll = true;
}
}
@ -95,12 +95,11 @@ define(function () {
$scope.ngModel.checked[type] = false;
});
// Change the filters string depending on checkAll status
if ($scope.ngModel.checkAll) {
// This setting will make the filters display hidden
$scope.ngModel.filtersString = '';
} else {
$scope.ngModel.filtersString = 'NONE';
// This setting will make the filters display hidden
$scope.ngModel.filtersString = '';
// Do not let checkAll become unchecked when it is the only checked filter
if (!$scope.ngModel.checkAll) {
$scope.ngModel.checkAll = true;
}
// Re-filter results

View File

@ -76,14 +76,16 @@ define(
expect(mockScope.ngModel.filtersString).not.toEqual('');
});
it("changing checkAll status updates the filter string", function () {
it("changing checkAll status sets checkAll to true", function () {
controller.checkAll();
expect(mockScope.ngModel.checkAll).toEqual(true);
expect(mockScope.ngModel.filtersString).toEqual('');
mockScope.ngModel.checkAll = false;
controller.checkAll();
expect(mockScope.ngModel.filtersString).toEqual('NONE');
expect(mockScope.ngModel.checkAll).toEqual(true);
expect(mockScope.ngModel.filtersString).toEqual('');
});
it("checking checkAll option resets other options", function () {
@ -97,7 +99,7 @@ define(
});
});
it("tells the user when no options are checked", function () {
it("checks checkAll when no options are checked", function () {
Object.keys(mockScope.ngModel.checked).forEach(function (type) {
mockScope.ngModel.checked[type] = false;
});
@ -105,7 +107,8 @@ define(
controller.updateOptions();
expect(mockScope.ngModel.filtersString).toEqual('NONE');
expect(mockScope.ngModel.filtersString).toEqual('');
expect(mockScope.ngModel.checkAll).toEqual(true);
});
it("tells the user when options are checked", function () {
@ -116,7 +119,6 @@ define(
controller.updateOptions();
expect(mockScope.ngModel.filtersString).not.toEqual('NONE');
expect(mockScope.ngModel.filtersString).not.toEqual('');
});
});