mirror of
https://github.com/nasa/openmct.git
synced 2025-02-01 00:45:41 +00:00
[Search] Results without folders
Folders are now no longer included in the results list.
This commit is contained in:
parent
a337e04fae
commit
8eda495aa7
@ -82,30 +82,35 @@ define(function () {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search through items for items which contain the search term
|
// Search through items for items which contain the search term in the name
|
||||||
// in the title
|
|
||||||
function search(term) {
|
function search(term) {
|
||||||
console.log('search called, with term ', term);
|
console.log('search called, with term ', term);
|
||||||
var searchResults = [],
|
var searchResults = [],
|
||||||
itemsLength,
|
itemsLength,
|
||||||
|
itemModel,
|
||||||
itemName,
|
itemName,
|
||||||
i;
|
i;
|
||||||
|
|
||||||
// Make not case sensitive
|
// Make not case sensitive
|
||||||
if (term) {
|
if (term) {
|
||||||
term = term.toLocaleLowerCase();
|
term = term.toLocaleLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
// refresh items list
|
// Refresh items list
|
||||||
return listify().then( function () {
|
return listify().then( function () {
|
||||||
itemsLength = $scope.items.length; // Slight time optimization
|
// Slight time optimization
|
||||||
|
itemsLength = $scope.items.length;
|
||||||
|
|
||||||
for (i = 0; i < itemsLength; i += 1) {
|
for (i = 0; i < itemsLength; i += 1) {
|
||||||
itemName = $scope.items[i].getModel().name;
|
itemModel = $scope.items[i].getModel();
|
||||||
console.log('items[', i, '] name', itemName);
|
itemName = itemModel.name.toLocaleLowerCase();
|
||||||
if (itemName.toLocaleLowerCase().includes(term)) {
|
|
||||||
|
// Include any matching items, except folders
|
||||||
|
if (itemName.includes(term) && itemModel.type !== 'folder') {
|
||||||
searchResults.push($scope.items[i]);
|
searchResults.push($scope.items[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log('search results ', searchResults);
|
|
||||||
$scope.results = searchResults; // Somewhat redundant
|
$scope.results = searchResults; // Somewhat redundant
|
||||||
return searchResults;
|
return searchResults;
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user