mirror of
https://github.com/nasa/openmct.git
synced 2025-02-21 01:42:31 +00:00
[Search] Load more option
Made the search view have a 'Load more' button. Added functionalty to allow this to happen.
This commit is contained in:
parent
4191bc1ac3
commit
5f30249065
@ -42,6 +42,11 @@
|
||||
<p>
|
||||
Results:
|
||||
</p>
|
||||
<div ng-if="controller.areMore()">
|
||||
<button ng-click="controller.loadMore()">
|
||||
Load more
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<mct-representation key="'grid-item'"
|
||||
|
@ -184,6 +184,14 @@ define(
|
||||
*/
|
||||
getLatestTimestamps: function () {
|
||||
return lastMergeTimestamps;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get the number of search results that have been calculated most
|
||||
* recently.
|
||||
*/
|
||||
getNumResults: function () {
|
||||
return latestMergedResults.length;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -27,17 +27,14 @@
|
||||
define(function () {
|
||||
"use strict";
|
||||
|
||||
var INITIAL_LOAD_NUMBER = 5,
|
||||
LOAD_INCREMENT = 5;
|
||||
|
||||
function SearchController($scope, $timeout, searchService) {
|
||||
// Starting amount of results to load. Will get increased.
|
||||
var numResults = INITIAL_LOAD_NUMBER;
|
||||
|
||||
function search(inputID) {
|
||||
var date = new Date(),
|
||||
timestamp = date.getTime(),
|
||||
numResults = 20;
|
||||
|
||||
// Send the query
|
||||
searchService.sendQuery(inputID, timestamp);
|
||||
|
||||
function update(timestamp) {
|
||||
// Get the results
|
||||
$scope.results = searchService.getLatestResults(0, numResults);
|
||||
|
||||
@ -58,6 +55,19 @@ define(function () {
|
||||
waitForLatest();
|
||||
}
|
||||
|
||||
function search(inputID) {
|
||||
var date = new Date(),
|
||||
timestamp = date.getTime();
|
||||
|
||||
// Reset 'load more'
|
||||
numResults = INITIAL_LOAD_NUMBER;
|
||||
|
||||
// Send the query
|
||||
searchService.sendQuery(inputID, timestamp);
|
||||
|
||||
update(timestamp);
|
||||
}
|
||||
|
||||
return {
|
||||
/**
|
||||
* Search the filetree.
|
||||
@ -76,6 +86,22 @@ define(function () {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Checks to see if there are more search results to display.
|
||||
*/
|
||||
areMore: function () {
|
||||
return numResults < searchService.getNumResults();
|
||||
},
|
||||
|
||||
/**
|
||||
* Increases the number of search results to display, and then
|
||||
* load them.
|
||||
*/
|
||||
loadMore: function () {
|
||||
numResults += LOAD_INCREMENT;
|
||||
update();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user