[Search] Results without folders

Folders are now no longer included in
the results list.
This commit is contained in:
shale 2015-07-10 15:06:19 -07:00
parent a337e04fae
commit 8eda495aa7

View File

@ -82,30 +82,35 @@ define(function () {
});
}
// Search through items for items which contain the search term
// in the title
// Search through items for items which contain the search term in the name
function search(term) {
console.log('search called, with term ', term);
var searchResults = [],
itemsLength,
itemModel,
itemName,
i;
// Make not case sensitive
if (term) {
term = term.toLocaleLowerCase();
}
// refresh items list
// Refresh items list
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) {
itemName = $scope.items[i].getModel().name;
console.log('items[', i, '] name', itemName);
if (itemName.toLocaleLowerCase().includes(term)) {
itemModel = $scope.items[i].getModel();
itemName = itemModel.name.toLocaleLowerCase();
// Include any matching items, except folders
if (itemName.includes(term) && itemModel.type !== 'folder') {
searchResults.push($scope.items[i]);
}
}
console.log('search results ', searchResults);
$scope.results = searchResults; // Somewhat redundant
return searchResults;
});