diff --git a/client/src/modules/stock/requisition/modals/action.modal.html b/client/src/modules/stock/requisition/modals/action.modal.html index ccdcb4c8ee..8788f976f1 100644 --- a/client/src/modules/stock/requisition/modals/action.modal.html +++ b/client/src/modules/stock/requisition/modals/action.modal.html @@ -32,7 +32,6 @@ FORM.INFO.LOADING -
@@ -69,7 +68,7 @@ - + FORM.BUTTONS.SUBMIT
diff --git a/client/src/modules/stock/requisition/modals/action.modal.js b/client/src/modules/stock/requisition/modals/action.modal.js index d8b00c93ad..ff50b0fd8c 100644 --- a/client/src/modules/stock/requisition/modals/action.modal.js +++ b/client/src/modules/stock/requisition/modals/action.modal.js @@ -8,7 +8,7 @@ ActionRequisitionModalController.$inject = [ ]; function ActionRequisitionModalController( - $state, Store, Inventories, Notify, Modal, Stock, Receipts + $state, Store, Inventories, Notify, Modal, Stock, Receipts, ) { const vm = this; const store = new Store({ data : [] }); @@ -76,6 +76,8 @@ function ActionRequisitionModalController( if (!items.length) { return null; } + vm.loading = true; + angular.extend(vm.model, { items }); return Stock.stockRequisition.create(vm.model) @@ -83,7 +85,10 @@ function ActionRequisitionModalController( Receipts.stockRequisitionReceipt(res.uuid, true); Modal.close(true); }) - .catch(Notify.handleError); + .catch(Notify.handleError) + .finally(() => { + vm.loading = false; + }); }; function autoSuggestInventories() { diff --git a/client/src/modules/stock/requisition/registry.js b/client/src/modules/stock/requisition/registry.js index ae0b137444..0a6a63c83f 100644 --- a/client/src/modules/stock/requisition/registry.js +++ b/client/src/modules/stock/requisition/registry.js @@ -265,17 +265,6 @@ function StockRequisitionController( Notify.handleError(error); } - /** - * @function toggleLoadingIndicator - * - * @description - * Toggles the grid's loading indicator to eliminate the flash when rendering - * requisitions movements and allow a better UX for slow loads. - */ - function toggleLoadingIndicator() { - vm.loading = !vm.loading; - } - /** * @method load * @@ -285,14 +274,16 @@ function StockRequisitionController( */ function load(filters) { vm.hasError = false; - toggleLoadingIndicator(); + vm.loading = true; Stock.stockRequisition.read(null, filters) .then((requisitions) => { vm.gridOptions.data = requisitions; }) .catch(errorHandler) - .finally(toggleLoadingIndicator); + .finally(() => { + vm.loading = false; + }); } startup();