Author: bleny Date: 2013-03-27 16:52:22 +0100 (Wed, 27 Mar 2013) New Revision: 53 Url: http://forge.codelutin.com/projects/franciaflex-magalie/repository/revisions... Log: implements report error on a site Modified: trunk/magalie-web/src/main/webapp/js/withdraw-item-input.js Modified: trunk/magalie-web/src/main/webapp/js/withdraw-item-input.js =================================================================== --- trunk/magalie-web/src/main/webapp/js/withdraw-item-input.js 2013-03-27 15:41:29 UTC (rev 52) +++ trunk/magalie-web/src/main/webapp/js/withdraw-item-input.js 2013-03-27 15:52:22 UTC (rev 53) @@ -72,7 +72,7 @@ return withdrawn; }; -model.withdraw = function(barcode, quantity) { +model.getStorageMovement = function(barcode) { var storageMovement; for (var i = 0; i < this.storageMovements.length; i++) { if (barcode == this.storageMovements[i].originSite.barcode) { @@ -82,11 +82,26 @@ if (storageMovement == null) { throw new ValidationError(barcode + " n'est pas le code barre d'un emplacement valide"); } + return storageMovement; +}; + +model.withdraw = function(barcode, quantity) { + if ( ! isFinite(quantity) || quantity < 0) { + throw new ValidationError('Il faut entrer une quantité strictement supérieure à 0'); + } + var storageMovement = this.getStorageMovement(barcode); storageMovement.used = true; storageMovement.defect = quantity != storageMovement.quantity; storageMovement.withdrawn = quantity; }; +model.reportError = function(barcode) { + var storageMovement = this.getStorageMovement(barcode); + storageMovement.used = true; + storageMovement.defect = true; + storageMovement.withdrawn = 0; +}; + model.nextSite = function() { this.storageMovementsIndex += 1; if (this.storageMovementsIndex >= this.storageMovements.length) { @@ -171,9 +186,6 @@ var barcode = $('#siteBarcode').val(); var quantity = parseInt($('#quantity').val()); - if ( ! isFinite(quantity) || quantity < 0) { - throw new ValidationError('Il faut entrer une quantité strictement supérieure à 0'); - } model.withdraw(barcode, quantity); @@ -194,6 +206,35 @@ } }, + onReportError : function() { + + try { + + if (model.allowSubmit) { + + } else { + + var barcode = $('#siteBarcode').val(); + + model.reportError(barcode); + + // if used site focused as current, highlight next site to go + if (barcode == model.storageMovements[model.storageMovementsIndex].originSite.barcode) { + model.nextSite(); + } + + } + + } catch (ex) { + + if (ex instanceof ValidationError) { + handleValidationError(ex); + } else { + throw ex; + } + } + }, + onSubmit : function(e) { if (model.allowSubmit) { // push model as Json in a hidden field @@ -214,7 +255,7 @@ // bindings $(document).ready(function() { $('form').submit(controller.onSubmit); - $('#reportError').click(null); + $('#reportError').click(controller.onReportError); $('#next').click(controller.onNext); view.refresh();
participants (1)
-
bleny@users.forge.codelutin.com