[pollen] branch develop updated (edd65be -> 2c020bc)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository pollen. See http://git.chorem.org/pollen.git from edd65be optimize import new 2c020bc add group result, improve UI with group result The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 2c020bcaa7b8eb4e519ee2188d7fb99858cc4e37 Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Mon Aug 18 17:03:09 2014 +0200 add group result, improve UI with group result Summary of changes: .../services/bean/GroupVoteCountingResultBean.java | 16 ++++- ...tBean.java => VoteCountingGroupResultBean.java} | 31 ++++++++- .../services/bean/VoteCountingResultBean.java | 11 +++ .../services/service/VoteCountingService.java | 3 +- pollen-ui-angular/src/main/webapp/i18n/fr.js | 6 ++ .../src/main/webapp/js/controllers/pollCtrl.js | 80 +++++++++++++++------- pollen-ui-angular/src/main/webapp/js/services.js | 4 ++ .../src/main/webapp/partials/poll-result.html | 42 +++++++++++- .../pollen/votecounting/model/GroupOfVoter.java | 1 + .../votecounting/model/VoteCountingResult.java | 10 +++ 10 files changed, 170 insertions(+), 34 deletions(-) copy pollen-services/src/main/java/org/chorem/pollen/services/bean/{VoteCountingResultBean.java => VoteCountingGroupResultBean.java} (70%) -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
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 2c020bcaa7b8eb4e519ee2188d7fb99858cc4e37 Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Mon Aug 18 17:03:09 2014 +0200 add group result, improve UI with group result --- .../services/bean/GroupVoteCountingResultBean.java | 16 ++++- ...tBean.java => VoteCountingGroupResultBean.java} | 31 ++++++++- .../services/bean/VoteCountingResultBean.java | 11 +++ .../services/service/VoteCountingService.java | 3 +- pollen-ui-angular/src/main/webapp/i18n/fr.js | 6 ++ .../src/main/webapp/js/controllers/pollCtrl.js | 80 +++++++++++++++------- pollen-ui-angular/src/main/webapp/js/services.js | 4 ++ .../src/main/webapp/partials/poll-result.html | 42 +++++++++++- .../pollen/votecounting/model/GroupOfVoter.java | 1 + .../votecounting/model/VoteCountingResult.java | 10 +++ 10 files changed, 170 insertions(+), 34 deletions(-) diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/bean/GroupVoteCountingResultBean.java b/pollen-services/src/main/java/org/chorem/pollen/services/bean/GroupVoteCountingResultBean.java index bfe5c7f..ea44313 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/bean/GroupVoteCountingResultBean.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/bean/GroupVoteCountingResultBean.java @@ -24,6 +24,10 @@ package org.chorem.pollen.services.bean; import org.chorem.pollen.votecounting.model.GroupVoteCountingResult; import org.chorem.pollen.votecounting.model.VoteCountingResult; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + /** * //FIXME * Created on 5/27/14. @@ -35,11 +39,21 @@ public class GroupVoteCountingResultBean { protected VoteCountingResultBean mainResult; + protected List<VoteCountingGroupResultBean> groupResult; + + public GroupVoteCountingResultBean() { + groupResult = new ArrayList<>(); + } + public void fromResult(GroupVoteCountingResult result) { setMainResult(result.getMainResult()); - //TODO dralagen 14/08/14 : Add group Result + for(String groupId: result.getGroupIds()) { + VoteCountingGroupResultBean voteCountingGroupResult = new VoteCountingGroupResultBean(); + voteCountingGroupResult.fromResult(result.getGroupResult(groupId), groupId); + groupResult.add(voteCountingGroupResult); + } } diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/bean/VoteCountingResultBean.java b/pollen-services/src/main/java/org/chorem/pollen/services/bean/VoteCountingGroupResultBean.java similarity index 70% copy from pollen-services/src/main/java/org/chorem/pollen/services/bean/VoteCountingResultBean.java copy to pollen-services/src/main/java/org/chorem/pollen/services/bean/VoteCountingGroupResultBean.java index d76b13b..974b06a 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/bean/VoteCountingResultBean.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/bean/VoteCountingGroupResultBean.java @@ -21,6 +21,7 @@ package org.chorem.pollen.services.bean; * #L% */ +import org.chorem.pollen.persistence.entity.VoterList; import org.chorem.pollen.votecounting.model.ChoiceScore; import org.chorem.pollen.votecounting.model.VoteCountingResult; @@ -33,7 +34,7 @@ import java.util.List; * @author Tony Chemit <chemit@codelutin.com> * @since 2.0 */ -public class VoteCountingResultBean { +public class VoteCountingGroupResultBean { /** * Results for each choice. @@ -43,11 +44,16 @@ public class VoteCountingResultBean { */ protected List<ChoiceScoreBean> scores; - public VoteCountingResultBean() { + protected int nbVotants; + + protected PollenEntityId<VoterList> groupId; + + public VoteCountingGroupResultBean() { scores = new LinkedList<>(); + groupId = new PollenEntityId<>(VoterList.class); } - public void fromResult(VoteCountingResult result) { + public void fromResult(VoteCountingResult result, String groupId) { scores.clear(); @@ -59,6 +65,9 @@ public class VoteCountingResultBean { } + setNbVotants(result.getNbVotants()); + + setGroupId(groupId); } public List<ChoiceScoreBean> getScores() { @@ -68,4 +77,20 @@ public class VoteCountingResultBean { public void setScores(List<ChoiceScoreBean> scores) { this.scores = scores; } + + public int getNbVotants() { + return nbVotants; + } + + public void setNbVotants(int nbVotants) { + this.nbVotants = nbVotants; + } + + public PollenEntityId<VoterList> getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId.setEntityId(groupId); + } } diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/bean/VoteCountingResultBean.java b/pollen-services/src/main/java/org/chorem/pollen/services/bean/VoteCountingResultBean.java index d76b13b..149a4ec 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/bean/VoteCountingResultBean.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/bean/VoteCountingResultBean.java @@ -43,6 +43,8 @@ public class VoteCountingResultBean { */ protected List<ChoiceScoreBean> scores; + protected int nbVotants; + public VoteCountingResultBean() { scores = new LinkedList<>(); } @@ -59,6 +61,7 @@ public class VoteCountingResultBean { } + setNbVotants(result.getNbVotants()); } public List<ChoiceScoreBean> getScores() { @@ -68,4 +71,12 @@ public class VoteCountingResultBean { public void setScores(List<ChoiceScoreBean> scores) { this.scores = scores; } + + public int getNbVotants() { + return nbVotants; + } + + public void setNbVotants(int nbVotants) { + this.nbVotants = nbVotants; + } } diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteCountingService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteCountingService.java index 9ecddb2..6143776 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteCountingService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteCountingService.java @@ -36,6 +36,7 @@ import org.chorem.pollen.services.bean.GroupVoteCountingResultBean; import org.chorem.pollen.services.bean.VoteBean; import org.chorem.pollen.services.bean.VoteCountingResultBean; import org.chorem.pollen.services.bean.VoteToChoiceBean; +import org.chorem.pollen.services.service.security.PermissionVerb; import org.chorem.pollen.votecounting.VoteCounting; import org.chorem.pollen.votecounting.VoteCountingFactory; import org.chorem.pollen.votecounting.VoteCountingStrategy; @@ -64,7 +65,7 @@ public class VoteCountingService extends PollenServiceSupport { public VoteCountingResultBean getMainResult(String pollId) { Preconditions.checkNotNull(pollId); - + checkPermission(PermissionVerb.readPollResult, pollId); Poll poll = getPollService().getPoll0(pollId); diff --git a/pollen-ui-angular/src/main/webapp/i18n/fr.js b/pollen-ui-angular/src/main/webapp/i18n/fr.js index 2b13096..9c79e26 100644 --- a/pollen-ui-angular/src/main/webapp/i18n/fr.js +++ b/pollen-ui-angular/src/main/webapp/i18n/fr.js @@ -92,6 +92,12 @@ var translateFR = { 'poll.result.title.zero' : 'Aucun Résultat', 'poll.result.title.one' : 'Résultat : Un votant', 'poll.result.title.other' : 'Résultat : {{nbVoter}} Votants', +'poll.result.title.group.zero' : 'Aucun Résultat', +'poll.result.title.group.one' : 'Résultat : Un group', +'poll.result.title.group.other' : 'Résultat : {{nbVoter}} Groups', +'poll.result.group.title.zero' : 'Group : {{name}}, aucun votants', +'poll.result.group.title.one' : 'Group : {{name}}, un votants', +'poll.result.group.title.other' : 'Group : {{name}}, {{nbVoter}} Votants', 'poll.config.title.creator' : 'Information du créateur', 'poll.config.title.poll' : 'Configuration globale', 'poll.config.title.choice' : 'Configuration des choix', 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 cde3338..7e3317f 100644 --- a/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js +++ b/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js @@ -1607,18 +1607,35 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr // Result of poll controller // ////////////////////////////////// -.controller('PollResultCtrl', ['$scope', '$q', '$controller', '$route', '$routeParams', 'Poll', 'PollChoice', 'PollVote', '$translate', '$filter', '$timeout', 'Page', - function ($scope, $q, $controller, $route, $routeParams, Poll, PollChoice, PollVote, $translate, $filter, $timeout, Page) { +.controller('PollResultCtrl', ['$scope', '$q', '$controller', '$route', '$routeParams', 'Poll', 'PollChoice', 'PollVote', 'PollVoterList', '$translate', '$filter', '$timeout', 'Page', + function ($scope, $q, $controller, $route, $routeParams, Poll, PollChoice, PollVote, PollVoterList, $translate, $filter, $timeout, Page) { if (angular.isUndefined($scope.globalVariables)) { $scope.globalVariables = {}; } Page.setTitle('title.poll.result'); - $scope.translateTitle = { - '0' : "{{ 'poll.result.title.zero' | translate }}", - 'one' : "{{ 'poll.result.title.one' | translate }}", - 'other' : "{{ 'poll.result.title.other' | translate:{nbVoter:data.result.nbVotant} }}" + $scope.pollDeferred.promise.then(function () { + if ($scope.data.poll.pollType == 'GROUP') { + $scope.translateTitle = { + '0' : "{{ 'poll.result.title.group.zero' | translate }}", + 'one' : "{{ 'poll.result.title.group.one' | translate }}", + 'other': "{{ 'poll.result.title.group.other' | translate:{nbVoter:data.result.nbVotants} }}" + }; + } + else { + $scope.translateTitle = { + '0' : "{{ 'poll.result.title.zero' | translate }}", + 'one' : "{{ 'poll.result.title.one' | translate }}", + 'other': "{{ 'poll.result.title.other' | translate:{nbVoter:data.result.nbVotants} }}" + }; + } + }); + + $scope.translateTitleGroup = { + '0' : "{{ 'poll.result.group.title.zero' | translate:{name:result.group.name} }}", + 'one' : "{{ 'poll.result.group.title.one' | translate:{name:result.group.name} }}", + 'other' : "{{ 'poll.result.group.title.other' | translate:{nbVoter:result.nbVotants, name:result.group.name} }}" }; $scope.plot = 'chart'; @@ -1638,24 +1655,26 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr choicesDeferred.resolve('choices load'); }); - - var votesDeferred = $q.defer(); - PollVote.query({pollId:$routeParams.pollId}, function (votes) { - $scope.data.votants = votes; - resultDeferred.promise.then(function () { - $scope.data.result.nbVotant = $scope.data.votants.length; - votesDeferred.resolve('votes load'); - }); - }); - var resultDeferred = $q.defer(); - Poll.result({pollId:$routeParams.pollId}, function (result) { - $scope.data.result = result; + $scope.pollDeferred.promise.then(function() { + if ($scope.data.poll.pollType == 'GROUP') { + // group result + Poll.groupResult({pollId: $routeParams.pollId}, function (data) { + $scope.data.result = simpleResult(data.mainResult); + $scope.data.groupResult = groupResult(data.groupResult); + }) + } + else { + Poll.result({pollId: $routeParams.pollId}, function (result) { + $scope.data.result = simpleResult(result); + }); + } + + }) + var simpleResult = function(result) { choicesDeferred.promise.then(function () { var scores = []; - $scope.data.result.scoreTotal = 0; - angular.forEach(result.scores, function(value, key) { - $scope.data.result.scoreTotal += value.scoreValue; + angular.forEach(result.scores, function (value, key) { for (var i = 0; i < $scope.data.choices.length; i++) { if ($scope.data.choices[i].id == value.choiceId) { value.choice = $scope.data.choices[i]; @@ -1684,13 +1703,22 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr }); resultDeferred.resolve('result load'); - votesDeferred.promise.then(function () { - $scope.data.result.scoresChart = scores; - }); - + result.scoresChart = scores; }); - }); + return result; + }; + + var groupResult = function(groupResult) { + angular.forEach(groupResult, function (result) { + var groupId = result.groupId; + result = simpleResult(result); + PollVoterList.get({pollId:$routeParams.pollId, voterListId:groupId}, function (voterList) { + result.group = voterList; + }); + }); + return groupResult; + }; }]) ////////////////////////////////// diff --git a/pollen-ui-angular/src/main/webapp/js/services.js b/pollen-ui-angular/src/main/webapp/js/services.js index f7ab222..de2714b 100644 --- a/pollen-ui-angular/src/main/webapp/js/services.js +++ b/pollen-ui-angular/src/main/webapp/js/services.js @@ -36,6 +36,10 @@ angular.module('pollenServices', ['ngResource']) method : 'GET', url : conf.restURL+'/polls/:pollId/results' }, + 'groupResult' : { + method : 'GET', + url : conf.restURL+'/polls/:pollId/groupResults' + }, 'add' : { method : 'POST', transformRequest : function (data) { diff --git a/pollen-ui-angular/src/main/webapp/partials/poll-result.html b/pollen-ui-angular/src/main/webapp/partials/poll-result.html index 2e8dff7..ea74e2d 100644 --- a/pollen-ui-angular/src/main/webapp/partials/poll-result.html +++ b/pollen-ui-angular/src/main/webapp/partials/poll-result.html @@ -21,14 +21,14 @@ <h1>{{data.poll.title}}</h1> -<h2> <ng-pluralize count="data.result.nbVotant" when="translateTitle"></ng-pluralize> </h2> +<h2> <ng-pluralize count="data.result.nbVotants" when="translateTitle"></ng-pluralize> </h2> -<div ng-if="data.result.nbVotant > 0"> +<div ng-if="data.result.nbVotants > 0"> <hr/> <div> <button class="btn btn-default" ng-click="plot = 'chart'"><img src="img/chart-icon.png" /></button> - <button class="btn btn-default" ng-click="plot = 'pie'"><img src="img/pie-icon.png" </button> + <button class="btn btn-default" ng-click="plot = 'pie'"><img src="img/pie-icon.png" /></button> </div> <div class="plot"> <div ng-if="plot == 'chart'"> @@ -52,4 +52,40 @@ </tr> </table> +</div> + +<div ng-if="data.groupResult"> + <div ng-repeat="result in data.groupResult"> + <hr/> + <h3> + <ng-pluralize count="result.nbVotants" when="translateTitleGroup"></ng-pluralize> + </h3> + <div> + <button class="btn btn-default" ng-click="plot = 'chart'"><img src="img/chart-icon.png" /></button> + <button class="btn btn-default" ng-click="plot = 'pie'"><img src="img/pie-icon.png" /></button> + </div> + <div class="plot"> + <div ng-if="plot == 'chart'"> + <chart data="result.scoresChart"></chart> + </div> + <div ng-if="plot == 'pie'"> + <pie data="result.scoresChart"></pie> + </div> + </div> + <hr/> + + <table class="table-result"> + <tr> + <th>{{ 'poll.result.choice' | translate }}</th> + <th>{{ 'poll.result.score' | translate }}</th> + </tr> + <tr ng-repeat="score in result.scores"> + <th> {{ score.choice.choiceValue.meta.name || (score.choice.choiceValue | date:globalVariables.dateTimeFormat) || score.choice.choiceValue }} </th> + <td> + {{score.scoreValue}} + </td> + </tr> + </table> + + </div> </div> \ No newline at end of file diff --git a/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/GroupOfVoter.java b/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/GroupOfVoter.java index c6d8225..f6b3361 100644 --- a/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/GroupOfVoter.java +++ b/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/GroupOfVoter.java @@ -107,6 +107,7 @@ public class GroupOfVoter implements Voter, Iterable<Voter> { public void setResult(VoteCountingResult result) { this.result = result; + this.result.setNbVotants(voters.size()); Collection<ChoiceScore> winners = result.getTopRanking(); for (ChoiceScore choiceScore : result.getScores()) { diff --git a/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/VoteCountingResult.java b/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/VoteCountingResult.java index 8104028..7d150d0 100644 --- a/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/VoteCountingResult.java +++ b/pollen-votecounting-api/src/main/java/org/chorem/pollen/votecounting/model/VoteCountingResult.java @@ -47,6 +47,8 @@ public class VoteCountingResult implements Serializable { */ private List<ChoiceScore> scores; + private int nbVotants; + /** * Result for each choice order by their winning rank. * @@ -90,4 +92,12 @@ public class VoteCountingResult implements Serializable { } return scoresByRank; } + + public int getNbVotants() { + return nbVotants; + } + + public void setNbVotants(int nbVotants) { + this.nbVotants = nbVotants; + } } -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm