Skip to content

Commit

Permalink
improvement(Modal Depot)
Browse files Browse the repository at this point in the history
- Remove depotLeft and depotRight
- Use index for display depot in two column
  • Loading branch information
lomamech committed Jun 1, 2021
1 parent 0f96a23 commit 2d85831
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 45 deletions.
33 changes: 17 additions & 16 deletions client/src/modules/depots/modals/depot.modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -153,25 +153,26 @@

<div ng-if="DepotModalCtrl.enable_strict_depot_distribution">
<label class="control-label" translate>DEPOT.ALLOWED_DESTINATION_DEPOTS</label>

<div class="row">
<div class="col-md-6">
<div ng-repeat ="r in DepotModalCtrl.depotRight">
<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 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>
<div class="col-md-6">
<div ng-repeat ="l in DepotModalCtrl.depotLeft">
<div class="checkbox">
<label>
<input type="checkbox" ng-model="l.checked" ng-true-value="1" ng-false-value="0">
<span translate> {{ l.text }} </span>
</label>
<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>
Expand Down
33 changes: 4 additions & 29 deletions client/src/modules/depots/modals/depot.modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ function DepotModalController($state, Depots, Notify, Session, params) {
const vm = this;

vm.depot = {};
vm.depotRight = [];
vm.depotLeft = [];

vm.identifier = params.uuid;
vm.isCreateState = params.isCreateState;
Expand All @@ -28,19 +26,6 @@ function DepotModalController($state, Depots, Notify, Session, params) {
Depots.read()
.then(depots => {
vm.depots = depots;

let index = 0;
depots.forEach(depot => {
if ((vm.identifier && (vm.identifier !== depot.uuid)) || !vm.identifier) {
const indexCheck = index % 2;
if (indexCheck === 0) {
vm.depotRight.push(depot);
} else if (indexCheck === 1) {
vm.depotLeft.push(depot);
}
index++;
}
});
})
.catch(Notify.handleError);

Expand All @@ -49,15 +34,9 @@ function DepotModalController($state, Depots, Notify, Session, params) {
Depots.read(vm.identifier)
.then(depot => {
depot.allowed_distribution_depots.forEach(depotDist => {
vm.depotRight.forEach(r => {
if (r.uuid === depotDist) {
r.checked = 1;
}
});

vm.depotLeft.forEach(l => {
if (l.uuid === depotDist) {
l.checked = 1;
vm.depots.forEach(d => {
if (d.uuid === depotDist) {
d.checked = 1;
}
});
});
Expand Down Expand Up @@ -104,11 +83,7 @@ function DepotModalController($state, Depots, Notify, Session, params) {

vm.depot.allowed_distribution_depots = [];

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

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

Expand Down

0 comments on commit 2d85831

Please sign in to comment.