Commit d34b217a by Damien Moulard

linting

parent 7ae3c4ec
dev_cooperatic #5673_bug_calendrier_echange_service 3832-makeups-and-member-status-update 4081 4444_improve_presence_recording 4709 4778-reception-dont-get-finished-orders 4809-remove-shelf-value-col-to-reduce-server-load 4880-rapports-reception-faux 4950-douchage-appli-reception 5474-et-5462-Voir-les-rattrapages-choisis-dans-admin-bdm-et-corrige-lenteur-affichage-admin-rattrapages 5641-reception-trier-a-la-maj-prix-dans-ordre-de-pointage-quantites 6286_bug_encaissement_souscription_cheque_espece 6813-marking-parent-gone-when-unpairing-binom-does-not-unsuscribe-parent-from-shift-template 6832--certaines-absences-engendrent-une-erreur 7723-7559-change-purchase-order-workflow-django-side 7731-third-party-side-brinks-pos-export-not-working 7747-inventaire-par-article 7800-make-test-solution-work 7848-cannot-validate-qty-with-decimal-on-kg-product adaptation_supercafoutch adaptation_supercoop adaptation_supercoop_supercafoutch adpatation_chouette assistance_import_article coop_dev_necessitant_modules_bdm_odoo_modifies correctif_nb_rattrapages_creation_binome_avec_ajout_automatique_au_point_negatif dev_lgds dev_principale dev_principale_clean docker export_capital_detenu fix_bug_process_picking fusion_custom_graoucoop graoucoop_backup graoucoop_prod graoucoop_tmp hot_fix_shelf_labels_auto_print howto impression_etiquettes_rayons integration_lien_precommandes_dans_espace_membre lacagette_prod local_branch master meal-voucher-and-label-printer-software-bug migration-v12 pour_graoucoop_prod pour_version_prod_cagette refonte_espace_membre_sc retouches_tickets_supercoop sc-setup-stock-app supercafoutch-preprod supercafoutch-prod-20221003 supercafoutch_prod ticket_4146 20210701 supercafoutch_20250120_151258 supercafoutch_20250120_150340 supercafoutch_20240909_080630 supercafoutch_20240609_115709 supercafoutch_20240212_082431 supercafoutch_20240107_181851 supercafoutch_prod_until_240107 supercafoutch-prod-20221003 supercafoutch-230911 supercafoutch-230824 supercafoutch-230823 supercafoutch-230823-the-true-one migration-v12-tag lacagette_20240310_074751 lacagette_20240107_122554 lacagette_20240107_120916 graoucoop_20240609_122614 cagette_testtag cagette-230814 cagette-230630
4 merge requests!40Add Howto page (to explain how to use 'Odoo user connect' feature),!35Aide a la commande,!106Dev principale,!45Intégration des Dev cooperatic (Aide à la commande, Réception avec cache couchDB, possibilité de valider une présence Comité)
Pipeline #963 passed with stage
in 21 seconds
......@@ -6,22 +6,26 @@ var suppliers_list = [],
/**
* Add a supplier to the selected suppliers list.
*
* @returns -1 if validation failed, void otherwise
* @returns -1 if validation failed, 0 otherwise
*/
function add_supplier() {
const user_input = $("#supplier_input").val();
// Check if user input is a valid supplier
const supplier = suppliers_list.find(s => s.display_name === user_input)
const supplier = suppliers_list.find(s => s.display_name === user_input);
if (supplier === undefined) {
alert("Le fournisseur renseigné n'est pas valide.\n"
+ "Veuillez sélectionner un fournisseur dans la liste déroulante.");
return -1;
}
const supplier_selected = selected_suppliers.find(s => s.display_name === user_input)
const supplier_selected = selected_suppliers.find(s => s.display_name === user_input);
if (supplier_selected !== undefined) {
alert("Ce fournisseur est déjà sélectionné.");
return -1;
}
......@@ -30,6 +34,7 @@ function add_supplier() {
selected_suppliers.push(supplier);
let url = "/orders/get_supplier_products";
url += "?sid=" + encodeURIComponent(supplier.id);
// Fetch supplier products
......@@ -42,7 +47,7 @@ function add_supplier() {
success: function(data) {
save_supplier_products(supplier, data.res.products);
update_display();
$("#supplier_input").val("")
$("#supplier_input").val("");
closeModal();
},
error: function(data) {
......@@ -56,6 +61,8 @@ function add_supplier() {
alert('Erreur lors de la récupération des produits, réessayer plus tard.');
}
});
return 0;
}
/**
......@@ -65,15 +72,15 @@ function add_supplier() {
*/
function remove_supplier(supplier_id) {
// Remove from suppliers list
selected_suppliers = selected_suppliers.filter(supplier => supplier.id != supplier_id)
selected_suppliers = selected_suppliers.filter(supplier => supplier.id != supplier_id);
// Remove the supplier from the products suppliers list
for (const i in products) {
products[i].suppliers = products[i].suppliers.filter(supplier => supplier.id != supplier_id)
products[i].suppliers = products[i].suppliers.filter(supplier => supplier.id != supplier_id);
}
// Remove products only associated to this product
products = products.filter(product => product.suppliers.length > 0)
products = products.filter(product => product.suppliers.length > 0);
update_display();
}
......@@ -92,9 +99,9 @@ function save_supplier_products(supplier, new_products) {
if (index === -1) {
np.suppliers = [{ ...supplier }];
products.push(np)
products.push(np);
} else {
products[index].suppliers.push({ ...supplier })
products[index].suppliers.push({ ...supplier });
}
}
}
......@@ -143,21 +150,25 @@ function supplier_column_name(supplier) {
*/
function display_suppliers() {
let supplier_container = $("#suppliers_container");
$("#suppliers_container").empty();
for (supplier of selected_suppliers) {
let template = $("#templates #supplier_pill")
let template = $("#templates #supplier_pill");
template.find(".supplier_name").text(supplier.display_name);
template.find(".remove_supplier_icon").attr('id', `remove_supplier_${supplier.id}`)
template.find(".remove_supplier_icon").attr('id', `remove_supplier_${supplier.id}`);
supplier_container.append(template.html());
}
$(".remove_supplier_icon").on("click", function(e) {
const el_id = $(this).attr('id').split('_');
$(".remove_supplier_icon").on("click", function() {
const el_id = $(this).attr('id')
.split('_');
const supplier_id = el_id[el_id.length-1];
let modal_remove_supplier = $('#templates #modal_remove_supplier');
modal_remove_supplier.find(".supplier_name").text(supplier.display_name);
openModal(
......@@ -165,9 +176,9 @@ function display_suppliers() {
() => {
remove_supplier(supplier_id);
},
'Valider',
'Valider'
);
})
});
}
/* DATATABLE */
......@@ -182,7 +193,7 @@ function prepare_datatable_data() {
let item = {
id: product.id,
name: product.name
}
};
// If product not related to supplier : false ; else null (qty to be set) or qty
for (product_supplier of product.suppliers) {
......@@ -213,7 +224,7 @@ function prepare_datatable_columns() {
},
{
data: "name",
title: "Produit",
title: "Produit"
}
];
......@@ -227,11 +238,13 @@ function prepare_datatable_columns() {
if (data === false) {
return "X";
} else {
const input_id = `product_${full.id}_supplier_${supplier.id}_qty_input`
return `<input type="number" class="product_qty_input" id=${input_id} value=${data}>`
const input_id = `product_${full.id}_supplier_${supplier.id}_qty_input`;
return `<input type="number" class="product_qty_input" id=${input_id} value=${data}>`;
}
}
})
});
}
return columns;
......@@ -244,6 +257,7 @@ function display_products() {
// Empty datatable if already exists
if (products.length == 0) {
$('.main').hide();
return -1;
}
......@@ -273,16 +287,20 @@ function display_products() {
// Save value on inputs change
$('#products_table').on('input', 'tbody td .product_qty_input', function () {
let val = parseFloat($(this).val())
let val = parseFloat($(this).val());
// If value is a number
if (!isNaN(val)) {
const id_split = $(this).attr('id').split('_')
const id_split = $(this).attr('id')
.split('_');
const prod_id = id_split[1];
const supplier_id = id_split[3];
save_product_supplier_qty(prod_id, supplier_id, val);
}
});
return 0;
}
/**
......@@ -309,7 +327,7 @@ $(document).ready(function() {
suppliers_list = data.res;
// Set up autocomplete on supplier input
$( "#supplier_input" ).autocomplete({
$("#supplier_input").autocomplete({
source: suppliers_list.map(a => a.display_name)
});
......@@ -330,7 +348,7 @@ $(document).ready(function() {
$("#supplier_form").on("submit", function(e) {
e.preventDefault();
add_supplier();
})
});
// TODO: on click on 'X' change to input
});
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