Skip to content

Commit

Permalink
list picker caches any previously requested options (unless total res…
Browse files Browse the repository at this point in the history
…ult size changes)
  • Loading branch information
Hendy committed May 9, 2017
1 parent 3d70adc commit 0f1432e
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@
//var itemsPerPage = $scope.model.config.pagedListPicker.itemsPerPage;
$scope.currentPage = 1;
$scope.pages = []; // an array of page numbers (suitable for ng-repeat)
$scope.pageOptions = []; //[pageNumber][null or array of options]
$scope.total = null;

// watch count, as if it changes, the number of pages will need to be recalculated
$scope.$watch('total', function (newValue, oldValue) {
if (newValue != oldValue) {

$scope.pageOptions = []; // clear any previously requested pages

var totalPages = Math.ceil(newValue / $scope.model.config.pagedListPicker.itemsPerPage);
var pages = [];
Expand All @@ -32,12 +35,19 @@
function getEditorDataItems() {

// has this page been requested before ?
if (angular.isArray($scope.pageOptions[$scope.currentPage]))
{
$scope.$parent.selectableOptions = $scope.pageOptions[$scope.currentPage];
}
else
{
editorResource.getEditorDataItems($scope.model, $scope.currentPage).then(function (response) {
$scope.pageOptions[$scope.currentPage] = response.data.editorDataItems;
$scope.$parent.selectableOptions = response.data.editorDataItems;
$scope.total = response.data.total;
});
}


editorResource.getEditorDataItems($scope.model, $scope.currentPage).then(function (response) {
$scope.$parent.selectableOptions = response.data.editorDataItems;
$scope.total = response.data.total;
});
}

// get selectable options
Expand Down

0 comments on commit 0f1432e

Please sign in to comment.