mirror of
https://github.com/nasa/openmct.git
synced 2025-02-21 01:42:31 +00:00
[Search] Removed paging
Removed the paging from the search view, because later instead of paging there will be a 'view more' option. Also made the generic search provider return searchResult objects instead of raw domain objects.
This commit is contained in:
parent
4f4af87285
commit
a5febf8f0f
@ -42,22 +42,10 @@
|
||||
<p>
|
||||
Results:
|
||||
</p>
|
||||
<div ng-if="controller.arePaging()">
|
||||
<button ng-if="controller.canGoBack()"
|
||||
ng-click="controller.previousPage()">
|
||||
Previous Page
|
||||
</button>
|
||||
showing results {{ index+1 }} - {{ index + pageLength }}
|
||||
of {{ results.length }}
|
||||
<button ng-if="controller.canGoForward()"
|
||||
ng-click="controller.nextPage()">
|
||||
Next Page
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<mct-representation key="'grid-item'"
|
||||
ng-repeat="result in page"
|
||||
ng-repeat="result in results"
|
||||
mct-object="result.object">
|
||||
</mct-representation>
|
||||
</div>
|
||||
|
@ -29,16 +29,6 @@ define(function () {
|
||||
|
||||
|
||||
function SearchController($scope, searchService, objectService) {
|
||||
$scope.pageLength = 16;
|
||||
|
||||
function page(start, howMany) {
|
||||
if (!howMany) {
|
||||
howMany = $scope.pageLength;
|
||||
}
|
||||
|
||||
$scope.index = start;
|
||||
$scope.page = $scope.results.slice(start, start + howMany);
|
||||
}
|
||||
|
||||
function search(inputID) {
|
||||
|
||||
@ -47,10 +37,10 @@ define(function () {
|
||||
// result page) here, using pseudo linkedlist searchResult
|
||||
|
||||
searchService.sendQuery(inputID).then(function (c) {
|
||||
$scope.results = c;
|
||||
$scope.index = 0;
|
||||
page($scope.index, $scope.pageLength);
|
||||
//$scope.results = c;
|
||||
});
|
||||
$scope.results = searchService.getLatestResults(0, 5);
|
||||
console.log('$scope results', $scope.results);
|
||||
}
|
||||
|
||||
return {
|
||||
@ -64,41 +54,6 @@ define(function () {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
// Check to see if there are enough results to be paging them
|
||||
arePaging: function () {
|
||||
return $scope.results.length > $scope.page.length;
|
||||
},
|
||||
|
||||
// Check to see if are items such that we can go back a page
|
||||
canGoBack: function () {
|
||||
return $scope.index > 0;
|
||||
},
|
||||
|
||||
// Check to see if are items such that we can go forward a page
|
||||
canGoForward: function () {
|
||||
return ($scope.index + $scope.pageLength) < $scope.results.length;
|
||||
},
|
||||
|
||||
// Change the items in scope to be the ones in the next page
|
||||
nextPage: function (howMany) {
|
||||
if (!howMany) {
|
||||
howMany = $scope.pageLength;
|
||||
}
|
||||
|
||||
$scope.index = $scope.index + howMany;
|
||||
$scope.page = $scope.results.slice($scope.index, $scope.index + howMany);
|
||||
},
|
||||
|
||||
// Change the items in scope to be the ones in the previous page
|
||||
previousPage: function (howMany) {
|
||||
if (!howMany) {
|
||||
howMany = $scope.pageLength;
|
||||
}
|
||||
|
||||
$scope.index = $scope.index - howMany;
|
||||
$scope.page = $scope.results.slice($scope.index, $scope.index + howMany);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -85,8 +85,12 @@ define(
|
||||
}
|
||||
objectService.getObjects(ids).then(function (objects) {
|
||||
latestResults = [];
|
||||
for (var i in objects) {
|
||||
latestResults.push(objects[i]);
|
||||
for (var id in objects) {
|
||||
latestResults.push({
|
||||
object: objects[id],
|
||||
id: id
|
||||
// TODO: Make the event.data.results able to get score from id
|
||||
});
|
||||
}
|
||||
lastSearchTimestamp = event.data.timestamp;
|
||||
console.log('updated latestResults', latestResults, 'with time', lastSearchTimestamp);
|
||||
|
@ -57,8 +57,7 @@
|
||||
}
|
||||
|
||||
var message = {
|
||||
request: 'index',
|
||||
results: undefined
|
||||
request: 'index'
|
||||
};
|
||||
return message;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user