[Search] Menu checkboxes and labels

Added checkboxes with styling to the menu. Set
up a types list for the menu.
This commit is contained in:
slhale
2015-08-13 10:59:12 -07:00
parent a9c85d5241
commit c51856522c
5 changed files with 100 additions and 35 deletions

View File

@ -30,12 +30,14 @@ define(function () {
var INITIAL_LOAD_NUMBER = 20,
LOAD_INCREMENT = 20;
function SearchController($scope, searchService) {
function SearchController($scope, searchService, types) {
// Starting amount of results to load. Will get increased.
var numResults = INITIAL_LOAD_NUMBER,
loading = false,
fullResults = {hits: []};
console.log('types', types);
function search(maxResults) {
var inputText = $scope.ngModel.input;
@ -71,6 +73,31 @@ define(function () {
});
}
function filter(types) {
var newResults = [],
i = 0;
while (newResults.length < numResults && newResults.length < fullResults.hits.length) {
// If this is of an acceptable type, add it to the list
if (types.indexOf(fullResults.hits[i].getModel().type) !== -1) {
newResults.push(fullResults.hits[i]);
}
i += 1;
}
$scope.results = newResults;
}
$scope.types = [];
// On initialization, fill the scope's types with type keys
types.forEach(function (type) {
// We only want some types: the ones that have keys and
// descriptions are probably human user usable types
if (type.key && type.description) {
$scope.types.push(type);
}
});
return {
/**
* Search the filetree.