mirror of
https://github.com/nasa/openmct.git
synced 2025-03-11 06:54:01 +00:00
[Search] Search results by name
doSearch() does search by getting each object's name. Still buggy.
This commit is contained in:
parent
4e39c4f900
commit
efba0f0236
@ -19,24 +19,35 @@
|
||||
this source code distribution or the Licensing information page available
|
||||
at runtime from the About dialog for additional information.
|
||||
-->
|
||||
<!-- Based on items -->
|
||||
<!-- Based on items view -->
|
||||
<div class="items-holder grid abs"
|
||||
ng-controller="SearchController as controller">
|
||||
|
||||
<!-- Search bar -->
|
||||
<div id="formid">
|
||||
<form>
|
||||
<!--
|
||||
<div>
|
||||
<label for="searchinput">Search this folder:</label>
|
||||
<input type="text" id="searchinput" />
|
||||
</div>
|
||||
-->
|
||||
Search: <br>
|
||||
<input type="text"
|
||||
id="searchinput"
|
||||
name="searchform" />
|
||||
<!--
|
||||
Search in this folder: <br>
|
||||
<input type="text" name="searchform"> -->
|
||||
<div class="button">
|
||||
<button type="submit">Search</button>
|
||||
</div>
|
||||
<!-- input type="submit" value="Search" -->
|
||||
-->
|
||||
<!--
|
||||
<input type="submit" value="go" />
|
||||
-->
|
||||
<span class="button">
|
||||
<button type="button"
|
||||
ng-click="controller.search()">Go</button>
|
||||
</span>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
@ -41,28 +41,31 @@ define(function () {
|
||||
|
||||
// Recursive case. Is asynchronous.
|
||||
return composition.invoke().then(function (children) {
|
||||
console.log('children (pre) ', children);
|
||||
//(children.forEach(listHelper)).then(function (subList) {
|
||||
// console.log('children (post) ', children);
|
||||
// return [current].concat(children);
|
||||
//});
|
||||
children.forEach(listHelper);
|
||||
console.log('children (post) ', children);
|
||||
return [current].concat(children);
|
||||
/*
|
||||
var subList = [current];
|
||||
var subList = [current],
|
||||
i;
|
||||
console.log('children ', children);
|
||||
for (var i = 0; i < children.length; i += 1) {
|
||||
for (i = 0; i < children.length; i += 1) {
|
||||
console.log('children[', i, ']', children[i]);
|
||||
//subList.push(listHelper(children[i]));
|
||||
listHelper(children[i]).then(function (c) {
|
||||
subList.concat(c);
|
||||
});
|
||||
subList.push(listHelper(children[i]));
|
||||
console.log('subList', subList, 'index', i);
|
||||
}
|
||||
console.log('sublist ', subList);
|
||||
return subList;
|
||||
*/
|
||||
});
|
||||
}
|
||||
|
||||
// Recursive helper function to go through the tree
|
||||
function listHelper2(current) {
|
||||
return current.getCapability('composition').invoke().then(function (children) {
|
||||
return [current].concat(children.forEach(function (child) {
|
||||
if (child.hasCapability('composition')) {
|
||||
return listHelper2(child);//.then(function (c) {
|
||||
// return c;
|
||||
//});
|
||||
} else {
|
||||
return child;
|
||||
}
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
@ -71,9 +74,9 @@ define(function () {
|
||||
function listify() {
|
||||
// Aquire My Items (root folder)
|
||||
return objectService.getObjects(['mine']).then(function (objects) {
|
||||
console.log(' ');
|
||||
return listHelper(objects.mine).then(function (c) {
|
||||
console.log('final result ', c);
|
||||
$scope.items = c; // Somewhat redundant
|
||||
return c;
|
||||
});
|
||||
});
|
||||
@ -82,14 +85,23 @@ define(function () {
|
||||
// Search through items for items which contain the search term
|
||||
// in the title
|
||||
function search(term) {
|
||||
console.log('search called');
|
||||
console.log('search term ', term);
|
||||
var searchResults = [],
|
||||
itemsLength = $scope.items.length, // Slight time optimization
|
||||
itemsLength,
|
||||
i;
|
||||
// refresh items list
|
||||
listify();
|
||||
itemsLength = $scope.items.length; // Slight time optimization
|
||||
|
||||
for (i = 0; i < itemsLength; i += 1) {
|
||||
if ($scope.items[i].includes(term)) {
|
||||
console.log('items[', i, '].getModel', $scope.items[i].getModel());
|
||||
if ($scope.items[i].getModel().name.includes(term)) {
|
||||
searchResults.push($scope.items[i]);
|
||||
}
|
||||
}
|
||||
console.log('search results ', searchResults);
|
||||
$scope.results = searchResults; // Somewhat redundant
|
||||
return searchResults;
|
||||
}
|
||||
|
||||
@ -98,6 +110,10 @@ define(function () {
|
||||
|
||||
$scope.items = listify();
|
||||
$scope.results = search();
|
||||
|
||||
return {
|
||||
search: search
|
||||
};
|
||||
}
|
||||
return SearchController;
|
||||
});
|
||||
@ -147,6 +163,18 @@ define(function () {
|
||||
console.log('array ', array);
|
||||
return array;
|
||||
*/
|
||||
/*
|
||||
var subList = [];//= Promise.all([]);
|
||||
subList.push(current);
|
||||
for (var i = 0, len = children.length; i < len; i++) {
|
||||
listHelper(children[i]).then(function (c) {
|
||||
subList.concat(c);
|
||||
});
|
||||
}
|
||||
return subList;//.then(function (c) {
|
||||
// return c;
|
||||
//});
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user