[Search] Tree selection syncs

Selecting something in the search results now
also makes it selected in the filetree. It
remains selected even when the search results
are cleared. (The filetree does not
automatically expand to that position though.)
This commit is contained in:
shale 2015-07-23 12:15:14 -07:00
parent 29d5535e7c
commit 2680e466fa
6 changed files with 26 additions and 55 deletions

View File

@ -707,6 +707,9 @@ mct-container {
/* line 42, ../sass/search/_layout.scss */ /* line 42, ../sass/search/_layout.scss */
.pane.treeview.left .tree-holder { .pane.treeview.left .tree-holder {
top: 0; } top: 0; }
/* line 47, ../sass/search/_layout.scss */
.pane.treeview.left .tree-holder.search-in-use {
display: none; }
/***************************************************************************** /*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government * Open MCT Web, Copyright (c) 2014-2015, United States Government

View File

@ -42,6 +42,11 @@
.tree-holder { .tree-holder {
// Want tree holder to start right below the search bar // Want tree holder to start right below the search bar
top: 0; top: 0;
// Make tree invisible when there are things in search results
&.search-in-use {
display: none;
}
} }
} }
} }

View File

@ -165,7 +165,18 @@ define(
* @returns true if this should be highlighted * @returns true if this should be highlighted
*/ */
isSelected: function () { isSelected: function () {
//return isSelected;
// Modification for compatibility with search.
// If this object is the same as the model's selected object
// Same being them having the same ID (this allows different
// instances of the same thing to be recognized as the same)
if ($scope.ngModel.selectedObject.getId() === $scope.domainObject.getId()) {
setSelection($scope.domainObject);
}
return isSelected; return isSelected;
// TODO: Check to make sure this change doesn't break anything.
} }
}; };
} }

View File

@ -47,7 +47,7 @@
<span class="title-label">Loading...</span> <span class="title-label">Loading...</span>
</div> </div>
<!-- Load more --> <!-- Load more button -->
<div ng-if="controller.areMore()"> <div ng-if="controller.areMore()">
<button class="load-more-button btn very-subtle" <button class="load-more-button btn very-subtle"
ng-click="controller.loadMore()"> ng-click="controller.loadMore()">

View File

@ -28,55 +28,7 @@ define(function () {
"use strict"; "use strict";
function SearchItemController($scope) { function SearchItemController($scope) {
var selectedObject = ($scope.ngModel || {}).selectedObject;//, var selectedObject = ($scope.ngModel || {}).selectedObject;
//isSelected = false;
/*
// Consider the currently-navigated object and update
// parameters which support display.
function checkSelection() {
var nodeObject = $scope.domainObject,
navObject = selectedObject,
nodeContext = nodeObject &&
nodeObject.getCapability('context'),
navContext = navObject &&
navObject.getCapability('context'),
nodePath,
navPath;
// Deselect; we will reselect below, iff we are
// exactly at the end of the path.
isSelected = false;
// Expand if necessary (if the navigated object will
// be in this node's subtree)
if (nodeContext && navContext) {
// Get the paths as arrays of identifiers
nodePath = nodeContext.getPath().map(getId);
navPath = navContext.getPath().map(getId);
// Check to see if the node's path lies entirely
// within the navigation path; otherwise, navigation
// has happened in some other subtree.
if (navPath.length >= nodePath.length &&
checkPath(nodePath, navPath)) {
// nodePath is along the navPath; if it's
// at the end of the path, highlight;
// otherwise, expand.
if (nodePath.length === navPath.length) {
isSelected = true;
} else { // node path is shorter: Expand!
if ($scope.toggle) {
$scope.toggle.setState(true);
}
trackExpansion();
}
}
}
}
*/
// Callback for the selection updates; track the currently // Callback for the selection updates; track the currently
// navigated object and update display parameters as needed. // navigated object and update display parameters as needed.
@ -86,14 +38,14 @@ define(function () {
// Listen for changes which will effect display parameters // Listen for changes which will effect display parameters
$scope.$watch("ngModel.selectedObject", setSelection); $scope.$watch("ngModel.selectedObject", setSelection);
//$scope.$watch("domainObject", checkSelection);
return { return {
/** /**
* Check whether or not the domain object represented by * Check whether or not the domain object represented by
* this tree node should be highlighted. * this search item should be highlighted.
* An object will be highlighted if it matches * An object will be highlighted if its ID matches
* ngModel.selectedObject * ngModel.selectedObject
*
* @returns true if this should be highlighted * @returns true if this should be highlighted
*/ */
isSelected: function () { isSelected: function () {