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

View File

@ -76,14 +76,16 @@ define(
expect(mockScope.ngModel.filtersString).not.toEqual(''); 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(); controller.checkAll();
expect(mockScope.ngModel.checkAll).toEqual(true);
expect(mockScope.ngModel.filtersString).toEqual(''); expect(mockScope.ngModel.filtersString).toEqual('');
mockScope.ngModel.checkAll = false; mockScope.ngModel.checkAll = false;
controller.checkAll(); 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 () { 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) { Object.keys(mockScope.ngModel.checked).forEach(function (type) {
mockScope.ngModel.checked[type] = false; mockScope.ngModel.checked[type] = false;
}); });
@ -105,7 +107,8 @@ define(
controller.updateOptions(); 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 () { it("tells the user when options are checked", function () {
@ -116,7 +119,6 @@ define(
controller.updateOptions(); controller.updateOptions();
expect(mockScope.ngModel.filtersString).not.toEqual('NONE');
expect(mockScope.ngModel.filtersString).not.toEqual(''); expect(mockScope.ngModel.filtersString).not.toEqual('');
}); });
}); });