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 8a2ccd02ab6e0acd4bdb5ff9aaab688f16675db9 Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Mon Jun 30 12:17:02 2014 +0200 add flag in pollBean --- .../org/chorem/pollen/services/bean/PollBean.java | 67 ++++++++++++++++++++++ pollen-ui-angular/src/main/webapp/index.html | 6 +- .../src/main/webapp/js/controllers/pollCtrl.js | 46 +++++++++------ .../src/main/webapp/partials/poll-link.html | 2 +- .../src/main/webapp/partials/poll.html | 4 +- 5 files changed, 100 insertions(+), 25 deletions(-) diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/bean/PollBean.java b/pollen-services/src/main/java/org/chorem/pollen/services/bean/PollBean.java index 0613f68..6ba3655 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/bean/PollBean.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/bean/PollBean.java @@ -93,6 +93,14 @@ public class PollBean extends PollenBean<Poll> { protected ResultVisibility resultVisibility; + protected boolean isClosed; + + protected boolean resultIsVisible; + + protected boolean commentIsVisible; + + protected boolean voteIsVisible; + @Override public void fromEntity(Poll entity) { @@ -130,7 +138,9 @@ public class PollBean extends PollenBean<Poll> { setVoteVisibility(entity.getVoteVisibility()); setCommentVisibility(entity.getCommentVisibility()); setResultVisibility(entity.getResultVisibility()); + setClosed(entity.getClosed()); + setFlag(); } @Override @@ -171,6 +181,8 @@ public class PollBean extends PollenBean<Poll> { public void setPermission(String permission) { this.permission = permission; + // check new permission + setFlag(); } public String getCreatorName() { @@ -309,4 +321,59 @@ public class PollBean extends PollenBean<Poll> { this.resultVisibility = resultVisibility; } + public boolean isClosed() { + return isClosed; + } + + public void setClosed(boolean isClosed) { + this.isClosed = isClosed; + } + + public boolean isResultIsVisible() { + return resultIsVisible; + } + + public void setResultIsVisible(boolean resultIsVisible) { + this.resultIsVisible = resultIsVisible; + } + + public boolean isCommentIsVisible() { + return commentIsVisible; + } + + public void setCommentIsVisible(boolean commentIsVisible) { + this.commentIsVisible = commentIsVisible; + } + + public boolean isVoteIsVisible() { + return voteIsVisible; + } + + public void setVoteIsVisible(boolean voteIsVisible) { + this.voteIsVisible = voteIsVisible; + } + + protected void setFlag() { + // TODO: check CommentVisibility.VOTER + if (getPermission() != null || getCommentVisibility() == CommentVisibility.EVERYBODY) { + setCommentIsVisible(true); + } else { + setCommentIsVisible(false); + } + + // TODO: check VoteVisibility.VOTER + if ((getPermission() != null || getVoteVisibility() == VoteVisibility.EVERYBODY) && getVoteVisibility() != VoteVisibility.ANONYMOUS) { + setVoteIsVisible(true); + } else { + setVoteIsVisible(false); + } + + // TODO: check ResultVisibility.VOTER + if ( (getPermission() != null || getResultVisibility() == ResultVisibility.EVERYBODY) + && (isContinuousResults() || isClosed()) ) { + setResultIsVisible(true); + } else { + setResultIsVisible(false); + } + } } diff --git a/pollen-ui-angular/src/main/webapp/index.html b/pollen-ui-angular/src/main/webapp/index.html index 23582be..f1da5fa 100644 --- a/pollen-ui-angular/src/main/webapp/index.html +++ b/pollen-ui-angular/src/main/webapp/index.html @@ -31,9 +31,9 @@ ou $ mvn compile --> - <link rel="stylesheet/less" type="text/css" href="less/style.less" /> - <script language="javascript" type="text/javascript" src="lib/less/dist/less-1.7.3.min.js"></script> - <!--<link rel="stylesheet" type="text/css" href="css/style.css"/>--> + <!--<link rel="stylesheet/less" type="text/css" href="less/style.less" /> + <script language="javascript" type="text/javascript" src="lib/less/dist/less-1.7.3.min.js"></script>--> + <link rel="stylesheet" type="text/css" href="css/style.css"/> <script language="javascript" type="text/javascript" src="js/conf.js"></script> 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 63c7bfe..33bbf22 100644 --- a/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js +++ b/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js @@ -24,8 +24,8 @@ angular.module('pollControllers', []) }]) .controller('PollCtrl', - ['$scope', '$controller', '$sce', '$timeout', '$routeParams', '$location', 'SessionStorage', '$translate', '$route', '$q', 'Poll', - function ( $scope, $controller, $sce, $timeout, $routeParams, $location, SessionStorage, $translate, $route, $q, Poll) { + ['$scope', '$rootScope', '$controller', '$sce', '$timeout', '$routeParams', '$location', 'SessionStorage', '$translate', '$route', '$q', 'Poll', + function ( $scope, $rootScope, $controller, $sce, $timeout, $routeParams, $location, SessionStorage, $translate, $route, $q, Poll) { $scope.setTab = function (defaultValue) { if (angular.isDefined($routeParams.tab)) { return $routeParams.tab; @@ -785,27 +785,33 @@ angular.module('pollControllers', []) $scope.data.choices = choices; }).$promise; - - PollVote.query({pollId:$routeParams.pollId, permission:$routeParams.voteToken}, function (votes) { - $scope.data.votants = votes; - angular.forEach($scope.data.votants, function (vote) { - angular.forEach(vote.choice, function (choice) { - if ($scope.voteCountingIsBoolean()) { - if (choice.voteValue != null && choice.voteValue != 0.0) { - choice.voteValue = true; - } - else { - choice.voteValue = false; + if ($scope.data.poll.voteIsVisible) { + PollVote.query({pollId:$routeParams.pollId, permission:$routeParams.voteToken}, function (votes) { + $scope.data.votants = votes; + angular.forEach($scope.data.votants, function (vote) { + angular.forEach(vote.choice, function (choice) { + if ($scope.voteCountingIsBoolean()) { + if (choice.voteValue != null && choice.voteValue != 0.0) { + choice.voteValue = true; + } + else { + choice.voteValue = false; + } } - } - choice.inputType = $scope.getInputType(); + choice.inputType = $scope.getInputType(); + }) }) - }) - }); + }); + } else { + $scope.data.votants = []; + } - $q.all([$scope.pollDeferred.promise, pollChoicePromise]).then(function() { initVote(); }); + $q.all([$scope.pollDeferred.promise, pollChoicePromise]).then(function() { + initVote(); + $scope.pollDeferred.resolve(); + }); } - initPoll(); + $scope.pollDeferred.promise.then(initPoll); var initAuthor = function () { if (angular.isDefined($scope.session.user)) { @@ -848,6 +854,7 @@ angular.module('pollControllers', []) // edit vote PollVote.update({pollId:$routeParams.pollId}, sendVote, function (data) { $rootScope.$broadcast('newSuccess', 'vote.added'); + $location.url('/vote/'+$routeParams.pollId+'/'+ data.permission); }, function (error) { $scope.data.vote.restError = { voterName : error.data["voter.name"]}; }) @@ -861,6 +868,7 @@ angular.module('pollControllers', []) $scope.data.votants.push(angular.copy($scope.data.vote)); $rootScope.$broadcast('newSuccess', 'vote.added'); initVote(); + $location.url('/vote/'+$routeParams.pollId+'/'+ returnRequest.permission); }, function (error) { $scope.data.vote.restError = { voterName : error.data["voter.name"]}; }); diff --git a/pollen-ui-angular/src/main/webapp/partials/poll-link.html b/pollen-ui-angular/src/main/webapp/partials/poll-link.html index 7d20101..76402f4 100644 --- a/pollen-ui-angular/src/main/webapp/partials/poll-link.html +++ b/pollen-ui-angular/src/main/webapp/partials/poll-link.html @@ -30,7 +30,7 @@ </a> <input type="text" select-on-click value="{{globalVariables.linkVote}}" readonly class="form-control input-mini"/> </li> - <li ng-if="data.poll.id"> + <li ng-if="data.poll.resultIsVisible"> <a href="{{globalVariables.linkResult}}"> <span class="glyphicon glyphicon-stats" title="{{ 'poll.link.result' | translate }}"></span> <span class="text">{{ 'poll.link.result' | translate }}</span> diff --git a/pollen-ui-angular/src/main/webapp/partials/poll.html b/pollen-ui-angular/src/main/webapp/partials/poll.html index 04edd32..234c6fd 100644 --- a/pollen-ui-angular/src/main/webapp/partials/poll.html +++ b/pollen-ui-angular/src/main/webapp/partials/poll.html @@ -22,8 +22,8 @@ <div id="poll-content" ng-class="{'maxi-content': globalVariables.minify || !data.poll.id}"> <ul class="nav nav-tabs"> <li ng-class="{active: tab == 'vote'}" ng-show="data.poll.id"><a href="{{globalVariables.linkVote}}" ng-click="tab = 'vote'">{{ 'poll.tab.vote' | translate }}</a></li> - <li ng-class="{active: tab == 'comment'}" ng-show="data.poll.id"><a href="{{globalVariables.linkComment}}" ng-click="tab = 'comment'">{{ 'poll.tab.comment' | translate }}</a></li> - <li ng-class="{active: tab == 'result'}" ng-show="!globalVariables.create"><a href="{{globalVariables.linkResult}}" ng-click="tab = 'result'">{{ 'poll.tab.result' | translate }}</a></li> + <li ng-class="{active: tab == 'comment'}" ng-show="data.poll.commentIsVisible"><a href="{{globalVariables.linkComment}}" ng-click="tab = 'comment'">{{ 'poll.tab.comment' | translate }}</a></li> + <li ng-class="{active: tab == 'result'}" ng-show="data.poll.resultIsVisible"><a href="{{globalVariables.linkResult}}" ng-click="tab = 'result'">{{ 'poll.tab.result' | translate }}</a></li> <li ng-class="{active: tab == 'edit'}" ng-show="globalVariables.create"><a href="#/poll/create" ng-click="tab = 'edit'">{{ 'poll.tab.create' | translate }}</a></li> <li ng-class="{active: tab == 'edit'}" ng-show="data.poll.permission"><a href="{{globalVariables.linkEdit}}" ng-click="tab = 'edit'">{{ 'poll.tab.edit' | translate }}</a></li> <li ng-class="{active: tab == 'conf'}" ng-show="data.poll.permission || globalVariables.create"><a href="{{globalVariables.linkConf || '#/poll/create/conf'}}" ng-click="tab = 'conf'">{{ 'poll.tab.conf' | translate }}</a></li> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.