Merge branch 'search' into open70

Conflicts:
	platform/commonUI/browse/res/templates/browse.html
This commit is contained in:
slhale
2015-08-19 10:05:38 -07:00
5 changed files with 33 additions and 46 deletions

View File

@@ -29,12 +29,11 @@
<mct-representation key="'create-button'" mct-object="navigatedObject"> <mct-representation key="'create-button'" mct-object="navigatedObject">
</mct-representation> </mct-representation>
<div class='holder search-holder abs' <div class='holder search-holder abs'
ng-class="{active: treeModel.search}" ng-class="{active: treeModel.search}">
> <mct-representation key="'search'"
<mct-include key="'search'"
mct-object="domainObject" mct-object="domainObject"
ng-model="treeModel"> ng-model="treeModel">
</mct-include> </mct-representation>
</div> </div>
<div class='holder tree-holder abs' <div class='holder tree-holder abs'
ng-hide="treeModel.search"> ng-hide="treeModel.search">

View File

@@ -26,7 +26,7 @@
"depends": [ "$scope", "$document" ] "depends": [ "$scope", "$document" ]
} }
], ],
"templates": [ "representations": [
{ {
"key": "search", "key": "search",
"templateUrl": "templates/search.html" "templateUrl": "templates/search.html"
@@ -34,9 +34,7 @@
{ {
"key": "search-menu", "key": "search-menu",
"templateUrl": "templates/search-menu.html" "templateUrl": "templates/search-menu.html"
} },
],
"representations": [
{ {
"key": "search-item", "key": "search-item",
"templateUrl": "templates/search-item.html" "templateUrl": "templates/search-item.html"

View File

@@ -58,12 +58,12 @@
</a> </a>
<!-- Menu --> <!-- Menu -->
<mct-include key="'search-menu'" <mct-representation key="'search-menu'"
class="menu-element search-menu-holder" class="menu-element search-menu-holder"
ng-class="{off: !toggle.isActive()}" ng-class="{off: !toggle.isActive()}"
ng-model="ngModel" ng-model="ngModel"
ng-click="toggle.setState(true)"> ng-click="toggle.setState(true)">
</mct-include> </mct-representation>
</div> </div>
<!-- Active filter display --> <!-- Active filter display -->

View File

@@ -30,8 +30,8 @@ define(function () {
var INITIAL_LOAD_NUMBER = 20, var INITIAL_LOAD_NUMBER = 20,
LOAD_INCREMENT = 20; LOAD_INCREMENT = 20;
function SearchController($scope, searchService, types) { function SearchController($scope, searchService) {
// numResults is the starting amount of results to load. Will get increased. // numResults is the amount of results to display. Will get increased.
// fullResults holds the most recent complete searchService response object // fullResults holds the most recent complete searchService response object
var numResults = INITIAL_LOAD_NUMBER, var numResults = INITIAL_LOAD_NUMBER,
fullResults = {hits: []}; fullResults = {hits: []};
@@ -46,7 +46,7 @@ define(function () {
// ngModel.filter, the function filter defined below // ngModel.filter, the function filter defined below
// ngModel.types, an array of type objects // ngModel.types, an array of type objects
// ngModel.checked, a dictionary of which type filter options are checked // ngModel.checked, a dictionary of which type filter options are checked
// ngModel.checkAll, a boolean of whether all of the types in ngModel.checked are checked // ngModel.checkAll, a boolean of whether to search all types
// ngModel.filtersString, a string list of what filters on the results are active // ngModel.filtersString, a string list of what filters on the results are active
$scope.results = []; $scope.results = [];
$scope.loading = false; $scope.loading = false;
@@ -70,7 +70,7 @@ define(function () {
} else { } else {
while (newResults.length < numResults && i < hits.length) { while (newResults.length < numResults && i < hits.length) {
// If this is of an acceptable type, add it to the list // If this is of an acceptable type, add it to the list
if ($scope.ngModel.checked[hits[i].object.getModel().type] === true) { if ($scope.ngModel.checked[hits[i].object.getModel().type]) {
newResults.push(fullResults.hits[i]); newResults.push(fullResults.hits[i]);
} }
i += 1; i += 1;
@@ -88,14 +88,12 @@ define(function () {
function search(maxResults) { function search(maxResults) {
var inputText = $scope.ngModel.input; var inputText = $scope.ngModel.input;
// We are starting to load.
if (inputText !== '' && inputText !== undefined) { if (inputText !== '' && inputText !== undefined) {
// We are starting to load.
$scope.loading = true; $scope.loading = true;
}
// Update whether the file tree should be displayed
// Update whether the file tree should be displayed // Hide tree only when starting search
// Hide tree only when starting search
if (inputText !== '' && inputText !== undefined) {
$scope.ngModel.search = true; $scope.ngModel.search = true;
} }
@@ -106,8 +104,9 @@ define(function () {
// Send the query // Send the query
searchService.query(inputText, maxResults).then(function (result) { searchService.query(inputText, maxResults).then(function (result) {
// Store all the results before splicing off the front, so that
// we can load more to display later.
fullResults = result; fullResults = result;
//$scope.results = result.hits.slice(0, numResults);
$scope.results = filter(result.hits); $scope.results = filter(result.hits);
// Update whether the file tree should be displayed // Update whether the file tree should be displayed

View File

@@ -40,7 +40,7 @@ define(function () {
$scope.ngModel.checkAll = true; $scope.ngModel.checkAll = true;
$scope.ngModel.filtersString = ''; $scope.ngModel.filtersString = '';
// On initialization, fill the scope's types with type keys // On initialization, fill the model's types with type keys
types.forEach(function (type) { types.forEach(function (type) {
// We only want some types, the ones that are probably human readable // We only want some types, the ones that are probably human readable
// Manually remove 'root', but not 'unknown' // Manually remove 'root', but not 'unknown'
@@ -67,7 +67,7 @@ define(function () {
// Update the current filters string // Update the current filters string
$scope.ngModel.filtersString = ''; $scope.ngModel.filtersString = '';
if ($scope.ngModel.checkAll !== true) { if (!$scope.ngModel.checkAll) {
for (i = 0; i < $scope.ngModel.types.length; i += 1) { for (i = 0; i < $scope.ngModel.types.length; i += 1) {
// If the type key corresponds to a checked option... // If the type key corresponds to a checked option...
if ($scope.ngModel.checked[$scope.ngModel.types[i].key]) { if ($scope.ngModel.checked[$scope.ngModel.types[i].key]) {
@@ -94,30 +94,21 @@ define(function () {
function checkAll() { function checkAll() {
var type; var type;
// If model's checkAll has just been checked, reset everything else // Reset all the other options to original/default position
// to default view, and behave as if there are no filters (default) for (type in $scope.ngModel.checked) {
if ($scope.ngModel.checkAll) { $scope.ngModel.checked[type] = false;
// Uncheck everything else
for (type in $scope.ngModel.checked) {
$scope.ngModel.checked[type] = false;
}
// Reset filter display
$scope.ngModel.filtersString = '';
// Re-filter results
$scope.ngModel.filter();
} else {
// If model's checkAll has just been UNchecked, set filters to none
for (type in $scope.ngModel.checked) {
$scope.ngModel.checked[type] = false;
}
$scope.ngModel.filtersString = 'NONE';
// Re-filter results
$scope.ngModel.filter();
} }
// Change the filters string depending on checkAll status
if ($scope.ngModel.checkAll) {
// This setting will make the filters display hidden
$scope.ngModel.filtersString = '';
} else {
$scope.ngModel.filtersString = 'NONE';
}
// Re-filter results
$scope.ngModel.filter();
} }
return { return {