[pollen] branch develop updated (27ffc1f -> 269a05b)
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 27ffc1f hover alert reset timeout new 28a498b add permission addChoice, check choice type DATE no fail if choiceValue == null fix pollBeanFunction new 5deacbb can edit and add choice in page of vote new e94a143 auto complet input vote and old vote when you add choice new 59e2c4b Improve permission for delete choice new 269a05b Merge branch 'feature/addChoiceInVote' into develop The 5 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 269a05bffec74bd2cf9ad3e84f9bc20e76b63d5e Merge: 27ffc1f 59e2c4b Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Wed Jul 30 17:23:32 2014 +0200 Merge branch 'feature/addChoiceInVote' into develop commit 59e2c4b70cf1a9e9a8d1327195ab8693aa6049f9 Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Wed Jul 30 17:05:14 2014 +0200 Improve permission for delete choice 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 commit 5deacbbbec104a36ae359d8cb6599b6d2f6f37bd Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Wed Jul 30 15:32:46 2014 +0200 can edit and add choice in page of vote commit 28a498bdfe832c1fd4136f58e4e4a0f063473288 Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Wed Jul 30 15:30:00 2014 +0200 add permission addChoice, check choice type DATE no fail if choiceValue == null fix pollBeanFunction Summary of changes: .../chorem/pollen/services/bean/ChoiceBean.java | 10 + .../pollen/services/service/ChoiceService.java | 14 +- .../pollen/services/service/PollService.java | 16 - .../services/service/security/SecurityService.java | 27 +- .../src/main/webapp/js/controllers/pollCtrl.js | 359 ++++++++++++--------- .../src/main/webapp/partials/inline-poll.html | 16 +- .../src/main/webapp/partials/poll-popupChoice.html | 2 +- 7 files changed, 245 insertions(+), 199 deletions(-) -- 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 28a498bdfe832c1fd4136f58e4e4a0f063473288 Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Wed Jul 30 15:30:00 2014 +0200 add permission addChoice, check choice type DATE no fail if choiceValue == null fix pollBeanFunction --- .../chorem/pollen/services/service/ChoiceService.java | 12 ++++-------- .../org/chorem/pollen/services/service/PollService.java | 16 ---------------- .../services/service/security/SecurityService.java | 4 ++++ 3 files changed, 8 insertions(+), 24 deletions(-) diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java index d8dcf14..b081f6a 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java @@ -114,7 +114,7 @@ public class ChoiceService extends PollenServiceSupport { checkNotNull(pollId); checkNotNull(choice); checkIsNotPersisted(choice); - checkPermission(PermissionVerb.editPoll, pollId); + checkPermission(PermissionVerb.addChoice, pollId); Poll poll = getPollService().getPoll0(pollId); List<Choice> existingChoices = getChoiceDao().findAll(poll); @@ -323,17 +323,13 @@ public class ChoiceService extends PollenServiceSupport { Date choiceDate = null; if (choice.getChoiceValue() != null) { choiceDate = new Date(Long.parseLong(choice.getChoiceValue())); - } - - boolean dateNotBlank = checkNotBlank(errors, - "choiceValue", - String.valueOf(choiceDate), - l(getLocale(), "pollen.error.choice.choiceDateEmpty")); - if (dateNotBlank) { boolean dateAdded = choiceNames.add(String.valueOf(choiceDate.getTime())); check(errors, "choiceValue", dateAdded, l(getLocale(), "pollen.error.choice.choiceDateExist")); } + else { + check(errors, "choiceValue", false, l(getLocale(), "pollen.error.choice.choiceDateEmpty")); + } break; diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java index 7c28055..409a4f2 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java @@ -62,22 +62,6 @@ public class PollService extends PollenServiceSupport { input.setResultIsVisible(isPermitted(PermissionVerb.readPollResult, input.getEntityId())); - if (input.isChoiceAddAllowed()) { - Date endDate = input.getEndChoiceDate(); - if (endDate == null) { - endDate = input.getEndDate(); - if (endDate == null) { - input.setAddChoiceAllowed(true); - } - } - - if (endDate != null) { - input.setAddChoiceAllowed(endDate.compareTo(serviceContext.getNow()) > 0); - } - } else { - input.setAddChoiceAllowed(false); - } - return input; } }; diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityService.java index 6ae0d90..2fb04c8 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityService.java @@ -382,6 +382,10 @@ public class SecurityService extends PollenServiceSupport { permissions.add(createSubjectPermission(PermissionVerb.readPollResult, poll)); } + if (poll.isChoiceAddAllowed()) { + permissions.add(createSubjectPermission(PermissionVerb.addChoice, poll)); + } + // add choices permissions List<Choice> choices = getChoiceDao().forPollEquals(poll).findAll(); -- 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 5deacbbbec104a36ae359d8cb6599b6d2f6f37bd Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Wed Jul 30 15:32:46 2014 +0200 can edit and add choice in page of vote --- .../src/main/webapp/js/controllers/pollCtrl.js | 305 ++++++++++++--------- .../src/main/webapp/partials/inline-poll.html | 16 +- 2 files changed, 179 insertions(+), 142 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 f6d6b4f..7da43e7 100644 --- a/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js +++ b/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js @@ -26,6 +26,10 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr Poll.skeletonNew(); }]) +////////////////////////////////// +// Poll global controller // +////////////////////////////////// + .controller('PollCtrl', ['$scope', '$rootScope', '$controller', '$sce', '$timeout', '$routeParams', '$location', 'SessionStorage', '$translate', '$route', '$q', 'Poll', 'PollenResource', 'Page', 'DateFormat', function ( $scope, $rootScope, $controller, $sce, $timeout, $routeParams, $location, SessionStorage, $translate, $route, $q, Poll, PollenResource, Page, DateFormat) { @@ -325,72 +329,20 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr }]) -.controller('PollAdminCtrl', ['$scope', '$rootScope', '$controller', '$modal', '$timeout', '$routeParams', 'Poll', - function ($scope, $rootScope, $controller, $modal, $timeout, $routeParams, Poll) { - if (angular.isUndefined($scope.globalVariables)) { - $scope.globalVariables = {}; - } - - $scope.globalVariables.editMode = true; - //$scope.globalVariables.voted = angular.isDefined($scope.data.votants); - $scope.globalVariables.lastType = 'TEXT'; - $scope.globalVariables.lastDate = null; - $scope.restError = {}; - - //////////////////////////////// - //// VOTER LIST ///// - //////////////////////////////// - - var newMember = function () { - return {name:'', email:'', weight:1.0}; - } - - var newGroup = function () { - var members = []; - for (var j = 0; j < 3; j++) { - members.push(newMember()); - } - return {group:{name:'', weight:1.0}, members:members} - } - - $scope.data.voterList = []; - $scope.data.voterList.push(newGroup()); - - $timeout(function () { - $scope.$watch('data.poll.pollType', function (newVal, oldVal) { - if (newVal != oldVal && newVal == 'RESTRICTED') { - var listMember = []; - for (var i = 0; i < $scope.data.voterList.length; i++) { - for (var j = 0; j < $scope.data.voterList[i].members.length; j++) { - // check if not a empty line - if ($scope.data.voterList[i].members[j].email != '' || $scope.data.voterList[i].members[j].name != '') { - listMember.push($scope.data.voterList[i].members[j]); - } - } - } - // get the first group - $scope.data.voterList = $scope.data.voterList.splice(0,1); +////////////////////////////////// +// Admin choice controller // +////////////////////////////////// - // check if one voter is enter in one group - if (listMember.length > 0) { - $scope.data.voterList[0].members = listMember; - } - } - }); - }); - - $scope.addVoter = function (index) { - $scope.data.voterList[index].members.push(newMember()); - } +.controller('PollAdminChoiceCtrl', ['$scope', '$rootScope', '$modal', '$routeParams', 'PollChoice', + function ($scope, $rootScope, $modal, $routeParams, PollChoice) { - $scope.addGroup = function () { - $scope.data.voterList.push(newGroup()); + if (angular.isUndefined($scope.globalVariables)) { + $scope.globalVariables = {}; } - //////////////////////////////// - //// CHOICE ///// - //////////////////////////////// + $scope.globalVariables.lastType = 'TEXT'; + $scope.globalVariables.lastDate = null; var initChoice = function () { return { @@ -408,21 +360,82 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr popupChoice(choice, 'Ajout d\'un Choix', $scope.callBackAddChoice); } - $scope.callBackAddChoice = function (choice) {} - $scope.editChoice = function (choice) { popupChoice(choice, 'Edition du Choix', $scope.callBackEditChoice); } - $scope.callBackEditChoice = function (choice) {} + + $scope.callBackAddChoice = function (choice) { + if (angular.isDefined($routeParams.pollId)) { + var saveChoice = angular.copy(choice); + + saveChoice = $scope.preSendChoice(saveChoice); + + PollChoice.add({pollId:$routeParams.pollId, permission:$scope.globalVariables.pollToken}, saveChoice, function (data) { + delete choice.restError; + choice.id = data.id; + choice.permission = data.permission; + $rootScope.$broadcast('newSuccess', 'poll.saved'); + }, function (error) { + choice.restError = error.data; + }); + } + } + + $scope.callBackEditChoice = function (choice) { + if (angular.isDefined($routeParams.pollId)) { + var saveChoice = angular.copy(choice); + + saveChoice = $scope.preSendChoice(saveChoice); + + PollChoice.update({pollId:$routeParams.pollId, permission:choice.permission}, saveChoice, function() { + delete choice.restError; + $rootScope.$broadcast('newSuccess', 'poll.saved'); + }, function (error) { + choice.restError = error.data; + }); + } + } $scope.deleteChoice = function (choice) { + if (angular.isDefined($routeParams.pollId)) { + PollChoice.remove({pollId:$routeParams.pollId, permission:$scope.globalVariables.pollToken, choiceId: choice.id}, function () { + $rootScope.$broadcast('newSuccess', 'poll.saved'); + deleteChoice(choice); + }, function (error) { + if (error.status == 400) { + angular.extend($scope.restError, error.data); + if (angular.isDefined(error.data.choice)) { + $rootScope.$broadcast('newError', error.data.choice[0]); + } + } + else { + deleteChoice(choice); + } + }); + } else { + deleteChoice(choice); + } + }; + + var deleteChoice = function (choice) { var index = $scope.data.choices.indexOf(choice); if (index > -1) { $scope.data.choices.splice(index,1); } } + $scope.saveChoice = function (choice) { + if (angular.isDefined(choice)) { + if (angular.isDefined(choice.id) && choice.id != null) { + $scope.callBackEditChoice(choice); + } + else { + $scope.callBackAddChoice(choice); + } + } + } + var popupChoice = function (choiceEdit, title, callBack) { var choice = angular.copy(choiceEdit); @@ -546,12 +559,74 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr } - $scope.printCheckbox= function (value) { - if (value) { - return 'Oui'; - } else { - return 'Non'; +}]) + + +////////////////////////////////// +// Admin poll controller // +////////////////////////////////// + +.controller('PollAdminCtrl', ['$scope', '$rootScope', '$controller', '$timeout', '$routeParams', 'Poll', + function ($scope, $rootScope, $controller, $timeout, $routeParams, Poll) { + $controller('PollAdminChoiceCtrl', {$scope:$scope}); + + + if (angular.isUndefined($scope.globalVariables)) { + $scope.globalVariables = {}; + } + + $scope.globalVariables.editMode = true; + $scope.restError = {}; + + //////////////////////////////// + //// VOTER LIST ///// + //////////////////////////////// + + var newMember = function () { + return {name:'', email:'', weight:1.0}; + } + + var newGroup = function () { + var members = []; + for (var j = 0; j < 3; j++) { + members.push(newMember()); } + return {group:{name:'', weight:1.0}, members:members} + } + + $scope.data.voterList = []; + $scope.data.voterList.push(newGroup()); + + $timeout(function () { + $scope.$watch('data.poll.pollType', function (newVal, oldVal) { + if (newVal != oldVal && newVal == 'RESTRICTED') { + var listMember = []; + for (var i = 0; i < $scope.data.voterList.length; i++) { + for (var j = 0; j < $scope.data.voterList[i].members.length; j++) { + // check if not a empty line + if ($scope.data.voterList[i].members[j].email != '' || $scope.data.voterList[i].members[j].name != '') { + listMember.push($scope.data.voterList[i].members[j]); + } + } + } + + // get the first group + $scope.data.voterList = $scope.data.voterList.splice(0,1); + + // check if one voter is enter in one group + if (listMember.length > 0) { + $scope.data.voterList[0].members = listMember; + } + } + }); + }); + + $scope.addVoter = function (index) { + $scope.data.voterList[index].members.push(newMember()); + } + + $scope.addGroup = function () { + $scope.data.voterList.push(newGroup()); } //////////////////////////////// @@ -586,6 +661,11 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr }); }]) + +////////////////////////////////// +// Admin create poll controller // +////////////////////////////////// + .controller('PollCreateCtrl', ['$scope', '$rootScope', '$controller', '$location', 'Poll', 'SessionStorage', 'PollVoterList', 'Page', function ( $scope, $rootScope, $controller, $location, Poll, SessionStorage, PollVoterList, Page) { $controller('PollCtrl', {$scope:$scope}); @@ -664,6 +744,10 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr }]) +////////////////////////////////// +// Admin edit poll controller // +////////////////////////////////// + .controller('PollEditCtrl', ['$scope', '$rootScope', '$controller', '$routeParams', '$location', '$timeout', '$translate', 'Poll', 'PollChoice', 'PollVote', 'PollVoterList', 'PollVoterListMember', 'FavoriteList', 'SessionStorage', 'Page', function ( $scope, $rootScope, $controller, $routeParams, $location, $timeout, $translate, Poll, PollChoice, PollVote, PollVoterList, PollVoterListMember, FavoriteList, SessionStorage, Page) { $controller('PollAdminCtrl', {$scope:$scope}); @@ -671,71 +755,6 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr Page.setTitle('title.poll.edit'); //////////////////////////////// - //// CHOICE ///// - //////////////////////////////// - - $scope.callBackAddChoice = function (choice) { - var saveChoice = angular.copy(choice); - - saveChoice = $scope.preSendChoice(saveChoice); - - PollChoice.add({pollId:$routeParams.pollId, permission:$scope.globalVariables.pollToken}, saveChoice, function (data) { - delete choice.restError; - choice.id = data.id; - $rootScope.$broadcast('newSuccess', 'poll.saved'); - }, function (error) { - choice.restError = error.data; - }); - } - - $scope.callBackEditChoice = function (choice) { - var saveChoice = angular.copy(choice); - - saveChoice = $scope.preSendChoice(saveChoice); - - PollChoice.update({pollId:$routeParams.pollId, permission:$scope.globalVariables.pollToken}, saveChoice, function() { - delete choice.restError; - $rootScope.$broadcast('newSuccess', 'poll.saved'); - }, function (error) { - choice.restError = error.data; - }); - } - - $scope.deleteChoice = function (choice) { - PollChoice.remove({pollId:$routeParams.pollId, permission:$scope.globalVariables.pollToken, choiceId: choice.id}, function () { - $rootScope.$broadcast('newSuccess', 'poll.saved'); - var index = $scope.data.choices.indexOf(choice); - if (index > -1) { - $scope.data.choices.splice(index,1); - } - }, function (error) { - if (error.status == 400) { - angular.extend($scope.restError, error.data); - if (angular.isDefined(error.data.choice)) { - $rootScope.$broadcast('newError', error.data.choice[0]); - } - } - else { - var index = $scope.data.choices.indexOf(choice); - if (index > -1) { - $scope.data.choices.splice(index,1); - } - } - }); - }; - - $scope.saveChoice = function (choice) { - if (angular.isDefined(choice)) { - if (angular.isDefined(choice.id) && choice.id != null) { - $scope.callBackEditChoice(choice); - } - else { - $scope.callBackAddChoice(choice); - } - } - } - - //////////////////////////////// //// VOTER LIST ///// //////////////////////////////// @@ -1027,8 +1046,14 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr }]) +////////////////////////////////// +// Vote controller // +////////////////////////////////// + .controller('PollVoteCtrl', ['$scope', '$rootScope', '$q', '$controller', '$routeParams', 'Poll', 'PollChoice', 'PollVote', '$translate', '$location', 'Page', function ($scope, $rootScope, $q, $controller, $routeParams, Poll, PollChoice, PollVote, $translate, $location, Page) { + $controller('PollAdminChoiceCtrl', {$scope:$scope}); + if (angular.isUndefined($scope.globalVariables)) { $scope.globalVariables = {}; } @@ -1204,6 +1229,10 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr }]) +////////////////////////////////// +// Comment controller // +////////////////////////////////// + .controller('PollCommentCtrl', ['$scope', '$rootScope', '$controller', '$routeParams', 'Poll', 'PollComment', '$translate', '$timeout', '$location', 'Page', function ( $scope, $rootScope, $controller, $routeParams, Poll, PollComment, $translate, $timeout, $location, Page) { @@ -1370,6 +1399,10 @@ 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) { if (angular.isUndefined($scope.globalVariables)) { @@ -1456,6 +1489,10 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr }]) +////////////////////////////////// +// List of poll controller // +////////////////////////////////// + .controller('PollListCtrl', ['$scope', '$rootScope', '$controller', '$routeParams', '$timeout', '$location', '$sce', '$q', 'Poll', 'Page', function ($scope, $rootScope, $controller, $routeParams, $timeout, $location, $sce, $q, Poll, Page) { diff --git a/pollen-ui-angular/src/main/webapp/partials/inline-poll.html b/pollen-ui-angular/src/main/webapp/partials/inline-poll.html index 82bca7b..730e339 100644 --- a/pollen-ui-angular/src/main/webapp/partials/inline-poll.html +++ b/pollen-ui-angular/src/main/webapp/partials/inline-poll.html @@ -27,22 +27,22 @@ </td> <td ng-repeat="choice in data.choices" class="pollChoice pollAnim" ng-mouseenter="showEditHover = true" ng-mouseleave="showEditHover = false"> <div ng-if="choice.choiceType == 'TEXT'" edit-me="showEdit" > - <div ng-hide="showEdit && !globalVariables.voted" class="fixe-input" title="{{choice.description}}"> + <div ng-hide="showEdit && ((data.poll.addChoiceAllowed && choice.permission) || globalVariables.editMode)" class="fixe-input" title="{{choice.description}}"> {{ choice.choiceValue || ('poll.edit' | translate) }} <info-error error="choice.restError.choiceValue[0]" data="choice.choiceValue"></info-error> - <input type="button" class="btn btn-default" ng-if="!globalVariables.voted && globalVariables.editMode" ng-show="showEditHover" ng-click="editChoice(choice)" value="..."/></div> - <div ng-show="showEdit && !globalVariables.voted"> + <input type="button" class="btn btn-default" ng-if="(data.poll.choiceAddAllowed && choice.permission) || globalVariables.editMode" ng-show="showEditHover" ng-click="editChoice(choice)" value="..."/></div> + <div ng-show="showEdit && ((data.poll.addChoiceAllowed && choice.permission) || globalVariables.editMode)"> <input type="text" class="form-control" ng-model="choice.choiceValue" focus-me="showEdit" ng-exit="showEdit = false;" auto-save="saveChoice(choice)" required/> <input type="button" class="btn btn-default" data-toggle="modal" data-target="#popupAddChoice" ng-click="editChoice(choice)" value="..."/> </div> </div> <div ng-if="choice.choiceType == 'DATE'" edit-me="showEdit" > - <div ng-hide="!globalVariables.voted && showEdit || isOpen" class="fixe-input" title="{{choice.description}}"> + <div ng-hide="showEdit && (data.poll.addChoiceAllowed && choice.permission || globalVariables.editMode)" class="fixe-input" title="{{choice.description}}"> {{ (choice.choiceValue | date:globalVariables.dateTimeFormat) || ('poll.edit' | translate) }} <info-error error="choice.restError.choiceValue[0]" data="choice.choiceValue"></info-error> - <input type="button" class="btn btn-default" ng-if="!globalVariables.voted && globalVariables.editMode" ng-show="showEditHover" ng-click="editChoice(choice)" value="..."/> + <input type="button" class="btn btn-default" ng-if="(data.poll.choiceAddAllowed && choice.permission) || globalVariables.editMode" ng-show="showEditHover" ng-click="editChoice(choice)" value="..."/> </div> - <div ng-show="!globalVariables.voted && showEdit" > + <div ng-show="showEdit && (data.poll.choiceAddAllowed && choice.permission || globalVariables.editMode)" > <datetimepicker ng-model="choice.choiceValue" focus="showEdit" ng-exit="showEdit = false" ng-save="saveChoice(choice)"></datetimepicker> <input type="button" class="btn btn-default" data-toggle="modal" data-target="#popupAddChoice" ng-click="editChoice(choice)" value="..."/> </div> @@ -51,7 +51,7 @@ <div class="fixe-input" title="{{choice.description}}"> {{choice.choiceValue.meta.name}} <info-error error="choice.restError.choiceValue[0]" data="choice.choiceValue"></info-error> - <input type="button" class="btn btn-default" ng-if="!globalVariables.voted && globalVariables.editMode" ng-show="showEditHover" ng-click="editChoice(choice)" value="..."/> + <input type="button" class="btn btn-default" ng-if="data.poll.choiceAddAllowed && choice.permission || globalVariables.editMode" ng-show="showEditHover" ng-click="editChoice(choice)" value="..."/> <br/> <print-resource image="choice.choiceValue.id" name="choice.choiceValue.meta.name"></print-resource> @@ -60,7 +60,7 @@ </div> </td> - <td ng-if="!globalVariables.voted && globalVariables.editMode"><button class="btn btn-default btn-large" ng-click="addChoice()"> <span class="glyphicon glyphicon-plus"></span> </button></td> + <td ng-if="data.poll.choiceAddAllowed || globalVariables.editMode"><button class="btn btn-default btn-large" ng-click="addChoice()"> <span class="glyphicon glyphicon-plus"></span> </button></td> </tr> <!-- end print choice --> -- 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 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>.
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 59e2c4b70cf1a9e9a8d1327195ab8693aa6049f9 Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Wed Jul 30 17:05:14 2014 +0200 Improve permission for delete choice --- .../chorem/pollen/services/bean/ChoiceBean.java | 10 ++++++++++ .../pollen/services/service/ChoiceService.java | 2 ++ .../services/service/security/SecurityService.java | 23 ++++++++++++++-------- .../src/main/webapp/js/controllers/pollCtrl.js | 16 ++++----------- .../src/main/webapp/partials/poll-popupChoice.html | 2 +- 5 files changed, 32 insertions(+), 21 deletions(-) diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/bean/ChoiceBean.java b/pollen-services/src/main/java/org/chorem/pollen/services/bean/ChoiceBean.java index 5b2ffb4..b469956 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/bean/ChoiceBean.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/bean/ChoiceBean.java @@ -43,6 +43,8 @@ public class ChoiceBean extends PollenBean<Choice> { protected String description; + protected boolean choiceIsDeletable; + public ChoiceBean() { super(Choice.class); } @@ -164,4 +166,12 @@ public class ChoiceBean extends PollenBean<Choice> { public void setChoiceOrder(int choiceOrder) { this.choiceOrder = choiceOrder; } + + public boolean isChoiceIsDeletable() { + return choiceIsDeletable; + } + + public void setChoiceIsDeletable(boolean choiceIsDeletable) { + this.choiceIsDeletable = choiceIsDeletable; + } } diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java index b081f6a..c6ce328 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java @@ -56,6 +56,8 @@ public class ChoiceService extends PollenServiceSupport { input.setChoiceValue(getPollenResourceService().getReduceIdByTopiaId(input.getChoiceValue())); } + input.setChoiceIsDeletable(isPermitted(PermissionVerb.deleteChoice, input.getEntityId())); + return input; } }; diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityService.java index 2fb04c8..c2e3342 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityService.java @@ -463,14 +463,6 @@ public class SecurityService extends PollenServiceSupport { // creator has all rights on the poll, choices and comments, but can only read votes permissions.add(createWildcardSubjectPermission(poll)); - // add choices permissions - - List<Choice> choices = getChoiceDao().forPollEquals(poll).findAll(); - if (CollectionUtils.isNotEmpty(choices)) { - for (Choice choice : choices) { - permissions.add(createWildcardSubjectPermission(choice)); - } - } // add comment permissions @@ -490,6 +482,21 @@ public class SecurityService extends PollenServiceSupport { } } + // add choices permissions + + List<Choice> choices = getChoiceDao().forPollEquals(poll).findAll(); + if (CollectionUtils.isNotEmpty(choices)) { + for (Choice choice : choices) { + if (CollectionUtils.isEmpty(votes)) { + permissions.add(createWildcardSubjectPermission(choice)); + } + else { + // can only read or edit the choice because have vote + permissions.add(createSubjectPermission(PermissionVerb.readChoice, choice)); + permissions.add(createSubjectPermission(PermissionVerb.editChoice, choice)); + } + } + } } return permissions; 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 bd9b1f6..3a14bdf 100644 --- a/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js +++ b/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js @@ -347,7 +347,8 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr var initChoice = function () { return { choiceType : $scope.globalVariables.lastType, - choiceValue : '' + choiceValue : '', + choiceIsDeletable: true }; } @@ -407,7 +408,7 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr } $scope.deleteChoice = function (choice) { - if (angular.isDefined($routeParams.pollId)) { + if (angular.isDefined($routeParams.pollId) && angular.isDefined(choice.id)) { PollChoice.remove({pollId:$routeParams.pollId, permission:$scope.globalVariables.pollToken, choiceId: choice.id}, function () { $rootScope.$broadcast('newSuccess', 'poll.saved'); deleteChoice(choice); @@ -994,16 +995,7 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr ch = $scope.postReceiveChoice(ch); }) $scope.data.vote = {}; - $scope.data.vote.choice = $scope.data.choices; - }); - - PollVote.query({pollId:$routeParams.pollId}, 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); - }) - }); + $scope.data.vote.choice = angular.copy($scope.data.choices); }); }; $scope.pollDeferred.promise.then(function () { diff --git a/pollen-ui-angular/src/main/webapp/partials/poll-popupChoice.html b/pollen-ui-angular/src/main/webapp/partials/poll-popupChoice.html index 07c7d20..86f7dd8 100644 --- a/pollen-ui-angular/src/main/webapp/partials/poll-popupChoice.html +++ b/pollen-ui-angular/src/main/webapp/partials/poll-popupChoice.html @@ -69,7 +69,7 @@ </div> </div> <div class="modal-footer"> - <button type="button" class="btn btn-danger" ng-click="deleteChoice(choice)"><span class="glyphicon glyphicon-trash"></span> Supprimer</button> + <button type="button" class="btn btn-danger" ng-if="choice.choiceIsDeletable" ng-click="deleteChoice(choice)"><span class="glyphicon glyphicon-trash"></span> Supprimer</button> <button type="button" class="btn btn-default" ng-click="cancelChoice()"><span class="glyphicon glyphicon-remove"></span> Annuler</button> <button type="button" class="btn btn-primary" ng-click="saveChoice()"><span class="glyphicon glyphicon-save"></span> Sauvegarder</button> </div> -- 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 269a05bffec74bd2cf9ad3e84f9bc20e76b63d5e Merge: 27ffc1f 59e2c4b Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Wed Jul 30 17:23:32 2014 +0200 Merge branch 'feature/addChoiceInVote' into develop .../chorem/pollen/services/bean/ChoiceBean.java | 10 + .../pollen/services/service/ChoiceService.java | 14 +- .../pollen/services/service/PollService.java | 16 - .../services/service/security/SecurityService.java | 27 +- .../src/main/webapp/js/controllers/pollCtrl.js | 359 ++++++++++++--------- .../src/main/webapp/partials/inline-poll.html | 16 +- .../src/main/webapp/partials/poll-popupChoice.html | 2 +- 7 files changed, 245 insertions(+), 199 deletions(-) -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm