mirror of
https://github.com/nasa/openmct.git
synced 2025-01-02 19:36:41 +00:00
[Search] Listify filetree
SearchController now attempts to convert the filetree into a list format. Still needs to be modified to be asynchronous.
This commit is contained in:
parent
32eaf3893a
commit
94b306e129
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Search View",
|
||||
"description": "Allows the user to search through the file three.",
|
||||
"description": "Allows the user to search through the file tree.",
|
||||
"extensions": {
|
||||
"views": [
|
||||
{
|
||||
@ -15,14 +15,14 @@
|
||||
{
|
||||
"key": "SearchController",
|
||||
"implementation": "SearchController.js",
|
||||
"depends": [ "$scope" ]
|
||||
"depends": [ "$scope", "objectService" ]
|
||||
}
|
||||
],
|
||||
"representations": [
|
||||
{
|
||||
"key": "search-item",
|
||||
"templateUrl": "templates/search-item.html",
|
||||
"uses": [ "type", "action" ],
|
||||
"uses": [ "type", "action", "composition" ],
|
||||
"gestures": [ "info", "menu" ]
|
||||
}
|
||||
]
|
||||
|
@ -23,7 +23,7 @@
|
||||
<!-- For selected, add class 'selected' to outer div -->
|
||||
<div class='item' ng-click='action.perform("navigate")'>
|
||||
ITEM
|
||||
<div class="contents abs">
|
||||
<!--div class="contents abs">
|
||||
<div class='top-bar bar abs'>
|
||||
<div class='left abs'>
|
||||
<mct-include key="_checkbox"></mct-include>
|
||||
@ -45,5 +45,5 @@
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div-->
|
||||
</div>
|
@ -20,14 +20,23 @@
|
||||
at runtime from the About dialog for additional information.
|
||||
-->
|
||||
<!-- Based on items -->
|
||||
<div class='items-holder grid abs'>
|
||||
<div class="items-holder grid abs"
|
||||
ng-controller="SearchController as controller">
|
||||
|
||||
<!-- Search bar -->
|
||||
<div>
|
||||
<div id="formid">
|
||||
<form>
|
||||
<div>
|
||||
<label for="searchinput">Search this folder:</label>
|
||||
<input type="text" id="searchinput" />
|
||||
</div>
|
||||
<!--
|
||||
Search in this folder: <br>
|
||||
<input type="text" name="searchform">
|
||||
<input type="submit" value="Search">
|
||||
<input type="text" name="searchform"> -->
|
||||
<div class="button">
|
||||
<button type="submit">Search</button>
|
||||
</div>
|
||||
<!-- input type="submit" value="Search" -->
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@ -42,7 +51,9 @@
|
||||
mct-object="childObject"--></mct-representation>
|
||||
</li>
|
||||
<li>
|
||||
<mct-representation key="'search-item'"></mct-representation>
|
||||
<mct-representation key="'search-item'"
|
||||
ng-repeat="result in results"
|
||||
mct-object="result"></mct-representation>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
@ -19,30 +19,95 @@
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/*global define,Promise*/
|
||||
/*global define*/
|
||||
|
||||
/**
|
||||
* Module defining SearchController. Created by shale on 07/08/2015.
|
||||
*/
|
||||
define(function () {
|
||||
"use strict";
|
||||
|
||||
function SearchController($scope) {
|
||||
function SearchController($scope, objectService) {
|
||||
var items = [],
|
||||
searchResults = [];
|
||||
|
||||
// Indexes the filetree into a searchable format
|
||||
function indexTree() {
|
||||
// Get the root object
|
||||
/*
|
||||
objectService.getObjects(['root']).then(function (objects) {
|
||||
console.log('rootObject 1', rootObject);
|
||||
rootObject = objects.root;
|
||||
console.log('rootObject 2', rootObject);
|
||||
|
||||
|
||||
|
||||
console.log('hasCapability("editor") ', rootObject.hasCapability('editor'));
|
||||
console.log('getModel() ', rootObject.getModel());
|
||||
console.log('getId() ', rootObject.getId());
|
||||
|
||||
// Get the children of the root object
|
||||
console.log('hasCapability("composition") ', rootObject.hasCapability('composition'));
|
||||
if (rootObject.hasCapability('composition')) {
|
||||
rootComposition = rootObject.getCapability('composition').invoke();
|
||||
console.log('rootComposition ', rootComposition);
|
||||
}
|
||||
});
|
||||
console.log('rootObject 3', rootObject);
|
||||
*/
|
||||
|
||||
|
||||
|
||||
// Converts the filetree into a list
|
||||
// Eventually, plan to call search service
|
||||
// (but do here for now)
|
||||
function listify() {
|
||||
// For now, we want this view to only be in the My Items folder
|
||||
if ($scope.domainObject.getId() === 'mine') {
|
||||
var out = listHelper($scope.domainObject);
|
||||
//console.log('out', out);
|
||||
return out;
|
||||
}
|
||||
// Fallback if we aren't in My Items
|
||||
return items;
|
||||
}
|
||||
// Recursive helper function to go through the tree
|
||||
function listHelper(current) {
|
||||
//console.log('current', current);
|
||||
//console.log('current.getID', current.getId());
|
||||
var composition;
|
||||
if (current.hasCapability('composition')) {
|
||||
composition = current.getCapability('composition');
|
||||
} else {
|
||||
//console.log('does not have capability');
|
||||
return current;
|
||||
}
|
||||
composition.invoke().then(function (children) {
|
||||
if (children === []) {
|
||||
return current;
|
||||
} else {
|
||||
var subList = [current],
|
||||
i;
|
||||
for (i = 0; i < children.length; i += 1) {
|
||||
subList.concat(listHelper(children[i]));
|
||||
}
|
||||
//console.log('subList ', subList); ////////////
|
||||
return subList;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Search through items for items which have the search term
|
||||
// in the title
|
||||
function search(term) {
|
||||
// modify searchResults
|
||||
|
||||
return searchResults;
|
||||
}
|
||||
|
||||
// When the search view is opened, call indexTree()
|
||||
// When the search view is opened, call listify()
|
||||
// When the search button is pressed, call search()
|
||||
|
||||
$scope.items = listify();
|
||||
$scope.results = search();
|
||||
}
|
||||
return SearchController;
|
||||
});
|
Loading…
Reference in New Issue
Block a user