Skip to content

Commit

Permalink
Merge #5714
Browse files Browse the repository at this point in the history
5714: improvement(Depot) r=jniles a=lomamech

- Improve display in Allowed Destination Depots

closes #5713

Co-authored-by: lomamech <lomamech@gmail.com>
  • Loading branch information
bors[bot] and lomamech authored Jun 9, 2021
2 parents 75bbb6a + a46b9e2 commit 211e548
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 6 deletions.
30 changes: 24 additions & 6 deletions client/src/modules/depots/modals/depot.modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,30 @@

<div ng-if="DepotModalCtrl.enable_strict_depot_distribution">
<label class="control-label" translate>DEPOT.ALLOWED_DESTINATION_DEPOTS</label>
<p ng-if="!DepotModalCtrl.depot.allowed_distribution_depots.length"><i translate>DEPOT.NO_DEPOT</i></p>
<bh-depot-search-select label="STOCK.DEPOT" id="distribution_depots"
depots-uuids="DepotModalCtrl.depot.allowed_distribution_depots"
on-change="DepotModalCtrl.onDistributionDepotChange(depots)"
required="DepotModalCtrl.enable_strict_depot_distribution">
</bh-depot-search-select>
<div class="row">
<div ng-repeat ="d in DepotModalCtrl.depots">
<div class="col-md-6">
<div ng-if="$index %2 == 0">
<div class="checkbox">
<label>
<input type="checkbox" ng-model="d.checked" ng-true-value="1" ng-false-value="0">
<span translate> {{ d.text }} </span>
</label>
</div>
</div>
</div>
<div class="col-md-6">
<div ng-if="$index %2 != 0">
<div class="checkbox">
<label>
<input type="checkbox" ng-model="d.checked" ng-true-value="1" ng-false-value="0">
<span translate> {{ d.text }} </span>
</label>
</div>
</div>
</div>
</div>
</div>
</div>

<div class="form-group" ng-class="{'has-error' : DepotForm.description.$invalid && DepotForm.$submitted}">
Expand Down
21 changes: 21 additions & 0 deletions client/src/modules/depots/modals/depot.modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ function DepotModalController($state, Depots, Notify, Session, params) {
const vm = this;

vm.depot = {};

vm.identifier = params.uuid;
vm.isCreateState = params.isCreateState;
vm.enable_strict_depot_distribution = Session.stock_settings.enable_strict_depot_distribution;
Expand All @@ -22,10 +23,24 @@ function DepotModalController($state, Depots, Notify, Session, params) {
vm.depot.parent_uuid = params.parentUuid;
}

Depots.read()
.then(depots => {
vm.depots = depots;
})
.catch(Notify.handleError);

if (!vm.isCreateState) {
if (!vm.identifier) { return; }
Depots.read(vm.identifier)
.then(depot => {
depot.allowed_distribution_depots.forEach(depotDist => {
vm.depots.forEach(d => {
if (d.uuid === depotDist) {
d.checked = 1;
}
});
});

vm.depot = depot;

// make sure hasLocation is set
Expand Down Expand Up @@ -66,6 +81,12 @@ function DepotModalController($state, Depots, Notify, Session, params) {
return 0;
}

vm.depot.allowed_distribution_depots = [];

vm.depots.forEach(depot => {
if (depot.checked) vm.depot.allowed_distribution_depots.push(depot.uuid);
});

Depots.clean(vm.depot);

if (vm.hasLocation === 0) {
Expand Down

0 comments on commit 211e548

Please sign in to comment.