Commit da42e4c6 by Alexis Aoun

refactor des fonctions qui geres le css des btns des popup

parent 00edd610
...@@ -112,22 +112,7 @@ function select_product_from_bc(barcode) { ...@@ -112,22 +112,7 @@ function select_product_from_bc(barcode) {
else if(qtyIsPriceToWeight){ else if(qtyIsPriceToWeight){
openModal($('#templates #modal_confirm_price_to_weight').html(), price_to_weight_is_wrong, 'Non', false, true, price_to_weight_confirmed_callback(found, p)); openModal($('#templates #modal_confirm_price_to_weight').html(), price_to_weight_is_wrong, 'Non', false, true, price_to_weight_confirmed_callback(found, p));
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
//rien modifier et sortir du pop up, ce qui correspond au comportement du bouton annulation
//(ou aussi appeler cancel button)
document.querySelector('#modal_closebtn_bottom').innerHTML = 'Oui';
document.getElementById("modal_closebtn_bottom").style.backgroundColor = "green";
document.getElementsByClassName("btn--success")[0].style.backgroundColor = "red";
document.querySelector('#product_to_verify').innerHTML = p.data[0];
document.querySelector('#price_to_verify').innerHTML = p.data[6];
document.getElementById("new_price_to_weight").style.display = "none";
document.getElementsByClassName("btn--success")[0].style.display = "";
} }
...@@ -213,19 +198,13 @@ function price_to_weight_confirmed_callback (found, p){ ...@@ -213,19 +198,13 @@ function price_to_weight_confirmed_callback (found, p){
editProductInfo(found.data, found.data.product_qty); editProductInfo(found.data, found.data.product_qty);
if (found.place === 'to_process') { if (found.place === 'to_process') {
let row = table_to_process.row($('#'+found.data.product_id[0])); let row = table_to_process.row($('#'+found.data.product_id[0]));
remove_from_toProcess(row, found.data); remove_from_toProcess(row, found.data);
} }
document.getElementsByClassName("btn--success")[0].style.display = ""; resetPopUpButtons();
document.getElementsByClassName("btn--success")[0].style.backgroundColor = "";
document.querySelector('#modal_closebtn_bottom').style.backgroundColor = "";
} }
}
} }
}
function price_to_weight_is_wrong(){ function price_to_weight_is_wrong(){
document.getElementById("new_price_to_weight").style.display = ""; document.getElementById("new_price_to_weight").style.display = "";
document.getElementsByClassName("btn--success")[0].style.display = "none"; document.getElementsByClassName("btn--success")[0].style.display = "none";
...@@ -233,6 +212,30 @@ function price_to_weight_is_wrong(){ ...@@ -233,6 +212,30 @@ function price_to_weight_is_wrong(){
priceToWeightIsCorrect = false; priceToWeightIsCorrect = false;
} }
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
//rien modifier et sortir du pop up, ce qui correspond au comportement du bouton annulation
//(ou aussi appeler cancel button)
document.querySelector('#modal_closebtn_bottom').innerHTML = 'Oui';
document.getElementById("modal_closebtn_bottom").style.backgroundColor = "green";
document.getElementsByClassName("btn--success")[0].style.backgroundColor = "red";
document.querySelector('#product_to_verify').innerHTML = p.data[0];
document.querySelector('#price_to_verify').innerHTML = p.data[6];
document.getElementById("new_price_to_weight").style.display = "none";
document.getElementsByClassName("btn--success")[0].style.display = "";
}
function resetPopUpButtons () {
document.getElementsByClassName("btn--success")[0].style.display = "";
document.getElementsByClassName("btn--success")[0].style.backgroundColor = "";
document.querySelector('#modal_closebtn_bottom').style.backgroundColor = "";
}
/* INIT */ /* INIT */
// Get order(s) data from server // Get order(s) data from server
......
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