Skip to content

Commit

Permalink
Fix bug in dashboard Add panel pager where it always said x of x (e…
Browse files Browse the repository at this point in the history
…lastic#11617)

* pagination fixed

* pagination label changed

* Variations on the pager implementation

* Add a safety check since this relies on inherited scope.

* Don't use noop function

It’s possible a parent could mess with the function after we set it to
a noop (maybe delete it)?
  • Loading branch information
stacey-gammon authored and snide committed May 30, 2017
1 parent a14437d commit fd5f4d3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/ui/public/directives/paginate.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ uiModules.get('kibana')
page.count = count;
page.first = page.number === 1;
page.last = page.number === count;
page.firstItem = (page.number - 1) * perPage + 1;
page.lastItem = Math.min(page.number * perPage, $scope.list.length);

page.prev = $scope.pages[i - 1];
if (page.prev) page.prev.next = page;
Expand All @@ -135,6 +137,10 @@ uiModules.get('kibana')
} else {
$scope.page = $scope.pages[0];
}

if ($scope.page && $scope.onPageChanged) {
$scope.onPageChanged($scope.page);
}
};

self.changePage = function (page) {
Expand Down Expand Up @@ -171,6 +177,10 @@ uiModules.get('kibana')
if (other.last) $scope.otherPages.containsLast = true;
if (other.first) $scope.otherPages.containsFirst = true;
}

if ($scope.onPageChanged) {
$scope.onPageChanged($scope.page);
}
};

function setPerPage(val) {
Expand Down
7 changes: 7 additions & 0 deletions src/ui/public/directives/saved_object_finder.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ module.directive('savedObjectFinder', function ($location, $injector, kbnUrl, Pr
filterResults();
});

$scope.pageFirstItem = 0;
$scope.pageLastItem = 0;
$scope.onPageChanged = (page) => {
$scope.pageFirstItem = page.firstItem;
$scope.pageLastItem = page.lastItem;
};

//manages the state of the keyboard selector
self.selector = {
enabled: false,
Expand Down
2 changes: 1 addition & 1 deletion src/ui/public/partials/saved_object_finder.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<div class="kuiBarSection">
<p class="kuiText kuiSubduedText">
{{ finder.hitCount }} of {{ finder.hitCount }}
{{ pageFirstItem }}-{{ pageLastItem }} of {{ finder.hitCount }}
</p>

<div class="kuiButtonGroup">
Expand Down

0 comments on commit fd5f4d3

Please sign in to comment.