Commit 9479e21d by Damien Moulard

linting

parent a91c4f18
Pipeline #2397 passed with stage
in 1 minute 28 seconds
......@@ -284,6 +284,7 @@ function create_pair(payload) {
data.responseJSON.errors.map(function(error) {
message += ('\n' + error);
return null;
});
}
......
......@@ -92,12 +92,12 @@ function new_coop_validation() {
coop_registration_details.find('.shift_template').text(st);
process_state.html(current_coop.firstname + ' ' +current_coop.lastname);
coop_registration_details.find("#parentName").text("")
coop_registration_details.find("#parent").attr("hidden", true)
coop_registration_details.find("#parentName").text("");
coop_registration_details.find("#parent").attr("hidden", true);
if (current_coop.parent_name !== undefined) {
coop_registration_details.find("#parentName").text(current_coop.parent_name)
coop_registration_details.find("#parent").removeAttr("hidden")
coop_registration_details.find("#parentName").text(current_coop.parent_name);
coop_registration_details.find("#parent").removeAttr("hidden");
}
if (current_coop.shift_template.data && current_coop.shift_template.data.id != ASSOCIATE_MEMBER_SHIFT) {
......@@ -126,7 +126,7 @@ function create_new_coop() {
$('.chosen_associate').html("");
$('.chosen_associate_area').hide();
$('.member_choice').removeClass('choice_active');
$(".remove_binome_icon").on("click", hide_chosen_associate)
$(".remove_binome_icon").on("click", hide_chosen_associate);
local_in_process = getLocalInProcess();
if (getLocalInProcess().length > 0) {
empty_waiting_local_processes();
......@@ -271,11 +271,13 @@ function store_new_coop(event) {
if (active_asso_area.length > 0) {
// If user click as if a "binôme" is beeing created, data about parent member must exist
let associated_data_ok = false;
if (
($(active_asso_area[0]).attr('id') === "new_member_choice" && $('#new_member_input').val().trim().length > 0)
($(active_asso_area[0]).attr('id') === "new_member_choice" && $('#new_member_input').val()
.trim().length > 0)
||
($(active_asso_area[0]).attr('id') === "existing_member_choice" && $('#existing_member_choice_action .chosen_associate div.member').length > 0)
) {
) {
associated_data_ok = true;
}
if (associated_data_ok === false) errors.push("Le membre 'titulaire' du binôme n'est pas défini");
......@@ -318,7 +320,7 @@ function store_new_coop(event) {
}
}
});
}
}
......@@ -361,6 +363,7 @@ function modify_current_coop() {
$('#new_member_choice_action').hide();
$('#existing_member_choice').addClass('choice_active');
var member_button = '<div>' + current_coop.parent_name + '</div>';
$('.chosen_associate').html(member_button);
$('.chosen_associate_area').show();
associated_old_choice = 'existing_member_choice';
......@@ -726,7 +729,7 @@ function display_possible_members() {
/**
* Search for members to associate a new member with an old one.
* Search for members to associate a new member with an old one.
*/
function searchMembersForAssociate() {
let search_str = $('#search_member_input').val();
......
......@@ -75,7 +75,7 @@ var reset_shift_process_actions_zone = function() {
current_shift_process_data_actions.off('click', 'a');
current_shift_process_data_actions.hide();
current_shift_process_data_actions.empty();
}
};
function fill_member_slide(member) {
no_pict_msg.hide();
......@@ -329,38 +329,39 @@ function fill_service_entry(s) {
reset_shift_process_actions_zone();
if (s.state == 'draft' || s.state == 'confirm') {
let btn = $('<a>').addClass('btn btn--primary txtcenter')
.text('Enregistrer les absences / présences')
.attr('id','record_shift_absences');
.text('Enregistrer les absences / présences')
.attr('id', 'record_shift_absences');
current_shift_process_data_actions.append(btn);
current_shift_process_data_actions.on('click', '#record_shift_absences', function(){
current_shift_process_data_actions.on('click', '#record_shift_absences', function() {
msg = "<p>Lancer le traitement des présences et absences de ce service</p>";
openModal(msg, function() {
btn.attr('disabled', 'true')
btn.attr('disabled', 'true');
try {
$.ajax({
url: '/members/record_shift_absences/' + s.id,
dataType : 'json'
})
.done(function(rData) {
if (typeof rData.res.update !== "undefined" && rData.res.update == true) {
enqueue_message_for_next_loading("Données de présences traitées.");
location.reload();
} else {
closeModal();
btn.removeAttr('disabled');
alert(JSON.stringify(rData.res));
}
});
.done(function(rData) {
if (typeof rData.res.update !== "undefined" && rData.res.update == true) {
enqueue_message_for_next_loading("Données de présences traitées.");
location.reload();
} else {
closeModal();
btn.removeAttr('disabled');
alert(JSON.stringify(rData.res));
}
});
} catch (e) {
console.log(e);
}
}, 'Confirmer');
});
} else {
current_shift_process_data_actions.append("<em>Traitement des présences : " + s.state + "</em>");
}
current_shift_process_data_actions.show();
}
rattrapage_ou_volant = null;
......
......@@ -25,7 +25,7 @@ function init_my_shifts_tile() {
function process_asked_shift_template_change(shift_t_id) {
var s_data = shift_templates[shift_t_id].data;
var shift_name = get_shift_name(s_data);
let msg = 'Inscription au créneau ' + shift_name
let msg = 'Inscription au créneau ' + shift_name;
openModal(
msg,
......@@ -85,7 +85,7 @@ function process_asked_shift_template_change(shift_t_id) {
}
}
});
},
'Valider',
true, // modal closes after validation
......@@ -94,8 +94,9 @@ function process_asked_shift_template_change(shift_t_id) {
);
}
function edit_shift_template_registration(){
function edit_shift_template_registration() {
let external = true;
if (calendar == null) calendar = $('#modal-calendar-choice').clone();
if ($('#modal-calendar-choice').html().length > 0) {
$('#modal-calendar-choice').empty();
......@@ -103,9 +104,12 @@ function edit_shift_template_registration(){
}
calendar.find('.oddeven_selector').empty();
displayMsg(calendar.html());
$('#week_types').find('input').change(()=>{filter_weeks(external)});
$('#week_types').find('input')
.change(() => {
filter_weeks(external);
});
retrieve_and_draw_shift_tempates(external);
}
......@@ -127,7 +131,8 @@ function init_home() {
});
$(".member_shift_name_area").on("click", ".fa-edit", (e) => {
$('#week_types').find('input').change(filter_weeks);
$('#week_types').find('input')
.change(filter_weeks);
e.preventDefault();
edit_shift_template_registration();
});
......
......@@ -280,7 +280,7 @@ function offer_extra_shift() {
timeout: 3000,
success: function() {
partner_data.extra_shift_done -= 1;
$("#can_delete_future_registrations_area").hide();
$(".delete_registration_button").off();
$(".delete_registration_button").hide();
......@@ -599,6 +599,7 @@ function init_calendar_page() {
} else {
// Display modal
let modal_template = $("#modal_add_shift_template");
modal_template.find(".date_new_shift").text(new_shift_date);
modal_template.find(".time_new_shift").text(new_shift_time);
openModal(
......@@ -609,7 +610,7 @@ function init_calendar_page() {
"Valider"
);
}
} else if (should_select_makeup()) {
/* choose a makeup service */
// Check if selected new shift is in less than 6 months
......@@ -757,14 +758,15 @@ function init_delete_registration_buttons() {
if (partner_data.extra_shift_done > 0) {
$(".delete_registration_button").on("click", function() {
let shift_name = $(this).closest("div")
.parent().parent()
.parent()
.parent()
.find(".shift_line_date")
.text()
.trim();
let shift_id = $(this).closest(".shift_line_container")
.attr('id')
.split('_')[2];
openModal(
`<p>Je m'apprête à supprimer ma présence au service du <b>${shift_name}</b></p>`,
() => {
......@@ -774,7 +776,7 @@ function init_delete_registration_buttons() {
false
);
});
$(".delete_registration_button").css('display', 'flex');
}
}
......@@ -839,17 +841,17 @@ function init_shifts_exchange() {
}
$('#start_adding_shift').click((c) => {
openModal(
"<p>Je souhaite sélectionner un service supplémentaire.</p>",
() => {
$(c.target).prop('disabled', true);
adding_mode = true;
closeModal();
},
"Confirmer",
false
);
});
openModal(
"<p>Je souhaite sélectionner un service supplémentaire.</p>",
() => {
$(c.target).prop('disabled', true);
adding_mode = true;
closeModal();
},
"Confirmer",
false
);
});
$(window).smartresize(function() {
// only apply if a width threshold is passed
......
......@@ -314,6 +314,7 @@ $(document).ready(function() {
// For associated people, their parent name is attached in their display name
let partner_name_split = partner_data.name.split(', ');
partner_data.name = partner_name_split[partner_name_split.length - 1];
base_location = (app_env === 'dev') ? '/members_space/' : '/';
......
......@@ -138,7 +138,7 @@ function debounceFunction(func, delay = 1000) {
*/
function handle_unauthorize() {
alert("La session a expiré. Vous allez devoir vous reconnecter.");
$( "#logout" ).trigger( "click" );
$("#logout").trigger("click");
}
/* - PRODUCTS */
......@@ -310,10 +310,11 @@ function compute_and_affect_product_supplier_quantities(coeff, days) {
const daily_conso = product.daily_conso;
let purchase_package_qty_for_coverage = compute_purchase_qty_for_coverage(product, coeff, stock, incoming_qty, daily_conso, days);
// Set qty to purchase for supplier with higher priority
let target_supplierinfo_index = 0;
let min_sequence = Number.POSITIVE_INFINITY; // min sequence = higher priority
let min_sequence = Number.POSITIVE_INFINITY; // min sequence = higher priority
for (let i in products[key].suppliersinfo) {
let suppliersinfo_sequence = products[key].suppliersinfo[i].sequence;
......@@ -491,7 +492,7 @@ function check_products_data() {
}
report_JS_error(err, 'orders');
alert(`Erreur lors de la vérification des données des articles. Certaines données peuvent être erronées`);
$('.notifyjs-wrapper').trigger('notify-hide');
// Don't block process if this call fails
resolve();
......@@ -559,15 +560,15 @@ function update_product_ref(input_el, p_id, p_index) {
handle_unauthorize();
} else {
let msg = "erreur serveur lors de la sauvegarde de la référence";
msg += ` (product_tmpl_id: ${product.id}`;
err = {msg: msg, ctx: 'update_product_ref'};
if (typeof data.responseJSON != 'undefined' && typeof data.responseJSON.error != 'undefined') {
err.msg += ' : ' + data.responseJSON.error;
}
report_JS_error(err, 'orders');
alert('Erreur lors de la sauvegarde de la référence dans Odoo. Veuillez recharger la page et ré-essayer plus tard.');
}
}
......@@ -637,7 +638,7 @@ function add_supplier() {
err.msg += ' : ' + data.responseJSON.error;
}
report_JS_error(err, 'orders');
closeModal();
alert('Erreur lors de la récupération des produits, réessayer plus tard.');
}
......@@ -741,15 +742,15 @@ function save_supplier_product_association(product, supplier, cell) {
handle_unauthorize();
} else {
let msg = "erreur serveur lors de la sauvegarde de l'association product/supplier";
msg += ` (product_tmpl_id: ${product.id}; supplier_id: ${supplier.id})`;
err = {msg: msg, ctx: 'save_supplier_product_association'};
if (typeof data.responseJSON != 'undefined' && typeof data.responseJSON.error != 'undefined') {
err.msg += ' : ' + data.responseJSON.error;
}
report_JS_error(err, 'orders');
closeModal();
alert('Erreur lors de la sauvegarde de l\'association. Veuillez ré-essayer plus tard.');
}
......@@ -800,13 +801,13 @@ function end_supplier_product_association(product, supplier) {
} else {
let msg = "erreur serveur lors de la suppression de l'association product/supplier".
msg += ` (product_tmpl_id: ${product.id}; supplier_id: ${supplier.id})`;
err = {msg: msg, ctx: 'end_supplier_product_association'};
if (typeof data.responseJSON != 'undefined' && typeof data.responseJSON.error != 'undefined') {
err.msg += ' : ' + data.responseJSON.error;
}
report_JS_error(err, 'orders');
closeModal();
alert('Erreur lors de la suppression de l\'association. Veuillez ré-essayer plus tard.');
}
......@@ -980,13 +981,13 @@ function commit_actions_on_product(product, inputs) {
} else {
let msg = "erreur serveur lors de la sauvegarde".
msg += ` (product_tmpl_id: ${product.id})`;
err = {msg: msg, ctx: 'commit_actions_on_product'};
if (typeof data.responseJSON != 'undefined' && typeof data.responseJSON.error != 'undefined') {
err.msg += ' : ' + data.responseJSON.error;
}
report_JS_error(err, 'orders');
try {
if (data.responseJSON.code === "archiving_with_incoming_qty") {
alert("Ce produit a des quantités entrantes, vous ne pouvez pas l'archiver.");
......@@ -998,7 +999,7 @@ function commit_actions_on_product(product, inputs) {
} catch (error) {
alert('Erreur lors de la sauvegarde des données. Veuillez ré-essayer plus tard.');
}
check_products_data()
.then(() => {
update_cdb_order();
......@@ -1081,12 +1082,12 @@ function generate_inventory() {
.append(`Faire un inventaire`);
let msg = "erreur serveur lors de la création de l'inventaire",
err = {msg: msg, ctx: 'generate_inventory'};
if (typeof data.responseJSON != 'undefined' && typeof data.responseJSON.error != 'undefined') {
err.msg += ' : ' + data.responseJSON.error;
}
report_JS_error(err, 'orders');
alert("Erreur lors de la création de l'inventaire. Réessayez plus tard.");
}
}
......@@ -1362,13 +1363,13 @@ function create_orders() {
handle_unauthorize();
} else {
let msg = "erreur serveur lors de la création des product orders";
err = {msg: msg, ctx: 'save_supplier_product_association', data: orders_data};
if (typeof data.responseJSON != 'undefined' && typeof data.responseJSON.error != 'undefined') {
err.msg += ' : ' + data.responseJSON.error;
}
report_JS_error(err, 'orders');
closeModal();
alert('Erreur lors de la création des commandes. Veuillez ré-essayer plus tard.');
}
......@@ -2826,7 +2827,7 @@ $(document).ready(function() {
err.msg += ' : ' + data.responseJSON.error;
}
report_JS_error(err, 'orders');
closeModal();
alert('Erreur lors de la récupération des fournisseurs, rechargez la page plus tard');
}
......
......@@ -1979,10 +1979,12 @@ function add_products_action() {
for (let qty_input of qty_inputs) {
if ($(qty_input).val() === "") {
has_empty_qty_input = true;
$(qty_input).closest(".product_qty").find(".product_qty_input_alert")
$(qty_input).closest(".product_qty")
.find(".product_qty_input_alert")
.show();
} else {
$(qty_input).closest(".product_qty").find(".product_qty_input_alert")
$(qty_input).closest(".product_qty")
.find(".product_qty_input_alert")
.hide();
}
}
......@@ -2024,8 +2026,10 @@ function create_orders() {
for (let i = 0; i < add_products_lines.length; i++) {
let line = add_products_lines[i];
if ($(line).find(".product_name").text() === p.name) {
product_uom = $(line).find(".product_uom").text();
if ($(line).find(".product_name")
.text() === p.name) {
product_uom = $(line).find(".product_uom")
.text();
if (product_uom.includes("kg")) {
product_qty = parseFloat($(line).find(".product_qty_input")
......@@ -2045,15 +2049,16 @@ function create_orders() {
// If package qty is > than input value, package qty will be used while creating order
let package_qty = p_supplierinfo.package_qty;
if (product_qty < package_qty) {
package_qty = product_qty;
}
// Round differently for unit & kg products
if (product_uom.includes("kg") ) {
if (product_uom.includes("kg")) {
item_qty_package = Math.round((product_qty / package_qty) * 1e2) / 1e2;
} else {
item_qty_package = Math.round(product_qty / package_qty)
item_qty_package = Math.round(product_qty / package_qty);
}
orders_data.suppliers_data[supplier_id].lines.push({
......
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