mirror of
https://github.com/nasa/openmct.git
synced 2025-01-01 10:56:41 +00:00
[Search] Input checks
More checks to see if the input is empty before doing search computations.
This commit is contained in:
parent
a48a0820ad
commit
11a45e4db0
@ -148,7 +148,7 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the user input is empty, we want to have no search results.
|
// If the user input is empty, we want to have no search results.
|
||||||
if (searchTerm !== '') {
|
if (searchTerm !== '' && searchTerm !== undefined) {
|
||||||
// Process the search term
|
// Process the search term
|
||||||
searchTerm = processSearchTerm(searchTerm);
|
searchTerm = processSearchTerm(searchTerm);
|
||||||
|
|
||||||
|
@ -40,7 +40,9 @@ define(function () {
|
|||||||
var inputText = $scope.ngModel.input;
|
var inputText = $scope.ngModel.input;
|
||||||
|
|
||||||
// We are starting to load.
|
// We are starting to load.
|
||||||
|
if (inputText !== '' && inputText !== undefined) {
|
||||||
loading = true;
|
loading = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Update whether the file tree should be displayed
|
// Update whether the file tree should be displayed
|
||||||
// Hide tree only when starting search
|
// Hide tree only when starting search
|
||||||
|
@ -184,13 +184,15 @@ define(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// For documentation, see query below
|
// For documentation, see query below
|
||||||
function query(input, timestamp, maxResults, timeout) {
|
function query(input, timestamp, maxResults, timeout) {
|
||||||
var terms = [],
|
var terms = [],
|
||||||
searchResults = [],
|
searchResults = [],
|
||||||
defer = $q.defer();
|
defer = $q.defer();
|
||||||
|
|
||||||
|
// If the input is nonempty, do a search
|
||||||
|
if (input !== '' && input !== undefined) {
|
||||||
|
|
||||||
// Allow us to access this promise later to resolve it later
|
// Allow us to access this promise later to resolve it later
|
||||||
pendingQueries[timestamp] = defer;
|
pendingQueries[timestamp] = defer;
|
||||||
|
|
||||||
@ -209,6 +211,10 @@ define(
|
|||||||
workerSearch(input, maxResults, timestamp, timeout);
|
workerSearch(input, maxResults, timestamp, timeout);
|
||||||
|
|
||||||
return defer.promise;
|
return defer.promise;
|
||||||
|
} else {
|
||||||
|
// Otherwise return an empty result
|
||||||
|
return {hits: [], total: 0};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Index the tree's contents once at the beginning
|
// Index the tree's contents once at the beginning
|
||||||
|
Loading…
Reference in New Issue
Block a user