Commit 88bbcc8e by Alexis Aoun

controle de l'input et fix des warnings de lint

parent ae99c34c
......@@ -69,6 +69,7 @@ function select_product_from_bc(barcode) {
try {
if (editing_product == null) {
var scannedProduct = barcodes.get_corresponding_odoo_product(barcode);
priceToWeightIsCorrect = true;
if (scannedProduct == null) {
......@@ -95,26 +96,24 @@ function select_product_from_bc(barcode) {
});
}
if(foundProduct.data !== null){
if(scannedProduct.rule === 'weight'){
if (foundProduct.data !== null) {
if (scannedProduct.rule === 'weight') {
foundProduct.data.product_qty = scannedProduct.qty;
}
else if(scannedProduct.rule === 'price_to_weight'){
} else if (scannedProduct.rule === 'price_to_weight') {
openModal($('#templates #modal_confirm_price_to_weight').html(), price_to_weight_is_wrong, 'Non', false, true, price_to_weight_confirmed_callback(foundProduct, scannedProduct));
setupPopUpBtnStyle(scannedProduct);
}
if(scannedProduct.rule !== 'price_to_weight'){
if(scannedProduct.rule === 'weight'){
if (scannedProduct.rule !== 'price_to_weight') {
if (scannedProduct.rule === 'weight') {
editProductInfo(foundProduct.data, foundProduct.data.product_qty);
}
else{
} else {
setLineEdition(foundProduct.data);
}
if (foundProduct.place === 'to_process') {
let row = table_to_process.row($('#'+foundProduct.data.product_id[0]));
remove_from_toProcess(row, foundProduct.data);
}
}
......@@ -174,35 +173,39 @@ function update_distant_orders() {
});
}
function price_to_weight_confirmed_callback (foundProduct, scannedProduct){
return function price_to_weight_confirmed(){
if(priceToWeightIsCorrect){
function price_to_weight_confirmed_callback (foundProduct, scannedProduct) {
return function price_to_weight_confirmed() {
if (priceToWeightIsCorrect) {
foundProduct.data.product_qty = scannedProduct.qty;
}
else{
} else {
//TODO il n'y a aucun controle sur l'input à corriger
foundProduct.data.product_qty = Number((scannedProduct.value/document.getElementById("new_price_to_weight").value).toFixed(3));
var tmp = Number((scannedProduct.value/document.getElementById("new_price_to_weight").value).toFixed(3));
if (isFinite(tmp)) {
foundProduct.data.product_qty = tmp;
}
}
if (foundProduct.data !== null) {
if (foundProduct.data !== null && isFinite(tmp)) {
editProductInfo(foundProduct.data, foundProduct.data.product_qty);
if (foundProduct.place === 'to_process') {
let row = table_to_process.row($('#'+foundProduct.data.product_id[0]));
remove_from_toProcess(row, foundProduct.data);
}
resetPopUpButtons();
}
}
};
}
function price_to_weight_is_wrong(){
function price_to_weight_is_wrong() {
document.getElementById("new_price_to_weight").style.display = "";
document.getElementsByClassName("btn--success")[0].style.display = "none";
document.querySelector('#modal_closebtn_bottom').innerHTML = 'OK';
priceToWeightIsCorrect = false;
}
function setupPopUpBtnStyle (p){
function setupPopUpBtnStyle (p) {
//On inverse en quelque sorte les boutons succes et d'annulation en mettant "Oui" sur le btn d'annulation
// et "Non" sur le bouton de reussite.
//Cela nous permet de reecrire moins de code puisque si la reponse est Oui on ne veut
......
......@@ -181,7 +181,7 @@
<h3>Confirmation du prix</h3>
<p>Est ce que le prix au kilo du produit <b><span id="product_to_verify"></span></b>
est bien <b><span id="price_to_verify"></span></b> euros/Kg ?</p>
<textarea name="Prix au Kilo" id="new_price_to_weight" cols="3" rows="1"></textarea>
<input type="number" min="0.00001" name="Prix au Kilo" id="new_price_to_weight">
</div>
</div>
<br/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment