Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improvement(Depot) #5714

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If depotLeft and depotRight are just for displaying depots left and right, you could use just one loop such as :

<div ng-repeat ="r in DepotModalCtrl.depots" class="col-md-6">
  <div class="checkbox">
    <label>
      <input type="checkbox" ng-model="r.checked" ng-true-value="1" ng-false-value="0">
      <span translate> {{ r.text }} </span>
    </label>
  </div>
</div>

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

I tried with this option, the display stays on one column, my idea on concerning the two-column display was just not to have a very long list

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

</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