Skip to content

Commit

Permalink
fix(stock): misc cleanup
Browse files Browse the repository at this point in the history
This commit cleans up and optimizes the code, fixing typos and artifacts
left behind from testing.
  • Loading branch information
jniles committed Sep 15, 2017
1 parent 57be952 commit 580ac80
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 37 deletions.
4 changes: 2 additions & 2 deletions client/src/i18n/en/depot.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
"TITLE" : "Depot Management"
},
"NO_DEPOT" : "No Depot",
"NOT_ALLOWED_ACTIONS" : "This depot is protect. You cannot modify its properties.",
"NOT_ALLOWED_ACTIONS" : "This depot is protected. You cannot modify its properties.",
"TITLE" : "Depot Management",
"UPDATED" : "Depot updated with success",
"WAREHOUSE" : "Warehouse",
"MODAL" : {
"SELECTION" : "Depot Selection",
"NO_DEPOTS" : "Do not see any depots?",
"SELECT_A_DEPOT" : "Select a depot",
"NO_DEFAULT_DEPOT" : "Oops! We need you to choose a depot.",
"NO_DEFAULT_DEPOT" : "You need to choose a depot.",
"SELECTION_EXPLANATION" : "It looks like you don't have a default depot set! Please select your depot from the list below. You will only need to do this once. If your depot is not listed below, you can add it with this link:"
}
}
Expand Down
2 changes: 1 addition & 1 deletion client/src/modules/depots/depots.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function DepotService(Api, Modal) {
* @description
* Opens the selection modal to allow a user to select a depot.
*
* @returns Promise - a promise containing the depot.
* @returns Promise - a promise containing the selected depot.
*/
service.openSelectionModal = function openSelectionModal(depot) {
return Modal.open({
Expand Down
27 changes: 5 additions & 22 deletions client/src/modules/stock/adjustment/adjustment.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,11 @@ function StockAdjustmentController(
.catch(Notify.handleError);
}

function setupStock() {
function setupStock(depot) {
vm.Stock.setup();
vm.Stock.store.clear();
loadInventories(depot);
checkValidity();
}

function startup() {
Expand All @@ -138,15 +140,9 @@ function StockAdjustmentController(
// make sure that the depot is loaded if it doesn't exist at startup.
if (vm.depot) {
setupStock();
loadInventories(vm.depot);
checkValidity();
} else {
changeDepot()
.then(setupStock)
.then(function () {
loadInventories(vm.depot);
checkValidity();
});
.then(setupStock);
}
}

Expand All @@ -160,20 +156,6 @@ function StockAdjustmentController(
.catch(Notify.handleError);
}

// remove item from selectable inventories
function popInventory(item) {
var idx;
if (!item) { return; }
vm.selectableInventories.indexOf(item.inventory);
vm.selectableInventories.splice(idx, 1);
}

// insert item into selectable inventories
function pushInventory(inventory) {
if (!inventory) { return; }
vm.selectableInventories.push(inventory);
}

// check validity
function checkValidity() {
var lotsExists = vm.Stock.store.data.every(function (item) {
Expand Down Expand Up @@ -229,6 +211,7 @@ function StockAdjustmentController(
.then(function (depot) {
vm.depot = depot;
cache.depot = vm.depot;
return depot;
});
}

Expand Down
12 changes: 4 additions & 8 deletions client/src/modules/stock/depot-selection.ctrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function SelectDepotModalController(Instance, Depots, Notify, depot) {
vm.hasSelectedDepot = hasSelectedDepot;
vm.loading = false;

// this is a one-time message shown to the user if they do not have a cached depot.
// this is a toggle for a one-time message shown to the user if they do not have a cached depot.
vm.hasNoDefaultDepot = !angular.isDefined(depot);

vm.submit = function submit() { Instance.close(vm.depot); };
Expand All @@ -37,13 +37,9 @@ function SelectDepotModalController(Instance, Depots, Notify, depot) {

// fired when a user selects a depot from a list
function selectDepot(uuid) {
var selected;

vm.depots.forEach(function (d) {
if (d.uuid === uuid) { selected = d; }
});

vm.depot = selected;
vm.depot = vm.depots.filter(function (d) {
return d.uuid === uuid;
}).pop();
}

function toggleLoadingIndicator() {
Expand Down
2 changes: 1 addition & 1 deletion client/src/modules/stock/depot-selection.modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<strong> <i class="fa fa-warning"></i> <span translate>DEPOT.MODAL.NO_DEFAULT_DEPOT</span></strong>
<br />
<span translate>DEPOT.MODAL.SELECTION_EXPLANATION</span>
<a href ui-sref="depots.create"><b><span translate>DEPOT.ADD_DEPOT</span></b></a>.
<strong><a ui-sref="depots.create"><b><span translate>DEPOT.ADD_DEPOT</span></b></a></strong>.
</p>
</div>

Expand Down
1 change: 0 additions & 1 deletion client/src/modules/stock/exit/exit.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ function StockExitController(
vm.gridOptions = gridOptions;
vm.checkValidity = checkValidity;

// exit type
function selectExitType(exitType) {
vm.movement.exit_type = exitType.label;
mapExit[exitType.label].find();
Expand Down
2 changes: 0 additions & 2 deletions test/end-to-end/stock/stock.lots.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const GU = require('../shared/GridUtils');
const helpers = require('../shared/helpers');
const components = require('../shared/components');
const SearchModal = require('../shared/search.page');
const Filters = require('../shared/components/bhFilters');

Expand Down Expand Up @@ -51,7 +50,6 @@ function StockLotsRegistryTests() {
});

it('find lots in depot principal', () => {
browser.debugger();
modal.setDepot('Depot Principal');
modal.submit();
GU.expectRowCount(gridId, 8 + depotGroupingRow);
Expand Down

0 comments on commit 580ac80

Please sign in to comment.