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 3bf4a58ddf9791d3212e3751b7f9076379a6d516 Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Wed Jun 11 15:21:43 2014 +0200 edit comment --- .../src/main/webapp/js/controllers/pollCtrl.js | 82 +++++++++++++--------- .../src/main/webapp/partials/poll-comment.html | 12 ++-- .../src/main/webapp/partials/poll.html | 4 +- 3 files changed, 60 insertions(+), 38 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 72bc2ae..0ba25a4 100644 --- a/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js +++ b/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js @@ -661,24 +661,25 @@ angular.module('pollControllers', []) function ( $scope, $controller, $routeParams, Poll, PollComment ) { $controller('PollCtrl', {$scope:$scope}); + $scope.tab = $scope.setTab('comment'); + $scope.globalVariables.commentMode = true; Poll.get({pollId:$routeParams.pollId, permission:$scope.globalVariables.permission}, function (data) { $scope.data.poll = data; }) - $scope.tab = $scope.setTab('comment'); - $scope.comment = {text:''}; - - if (angular.isDefined($scope.session.user)) { - if (angular.isDefined($scope.session.user.name)) { - $scope.comment.authorName = $scope.session.user.name; - } - else { - $scope.comment.authorName = $scope.session.user.login; + var initAuthor = function () { + if (angular.isDefined($scope.session.user)) { + if (angular.isDefined($scope.session.user.name)) { + $scope.comment.authorName = $scope.session.user.name; + } + else { + $scope.comment.authorName = $scope.session.user.login; + } } - } + }; initAuthor(); $scope.pageSize = conf.commentDefaultPageSize; $scope.urlPagination = $scope.setUrl(['page', 'pageSize']); @@ -712,29 +713,41 @@ angular.module('pollControllers', []) }); $scope.postComment = function () { - PollComment.add({pollId:$routeParams.pollId, permission:$scope.globalVariables.permission}, $scope.comment, function (data) { - $scope.globalVariables.saved = true; - - // add ID and Permission and push in list of comments - $scope.comment.id = data.id; - $scope.comment.permission = data.permission; - $scope.comment.postDate = new Date(); - - // reload comments - if ($scope.data.commentsPagination.desc) { - // change pageNumber without reload - paginationParameter.pageNumber = 0; - // reload + var commentPromise + if (angular.isDefined($scope.comment.id)) { + // edit + commentPromise = PollComment.update({pollId:$routeParams.pollId, permission:$scope.globalVariables.permission}, $scope.comment, function (data) { + paginationParameter.pageNumber = $scope.comment.page; 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; - }); - } + initAuthor(); + }).$promise; + } else { + //Add + commentPromise = PollComment.add({pollId:$routeParams.pollId, permission:$scope.globalVariables.permission}, $scope.comment, function (data) { + // add ID and Permission and push in list of comments + $scope.comment.id = data.id; + $scope.comment.permission = data.permission; + $scope.comment.postDate = new Date(); + + // reload comments + 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; + }); + } + }).$promise; + } + commentPromise.then(function () { + $scope.globalVariables.saved = true; //clean form $scope.comment.text = ''; delete $scope.comment.postDate; @@ -742,8 +755,13 @@ angular.module('pollControllers', []) delete $scope.comment.permission; }, function (error) { $scope.restError = error.data; - }); + }) }; + + $scope.editPost = function (comment) { + $scope.comment = angular.copy(comment); + $scope.comment.page = paginationParameter.pageNumber; + } }]) .controller('PollResultCtrl', ['$scope', '$q', '$controller', '$routeParams', 'Poll', 'PollChoice', 'PollVote', function ($scope, $q, $controller, $routeParams, Poll, PollChoice, PollVote) { 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 d10bf4f..90e2ca2 100644 --- a/pollen-ui-angular/src/main/webapp/partials/poll-comment.html +++ b/pollen-ui-angular/src/main/webapp/partials/poll-comment.html @@ -18,11 +18,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #L% --> -<div ng-controller="PollCommentCtrl"> +<div> <h2>{{ 'title.comment' | translate }}</h2> <!-- begin for add comment --> - <form ng-submit="postComment()"> + <form class="form-horizontal" ng-submit="postComment()"> <div class="form-group"> <label class="col-sm-2"> {{ 'user.name' | translate }} </label> <div class="col-sm-1"> @@ -42,7 +42,10 @@ </div> <div class="form-group"> - <button type="submit" class="btn btn-primary" ng-click="postComment()">{{ 'action.comment' | translate }}</button> + <div class="col-sm-3"> </div> + <div class="col-sm-9"> + <input type="submit" class="btn btn-primary" value="{{ 'action.comment' | translate }}" /> + </div> </div> </form> <!-- end form comment --> @@ -52,7 +55,8 @@ <tr ng-repeat="comment in data.comments"> <td> <i class="glyphicon glyphicon-user"></i>{{comment.authorName}}<br/> - <i class="glyphicon glyphicon-calendar"></i>{{comment.postDate | date:'dd/MM/yyyy HH:mm'}} + <i class="glyphicon glyphicon-calendar"></i>{{comment.postDate | date:globalVariables.dateFormat}}<br/> + <i class="glyphicon glyphicon-pencil" ng-show="comment.id" ng-click="editPost(comment)"></i> <i class="glyphicon glyphicon-remove danger" ng-show="comment.id" ng-click="deletePost(comment)"></i> </td> <td> <div ng-bind-html="toHTML(comment.text)"></div> diff --git a/pollen-ui-angular/src/main/webapp/partials/poll.html b/pollen-ui-angular/src/main/webapp/partials/poll.html index 888b3f1..87315b2 100644 --- a/pollen-ui-angular/src/main/webapp/partials/poll.html +++ b/pollen-ui-angular/src/main/webapp/partials/poll.html @@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #L% --> -<form class="form-horizontal" novalidate> +<div> <alert type="danger" class="alert-float" ng-if="restError.choice" close="restError.choice = false"> {{restError.choice[0]}} </alert> <alert type="success" class="alert-float" ng-if="globalVariables.editMode && globalVariables.saved" close="globalVariables.saved = false">{{ 'poll.saved' | translate }}</alert> <alert type="success" class="alert-float" ng-if="globalVariables.voteMode && globalVariables.saved" close="globalVariables.saved = false">{{ 'vote.added' | translate }}</alert> @@ -47,4 +47,4 @@ <div ng-include="'./partials/poll-listParticipant.html'" ng-if="tab == 'participant'"></div> -</form> \ No newline at end of file +</div> \ No newline at end of file -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm