From 8224aa44dd9b6d5dfd779ff94bb4264e202873c0 Mon Sep 17 00:00:00 2001 From: lomamech Date: Sat, 29 May 2021 07:37:26 +0100 Subject: [PATCH 1/3] improvement(Depot) - Improve display in Allowed Destination Depots closes #5713 --- .../modules/depots/modals/depot.modal.html | 31 ++++++++++--- .../src/modules/depots/modals/depot.modal.js | 46 +++++++++++++++++++ 2 files changed, 70 insertions(+), 7 deletions(-) diff --git a/client/src/modules/depots/modals/depot.modal.html b/client/src/modules/depots/modals/depot.modal.html index 0f6cb09d31..be5f800f5c 100644 --- a/client/src/modules/depots/modals/depot.modal.html +++ b/client/src/modules/depots/modals/depot.modal.html @@ -153,12 +153,29 @@
-

DEPOT.NO_DEPOT

- - + +
+
+
+
+ +
+
+
+
+
+
+ +
+
+
+
@@ -166,7 +183,7 @@
diff --git a/client/src/modules/depots/modals/depot.modal.js b/client/src/modules/depots/modals/depot.modal.js index 1a7fa1524e..6a7fd9e0e6 100644 --- a/client/src/modules/depots/modals/depot.modal.js +++ b/client/src/modules/depots/modals/depot.modal.js @@ -9,6 +9,9 @@ function DepotModalController($state, Depots, Notify, Session, params) { const vm = this; vm.depot = {}; + vm.depotRight = []; + vm.depotLeft = []; + vm.identifier = params.uuid; vm.isCreateState = params.isCreateState; vm.enable_strict_depot_distribution = Session.stock_settings.enable_strict_depot_distribution; @@ -22,10 +25,43 @@ function DepotModalController($state, Depots, Notify, Session, params) { vm.depot.parent_uuid = params.parentUuid; } + 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); + if (!vm.isCreateState) { if (!vm.identifier) { return; } 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.depot = depot; // make sure hasLocation is set @@ -66,6 +102,16 @@ function DepotModalController($state, Depots, Notify, Session, params) { return 0; } + vm.depot.allowed_distribution_depots = []; + + vm.depotRight.forEach(depot => { + if (depot.checked) vm.depot.allowed_distribution_depots.push(depot.uuid); + }); + + vm.depotLeft.forEach(depot => { + if (depot.checked) vm.depot.allowed_distribution_depots.push(depot.uuid); + }); + Depots.clean(vm.depot); if (vm.hasLocation === 0) { From e1c9e88f5d49d36fa3c07d31c0c1129e73f035f2 Mon Sep 17 00:00:00 2001 From: lomamech Date: Tue, 1 Jun 2021 11:20:10 +0100 Subject: [PATCH 2/3] improvement(Modal Depot) - Remove depotLeft and depotRight - Use index for display depot in two column --- .../modules/depots/modals/depot.modal.html | 33 ++++++++++--------- .../src/modules/depots/modals/depot.modal.js | 33 +++---------------- 2 files changed, 21 insertions(+), 45 deletions(-) diff --git a/client/src/modules/depots/modals/depot.modal.html b/client/src/modules/depots/modals/depot.modal.html index be5f800f5c..082c5cf5a0 100644 --- a/client/src/modules/depots/modals/depot.modal.html +++ b/client/src/modules/depots/modals/depot.modal.html @@ -153,25 +153,26 @@
-
-
-
-
- +
+
+
+
+ +
-
-
-
-
- +
+
+
+ +
diff --git a/client/src/modules/depots/modals/depot.modal.js b/client/src/modules/depots/modals/depot.modal.js index 6a7fd9e0e6..6bca1e85e7 100644 --- a/client/src/modules/depots/modals/depot.modal.js +++ b/client/src/modules/depots/modals/depot.modal.js @@ -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; @@ -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); @@ -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; } }); }); @@ -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); }); From a46b9e2c5e3a51faaead5e8c0809401014451fe4 Mon Sep 17 00:00:00 2001 From: lomamech Date: Thu, 3 Jun 2021 09:58:59 +0100 Subject: [PATCH 3/3] Clean and sanitaze code --- client/src/modules/depots/modals/depot.modal.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/modules/depots/modals/depot.modal.html b/client/src/modules/depots/modals/depot.modal.html index 082c5cf5a0..6cb4d73b97 100644 --- a/client/src/modules/depots/modals/depot.modal.html +++ b/client/src/modules/depots/modals/depot.modal.html @@ -184,7 +184,7 @@