03/04: create a page for result
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 d250985c1ebc52f74c0b0c428562fb59acda3adf Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Mon May 26 14:59:29 2014 +0200 create a page for result --- pollen-ui-angular/src/main/webapp/js/app.js | 1 + .../src/main/webapp/js/controllers/pollCtrl.js | 60 ++++++++++++++++++++-- .../src/main/webapp/partials/poll.html | 2 +- 3 files changed, 57 insertions(+), 6 deletions(-) diff --git a/pollen-ui-angular/src/main/webapp/js/app.js b/pollen-ui-angular/src/main/webapp/js/app.js index 0794019..0cc6144 100644 --- a/pollen-ui-angular/src/main/webapp/js/app.js +++ b/pollen-ui-angular/src/main/webapp/js/app.js @@ -63,6 +63,7 @@ angular.module('pollen', ['pollenServices', 'ngRoute', 'pollControllers', 'userC .when('/poll/create', {templateUrl: './partials/poll.html', controller: "PollCreateCtrl"}) .when('/poll/edit/:pollId', {templateUrl: './partials/poll.html', controller:"PollEditCtrl"}) .when('/poll/vote/:pollId', {templateUrl: './partials/poll.html', controller :"PollVoteCtrl"}) + .when('/poll/result/:pollId', {templateUrl: './partials/poll.html', controller :"PollResultCtrl"}) .when('/poll/list', {templateUrl: './partials/poll-list.html', controller :"PollListCtrl"}) .when('/poll/list/:cmd', {templateUrl: './partials/poll-list.html', controller :"PollListCtrl"}) .when('/user/register', {templateUrl: './partials/user-register.html', controller:"UserRegisterCtrl"}) 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 f19bd8e..d9eab78 100644 --- a/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js +++ b/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js @@ -75,9 +75,11 @@ angular.module('pollControllers', []) if (angular.isDefined($routeParams.pollId)) { $scope.globalVariables.linkVote = $location.protocol()+'://'+$location.host()+'/#/poll/vote/'+$routeParams.pollId; $scope.globalVariables.linkEdit = $location.protocol()+'://'+$location.host()+'/#/poll/edit/'+$routeParams.pollId; + $scope.globalVariables.linkResult = $location.protocol()+'://'+$location.host()+'/#/poll/result/'+$routeParams.pollId; if (angular.isDefined($scope.globalVariables.permission)) { $scope.globalVariables.linkEdit += '?token='+$scope.globalVariables.permission; + $scope.globalVariables.linkResult += '?token='+$scope.globalVariables.permission; } } @@ -113,7 +115,7 @@ angular.module('pollControllers', []) }]) -.controller('PollAdminCtrl', ['$scope', '$controller', '$modal', '$filter', '$timeout', '$routeParams', function ($scope, $controller, $modal, $filter, $timeout, $routeParams) { +.controller('PollAdminCtrl', ['$scope', '$controller', '$modal', '$timeout', '$routeParams', function ($scope, $controller, $modal, $timeout, $routeParams) { $controller('PollCtrl', {$scope:$scope}); if (angular.isDefined($routeParams.tab)) { @@ -184,7 +186,7 @@ angular.module('pollControllers', []) } - var PollPopChoiceCtrl = function ($scope, $filter, $modalInstance, title, choice) { + var PollPopChoiceCtrl = function ($scope, $modalInstance, title, choice) { $scope.title = title; $scope.choice = choice; @@ -363,7 +365,7 @@ angular.module('pollControllers', []) } }]) -.controller('PollVoteCtrl', ['$scope', '$q', '$filter', '$controller', '$routeParams', 'Poll', 'PollChoice', 'PollVote', function ($scope, $q, $filter, $controller, $routeParams, Poll, PollChoice, PollVote) { +.controller('PollVoteCtrl', ['$scope', '$q', '$controller', '$routeParams', 'Poll', 'PollChoice', 'PollVote', function ($scope, $q, $controller, $routeParams, Poll, PollChoice, PollVote) { $controller('PollCtrl', {$scope:$scope}); if (angular.isDefined($routeParams.tab)) { @@ -373,8 +375,6 @@ angular.module('pollControllers', []) $scope.tab = 'vote'; } - $scope.globalVariables.results = true; - var initPoll = function () { var pollPromise = Poll.get({pollId:$routeParams.pollId, permission:$scope.globalVariables.permission}, function (poll) { $scope.data.poll = poll; @@ -448,6 +448,56 @@ angular.module('pollControllers', []) } }]) +.controller('PollResultCtrl', ['$scope', '$q', '$controller', '$routeParams', 'Poll', 'PollChoice', 'PollVote', function ($scope, $q, $controller, $routeParams, Poll, PollChoice, PollVote) { + $controller('PollCtrl', {$scope:$scope}); + + if (angular.isDefined($routeParams.tab)) { + $scope.tab = $routeParams.tab; + } + else { + $scope.tab = 'result'; + } + + var pollPromise = Poll.get({pollId:$routeParams.pollId, permission:$scope.globalVariables.permission}, function (poll) { + $scope.data.poll = poll; + }).$promise; + + var choicesPromise = PollChoice.query({pollId:$routeParams.pollId}, function (choices) { + $scope.data.choices = choices; + }).$promise; + + + var votesPromise = PollVote.query({pollId:$routeParams.pollId}, function (votes) { + $scope.data.votants = votes; + angular.forEach($scope.data.votants, function (vote) { + angular.forEach(vote.choice, function (choice) { + if (choice.voteValue != null && choice.voteValue != 0.0) { + choice.voteValue = true; + } + else { + choice.voteValue = false; + } + }) + }) + }).$promise; + + $q.all([choicesPromise, votesPromise]).then(function () { + Poll.get({pollId:$routeParams.pollId, cmd:'results'}, function (result) { + $scope.data.result = result; + 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]; + i = $scope.data.choices.length; + } + } + }) + $scope.data.result.nbVotant = $scope.data.votants.length; + }); + }); + +}]) + .controller('PollListCtrl', ['$scope', '$controller', '$routeParams', 'Poll', function ($scope, $controller, $routeParams, Poll) { $controller('PollCtrl', {$scope:$scope}); diff --git a/pollen-ui-angular/src/main/webapp/partials/poll.html b/pollen-ui-angular/src/main/webapp/partials/poll.html index f77abba..eb56255 100644 --- a/pollen-ui-angular/src/main/webapp/partials/poll.html +++ b/pollen-ui-angular/src/main/webapp/partials/poll.html @@ -26,7 +26,7 @@ <ul class="nav nav-tabs"> <li ng-class="{active: tab == 'home'}"><a href="{{url}}tab=home"> <span class="glyphicon glyphicon-home"></span> </a></li> <li ng-class="{active: tab == 'vote'}" ng-show="data.poll.id"><a href="{{globalVariables.linkVote}}">Voter</a></li> - <li ng-class="{active: tab == 'result'}" ng-show="!globalVariables.create"><a href="{{url}}tab=result">Résultat</a></li> + <li ng-class="{active: tab == 'result'}" ng-show="!globalVariables.create"><a href="{{globalVariables.linkResult}}">Résultat</a></li> <li ng-class="{active: tab == 'edit'}" ng-show="globalVariables.create"><a href="#/poll/create">Créer</a></li> <li ng-class="{active: tab == 'edit'}" ng-show="data.poll.permission"><a href="{{globalVariables.linkEdit}}">Editer</a></li> <li ng-class="{active: tab == 'conf'}" ng-show="data.poll.permission || globalVariables.create"><a href="{{url}}tab=conf">Configuration</a></li> -- To stop receiving notification emails like this one, please contact Chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
Chorem.org scm