mirror of
https://github.com/nasa/openmct.git
synced 2025-06-16 14:18:16 +00:00
[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:
@ -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.
|
||||
|
Reference in New Issue
Block a user