Author: bleny Date: 2013-08-27 18:41:08 +0200 (Tue, 27 Aug 2013) New Revision: 379 Url: http://forge.codelutin.com/projects/franciaflex-magalie/repository/revisions... Log: fixes #2992 fixes #2993 reuse withdraw item UI in reception to add a confirm and cancel buttons Modified: trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/ReceptionService.java trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/action/PrepareArticleReceptionAction.java trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/action/ReceiveArticleAction.java trunk/magalie-web/src/main/webapp/WEB-INF/content/receive-article-input.jsp trunk/magalie-web/src/main/webapp/css/magalie-ck3x-reduced.css trunk/magalie-web/src/main/webapp/js/receive-article-input.js Modified: trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/ReceptionService.java =================================================================== --- trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/ReceptionService.java 2013-08-27 09:03:16 UTC (rev 378) +++ trunk/magalie-services/src/main/java/com/franciaflex/magalie/services/service/ReceptionService.java 2013-08-27 16:41:08 UTC (rev 379) @@ -352,7 +352,6 @@ Location destinationLocation = locationDao.findById(locationToStoredQuantity.getKey()); - // TODO brendan 25/07/13 what if destination.isFullLocation ? storageMovement.setDestinationLocation(destinationLocation); storageMovement.setMagalieUser(magalieUser); @@ -361,8 +360,16 @@ storageMovement.setActualQuantity(locationToStoredQuantity.getValue()); + storageMovement.setMovementDate(now); + storageMovement.setConfirmDate(now); + if (log.isWarnEnabled()) { + if (destinationLocation.isFullLocation()) { + log.warn("stored article in full destination location, should never occur " + storageMovement); + } + } + storageMovementDao.persist(storageMovement); storageMovements.add(storageMovement); @@ -459,8 +466,7 @@ /** * On cherche à savoir si pour un storedArticle donné, il y a encore des articles à recevoir pour le même fournisseur */ - public Optional<Supplier> isSupplierHaveOtherArticlesToReceive(Building building, String - storedArticleId) { + public Optional<Supplier> isSupplierHaveOtherArticlesToReceive(Building building, String storedArticleId) { JpaMagaliePersistenceContext persistenceContext = serviceContext.getPersistenceContext(); Modified: trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/action/PrepareArticleReceptionAction.java =================================================================== --- trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/action/PrepareArticleReceptionAction.java 2013-08-27 09:03:16 UTC (rev 378) +++ trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/action/PrepareArticleReceptionAction.java 2013-08-27 16:41:08 UTC (rev 379) @@ -30,6 +30,7 @@ import com.franciaflex.magalie.web.Activity; import com.franciaflex.magalie.web.MagalieActionSupport; import com.franciaflex.magalie.web.MagalieSession; +import com.google.common.base.Strings; import java.util.List; @@ -46,7 +47,7 @@ protected SuppliersToReceive suppliersToReceive; public void setSupplierId(String supplierId) { - this.supplierId = supplierId; + this.supplierId = Strings.emptyToNull(supplierId); } public void setService(ReceptionService service) { Modified: trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/action/ReceiveArticleAction.java =================================================================== --- trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/action/ReceiveArticleAction.java 2013-08-27 09:03:16 UTC (rev 378) +++ trunk/magalie-web/src/main/java/com/franciaflex/magalie/web/action/ReceiveArticleAction.java 2013-08-27 16:41:08 UTC (rev 379) @@ -29,6 +29,7 @@ import com.franciaflex.magalie.persistence.entity.Supplier; import com.franciaflex.magalie.services.exception.InvalidMagalieBarcodeException; import com.franciaflex.magalie.services.exception.PreparedArticleReceptionAlreadyStoredException; +import com.franciaflex.magalie.services.service.ArticleStorageService; import com.franciaflex.magalie.services.service.ReceptionConfirmation; import com.franciaflex.magalie.services.service.ReceptionService; import com.franciaflex.magalie.services.service.ReceptionTask; @@ -61,6 +62,8 @@ protected ReceptionService service; + protected ArticleStorageService articleStorageService; + protected String storedArticleId; protected String preparedArticleReceptionBarcode; @@ -79,6 +82,10 @@ this.service = service; } + public void setArticleStorageService(ArticleStorageService articleStorageService) { + this.articleStorageService = articleStorageService; + } + public void setStoredArticleId(String storedArticleId) { this.storedArticleId = storedArticleId; } @@ -132,10 +139,20 @@ } + Supplier supplier = receptionTask.getStoredArticle().getArticle().getSupplier(); + + if (supplier != null) { + supplierId = supplier.getId(); + } + return INPUT; } + public String getSupplierId() { + return supplierId; + } + public ReceptionTask getReceptionTask() { return receptionTask; } @@ -209,8 +226,31 @@ } - public String getSupplierId() { - return supplierId; + public void setSupplierId(String supplierId) { + this.supplierId = supplierId; } + public String cancel() { + + MagalieUser magalieUser = session.getMagalieUser(); + + // pas besoin, on stocke pas de mouvements non confirmés + // articleStorageService.cancelStorageMovements(magalieUser); + + String result; + + if (Activity.PREPARED_RECEPTIONS.equals(session.getActivity())) { + + result = Activity.PREPARED_RECEPTIONS.name(); + + } else { + + result = "REDIRECT_TO_ARTICLES"; + + } + + return result; + + } + } Modified: trunk/magalie-web/src/main/webapp/WEB-INF/content/receive-article-input.jsp =================================================================== --- trunk/magalie-web/src/main/webapp/WEB-INF/content/receive-article-input.jsp 2013-08-27 09:03:16 UTC (rev 378) +++ trunk/magalie-web/src/main/webapp/WEB-INF/content/receive-article-input.jsp 2013-08-27 16:41:08 UTC (rev 379) @@ -55,11 +55,15 @@ <s:textfield name="locationBarcode" label="Empl." inputAppendIcon="barcode" cssClass="input-small" /> <s:textfield name="quantity" label="Qté" inputAppend="%{receptionTask.storedArticle.article.unit}" cssClass="input-mini" /> <s:hidden name="preparedArticleReceptionBarcode" value="%{preparedArticleReceptionBarcode}" /> + <s:hidden name="supplierId" value="%{supplierId}" /> <s:hidden name="confirmation" /> - <div class="btn-group"> - <input type="button" name="full" value="Plein (F5)" class="btn btn-danger btn-small" id="receive-article_full" /> - <s:submit name="next" value="Suivant" cssClass="btn btn-primary btn-small" /> + <div style="width: 180px"> + <s:url action="receive-article!cancel" id="cancelUrl" /> + <s:a href="%{cancelUrl}" cssClass="btn btn-mini" id="cancelLink">Abandon (Esc)</s:a> + <input type="button" name="full" value="Plein (F5)" class="btn btn-danger btn-mini" id="receive-article_full" /> + <s:submit name="next" value="Suivant (⏎)" cssClass="btn btn-primary btn-mini" /> + <input type="button" id="confirm" value="Terminer (F4)" class="btn btn-success btn-mini" /> </div> </s:form> <div id="locationTemplate" class="template"> Modified: trunk/magalie-web/src/main/webapp/css/magalie-ck3x-reduced.css =================================================================== --- trunk/magalie-web/src/main/webapp/css/magalie-ck3x-reduced.css 2013-08-27 09:03:16 UTC (rev 378) +++ trunk/magalie-web/src/main/webapp/css/magalie-ck3x-reduced.css 2013-08-27 16:41:08 UTC (rev 379) @@ -64,10 +64,7 @@ margin-bottom: 0px; } -#locations { - min-height: 100px; /* 5 * 20px for each element */ -} - +#locations, #storageMovements { min-height: 80px; /* 4 * 20px for each element */ } Modified: trunk/magalie-web/src/main/webapp/js/receive-article-input.js =================================================================== --- trunk/magalie-web/src/main/webapp/js/receive-article-input.js 2013-08-27 09:03:16 UTC (rev 378) +++ trunk/magalie-web/src/main/webapp/js/receive-article-input.js 2013-08-27 16:41:08 UTC (rev 379) @@ -97,9 +97,6 @@ } model.getConfirmation = function() { - if (this.remainingQuantity() > 0.) { - throw new Error("Tout n'a pas été stocké"); - } var locationIdToStoredQuantities = {}; $.each(model.locations, function(key, location) { if (location.used && location.stored > 0.) { @@ -113,6 +110,20 @@ return confirmation; } +model.newEmptyStorageMovementForNextLocation = function() { + var quantityIsRemaining = model.remainingQuantity() > 0.; + var allIsUsed = true; + for (var i = 0; i < this.locations.length; i++) { + if ( ! this.locations[i].used) { + allIsUsed = false; + } + } + var proposeAnotherLocation = quantityIsRemaining && allIsUsed; + if (proposeAnotherLocation) { + this.locationsIndex += 1; + } +} + var view = { refreshSummary : function() { @@ -160,19 +171,10 @@ } }, - refreshButtons : function() { - if (model.allowSubmit) { - $('#receive-article_next').val('Terminer').removeClass('btn-primary').addClass('btn-success'); - } else { - $('#receive-article_next').val('Suivant').removeClass('btn-success').addClass('btn-primary'); - } - }, - refresh : function() { this.refreshSummary(); this.refreshLocations(); this.refreshForm(); - this.refreshButtons(); $('#receive-article_locationBarcode').focus(); } @@ -180,26 +182,65 @@ var controller = { + onShowFirstLocation : function () { + + model.newEmptyStorageMovementForNextLocation(); + + }, + + next : function(full) { + + var barcode = $('#receive-article_locationBarcode').val(); + + var quantity; + if (full) { + quantity = 0; + } else { + quantity = parseFloat($('#receive-article_quantity').val()); + } + + model.store(barcode, quantity); + + // if used location focused as current, highlight next location to go + if (barcode == model.locations[model.locationsIndex].barcode) { + model.nextLocation(); + } + + view.refresh(); + + }, + onNext : function() { try { - if (model.allowSubmit) { + controller.next(false); + model.newEmptyStorageMovementForNextLocation(); + + view.refresh(); + + } catch (ex) { + + if (ex instanceof ValidationError) { + handleValidationError(ex); } else { + throw ex; + } + } - var barcode = $('#receive-article_locationBarcode').val(); - var quantity = parseFloat($('#receive-article_quantity').val()); + }, - model.store(barcode, quantity); + onReportError : function() { - // if used location focused as current, highlight next location to go - if (barcode == model.locations[model.locationsIndex].barcode) { - model.nextLocation(); - } + try { - } + controller.next(true); + model.newEmptyStorageMovementForNextLocation(); + + view.refresh(); + } catch (ex) { if (ex instanceof ValidationError) { @@ -208,27 +249,47 @@ throw ex; } } + }, - onReportError : function() { + onConfirm : function() { try { - if (model.allowSubmit) { + var barcode = $('#receive-article_locationBarcode').val(); - } else { + if (barcode.length > 0) { - var barcode = $('#receive-article_locationBarcode').val(); + controller.next(false); - model.store(barcode, 0.); + } - // if used location focused as current, highlight next location to go - if (barcode == model.locations[model.locationsIndex].barcode) { - model.nextLocation(); + var confirmation = model.getConfirmation(); + + var storageMovementCount = Object.keys(confirmation.locationIdToStoredQuantities).length; + + if (storageMovementCount > 0) { + + var confirmMessage = 'Confirmer ' + storageMovementCount + ' mouvements ?'; + + if (confirm(confirmMessage)) { + + // push model as Json in a hidden field + $('#receive-article_confirmation').val(JSON.stringify(confirmation)); + + model.forceConfirm = true; + + $('#receive-article').submit(); + + } else { + + model.newEmptyStorageMovementForNextLocation(); + + view.refresh(); + } } - view.refresh(); } catch (ex) { @@ -237,31 +298,62 @@ } else { throw ex; } + } + }, + onCancel : function(e) { + + var confirmation = model.getConfirmation(); + + var confirmMessage = 'Annuler ' + Object.keys(confirmation.locationIdToStoredQuantities).length + ' mouvements ?'; + + var redirect = confirmation.locationIdToStoredQuantities.length == 0 + || confirm(confirmMessage); + + if (redirect) { + + redirectTo($('#cancelLink')); + + } else { + + if (e) { + e.preventDefault(); + } + + } + + }, + onSubmit : function(e) { - if (model.allowSubmit) { - // push model as Json in a hidden field - $('#receive-article_confirmation').val(JSON.stringify(model.getConfirmation())); + + if (model.forceConfirm) { + } else { + e.preventDefault(); - if (model.canTerminate()) { - model.allowSubmit = true; - } + } - view.refresh(); - } } }; // bindings $(document).ready(function() { + $('#receive-article').submit(controller.onSubmit); $('#receive-article_full').click(controller.onReportError); $('#receive-article_next').click(controller.onNext); + $('#confirm').click(controller.onConfirm); + $('#cancelLink').click(controller.onCancel); + + bindKey('F1', controller.onConfirm); + bindKey('F4', controller.onConfirm); bindKey('F5', controller.onReportError); + bindKey('Esc', controller.onCancel); + view.refresh(); + });
participants (1)
-
bleny@users.forge.codelutin.com