03/03: update pagination and add pagination in comments
This is an automated email from the git hooks/post-receive script. New commit to branch devel in repository Pollen. See http://git.None/Pollen.git commit a5da89832b2299fb38e30e933d56f6f5188b3b8a Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Wed May 28 15:30:47 2014 +0200 update pagination and add pagination in comments --- pollen-ui-angular/src/main/webapp/js/app.js | 12 ++++++-- .../src/main/webapp/js/controllers/pollCtrl.js | 36 +++++++++++++--------- .../src/main/webapp/partials/poll-comment.html | 5 ++- .../src/main/webapp/partials/poll-list.html | 3 +- 4 files changed, 35 insertions(+), 21 deletions(-) diff --git a/pollen-ui-angular/src/main/webapp/js/app.js b/pollen-ui-angular/src/main/webapp/js/app.js index 957151b..da816a1 100644 --- a/pollen-ui-angular/src/main/webapp/js/app.js +++ b/pollen-ui-angular/src/main/webapp/js/app.js @@ -199,13 +199,21 @@ angular.module('pollen', ['pollenServices', 'ngRoute', 'pollControllers', 'userC return { restrict: 'E', scope: { - pageList: '=', currentPage: '=', lastPage: '=', pageSize: '=', url: '=' }, - templateUrl: 'partials/pagination.html' + templateUrl: 'partials/pagination.html', + link: function (scope, element, attrs) { + //set pageList + scope.pageList = []; + scope.$watch('lastPage', function (newVal) { + for (var i = 0; i <= newVal; i++) { + scope.pageList.push(i); + } + }); + } } }) diff --git a/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js b/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js index ffa175d..0a9165d 100644 --- a/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js +++ b/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js @@ -458,6 +458,7 @@ angular.module('pollControllers', []) }) $scope.tab = $scope.setTab('comment'); + $scope.comment = {text:''}; if (angular.isDefined($scope.session.user)) { @@ -469,8 +470,22 @@ angular.module('pollControllers', []) } } - PollComment.get({pollId:$routeParams.pollId, permission:$scope.globalVariables.permission}, function (data) { + $scope.pageSize = 3; + $scope.urlPagination = $scope.setUrl(['page', 'pageSize']); + + var paginationParameter = {pageSize:$scope.pageSize}; + if (angular.isDefined($routeParams.page)) { + if (angular.isDefined($routeParams.pageSize)) { + paginationParameter = {pageSize:$routeParams.pageSize}; + $scope.pageSize = $routeParams.pageSize; + } + + paginationParameter.pageNumber = $routeParams.page; + } + + PollComment.get({pollId:$routeParams.pollId, permission:$scope.globalVariables.permission, paginationParameter:paginationParameter}, function (data) { $scope.data.comments = data.elements; + $scope.data.commentsPagination = data.pagination; }); $scope.postComment = function () { @@ -486,6 +501,8 @@ angular.module('pollControllers', []) //clean form $scope.comment.text = ''; delete $scope.comment.postDate; + delete $scope.comment.id; + delete $scope.comment.permission; }, function (error) { $scope.restError = error.data; }); @@ -542,23 +559,20 @@ angular.module('pollControllers', []) function ($scope, $controller, $routeParams, Poll) { $controller('PollCtrl', {$scope:$scope}); - $scope.pageSize = 10; + $scope.pageSize = 3; + $scope.urlPagination = $scope.setUrl(['page', 'pageSize']); - var pollPromise; - var paginationParameter; + var paginationParameter = {pageSize:$scope.pageSize}; if (angular.isDefined($routeParams.page)) { if (angular.isDefined($routeParams.pageSize)) { paginationParameter = {pageSize:$routeParams.pageSize}; $scope.pageSize = $routeParams.pageSize; } - else { - paginationParameter = {pageSize:$scope.pageSize}; - } paginationParameter.pageNumber = $routeParams.page; } - + var pollPromise; if (angular.isDefined($routeParams.cmd)) { pollPromise = Poll.get({cmd:$routeParams.cmd, paginationParameter:paginationParameter}).$promise; } @@ -569,16 +583,10 @@ angular.module('pollControllers', []) pollPromise.then(function (data) { $scope.data.polls = data.elements $scope.data.pollsPagination = data.pagination; - $scope.pageList = []; - for (var i = 0; i <= $scope.data.pollsPagination.lastPage; i++) { - $scope.pageList.push(i); - } }, function (error) { $scope.restError = {forbidden:true}; }); - $scope.urlPagination = $scope.setUrl(['page', 'pageSize']); - }]) ; \ No newline at end of file diff --git a/pollen-ui-angular/src/main/webapp/partials/poll-comment.html b/pollen-ui-angular/src/main/webapp/partials/poll-comment.html index 90d24ec..2dd295d 100644 --- a/pollen-ui-angular/src/main/webapp/partials/poll-comment.html +++ b/pollen-ui-angular/src/main/webapp/partials/poll-comment.html @@ -61,9 +61,8 @@ </table> <!-- end print comments --> - <make-pagination page-list="pageList" - current-page="data.pollsPagination.currentPage" - last-page="data.pollsPagination.lastPage" + <make-pagination current-page="data.commentsPagination.currentPage" + last-page="data.commentsPagination.lastPage" page-size="pageSize" url="urlPagination"></make-pagination> </div> \ No newline at end of file diff --git a/pollen-ui-angular/src/main/webapp/partials/poll-list.html b/pollen-ui-angular/src/main/webapp/partials/poll-list.html index b648f14..e1f74d8 100644 --- a/pollen-ui-angular/src/main/webapp/partials/poll-list.html +++ b/pollen-ui-angular/src/main/webapp/partials/poll-list.html @@ -7,8 +7,7 @@ <hr/> </div> -<make-pagination page-list="pageList" - current-page="data.pollsPagination.currentPage" +<make-pagination current-page="data.pollsPagination.currentPage" last-page="data.pollsPagination.lastPage" page-size="pageSize" url="urlPagination"></make-pagination> -- To stop receiving notification emails like this one, please contact Chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
Chorem.org scm