Merge "Behavioral fixes to Magic-Search"

This commit is contained in:
Jenkins 2016-09-29 02:12:45 +00:00 committed by Gerrit Code Review
commit 440e3d43ae
3 changed files with 13 additions and 15 deletions

View File

@ -269,6 +269,12 @@
ctrl.filteredOptions = ctrl.facetOptions = facet.options;
setMenuOpen(true);
}
var searchVal = searchInput.val();
if (searchVal) {
ctrl.currentSearch = ctrl.currentSearch.filter(notTextSearch);
ctrl.currentSearch.push(service.getTextFacet(searchVal, $scope.strings.text));
ctrl.textSearch = searchVal;
}
setSearchInput('');
setPrompt('');
$timeout(function() {
@ -310,13 +316,12 @@
}
function clearSearch() {
if (ctrl.currentSearch.length > 0) {
ctrl.currentSearch = [];
ctrl.unusedFacetChoices = ctrl.facetChoices.map(service.getFacetChoice);
resetState();
$scope.$emit(magicSearchEvents.SEARCH_UPDATED, '');
emitTextSearch('');
}
ctrl.currentSearch = [];
delete ctrl.textSearch;
ctrl.unusedFacetChoices = ctrl.facetChoices.map(service.getFacetChoice);
resetState();
$scope.$emit(magicSearchEvents.SEARCH_UPDATED, '');
emitTextSearch('');
}
function resetState() {

View File

@ -125,13 +125,6 @@
describe("clearSearch", function() {
it("does nothing when currentSearch is empty", function() {
spyOn(scope, '$emit');
ctrl.currentSearch = [];
ctrl.clearSearch();
expect(scope.$emit).not.toHaveBeenCalled();
});
it("clears the currentSearch when currentSearch is not empty", function() {
spyOn(scope, '$emit');
ctrl.currentSearch = ['a', 'b', 'c'];

View File

@ -45,7 +45,7 @@
</ul>
</span>
</span>
<a class="magic-search-clear" ng-click="ctrl.clearSearch()" ng-show="ctrl.currentSearch.length &gt; 0" title="{$ ::strings.cancel $}">
<a class="magic-search-clear" ng-click="ctrl.clearSearch()" title="{$ ::strings.cancel $}">
<span class="fi-x fa fa-times cancel"></span>
</a>
</div>