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 e94a143742a009504f00d6cec5ca32998bcbb127 Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Wed Jul 30 16:27:12 2014 +0200 auto complet input vote and old vote when you add choice --- .../src/main/webapp/js/controllers/pollCtrl.js | 42 ++++++++++++++-------- 1 file changed, 28 insertions(+), 14 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 7da43e7..bd9b1f6 100644 --- a/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js +++ b/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js @@ -209,19 +209,19 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr return false; } - $scope.getChoiceValue = function (choiceValue) { + $scope.getVoteValue = function (voteValue) { if ($scope.voteCountingIsBoolean()) { - return (choiceValue)?true:false; + return (voteValue)?true:false; } else { - if (choiceValue === true) { + if (voteValue === true) { return 1.0; } - else if (choiceValue === false) { + else if (voteValue === false) { return 0.0; } else { - return choiceValue; + return voteValue; } } } @@ -272,7 +272,7 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr if (newVal !== undefined) { angular.forEach($scope.data.votants, function(votant, key) { angular.forEach(votant.choice, function (choice) { - choice.voteValue = $scope.getChoiceValue(choice.voteValue); + choice.voteValue = $scope.getVoteValue(choice.voteValue); }); }); } @@ -375,6 +375,15 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr delete choice.restError; choice.id = data.id; choice.permission = data.permission; + + // add new input in choice input + $scope.data.vote.choice.push({choiceId: data.id, voteValue:$scope.getVoteValue('')}); + + // add null in vote + angular.forEach($scope.data.votants, function (voter) { + voter.choice.push({choiceId: $scope.data.choices[i].id, voteValue : $scope.getVoteValue(null)}); + }); + $rootScope.$broadcast('newSuccess', 'poll.saved'); }, function (error) { choice.restError = error.data; @@ -994,7 +1003,7 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr angular.forEach(vote.choice, function (choice) { choice.voteValue = $scope.getChoiceValue(choice.voteValue); }) - }) + }); }); }; $scope.pollDeferred.promise.then(function () { @@ -1074,13 +1083,18 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr }).$promise; 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) { - choice.voteValue = $scope.getChoiceValue(choice.voteValue); - }) - }) + pollChoicePromise.then(function () { + PollVote.query({pollId:$routeParams.pollId, permission:$routeParams.voteToken}, function (votes) { + $scope.data.votants = votes; + angular.forEach($scope.data.votants, function (voter) { + angular.forEach(voter.choice, function (choice) { + choice.voteValue = $scope.getVoteValue(choice.voteValue); + }); + for (var i = voter.choice.length; i < $scope.data.choices.length; ++i) { + voter.choice.push({choiceId: $scope.data.choices[i].id, voteValue : $scope.getVoteValue(null)}); + } + }); + }); }); } else { $scope.data.votants = []; -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.