mirror of
https://github.com/nasa/openmct.git
synced 2025-06-10 19:31:42 +00:00
[Search] Empty search resets results
When there is no input into the search bar no results are displayed/displayed results are removed. This is because the search providers were changed to return empty arrays for empty search strings.
This commit is contained in:
parent
b16af5fe3e
commit
b0e7dca985
@ -272,9 +272,9 @@ ul.tree {
|
|||||||
* at runtime from the About dialog for additional information.
|
* at runtime from the About dialog for additional information.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
/* line 27, ../sass/search/_search.scss */
|
/* line 27, ../sass/search/_search.scss */
|
||||||
.search .searchbar {
|
.search .search-input {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin-top: 20px; }
|
margin-top: 10px; }
|
||||||
/* line 32, ../sass/search/_search.scss */
|
/* line 32, ../sass/search/_search.scss */
|
||||||
.search .results {
|
.search .results {
|
||||||
margin-top: 10px; }
|
margin-top: 10px; }
|
||||||
|
@ -24,9 +24,9 @@
|
|||||||
$iconWidth: 20px;
|
$iconWidth: 20px;
|
||||||
$leftMargin: 6px;
|
$leftMargin: 6px;
|
||||||
|
|
||||||
.searchbar {
|
.search-input {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin-top: 20px;
|
margin-top: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.results {
|
.results {
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
ng-controller="SearchController as controller">
|
ng-controller="SearchController as controller">
|
||||||
<!-- Search bar input -->
|
<!-- Search bar input -->
|
||||||
<div>
|
<div>
|
||||||
<input class="searchbar"
|
<input class="search-input"
|
||||||
id="searchbarinput"
|
id="searchbarinput"
|
||||||
type="text"
|
type="text"
|
||||||
value=""
|
value=""
|
||||||
|
@ -159,24 +159,31 @@ define(
|
|||||||
// Get the user input
|
// Get the user input
|
||||||
searchTerm = document.getElementById(inputID).value;
|
searchTerm = document.getElementById(inputID).value;
|
||||||
|
|
||||||
// Process search term
|
// If the user input is empty, we want to have no search results.
|
||||||
searchTerm = processSearchTerm(searchTerm);
|
if (searchTerm !== '') {
|
||||||
|
// Process search term
|
||||||
// Create the query to elasticsearch
|
searchTerm = processSearchTerm(searchTerm);
|
||||||
esQuery = ROOT + "/_search/?q=" + searchTerm +
|
|
||||||
"&size=" + maxResults;
|
// Create the query to elasticsearch
|
||||||
if (timeout) {
|
esQuery = ROOT + "/_search/?q=" + searchTerm +
|
||||||
esQuery += "&timeout=" + timeout;
|
"&size=" + maxResults;
|
||||||
|
if (timeout) {
|
||||||
|
esQuery += "&timeout=" + timeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the data...
|
||||||
|
return $http({
|
||||||
|
method: "GET",
|
||||||
|
url: esQuery
|
||||||
|
}).then(function (rawResults) {
|
||||||
|
// ...then process the data
|
||||||
|
return processResults(rawResults, timestamp);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
latestResults = [];
|
||||||
|
lastSearchTimestamp = timestamp;
|
||||||
|
return latestResults;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the data...
|
|
||||||
return $http({
|
|
||||||
method: "GET",
|
|
||||||
url: esQuery
|
|
||||||
}).then(function (rawResults) {
|
|
||||||
// ...then process the data
|
|
||||||
return processResults(rawResults, timestamp);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -135,12 +135,16 @@
|
|||||||
terms = convertToTerms(input),
|
terms = convertToTerms(input),
|
||||||
timesToLoop = Math.min(indexedItems.length, data.maxNumber);
|
timesToLoop = Math.min(indexedItems.length, data.maxNumber);
|
||||||
|
|
||||||
for (var i = 0; i < timesToLoop; i++) {
|
|
||||||
var score = scoreItem(indexedItems[i], input, terms);
|
// If the user input is empty, we want to have no search results.
|
||||||
if (score > 0) {
|
if (input !== '') {
|
||||||
results[indexedItems[i].id] = {
|
for (var i = 0; i < timesToLoop; i++) {
|
||||||
score: score
|
var score = scoreItem(indexedItems[i], input, terms);
|
||||||
};
|
if (score > 0) {
|
||||||
|
results[indexedItems[i].id] = {
|
||||||
|
score: score
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user