r308 - in trunk/magalie-web/src/main: java/com/franciaflex/magalie/web/action webapp/WEB-INF/content webapp/js
Author: bleny Date: 2013-07-12 23:24:59 +0200 (Fri, 12 Jul 2013) New Revision: 308 Url: http://forge.codelutin.com/projects/franciaflex-magalie/repository/revisions... Log: allow report error in SimpleWithdrawItem Modified: trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/action/SimpleWithdrawItemAction.java trunk/magalie-web/src/main/webapp/WEB-INF/content/simple-withdraw-item-input.jsp trunk/magalie-web/src/main/webapp/js/withdraw-item-input.js Modified: trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/action/SimpleWithdrawItemAction.java =================================================================== --- trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/action/SimpleWithdrawItemAction.java 2013-07-12 20:50:13 UTC (rev 307) +++ trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/action/SimpleWithdrawItemAction.java 2013-07-12 21:24:59 UTC (rev 308) @@ -30,6 +30,7 @@ import com.franciaflex.magalie.services.SimpleWithdrawItemTask; import com.franciaflex.magalie.services.exception.IllegalWithdrawException; import com.franciaflex.magalie.services.exception.InvalidMagalieBarcodeException; +import com.franciaflex.magalie.services.service.LocationErrorsService; import com.franciaflex.magalie.services.service.SimpleWithdrawItemService; import com.franciaflex.magalie.web.MagalieActionSupport; import com.franciaflex.magalie.web.MagalieSession; @@ -50,6 +51,8 @@ protected SimpleWithdrawItemService service; + protected LocationErrorsService locationErrorsService; + protected String storedArticleId; protected String articleBarcode; @@ -62,6 +65,14 @@ protected String originLocationBarcode; + public void setService(SimpleWithdrawItemService service) { + this.service = service; + } + + public void setLocationErrorsService(LocationErrorsService locationErrorsService) { + this.locationErrorsService = locationErrorsService; + } + public void setSession(MagalieSession session) { this.session = session; } @@ -74,10 +85,6 @@ this.destinationWarehouseId = destinationWarehouseId; } - public void setService(SimpleWithdrawItemService service) { - this.service = service; - } - @Override public String input() { @@ -177,4 +184,37 @@ } + public String reportError() throws InvalidMagalieBarcodeException, IllegalWithdrawException { + + MagalieUser magalieUser = session.getMagalieUser(); + + Building building = session.getBuilding(); + + simpleWithdrawItemTask = service.getSimpleWithdrawItemTask(building, magalieUser, articleBarcode); + + Optional<StoredArticle> storedArticleOptional = + Iterables.tryFind( + simpleWithdrawItemTask.getStoredArticles(), + StoredArticles.locationBarcodeEquals(originLocationBarcode)); + + if (storedArticleOptional.isPresent()) { + + StoredArticle storedArticle = storedArticleOptional.get(); + + locationErrorsService.reportError(storedArticle.getLocation(), storedArticle.getArticle(), magalieUser); + + addActionMessage("Anomalie signalée"); + + simpleWithdrawItemTask = service.getSimpleWithdrawItemTask(building, magalieUser, articleBarcode); + + } else { + + addFieldError("originLocationBarcode", "Ce n'est pas le code-barre d'un emplacement valide"); + + } + + return INPUT; + + } + } Modified: trunk/magalie-web/src/main/webapp/WEB-INF/content/simple-withdraw-item-input.jsp =================================================================== --- trunk/magalie-web/src/main/webapp/WEB-INF/content/simple-withdraw-item-input.jsp 2013-07-12 20:50:13 UTC (rev 307) +++ trunk/magalie-web/src/main/webapp/WEB-INF/content/simple-withdraw-item-input.jsp 2013-07-12 21:24:59 UTC (rev 308) @@ -73,7 +73,8 @@ <div class="btn-group"> <s:a href="%{cancelUrl}" cssClass="btn" id="CancelLink" >Quitter (Esc)</s:a> - <s:submit name="" value="Valider" cssClass="btn btn-primary" /> + <s:submit action="simple-withdraw-item!reportError" value="Anomalie (F5)" cssClass="btn btn-danger" /> + <s:submit action="simple-withdraw-item" value="Valider" cssClass="btn btn-primary" /> </div> </s:form> Modified: trunk/magalie-web/src/main/webapp/js/withdraw-item-input.js =================================================================== --- trunk/magalie-web/src/main/webapp/js/withdraw-item-input.js 2013-07-12 20:50:13 UTC (rev 307) +++ trunk/magalie-web/src/main/webapp/js/withdraw-item-input.js 2013-07-12 21:24:59 UTC (rev 308) @@ -99,7 +99,7 @@ } }); if (storageMovement.articleUnavailable) { - alert('Pas de stock'); + alert('Plus de stock'); } else { if (this.expectedQuantity) { storageMovement.expectedQuantity = Math.min(model.remaining(), storageMovement.storedArticle.quantity); @@ -148,7 +148,6 @@ }, async: false, success: function(data) { - console.log(data); storageMovement.id = data.storageMovement.id; }, fail: function(jqXHR, textStatus, errorThrown) { @@ -260,7 +259,7 @@ }, - onNext : function() { + onNext : function(reportError) { try { @@ -269,6 +268,10 @@ model.withdraw(barcode, quantity); + if (reportError === true) { + model.reportError(barcode); + } + view.refresh(); var proposeAnotherLocation = ! model.expectedQuantity // pas de quantité demandée précisée au départ donc on ne sait pas s'il faut s'arrêter donc on propose au cas où @@ -292,25 +295,8 @@ onReportError : function() { - try { + controller.onNext(true); - var barcode = $('#withdraw-item_locationBarcode').val(); - var quantity = parseFloat($('#withdraw-item_quantity').val()); - - model.withdraw(barcode, quantity); - - model.reportError(barcode); - - view.refresh(); - - } catch (ex) { - - if (ex instanceof ValidationError) { - handleValidationError(ex); - } else { - throw ex; - } - } }, onConfirm : function() {
participants (1)
-
bleny@users.forge.codelutin.com