Skip to content

Commit

Permalink
Clean and sanitaze code
Browse files Browse the repository at this point in the history
  • Loading branch information
lomamech authored and jniles committed Mar 4, 2021
1 parent 26230b1 commit 31dea3e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ function StockConsumptionLotsModalController(
vm.submit = submit;
vm.cancel = cancel;

vm.onLotBlur = onLotBlur;
vm.onChanges = onChanges;
vm.onChangeQuantity = onChangeQuantity;
vm.onChangeUnitCost = onChangeUnitCost;
Expand Down Expand Up @@ -103,10 +102,6 @@ function StockConsumptionLotsModalController(
};

function init() {
if (cache.enableFastInsert) {
vm.enableFastInsert = cache.enableFastInsert;
}

if (vm.form.rows.length) { return; }

vm.form.addItem();
Expand All @@ -116,44 +111,6 @@ function StockConsumptionLotsModalController(
vm.gridApi = api;
}

/**
* @method onLotBlur
*
* @description
* if the fast insert option is enable do this :
* - add new row automatically on blur
* - set the focus in the new row
* @param {string} rowLot the row.entity.lot string
*/
function onLotBlur(rowLot) {
if (vm.enableFastInsert && rowLot) {

const emptyLotRow = getFirstEmptyLot();

if (emptyLotRow) {
// don't add new row but focus on the empty lot row
Focus(emptyLotRow.identifier);
} else {
// add a new row
const newLotRow = vm.form.addItem();
// set the focus on the new row
Focus(newLotRow.identifier);
}
}
}

function getFirstEmptyLot() {
let line;
for (let i = 0; i < vm.form.rows.length; i++) {
const row = vm.form.rows[i];
if (!row.lot || row.lot.length === 0) {
line = row;
break;
}
}
return line;
}

function onChanges() {
vm.errors = vm.form.validate();
vm.gridApi.core.notifyDataChange(uiGridConstants.dataChange.EDIT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const EXIT_AGGREGATED_CONSUMPTION_ID = 16;

/**
* @function fetch
* @description fetch stock exit for patient
* @description fetch stock exit for Aggregate consumption
*/
function fetch(depotUuid, dateFrom, dateTo, showDetails) {
const sql = `
Expand Down

0 comments on commit 31dea3e

Please sign in to comment.