Behavioral fixes to Magic-Search
Issues fixed: * Fixes issue where text entry is borked when clicking to make a new facet * No ‘x’ icon when text search only * Text search, then click “x”, text search NOT removed and search result not updated * Text search, then click facet, text hidden but still used * Text search, then select a facet, hit main “x”, only facet removed, text search NOT removed * text search, enter to make text facet, then “x”, then select a “Type” “Image” facet, then the text facet reappears, then “x” again and Image facet cleared but text facet remains Change-Id: I3f00836684fade0f1050d180a44924af48e3d868 Closes-Bug: 1628588
This commit is contained in:
@@ -269,6 +269,12 @@
|
|||||||
ctrl.filteredOptions = ctrl.facetOptions = facet.options;
|
ctrl.filteredOptions = ctrl.facetOptions = facet.options;
|
||||||
setMenuOpen(true);
|
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('');
|
setSearchInput('');
|
||||||
setPrompt('');
|
setPrompt('');
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
@@ -310,13 +316,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function clearSearch() {
|
function clearSearch() {
|
||||||
if (ctrl.currentSearch.length > 0) {
|
ctrl.currentSearch = [];
|
||||||
ctrl.currentSearch = [];
|
delete ctrl.textSearch;
|
||||||
ctrl.unusedFacetChoices = ctrl.facetChoices.map(service.getFacetChoice);
|
ctrl.unusedFacetChoices = ctrl.facetChoices.map(service.getFacetChoice);
|
||||||
resetState();
|
resetState();
|
||||||
$scope.$emit(magicSearchEvents.SEARCH_UPDATED, '');
|
$scope.$emit(magicSearchEvents.SEARCH_UPDATED, '');
|
||||||
emitTextSearch('');
|
emitTextSearch('');
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetState() {
|
function resetState() {
|
||||||
|
@@ -125,13 +125,6 @@
|
|||||||
|
|
||||||
describe("clearSearch", function() {
|
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() {
|
it("clears the currentSearch when currentSearch is not empty", function() {
|
||||||
spyOn(scope, '$emit');
|
spyOn(scope, '$emit');
|
||||||
ctrl.currentSearch = ['a', 'b', 'c'];
|
ctrl.currentSearch = ['a', 'b', 'c'];
|
||||||
|
@@ -45,7 +45,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
<a class="magic-search-clear" ng-click="ctrl.clearSearch()" ng-show="ctrl.currentSearch.length > 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>
|
<span class="fi-x fa fa-times cancel"></span>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user