02/04: rename ChoiceType.IMAGE to ChoiceType.RESOURCE
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 6e708eb9f59ec6c7aac74d352eae7e660b1eacbb Author: Adrien <a.garandel@dralagen.fr> Date: Fri Jul 18 15:13:30 2014 +0200 rename ChoiceType.IMAGE to ChoiceType.RESOURCE --- pollen-persistence/src/main/xmi/pollen.zargo | Bin 20385 -> 20479 bytes .../rest/api/converter/JsonArrayConverterTest.java | 4 +-- .../chorem/pollen/services/bean/ChoiceBean.java | 4 +-- .../pollen/services/service/ChoiceService.java | 30 +++++---------------- .../services/service/PollenResourceService.java | 5 +--- .../i18n/pollen-services_en_GB.properties | 3 +-- .../i18n/pollen-services_fr_FR.properties | 3 +-- .../src/main/webapp/js/controllers/pollCtrl.js | 10 +++---- pollen-ui-angular/src/main/webapp/js/directives.js | 17 +++++++++--- .../src/main/webapp/partials/inline-poll.html | 4 +-- .../src/main/webapp/partials/poll-popupChoice.html | 6 ++--- .../{zoomImage.html => printResource.html} | 4 +-- .../src/test/unit/pollControllersTest.js | 10 +++---- 13 files changed, 44 insertions(+), 56 deletions(-) diff --git a/pollen-persistence/src/main/xmi/pollen.zargo b/pollen-persistence/src/main/xmi/pollen.zargo index a6810ea..8f51a6f 100644 Binary files a/pollen-persistence/src/main/xmi/pollen.zargo and b/pollen-persistence/src/main/xmi/pollen.zargo differ diff --git a/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/converter/JsonArrayConverterTest.java b/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/converter/JsonArrayConverterTest.java index 6b86791..085d5a3 100644 --- a/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/converter/JsonArrayConverterTest.java +++ b/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/converter/JsonArrayConverterTest.java @@ -33,7 +33,7 @@ public class JsonArrayConverterTest { public void convertToType() throws Exception { String choicesStr = "[ {id: \"AAAA\", choiceValue: \"choice1\", choiceType: \"TEXT\", choiceOrder: 1}, " + - " {id: \"BBBB\", choiceValue: \"choice2\", choiceType: \"IMAGE\", choiceOrder: 2} ]"; + " {id: \"BBBB\", choiceValue: \"choice2\", choiceType: \"RESOURCE\", choiceOrder: 2} ]"; JsonArrayConverter converter = JsonArrayConverter.newConverter(new DefaultTopiaIdFactory(), ChoiceBean.class); @@ -48,7 +48,7 @@ public class JsonArrayConverterTest { Assert.assertNotNull(choices[1]); Assert.assertEquals("choice2", choices[1].getChoiceValue()); - Assert.assertEquals(ChoiceType.IMAGE, choices[1].getChoiceType()); + Assert.assertEquals(ChoiceType.RESOURCE, choices[1].getChoiceType()); Assert.assertEquals(2, choices[1].getChoiceOrder()); } 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 aa0bf6b..8f2a5cc 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 @@ -67,7 +67,7 @@ public class ChoiceBean extends PollenBean<Choice> { case TEXT: case DATE: - case IMAGE: + case RESOURCE: setChoiceValue(entity.getChoiceValue()); break; @@ -100,7 +100,7 @@ public class ChoiceBean extends PollenBean<Choice> { break; case DATE: - case IMAGE: + case RESOURCE: if ( getChoiceValue() != null ) { entity.setChoiceValue(getChoiceValue()); 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 06ab67e..79c45bf 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 @@ -172,7 +172,7 @@ public class ChoiceService extends PollenServiceSupport { errors.failIfNotEmpty(); } - if (choice.getChoiceType() == ChoiceType.IMAGE) { + if (choice.getChoiceType() == ChoiceType.RESOURCE) { PollenResourceService resourceService = getPollenResourceService(); String resourceId = resourceService.getTopiaIdByReduceId(choice.getChoiceValue()); @@ -243,7 +243,7 @@ public class ChoiceService extends PollenServiceSupport { case TEXT: case DATE: - case IMAGE: + case RESOURCE: toSave.setChoiceValue(choice.getChoiceValue()); break; @@ -325,30 +325,14 @@ public class ChoiceService extends PollenServiceSupport { break; - case IMAGE: + case RESOURCE: PollenResourceService resourceService = getPollenResourceService(); PollenResource resource = resourceService.getResource0(resourceService.getTopiaIdByReduceId(choice.getChoiceValue())); - boolean resourceExist = checkNotBlank(errors, - "choiceValue", - resource.getName(), - l(getLocale(), "pollen.error.image.notExist")); - - if (resourceExist) { - List<String> contentTypeAccepted = new ArrayList<>(); - contentTypeAccepted.add("image/bmp"); - contentTypeAccepted.add("image/gif"); - contentTypeAccepted.add("image/jpeg"); - contentTypeAccepted.add("image/png"); - contentTypeAccepted.add("image/vnd.microsoft.icon"); - - boolean isImage = contentTypeAccepted.contains(resource.getContentType()); - - check(errors, - "choiceValue", - isImage, - l(getLocale(), "pollen.error.image.badFormat")); - } + checkNotBlank(errors, + "choiceValue", + resource.getName(), + l(getLocale(), "pollen.error.resource.notExist")); break; 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 9a67b0e..742a6fa 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 @@ -64,10 +64,7 @@ public class PollenResourceService extends PollenServiceSupport implements Polle public void deleteResource (String resourceId) { checkNotNull(resourceId); - List<ChoiceType> choiceTypesResource = new ArrayList<>(); - choiceTypesResource.add(ChoiceType.IMAGE); - - List<Choice> choices = getChoiceDao().forIn(Choice.PROPERTY_CHOICE_TYPE, choiceTypesResource).addEquals(Choice.PROPERTY_CHOICE_VALUE, getReduceId(resourceId)).findAll(); + List<Choice> choices = getChoiceDao().forEquals(Choice.PROPERTY_CHOICE_TYPE, ChoiceType.RESOURCE).addEquals(Choice.PROPERTY_CHOICE_VALUE, getReduceId(resourceId)).findAll(); if (choices.size() == 0) { // Resource not used in choice PollenResource resource = getResource0(resourceId); diff --git a/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties b/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties index ba4905e..4e60c30 100644 --- a/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties +++ b/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties @@ -29,8 +29,6 @@ pollen.error.favoriteListMember.email.empty=member email can not be empty pollen.error.favoriteListMember.email.invalid=member email is not valid pollen.error.favoriteListMember.name.already.used=member name already used pollen.error.favoriteListMember.name.empty=member name can not be empty -pollen.error.image.badFormat=Your Image is in bad format -pollen.error.image.notExist=Image don't exist pollen.error.poll.choice.mandatory=At least a choice is mandatory pollen.error.poll.commentVisibility.mandatory=comment visiblity is mandatory pollen.error.poll.mismatch.freePoll=cant' have a voter list for a free poll @@ -42,6 +40,7 @@ pollen.error.poll.voteCountingType.mandatory=vote counting type is mandatory pollen.error.poll.voteVisibility.mandatory=vote visibility is mandatory pollen.error.poll.voterList.mandatory.for.groupedPoll=At least one voter list ins mandatory for a grouped poll pollen.error.poll.voterList.mismatch.freePoll= +pollen.error.resource.notExist=Image don't exist pollen.error.user.mailEmpty=email can not be empty pollen.error.user.mailExist=email already exists pollen.error.user.mailInvalid=email is not valid diff --git a/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties b/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties index b37f11a..93bdce1 100644 --- a/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties +++ b/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties @@ -29,8 +29,6 @@ pollen.error.favoriteListMember.email.empty=Le courriel est obligatoire pollen.error.favoriteListMember.email.invalid=Le courriel du membre est invalide pollen.error.favoriteListMember.name.already.used=Le nom du membre est déjà utilisé dans cette liste pollen.error.favoriteListMember.name.empty=Le nom du membre est obligatoire -pollen.error.image.badFormat=L'image n'est pas du bon format -pollen.error.image.notExist=L'image n'existe pas sur le serveur pollen.error.poll.choice.mandatory=Au moins un choix est nécessaire pollen.error.poll.commentVisibility.mandatory=la visibilité des commentaires est obligatoire pollen.error.poll.pollType.mandatory=le type de sondage est obligatoire @@ -41,6 +39,7 @@ pollen.error.poll.voteCountingType.mandatory=le type de vote est obligatoire pollen.error.poll.voteVisibility.mandatory=la visiblité des votes est obligatoire pollen.error.poll.voterList.mandatory.for.groupedPoll=Au moins une liste de votant est obligatoire pour un sondage groupé pollen.error.poll.voterList.mismatch.freePoll=Liste de votants impossible pour un sondage libre +pollen.error.resource.notExist=L'image n'existe pas sur le serveur pollen.error.user.mailEmpty=Courriel ne peut pas être vide pollen.error.user.mailExist=Courriel existe déjà pollen.error.user.mailInvalid=Courriel est invalide 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 95d2ed9..5c887ef 100644 --- a/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js +++ b/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js @@ -216,7 +216,7 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr choice.choiceValue = null; } } - else if (choice.choiceType == 'IMAGE') { + else if (choice.choiceType == 'RESOURCE') { try { choice.choiceValue = choice.choiceValue.meta.id; } catch (e) { @@ -231,7 +231,7 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr if (choice.choiceType == 'DATE') { choice.choiceValue = new Date(Number(choice.choiceValue)); } - else if (choice.choiceType == 'IMAGE') { + else if (choice.choiceType == 'RESOURCE') { var resourceId = choice.choiceValue; choice.choiceValue = {meta:{id:resourceId}, data:conf.restURL+'/resources/'+resourceId, id: resourceId}; PollenResource.getMeta({resourceId : resourceId}, function (data) { @@ -423,7 +423,7 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr else if (choice.choiceType == 'DATE') { choice.choiceValueDate = choice.choiceValue; } - else if (choice.choiceType == 'IMAGE') { + else if (choice.choiceType == 'RESOURCE') { choice.choiceValueImage = choice.choiceValue; } @@ -450,7 +450,7 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr choice.choiceValue = choice.choiceValueDate; $scope.globalVariables.lastDate = angular.copy(choice.choiceValueDate); } - else if (choice.choiceType == 'IMAGE') { + else if (choice.choiceType == 'RESOURCE') { choice.choiceValue = choice.choiceValueImage; } @@ -1319,7 +1319,7 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr scores.push([$filter('date')(value.choice.choiceValue, $scope.globalVariables.dateFormat), value.scoreValue]); break; - case 'IMAGE': + case 'RESOURCE': scores.push([value.choice.choiceValue.meta.name, value.scoreValue]); break; diff --git a/pollen-ui-angular/src/main/webapp/js/directives.js b/pollen-ui-angular/src/main/webapp/js/directives.js index d1c4c01..d58f819 100644 --- a/pollen-ui-angular/src/main/webapp/js/directives.js +++ b/pollen-ui-angular/src/main/webapp/js/directives.js @@ -437,10 +437,10 @@ angular.module('pollenDirective', []) }]) ////////////////////////////////////// -///// ZOOM IMAGE ///// +///// PRINT RESOURCE ///// ////////////////////////////////////// -.directive("zoomImage", function () { +.directive("printResource", ['$timeout', function ($timeout) { return { restrict : "E", scope : { @@ -448,10 +448,19 @@ angular.module('pollenDirective', []) name : "=" }, transclude : true, - templateUrl : "partials/zoomImage.html", + templateUrl : "partials/printResource.html", link : function (scope, element, attrs) { scope.showImage = false; + $timeout(function () { + scope.$watch('image', function (newVal) { + if (angular.isDefined(newVal)) { + scope.resourceURL = conf.restURL+"/resources/"+scope.image; + scope.previewURL = scope.resourceURL+"/preview"; + } + }); + }); + var toggleZoom = function () { scope.$apply(function() { scope.showImage = !scope.showImage; @@ -463,4 +472,4 @@ angular.module('pollenDirective', []) }); } } -}) \ No newline at end of file +}]) \ No newline at end of file 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 4290225..deec251 100644 --- a/pollen-ui-angular/src/main/webapp/partials/inline-poll.html +++ b/pollen-ui-angular/src/main/webapp/partials/inline-poll.html @@ -48,13 +48,13 @@ <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 == 'IMAGE'"> + <div ng-if="choice.choiceType == 'RESOURCE'"> <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="..."/> <br/> - <zoom-image image="choice.choiceValue.data" name="choice.choiceValue.meta.name"></zoom-image> + <print-resource image="choice.choiceValue.id" name="choice.choiceValue.meta.name"></print-resource> </div> 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 0a5a988..9262100 100644 --- a/pollen-ui-angular/src/main/webapp/partials/poll-popupChoice.html +++ b/pollen-ui-angular/src/main/webapp/partials/poll-popupChoice.html @@ -31,7 +31,7 @@ <div class="col-sm-8 btn-group"> <button type="button" class="btn btn-default" ng-model="choice.choiceType" btn-radio="'TEXT'">Text</button> <button type="button" class="btn btn-default" ng-model="choice.choiceType" btn-radio="'DATE'">Date</button> - <button type="button" class="btn btn-default" ng-model="choice.choiceType" btn-radio="'IMAGE'">Image</button> + <button type="button" class="btn btn-default" ng-model="choice.choiceType" btn-radio="'RESOURCE'">Resource</button> </div> </div> @@ -54,8 +54,8 @@ </div> </div> - <div class="form-group" ng-if="choice.choiceType == 'IMAGE'"> - <label class="col-sm-4 control-label">Image : </label> + <div class="form-group" ng-if="choice.choiceType == 'RESOURCE'"> + <label class="col-sm-4 control-label">Resource : </label> <div class="col-sm-6"> <upload-file ng-model="choice.choiceValueImage"></upload-file> diff --git a/pollen-ui-angular/src/main/webapp/partials/zoomImage.html b/pollen-ui-angular/src/main/webapp/partials/printResource.html similarity index 51% rename from pollen-ui-angular/src/main/webapp/partials/zoomImage.html rename to pollen-ui-angular/src/main/webapp/partials/printResource.html index 43db544..74fbdbc 100644 --- a/pollen-ui-angular/src/main/webapp/partials/zoomImage.html +++ b/pollen-ui-angular/src/main/webapp/partials/printResource.html @@ -1,7 +1,7 @@ -<div><img ng-attr-src="{{image}}" /></div> +<div><img ng-attr-src="{{previewURL}}" /></div> <div ng-show="showImage" class="full"> <div class="full-content"> <span>{{name}}</span> - <img ng-attr-src="{{image}}" /> + <img ng-attr-src="{{resourceURL}}" /> </div> </div> \ No newline at end of file diff --git a/pollen-ui-angular/src/test/unit/pollControllersTest.js b/pollen-ui-angular/src/test/unit/pollControllersTest.js index 3f23721..a9c5083 100644 --- a/pollen-ui-angular/src/test/unit/pollControllersTest.js +++ b/pollen-ui-angular/src/test/unit/pollControllersTest.js @@ -126,17 +126,17 @@ describe('Global poll controller', function () { runs(function () { var makeChoice, sendChoice; - makeChoice = {choiceType:'IMAGE', choiceValue:'not an image'}; + makeChoice = {choiceType:'RESOURCE', choiceValue:'not an image'}; sendChoice = $scope.preSendChoice(makeChoice); expect(sendChoice.choiceValue).toBeNull(); - expect(sendChoice.choiceType).toEqual('IMAGE'); + expect(sendChoice.choiceType).toEqual('RESOURCE'); makeChoice.choiceValue = {meta:{name:'image.png', id:'shortTopiaId'}, data:'urlpicture', id:'shortTopiaId'}; sendChoice = $scope.preSendChoice(makeChoice); expect(sendChoice.choiceValue).toEqual('shortTopiaId'); - expect(sendChoice.choiceType).toEqual('IMAGE'); + expect(sendChoice.choiceType).toEqual('RESOURCE'); }); }); @@ -166,13 +166,13 @@ describe('Global poll controller', function () { runs(function () { var makeChoice, receiveChoice; - makeChoice = {choiceType:'IMAGE', choiceValue:'shortTopiaId'}; + makeChoice = {choiceType:'RESOURCE', choiceValue:'shortTopiaId'}; receiveChoice = $scope.postReceiveChoice(makeChoice); expect(receiveChoice.choiceValue.id).toEqual('shortTopiaId'); expect(receiveChoice.choiceValue.meta.id).toEqual('shortTopiaId'); expect(receiveChoice.choiceValue.data).toEqual(conf.restURL+'/resources/shortTopiaId'); - expect(receiveChoice.choiceType).toEqual('IMAGE'); + expect(receiveChoice.choiceType).toEqual('RESOURCE'); }); }); }); -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm