r2057 - in trunk: wao-persistence/src/main/java/fr/ifremer/wao/entity wao-services/src/main/java/fr/ifremer/wao/services/service wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer wao-web/src/main/webapp/WEB-INF/content/obsmer
Author: bleny Date: 2014-06-17 19:09:33 +0200 (Tue, 17 Jun 2014) New Revision: 2057 Url: http://forge.codelutin.com/projects/wao/repository/revisions/2057 Log: fixes #5213 allow remove elligibility Added: trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/UpdateBoatElligibilityJsonAction.java Modified: trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/ElligibleBoatTopiaDao.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerBoatsService.java trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/boat-details.jsp Modified: trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/ElligibleBoatTopiaDao.java =================================================================== --- trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/ElligibleBoatTopiaDao.java 2014-06-17 16:01:52 UTC (rev 2056) +++ trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/ElligibleBoatTopiaDao.java 2014-06-17 17:09:33 UTC (rev 2057) @@ -21,6 +21,8 @@ * #L% */ +import org.nuiton.topia.persistence.TopiaQueryBuilderRunQueryWithUniqueResultStep; + public class ElligibleBoatTopiaDao extends AbstractElligibleBoatTopiaDao<ElligibleBoat> { public ElligibleBoat findUniqueOrNull(Contact contact) { @@ -37,4 +39,9 @@ ElligibleBoat.PROPERTY_SAMPLE_ROW, contact.getSampleRow()); return elligibleBoat; } + + public TopiaQueryBuilderRunQueryWithUniqueResultStep<ElligibleBoat> forBoatIdAndSampleRowId(String boatId, String sampleRowId) { + return newQueryBuilder().addTopiaIdEquals(ElligibleBoat.PROPERTY_BOAT, boatId) + .addTopiaIdEquals(ElligibleBoat.PROPERTY_SAMPLE_ROW, sampleRowId); + } } Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerBoatsService.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerBoatsService.java 2014-06-17 16:01:52 UTC (rev 2056) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerBoatsService.java 2014-06-17 17:09:33 UTC (rev 2057) @@ -38,6 +38,8 @@ import fr.ifremer.wao.entity.Contact; import fr.ifremer.wao.entity.ContactState; import fr.ifremer.wao.entity.ContactTopiaDao; +import fr.ifremer.wao.entity.ElligibleBoat; +import fr.ifremer.wao.entity.ElligibleBoatTopiaDao; import fr.ifremer.wao.entity.ObsProgram; import fr.ifremer.wao.services.AuthenticatedWaoUser; import fr.ifremer.wao.services.service.csv.BoatImportExportModel; @@ -269,4 +271,21 @@ return boats.getElements(); } + + public void changeBoatElligibility(AuthenticatedWaoUser authenticatedWaoUser, String boatId, String sampleRowId, boolean active) { + + ElligibleBoatTopiaDao dao = getElligibleBoatDao(); + + ElligibleBoat elligibleBoat = dao.forBoatIdAndSampleRowId(boatId, sampleRowId).findUnique(); + + if (authenticatedWaoUser.isAdmin()) { + elligibleBoat.setGlobalActive(active); + } else if (authenticatedWaoUser.isCoordinatorOrObserver()) { + elligibleBoat.setCompanyActive(active); + } else { + throw new IllegalStateException(authenticatedWaoUser.getWaoUser().toString()); + } + + commit(); + } } Added: trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/UpdateBoatElligibilityJsonAction.java =================================================================== --- trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/UpdateBoatElligibilityJsonAction.java (rev 0) +++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/UpdateBoatElligibilityJsonAction.java 2014-06-17 17:09:33 UTC (rev 2057) @@ -0,0 +1,39 @@ +package fr.ifremer.wao.web.action.obsmer; + +import fr.ifremer.wao.services.service.ObsMerBoatsService; +import fr.ifremer.wao.web.WaoJsonActionSupport; + +public class UpdateBoatElligibilityJsonAction extends WaoJsonActionSupport { + + protected ObsMerBoatsService service; + + protected String boatId; + + protected String sampleRowId; + + protected boolean active; + + public void setService(ObsMerBoatsService service) { + this.service = service; + } + + public void setActive(boolean active) { + this.active = active; + } + + public void setBoatId(String boatId) { + this.boatId = boatId; + } + + public void setSampleRowId(String sampleRowId) { + this.sampleRowId = sampleRowId; + } + + @Override + public String execute() { + + service.changeBoatElligibility(session.getAuthenticatedWaoUser(), boatId, sampleRowId, active); + + return SUCCESS; + } +} Modified: trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/boat-details.jsp =================================================================== --- trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/boat-details.jsp 2014-06-17 16:01:52 UTC (rev 2056) +++ trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/boat-details.jsp 2014-06-17 17:09:33 UTC (rev 2057) @@ -96,6 +96,19 @@ } }); + // suppresssion d'une éligibilité + $('.remove-boat-eligibility').click(function (e) { + e.preventDefault(); + if (confirm("<s:text name="wao.ui.removeBoatEligibility.confirm"/>")) { + var url = $(this).attr('href'); + var $toRemove = $(this).parents('li, div') + var successCallback = function (data) { + $toRemove.remove(); + }; + WAO.post(url, {}, successCallback); + } + }); + }); </script> @@ -185,8 +198,32 @@ <s:hidden name="boatId" value="%{boatDetails.boatInfos.boat.topiaId}"/> - <s:radio name="sampleRowId" list="boatDetails.elligibleForSampleRows" listKey="topiaId" listValue="code" /> + <div class="control-group"> + <div class="controls"> + <s:iterator value="boatDetails.elligibleForSampleRows" status="status"> + <div> + <s:set name="radioId">radio-<s:property value="#status.index"/></s:set> + <input type="radio" name="sampleRowId" id="<s:property value="#radioId"/>" value="<s:property value="topiaId"/>"/> + <%-- + <label for="<s:property value="%{#radioId}"/>" class="radio"> + <s:property value="code"/> + </label> + --%> + <s:property value="code"/> + <s:url action="update-boat-elligibility-json" id="updateBoatElligibilityUrl"> + <s:param name="boatId" value="boatDetails.boatInfos.boat.topiaId"/> + <s:param name="sampleRowId" value="topiaId"/> + <s:param name="active" value="false"/> + </s:url> + <s:a href="%{updateBoatElligibilityUrl}" cssClass="btn btn-link remove-boat-eligibility"> + <i class="icon-remove"></i> + </s:a> + </div> + </s:iterator> + </div> + </div> + <s:submit id="createContactFromBoatButton" type="button" cssClass="btn btn-success" disabled="true"> <i class="icon-plus"></i> <s:text name="wao.ui.contacts.createFromBoat"/> @@ -198,6 +235,14 @@ <s:iterator value="boatDetails.elligibleForSampleRows"> <li> <s:property value="code"/> + <s:url action="update-boat-elligibility-json" id="updateBoatElligibilityUrl"> + <s:param name="boatId" value="boatDetails.boatInfos.boat.topiaId"/> + <s:param name="sampleRowId" value="topiaId"/> + <s:param name="active" value="false"/> + </s:url> + <s:a href="%{updateBoatElligibilityUrl}" cssClass="btn btn-link remove-boat-eligibility"> + <i class="icon-remove"></i> + </s:a> </li> </s:iterator> </ul>
participants (1)
-
bleny@users.forge.codelutin.com