[pollen] branch develop updated (73e7c45 -> b74be20)
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 73e7c45 Merge branch 'feature/waitResourceBeforeSave' into develop new 47e45a8 edit list of poll new b74be20 Improve delete resource The 2 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 b74be2055671225d698e0c37f29a0f5b4bb5c35a Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Thu Jul 24 17:52:27 2014 +0200 Improve delete resource commit 47e45a86625c3048069e3baf59da74186e3f6001 Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Thu Jul 24 15:57:48 2014 +0200 edit list of poll - select one or more poll - delete selected poll Summary of changes: .../pollen/persistence/entity/ChoiceTopiaDao.java | 19 +++--- .../persistence/entity/PollenResourceTopiaDao.java | 41 +++++++++++++ pollen-rest-api/src/main/resources/mapping | 2 +- .../pollen/services/service/PollService.java | 2 - .../services/service/PollenResourceService.java | 14 +---- pollen-ui-angular/src/main/webapp/i18n/en.js | 9 ++- pollen-ui-angular/src/main/webapp/i18n/fr.js | 5 ++ .../src/main/webapp/js/controllers/pollCtrl.js | 71 +++++++++++++++++++++- .../src/main/webapp/partials/poll-list.html | 26 ++++++-- .../src/main/webapp/partials/poll-poll.html | 4 +- 10 files changed, 158 insertions(+), 35 deletions(-) create mode 100644 pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenResourceTopiaDao.java -- 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 47e45a86625c3048069e3baf59da74186e3f6001 Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Thu Jul 24 15:57:48 2014 +0200 edit list of poll - select one or more poll - delete selected poll --- .../pollen/services/service/PollService.java | 2 - pollen-ui-angular/src/main/webapp/i18n/en.js | 9 ++- pollen-ui-angular/src/main/webapp/i18n/fr.js | 5 ++ .../src/main/webapp/js/controllers/pollCtrl.js | 71 +++++++++++++++++++++- .../src/main/webapp/partials/poll-list.html | 26 ++++++-- .../src/main/webapp/partials/poll-poll.html | 4 +- 6 files changed, 103 insertions(+), 14 deletions(-) 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 77baf7e..ed55a43 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 @@ -205,8 +205,6 @@ public class PollService extends PollenServiceSupport { getPollDao().delete(poll); - //TODO agarandel 18/07/14 : Check resource without choice - commit(); getNotificationService().onPollDeleted(poll); diff --git a/pollen-ui-angular/src/main/webapp/i18n/en.js b/pollen-ui-angular/src/main/webapp/i18n/en.js index 8ba71b5..a2d676d 100644 --- a/pollen-ui-angular/src/main/webapp/i18n/en.js +++ b/pollen-ui-angular/src/main/webapp/i18n/en.js @@ -42,6 +42,7 @@ var translateEN = { 'user.error.login' : 'Error in e-mail or password', 'user.error.login.mandatory' : 'You must be connected', 'user.error.logout.mandatory' : 'You must be disconnected', +'user.error.listEmpty' : 'No user found', 'poll.tab.vote' : 'Vote', 'poll.tab.comment' : 'Comment', @@ -75,8 +76,8 @@ var translateEN = { 'poll.result.choice' : 'Choice', 'poll.result.score' : 'Score', 'poll.result.title.zero' : 'No result', -'poll.result.title.one' : 'Result : One voter', -'poll.result.title.other' : 'Result : {{nbVoter}} Voters', +'poll.result.title.one' : 'Result : One voter', +'poll.result.title.other' : 'Result : {{nbVoter}} Voters', 'poll.config.title.poll' : 'Global config', 'poll.config.title.choice' : 'Choice config', 'poll.config.title.vote' : 'Vote config', @@ -131,6 +132,10 @@ var translateEN = { 'action.favoriteList.delete' : 'Delete the favorite list', 'action.favoriteList.addMember' : 'Add a member', 'action.favoriteList.deleteMember' : 'Delete the member', +'action.selectAll' : 'Select All', +'action.unselectAll' : 'Unselect All', +'action.toggleSelectAll' : 'Toggle the select', +'action.deleteSelected' : 'Delete the selected', 'action.message.confirmDelete' : 'Are you sure to delete it?', 'action.message.confirmClose' : 'Are you sure to close it?', diff --git a/pollen-ui-angular/src/main/webapp/i18n/fr.js b/pollen-ui-angular/src/main/webapp/i18n/fr.js index fb3ff29..8336198 100644 --- a/pollen-ui-angular/src/main/webapp/i18n/fr.js +++ b/pollen-ui-angular/src/main/webapp/i18n/fr.js @@ -42,6 +42,7 @@ var translateFR = { 'user.error.login' : 'Erreur sur le nom d\'utilisateur ou le mot de passe', 'user.error.login.mandatory' : 'Accès refusé, vous devez êtes connecté(e)', 'user.error.logout.mandatory' : 'Accès refusé, vous êtes connecté(e)', +'user.error.listEmpty' : 'Aucun utilisateur trouvé', 'poll.tab.vote' : 'Voter', 'poll.tab.comment' : 'Commenter', @@ -131,6 +132,10 @@ var translateFR = { 'action.favoriteList.delete' : 'Supprimer la liste de diffusion', 'action.favoriteList.addMember' : 'Ajouter un membre', 'action.favoriteList.deleteMember' : 'Supprimer le membre', +'action.selectAll' : 'Sélectionner tous', +'action.unselectAll' : 'Déselectionner tous', +'action.toggleSelectAll' : 'Inverser la sélection', +'action.deleteSelected' : 'Supprimer la sélection', 'action.message.confirmDelete' : 'Êtes vous sûr de vouloir le supprimer?', 'action.message.confirmClose' : 'Êtes vous sûr de vouloir le fermer?', 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 8b66601..bd7ef2b 100644 --- a/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js +++ b/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js @@ -1386,9 +1386,59 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr }]) .controller('PollListCtrl', - ['$scope', '$rootScope', '$controller', '$routeParams', '$timeout', '$location', 'Poll', 'Page', - function ($scope, $rootScope, $controller, $routeParams, $timeout, $location, Poll, Page) { + ['$scope', '$rootScope', '$controller', '$routeParams', '$timeout', '$location', '$sce', '$q', 'Poll', 'Page', + function ($scope, $rootScope, $controller, $routeParams, $timeout, $location, $sce, $q, Poll, Page) { $scope.data = {}; + $scope.globalVariables = {}; + + $scope.toHTML = function (data) { + return $sce.trustAsHtml(data); + } + + $scope.toggleSelect = function (poll, event) { + if (angular.isUndefined(poll.selected)) { + poll.selected = true; + } + else { + poll.selected = !poll.selected; + } + + if (angular.isDefined(event)) { + event.stopPropagation(); + } + } + + $scope.selectAll = function () { + angular.forEach($scope.data.polls, function (poll) { + poll.selected = true; + }) + }; + + $scope.unselectAll = function () { + angular.forEach($scope.data.polls, function (poll) { + poll.selected = false; + }) + }; + + $scope.toggleSelectAll = function () { + angular.forEach($scope.data.polls, function (poll) { + $scope.toggleSelect(poll); + }) + }; + + $scope.deleteSelected = function () { + var deferred = []; + + angular.forEach($scope.data.polls, function (poll) { + if (poll.selected) { + deferred.push(Poll.remove({pollId: poll.id, permission:poll.permission}).$promise); + + $q.all(deferred).then(function () { + initPolls(); + }); + } + }) + } Page.setTitle('title.poll.list'); @@ -1413,6 +1463,23 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr Poll.get({paginationParameter:paginationParameter, cmd:$routeParams.cmd}, function (data) { $scope.data.polls = data.elements $scope.data.pollsPagination = data.pagination; + + // check if has elements + if (data.elements.length == 0 && data.pagination.currentPage > 0) { + data.pagination.currentPage--; + } + + // check the global right + $scope.globalVariables.hasAllRight = true; + for (var pollIndex in $scope.data.polls) { + var poll = $scope.data.polls[pollIndex]; + + if (angular.isUndefined(poll.permission)) { + $scope.globalVariables.hasAllRight = false; + break; + } + } + }, function (error) { $rootScope.$broadcast('newError', 'error.forbidden'); $location.url('/'); diff --git a/pollen-ui-angular/src/main/webapp/partials/poll-list.html b/pollen-ui-angular/src/main/webapp/partials/poll-list.html index 6217c3c..7eb9ed2 100644 --- a/pollen-ui-angular/src/main/webapp/partials/poll-list.html +++ b/pollen-ui-angular/src/main/webapp/partials/poll-list.html @@ -21,11 +21,27 @@ <div ng-if="!data.polls[0]"><h1>{{ 'poll.error.listEmpty' | translate }}</h1></div> -<div ng-repeat="poll in data.polls"> - <h2><a href="#/poll/vote/{{poll.id}}">{{poll.title}}</a></h2> - <p ng-bind-html="toHTML(poll.description)"></p> - <hr/> -</div> +<table class="table table-hover"> + <tr ng-repeat="poll in data.polls" ng-class="{'active':poll.selected}" ng-click="toggleSelect(poll, $event)"> + <td style="vertical-align:middle"> + <input type="checkbox" ng-model="poll.selected" ng-click="toggleSelect(poll, $event)"/> + </td> + <td> + <h2><a href="#/poll/vote/{{poll.id}}">{{poll.title}}</a></h2> + </td> + <td> + <div ng-bind-html="toHTML(poll.description)"></div> + </td> + </tr> + <tr ng-show="data.polls.length > 1"> + <td colspan="3"> + <button class="btn btn-default" ng-click="selectAll()"><span class="glyphicon glyphicon-check"></span> {{ 'action.selectAll' | translate }}</button> + <button class="btn btn-default" ng-click="unselectAll()"><span class="glyphicon glyphicon-unchecked"></span> {{ 'action.unselectAll' | translate }}</button> + <button class="btn btn-default" ng-click="toggleSelectAll()"><span class="glyphicon glyphicon-transfer"></span> {{ 'action.toggleSelectAll' | translate }}</button> + <button class="btn btn-danger" ng-click="deleteSelected()" ng-if="globalVariables.hasAllRight"><span class="glyphicon glyphicon-trash"></span> {{ 'action.deleteSelected' | translate }}</button> + </td> + </tr> +</table> <make-pagination current-page="data.pollsPagination.currentPage" last-page="data.pollsPagination.lastPage" diff --git a/pollen-ui-angular/src/main/webapp/partials/poll-poll.html b/pollen-ui-angular/src/main/webapp/partials/poll-poll.html index a2c2558..cca1a46 100644 --- a/pollen-ui-angular/src/main/webapp/partials/poll-poll.html +++ b/pollen-ui-angular/src/main/webapp/partials/poll-poll.html @@ -36,9 +36,7 @@ <div ng-show="showEditDesc" class="pollDesc"> <textarea id="descEditor" data-ck-editor ng-model="data.poll.description" focus-me="showEditDesc"></textarea> - <!-- fix me : no save in creation but save in edition --> - <button type="button" class="btn btn-primary" ng-click="showEditDesc = false;" ng-show="globalVariables.create">{{ 'action.return' | translate }}</button> - <button type="button" class="btn btn-primary" ng-click="showEditDesc = false; autoSavePoll()" ng-show="globalVariables.edit">{{ 'action.return' | translate }}</button> + <button type="button" class="btn btn-primary" ng-click="showEditDesc = false; autoSavePoll()">{{ 'action.return' | translate }}</button> </div> <div id="poll"> -- 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 b74be2055671225d698e0c37f29a0f5b4bb5c35a Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Thu Jul 24 17:52:27 2014 +0200 Improve delete resource --- .../pollen/persistence/entity/ChoiceTopiaDao.java | 19 +++++----- .../persistence/entity/PollenResourceTopiaDao.java | 41 ++++++++++++++++++++++ pollen-rest-api/src/main/resources/mapping | 2 +- .../services/service/PollenResourceService.java | 14 ++------ 4 files changed, 55 insertions(+), 21 deletions(-) diff --git a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/ChoiceTopiaDao.java b/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/ChoiceTopiaDao.java index c0548ed..0144bce 100644 --- a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/ChoiceTopiaDao.java +++ b/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/ChoiceTopiaDao.java @@ -39,14 +39,17 @@ public class ChoiceTopiaDao extends AbstractChoiceTopiaDao<Choice> { if (entity.getChoiceType() == ChoiceType.RESOURCE) { - // remove Resource - PollenResourceTopiaDao dao = topiaDaoSupplier - .getDao(PollenResource.class, PollenResourceTopiaDao.class); - PollenResource resource = dao - .forEquals(PollenResource.PROPERTY_TOPIA_ID, entity.getChoiceValue()) - .findUnique(); - - dao.delete(resource); + { // --- remove Resource --- // + + PollenResourceTopiaDao dao = topiaDaoSupplier + .getDao(PollenResource.class, PollenResourceTopiaDao.class); + PollenResource resource = dao + .forEquals(PollenResource.PROPERTY_TOPIA_ID, entity.getChoiceValue()) + .findUnique(); + + dao.delete(resource, entity.getTopiaId()); + + } } diff --git a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenResourceTopiaDao.java b/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenResourceTopiaDao.java new file mode 100644 index 0000000..a90cf09 --- /dev/null +++ b/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenResourceTopiaDao.java @@ -0,0 +1,41 @@ +package org.chorem.pollen.persistence.entity; + +/** + * Created on 24/07/14. + * + * @author dralagen + */ +public class PollenResourceTopiaDao extends AbstractPollenResourceTopiaDao<PollenResource> { + + @Override + public void delete(PollenResource entity) { + + // check if resource is used + ChoiceTopiaDao dao = topiaDaoSupplier + .getDao(Choice.class, ChoiceTopiaDao.class); + + boolean isUsed = dao.forEquals(Choice.PROPERTY_CHOICE_VALUE, entity.getTopiaId()) + .addEquals(Choice.PROPERTY_CHOICE_TYPE, ChoiceType.RESOURCE) + .exists(); + + if (!isUsed) { + super.delete(entity); + } + } + + public void delete(PollenResource entity, String choiceId) { + + ChoiceTopiaDao dao = topiaDaoSupplier + .getDao(Choice.class, ChoiceTopiaDao.class); + + boolean isUsed = dao.forEquals(Choice.PROPERTY_CHOICE_TYPE, ChoiceType.RESOURCE) + .addEquals(Choice.PROPERTY_CHOICE_VALUE, entity.getTopiaId()) + .addNotEquals(Choice.PROPERTY_TOPIA_ID, choiceId) + .exists(); + + if (!isUsed) { + super.delete(entity); + } + + } +} diff --git a/pollen-rest-api/src/main/resources/mapping b/pollen-rest-api/src/main/resources/mapping index 1d55eb5..07e4877 100644 --- a/pollen-rest-api/src/main/resources/mapping +++ b/pollen-rest-api/src/main/resources/mapping @@ -121,7 +121,7 @@ GET /v1/resources/{resourceId}/meta PollenResourceApi.getMetaReso GET /v1/resources/{resourceId}/preview PollenResourceApi.getPreviewResource POST /v1/resources PollenResourceApi.createResource POST /v1/resources/{resourceId} PollenResourceApi.editResource -# DELETE /v1/resources/{resourceId} PollenResourceApi.deleteResource +DELETE /v1/resources/{resourceId} PollenResourceApi.deleteResource # PollenUserApi diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenResourceService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenResourceService.java index 379579a..4375052 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenResourceService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenResourceService.java @@ -62,18 +62,8 @@ public class PollenResourceService extends PollenServiceSupport implements Polle public void deleteResource (String resourceId) { checkNotNull(resourceId); - boolean choiceExist = getChoiceDao() - .forEquals(Choice.PROPERTY_CHOICE_TYPE, ChoiceType.RESOURCE) - .addEquals(Choice.PROPERTY_CHOICE_VALUE, resourceId) - .exists(); - - if (!choiceExist) { // Resource not used in choice - PollenResource resource = getResource0(resourceId); - getPollenResourceDao().delete(resource); - } - else { - throw new PollenUnauthorizedException("PollenResource is used"); - } + PollenResource resource = getResource0(resourceId); + getPollenResourceDao().delete(resource); commit(); } -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm