mirror of
https://github.com/nasa/openmct.git
synced 2025-06-23 01:18:57 +00:00
[Search] Live search
As the user types, search happens with each new keypress, so the user does not need to press enter. (But can press enter as well.)
This commit is contained in:
@ -19,7 +19,7 @@
|
|||||||
this source code distribution or the Licensing information page available
|
this source code distribution or the Licensing information page available
|
||||||
at runtime from the About dialog for additional information.
|
at runtime from the About dialog for additional information.
|
||||||
-->
|
-->
|
||||||
<!-- Based on items view -->
|
|
||||||
<div class="items-holder grid abs"
|
<div class="items-holder grid abs"
|
||||||
ng-controller="SearchController as controller">
|
ng-controller="SearchController as controller">
|
||||||
|
|
||||||
@ -28,11 +28,9 @@
|
|||||||
<div style="height: 30px">Search:</div>
|
<div style="height: 30px">Search:</div>
|
||||||
<input type="text"
|
<input type="text"
|
||||||
id="searchinput"
|
id="searchinput"
|
||||||
value=""/>
|
value=""
|
||||||
<span class="button">
|
ng-keyup="controller.search('searchinput')"
|
||||||
<button type="button"
|
style="width: 66%"/>
|
||||||
ng-click="controller.search('searchinput')">Go</button>
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- some spacing -->
|
<!-- some spacing -->
|
||||||
|
@ -41,7 +41,7 @@ define(
|
|||||||
function QueryService($http, objectService, ROOT) {
|
function QueryService($http, objectService, ROOT) {
|
||||||
|
|
||||||
// Recursive helper function for getItems
|
// Recursive helper function for getItems
|
||||||
function listHelper(current) {
|
function itemsHelper(current) {
|
||||||
var composition;
|
var composition;
|
||||||
if (current.hasCapability('composition')) {
|
if (current.hasCapability('composition')) {
|
||||||
composition = current.getCapability('composition');
|
composition = current.getCapability('composition');
|
||||||
@ -55,7 +55,7 @@ define(
|
|||||||
var subList = [current],
|
var subList = [current],
|
||||||
i;
|
i;
|
||||||
for (i = 0; i < children.length; i += 1) {
|
for (i = 0; i < children.length; i += 1) {
|
||||||
subList.push(listHelper(children[i]));
|
subList.push(itemsHelper(children[i]));
|
||||||
}
|
}
|
||||||
return subList;
|
return subList;
|
||||||
});
|
});
|
||||||
@ -66,7 +66,7 @@ define(
|
|||||||
function getItems() {
|
function getItems() {
|
||||||
// Aquire My Items (root folder)
|
// Aquire My Items (root folder)
|
||||||
return objectService.getObjects(['mine']).then(function (objects) {
|
return objectService.getObjects(['mine']).then(function (objects) {
|
||||||
return listHelper(objects.mine).then(function (c) {
|
return itemsHelper(objects.mine).then(function (c) {
|
||||||
return c;
|
return c;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -121,6 +121,14 @@ define(
|
|||||||
|
|
||||||
// Currently specific to elasticsearch
|
// Currently specific to elasticsearch
|
||||||
function processSearchTerm(searchTerm) {
|
function processSearchTerm(searchTerm) {
|
||||||
|
// Shave any spaces off of the ends of the input
|
||||||
|
while (searchTerm.substr(0, 1) === ' ') {
|
||||||
|
searchTerm = searchTerm.substring(1, searchTerm.length);
|
||||||
|
}
|
||||||
|
while (searchTerm.substr(searchTerm.length - 1, 1) === ' ') {
|
||||||
|
searchTerm = searchTerm.substring(0, searchTerm.length - 1);
|
||||||
|
}
|
||||||
|
|
||||||
// Allow exact searches by checking to see if the first and last
|
// Allow exact searches by checking to see if the first and last
|
||||||
// chars are quotes.
|
// chars are quotes.
|
||||||
if ((searchTerm.substr(0, 1) === '"' && searchTerm.substr(searchTerm.length - 1, 1) === '"') ||
|
if ((searchTerm.substr(0, 1) === '"' && searchTerm.substr(searchTerm.length - 1, 1) === '"') ||
|
||||||
|
Reference in New Issue
Block a user