From 70127680cceb29b05713736b53bb65e13c2f856a Mon Sep 17 00:00:00 2001 From: Leolynn Castro Date: Tue, 15 Aug 2017 09:11:56 +0800 Subject: [PATCH] Page number input should not be more than the max page --- client/app/dashboard/model/list/ModelList.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/client/app/dashboard/model/list/ModelList.js b/client/app/dashboard/model/list/ModelList.js index aab21067..00026cbd 100644 --- a/client/app/dashboard/model/list/ModelList.js +++ b/client/app/dashboard/model/list/ModelList.js @@ -710,12 +710,19 @@ angular.module('dashboard.Dashboard.Model.List', [ } } }, true); - + $scope.$watch('pagingOptions', function (newVal, oldVal) { if (newVal.currentPage != oldVal.currentPage || newVal.pageSize != oldVal.pageSize) { $scope.pagingOptions.pageSize = $scope.pagingOptions.pageSize.toString(); $scope.loadItems(); } + $scope.$watch('pagingOptions.pageSize', (newVal, oldVal) => { + if(newVal !== oldVal) $scope.pagingOptions.currentPage = 1; + }); + $scope.$watch('pagingOptions.currentPage', (newVal, oldVal) => { + let maxPage = Math.ceil($scope.totalServerItems / $scope.pagingOptions.pageSize); + if (newVal !== oldVal && newVal > maxPage) $scope.pagingOptions.currentPage = maxPage; + }); }, true); $scope.$watch('gridOptions.$gridScope.filterText', _.debounce(function (newVal, oldVal) {