Author: garandel Date: 2014-04-30 16:52:28 +0200 (Wed, 30 Apr 2014) New Revision: 3892 Url: http://forge.chorem.org/projects/pollen/repository/revisions/3892 Log: fix vote in big poll template Modified: trunk/pollen-ui-angular/src/main/webapp/css/style.css trunk/pollen-ui-angular/src/main/webapp/js/app.js trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js trunk/pollen-ui-angular/src/main/webapp/partials/big-poll.html trunk/pollen-ui-angular/src/main/webapp/partials/inline-poll.html trunk/pollen-ui-angular/src/main/webapp/partials/poll.html Modified: trunk/pollen-ui-angular/src/main/webapp/css/style.css =================================================================== --- trunk/pollen-ui-angular/src/main/webapp/css/style.css 2014-04-30 11:26:00 UTC (rev 3891) +++ trunk/pollen-ui-angular/src/main/webapp/css/style.css 2014-04-30 14:52:28 UTC (rev 3892) @@ -172,6 +172,7 @@ } .pollBigChoice p { text-align:justify; + white-space:pre-line; } .pollBigChoice textarea { width:99%; Modified: trunk/pollen-ui-angular/src/main/webapp/js/app.js =================================================================== --- trunk/pollen-ui-angular/src/main/webapp/js/app.js 2014-04-30 11:26:00 UTC (rev 3891) +++ trunk/pollen-ui-angular/src/main/webapp/js/app.js 2014-04-30 14:52:28 UTC (rev 3892) @@ -83,7 +83,7 @@ .directive('ngExit', function ($timeout) { return function (scope, element, attrs) { element.bind("keydown keypress", function (event) { - if(event.which === 13 || event.which === 27) { + if(event.which === 27) { scope.$apply(function (){ scope.$eval(attrs.ngExit); }); Modified: trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js =================================================================== --- trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js 2014-04-30 11:26:00 UTC (rev 3891) +++ trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js 2014-04-30 14:52:28 UTC (rev 3892) @@ -95,7 +95,8 @@ if (!angular.isDefined($scope.poll.choices)) { $scope.poll = initPoll(); } - $scope.voteChoices = $scope.poll.choices; + $scope.vote = {}; + $scope.vote.choices = $scope.poll.choices; $scope.addChoice = function () { var index = $scope.poll.choices.push(initChoice()); @@ -181,31 +182,32 @@ $controller('PollCtrl', {$scope:$scope}); $scope.globalVariables.editMode = false; - $scope.$watch('voteName', function (newVal) { + $scope.$watch('vote.ame', function (newVal) { if (newVal != '') { $scope.globalVariables.errorForm = false; } }); var initVote = function () { - $scope.voteName = ""; - $scope.voteChoices = []; + $scope.vote = {}; + $scope.vote.name = ""; + $scope.vote.choices = []; for (var i = 0; i < $scope.poll.choices.length; ++i) { if ($scope.poll.choices[i].type == 'text') { - $scope.voteChoices.push({name:$scope.poll.choices[i].name, value:false}); + $scope.vote.choices.push({name:$scope.poll.choices[i].name, value:false}); } else if ($scope.poll.choices[i].type == 'date') { - $scope.voteChoices.push({name: $scope.poll.choices[i].date , value:false}); + $scope.vote.choices.push({name: $scope.poll.choices[i].date , value:false}); } } } initVote(); - $scope.vote = function () { - if ($scope.voteName != '') { + $scope.voter = function () { + if ($scope.vote.name != '') { var data = {}; - data.name = $scope.voteName; - data.choices = angular.copy($scope.voteChoices); + data.name = $scope.vote.name; + data.choices = angular.copy($scope.vote.choices); if (!angular.isDefined($scope.poll.votants)) { $scope.poll.votants = []; } Modified: trunk/pollen-ui-angular/src/main/webapp/partials/big-poll.html =================================================================== --- trunk/pollen-ui-angular/src/main/webapp/partials/big-poll.html 2014-04-30 11:26:00 UTC (rev 3891) +++ trunk/pollen-ui-angular/src/main/webapp/partials/big-poll.html 2014-04-30 14:52:28 UTC (rev 3892) @@ -24,7 +24,7 @@ <div ng-repeat="choice in poll.choices" class="row pollBigChoice"> <div class="col-sm-10"> - <div ng-click="showDesc = !showDesc" > + <div ng-click="showChoiceDesc = !showChoiceDesc" > <div ng-if="choice.type == 'text'"> <h3 edit-me="showEdit" ng-hide="showEdit" ng-mouseenter="showEditHover = true" ng-mouseleave="showEditHover = false"> <button class="btn btn-default" ng-if="!globalVariables.voted && globalVariables.editMode" ng-show="showEditHover" ng-click="editChoice(choice)">...</button> @@ -45,11 +45,11 @@ </h3> </div> </div> - <p collapse="!globalVariables.editMode && !showDesc" edit-me="showEditDesc" ng-hide="showEditDesc">{{choice.description}}</p> - <p ng-show="globalVariables.editMode && showEditDesc"><textarea ng-model="choice.description" focus-me="showEditDesc" ng-exit="showEditDesc = false" cols="80" rows="8"></textarea></p> + <p collapse="!globalVariables.editMode && !showChoiceDesc" edit-me="showEditChoiceDesc" ng-hide="showEditChoiceDesc">{{choice.description}}</p> + <p ng-show="globalVariables.editMode && showEditChoiceDesc"><textarea ng-model="choice.description" focus-me="showEditChoiceDesc" ng-exit="showEditChoiceDesc = false" cols="80" rows="8"></textarea></p> </div> <div class="col-sm-2 pollChoiceInput"> - <input type="checkbox" ng-model="choice.value"/> + <input type="checkbox" ng-model="vote.choices[$index].value"/> </div> </div> <div class="row pollBigChoice" ng-if="globalVariables.editMode"> @@ -62,6 +62,6 @@ </div> <div style="float:right; margin-top:5px;"> - <input type="text" placeholder="Votre Nom" ng-model="voteName"/> - <button class="btn btn-primary" >Voter</button> + <input type="text" placeholder="Votre Nom" ng-model="vote.name"/> + <button class="btn btn-primary" ng-click="voter()">Voter</button> </div> \ No newline at end of file Modified: trunk/pollen-ui-angular/src/main/webapp/partials/inline-poll.html =================================================================== --- trunk/pollen-ui-angular/src/main/webapp/partials/inline-poll.html 2014-04-30 11:26:00 UTC (rev 3891) +++ trunk/pollen-ui-angular/src/main/webapp/partials/inline-poll.html 2014-04-30 14:52:28 UTC (rev 3892) @@ -44,12 +44,12 @@ </tr> <tr> - <td class="pollChoice"> <input type="text" class="form-control" placeholder="votre nom" ng-model="voteName" /> </td> - <td ng-repeat="choice in voteChoices" class="pollChoice"> + <td class="pollChoice"> <input type="text" class="form-control" placeholder="votre nom" ng-model="vote.name" /> </td> + <td ng-repeat="choice in vote.choices" class="pollChoice"> <input type="checkbox" name="{{choice.name}}" ng-model="choice.value"/> </td> <td> - <input class="btn btn-primary btn-large" type="button" value="Vote" ng-click="vote()" /> + <input class="btn btn-primary btn-large" type="button" value="Vote" ng-click="voter()" /> </td> </tr> Modified: trunk/pollen-ui-angular/src/main/webapp/partials/poll.html =================================================================== --- trunk/pollen-ui-angular/src/main/webapp/partials/poll.html 2014-04-30 11:26:00 UTC (rev 3891) +++ trunk/pollen-ui-angular/src/main/webapp/partials/poll.html 2014-04-30 14:52:28 UTC (rev 3892) @@ -12,7 +12,7 @@ <h1 ng-show="showEditTitle"><input type="text" class="form-control" focus-me="showEditTitle" ng-model="poll.title" ng-exit="showEditTitle = false" required/></h1> </div> - <div ng-hide="showEditDesc" class="pollDesc" edit-me="showEditDesc"> + <div ng-hide="showEditDesc || !globalVariables.editMode && !poll.description " class="pollDesc" edit-me="showEditDesc"> <div ng-bind-html="toHTML(poll.description || 'Description (Facultatif). Ce cadre disparait si aucune description n\'est mise')"></div> </div> <div ng-show="showEditDesc" class="pollDesc " ng-exit="showEditDesc = false;">