This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository pollen. See http://git.chorem.org/pollen.git commit 1a65bb713d5353dd8ada054298a27f5305f9f590 Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Fri Jun 6 12:01:20 2014 +0200 redirect to the comment posted --- .../src/main/webapp/js/controllers/pollCtrl.js | 30 ++++++++++++++++------ 1 file changed, 22 insertions(+), 8 deletions(-) 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 ef63980..b6078c1 100644 --- a/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js +++ b/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js @@ -583,18 +583,20 @@ angular.module('pollControllers', []) } var initComments = function () { - if (angular.isUndefined(paginationParameter.pageNumber) || paginationParameter.pageNumber != $scope.data.commentsPagination.pageNumber) { - PollComment.get({pollId:$routeParams.pollId, permission:$scope.globalVariables.permission, paginationParameter:paginationParameter}, function (data) { + var commentPromise = PollComment.get({pollId:$routeParams.pollId, permission:$scope.globalVariables.permission, paginationParameter:paginationParameter}, function (data) { $scope.data.comments = data.elements; $scope.data.commentsPagination = data.pagination; - }); - } + }).$promise; + + return commentPromise; }; initComments(); $scope.$watch('data.commentsPagination.currentPage', function (newVal, oldVal) { - if (angular.isDefined(oldVal) && newVal != oldVal) { - paginationParameter.pageNumber = $scope.data.commentsPagination.currentPage; - initComments(); + if (angular.isDefined(oldVal) && newVal != oldVal) { // Value change + if (paginationParameter.pageNumber != $scope.data.commentsPagination.currentPage) { // not same page + paginationParameter.pageNumber = $scope.data.commentsPagination.currentPage; + initComments(); + } } }); @@ -608,7 +610,19 @@ angular.module('pollControllers', []) $scope.comment.postDate = new Date(); // reload comments - initComments(); + if ($scope.data.commentsPagination.desc) { + // change pageNumber without reload + paginationParameter.pageNumber = 0; + // reload + initComments(); + } else { + // change pageNumber without reload + paginationParameter.pageNumber = $scope.data.commentsPagination.lastPage; + // reload and check the last page. + initComments().then( function () { + $scope.data.commentsPagination.currentPage = $scope.data.commentsPagination.lastPage; + }); + } //clean form $scope.comment.text = ''; -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.