[Search] Items list updating

The search results now updates the items
list when called to make sure that it gets
all of the recently added items.
This commit is contained in:
shale 2015-07-10 12:53:12 -07:00
parent efba0f0236
commit b5756d2b99

View File

@ -85,24 +85,23 @@ define(function () {
// Search through items for items which contain the search term // Search through items for items which contain the search term
// in the title // in the title
function search(term) { function search(term) {
console.log('search called'); console.log('search called, with term ', term);
console.log('search term ', term);
var searchResults = [], var searchResults = [],
itemsLength, itemsLength,
i; i;
// refresh items list // refresh items list
listify(); return listify().then( function () {
itemsLength = $scope.items.length; // Slight time optimization itemsLength = $scope.items.length; // Slight time optimization
for (i = 0; i < itemsLength; i += 1) {
for (i = 0; i < itemsLength; i += 1) { console.log('items[', i, '].getModel', $scope.items[i].getModel());
console.log('items[', i, '].getModel', $scope.items[i].getModel()); if ($scope.items[i].getModel().name.includes(term)) {
if ($scope.items[i].getModel().name.includes(term)) { searchResults.push($scope.items[i]);
searchResults.push($scope.items[i]); }
} }
} console.log('search results ', searchResults);
console.log('search results ', searchResults); $scope.results = searchResults; // Somewhat redundant
$scope.results = searchResults; // Somewhat redundant return searchResults;
return searchResults; });
} }
// When the search view is opened, call listify() // When the search view is opened, call listify()