Skip to content

Commit

Permalink
wip(stock): fix validation on removeItem()
Browse files Browse the repository at this point in the history
Ensures validation happens when we remove the items form the grid.
  • Loading branch information
jniles committed Mar 4, 2022
1 parent 5f2be85 commit 8f9e00f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
6 changes: 6 additions & 0 deletions client/src/js/components/bhStockExitType.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ angular.module('bhima.components')
bindings : {
onSelectCallback : '&',
depot : '<?',
exitType : '<?',
},
});

Expand All @@ -52,6 +53,11 @@ function StockExitTypeController(TypeService, Notify) {
if (changes.depot) {
reloadExitTypes();
}

// when the exit type is cleared, reload exit types
if (changes.exitType?.currentValue === undefined) {
reloadExitTypes();
}
};

/**
Expand Down
6 changes: 1 addition & 5 deletions client/src/modules/stock/StockExitForm.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,11 +464,6 @@ function StockExitFormService(

// reset the depot and load stock
this.setDepot(depot);

// validate() is only set up to test on submission as it checks the validity
// of individual items which will not have been configured, manually
// reset error state
delete this._errors;
});
};

Expand Down Expand Up @@ -551,6 +546,7 @@ function StockExitFormService(
const showNeedsLotsInfoMessage = this.details.exit_type
&& !hasDestinationError
&& this.store.data.length === 0;

this._toggleInfoMessage(showNeedsLotsInfoMessage, 'info', INFO_NEEDS_LOTS, this.details);

return hasRequiredDetails
Expand Down
1 change: 1 addition & 0 deletions client/src/modules/stock/exit/exit.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<div class="row">
<bh-stock-exit-type
depot="StockCtrl.stockForm.depot"
exit-type="StockCtrl.stockForm.details.exit_type"
on-select-callback="StockCtrl.onSelectExitType(type, entity)">
</bh-stock-exit-type>
</div>
Expand Down
2 changes: 1 addition & 1 deletion client/src/modules/stock/exit/exit.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ function StockExitController(
vm.validate();
};

vm.onRemoveItem = function onRemoveItem(uuid) {
vm.removeItem = function removeItem(uuid) {
vm.stockForm.removeItem(uuid);
vm.validate();
};
Expand Down
2 changes: 1 addition & 1 deletion client/src/modules/stock/exit/templates/actions.tmpl.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div class="ui-grid-cell-contents text-center">
<a class="text-action" ng-click="grid.appScope.stockForm.removeItem(row.entity.uuid)" tabindex="-1"><i class="fa fa-trash-o text-danger"></i></a>
<a class="text-action" ng-click="grid.appScope.removeItem(row.entity.uuid)" tabindex="-1"><i class="fa fa-trash-o text-danger"></i></a>
</div>

0 comments on commit 8f9e00f

Please sign in to comment.