Unverified Commit 45a61456 by Paul B

lint: fix errors not automatically fixable from eslint

parent c2889195
...@@ -74,8 +74,8 @@ function set_envelops(envelops) { ...@@ -74,8 +74,8 @@ function set_envelops(envelops) {
let split_id = envelop._id.split('_'); let split_id = envelop._id.split('_');
let envelop_date = split_id[3] + "/" + split_id[2] + "/" + split_id[1]; let envelop_date = split_id[3] + "/" + split_id[2] + "/" + split_id[1];
var envelop_name = 'Enveloppe du ' + envelop_date; let envelop_name = 'Enveloppe du ' + envelop_date;
var envelop_content_id = 'content_cash_list_' + cash_index; let envelop_content_id = 'content_cash_list_' + cash_index;
set_envelop_dom(envelop, envelop_name, envelop_content_id, cash_index); set_envelop_dom(envelop, envelop_name, envelop_content_id, cash_index);
...@@ -83,8 +83,8 @@ function set_envelops(envelops) { ...@@ -83,8 +83,8 @@ function set_envelops(envelops) {
} else if (envelop.type == "ch") { } else if (envelop.type == "ch") {
ch_envelops.push(envelop); ch_envelops.push(envelop);
var envelop_name = 'Enveloppe #' + envelop.display_id; let envelop_name = 'Enveloppe #' + envelop.display_id;
var envelop_content_id = 'content_ch_list_' + ch_index; let envelop_content_id = 'content_ch_list_' + ch_index;
set_envelop_dom(envelop, envelop_name, envelop_content_id, ch_index); set_envelop_dom(envelop, envelop_name, envelop_content_id, ch_index);
...@@ -100,8 +100,8 @@ function set_envelops(envelops) { ...@@ -100,8 +100,8 @@ function set_envelops(envelops) {
// Set accordions // Set accordions
var acc = document.getElementsByClassName("accordion"); var acc = document.getElementsByClassName("accordion");
for (var i = 0; i < acc.length; i++) { for (var j = 0; j < acc.length; j++) {
acc[i].addEventListener("click", function() { acc[j].addEventListener("click", function() {
/* Toggle between adding and removing the "active" class, /* Toggle between adding and removing the "active" class,
to highlight the button that controls the panel */ to highlight the button that controls the panel */
this.classList.toggle("active"); this.classList.toggle("active");
......
...@@ -16,9 +16,6 @@ if (coop_is_connected()) { ...@@ -16,9 +16,6 @@ if (coop_is_connected()) {
$.each(info.change.docs, function(i, e) { $.each(info.change.docs, function(i, e) {
console.log('changement'); console.log('changement');
console.log(e); console.log(e);
if (false) {
need_reload = true;
}
}); });
if (need_reload == true) { if (need_reload == true) {
......
...@@ -210,7 +210,7 @@ function search_member() { ...@@ -210,7 +210,7 @@ function search_member() {
function get_simple_service_name(s) { function get_simple_service_name(s) {
var simple_name = s.name; var simple_name = s.name;
var reg = new RegExp('([a-z]+)\. - [0-9\:]+ ?-? ?([a-z]*)', 'i'); var reg = new RegExp('([a-z]+). - [0-9:]+ ?-? ?([a-z]*)', 'i');
if (reg.exec(s.name)) { if (reg.exec(s.name)) {
var wd = RegExp.$1; var wd = RegExp.$1;
...@@ -324,7 +324,7 @@ function get_service_entry_data() { ...@@ -324,7 +324,7 @@ function get_service_entry_data() {
var time_param = now.toISOString(); var time_param = now.toISOString();
var offset = now.getTimezoneOffset(); var offset = now.getTimezoneOffset();
if (/([^\/]+)$/.exec(window.location)) { if (/([^/]+)$/.exec(window.location)) {
time_param = RegExp.$1.replace('%20', 'T') + 'Z'; time_param = RegExp.$1.replace('%20', 'T') + 'Z';
offset = 0; offset = 0;
} }
...@@ -528,7 +528,7 @@ function save_photo() { ...@@ -528,7 +528,7 @@ function save_photo() {
// actually snap photo (from preview freeze) and store it // actually snap photo (from preview freeze) and store it
Webcam.snap(function(data_uri) { Webcam.snap(function(data_uri) {
if (/data\:image\/jpeg;base64,(.+)/.exec(data_uri)) { if (/data:image\/jpeg;base64,(.+)/.exec(data_uri)) {
image_code = RegExp.$1; image_code = RegExp.$1;
if (current_displayed_member != null) { if (current_displayed_member != null) {
cancel_preview(); cancel_preview();
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
// element when the popup window is dismissed. // element when the popup window is dismissed.
function id_to_windowname(text) { function id_to_windowname(text) {
text = text.replace(/\./g, '__dot__'); text = text.replace(/\./g, '__dot__');
text = text.replace(/\-/g, '__dash__'); text = text.replace(/-/g, '__dash__');
return text; return text;
} }
......
...@@ -215,7 +215,7 @@ function getStyle(oElm, strCssRule) { ...@@ -215,7 +215,7 @@ function getStyle(oElm, strCssRule) {
if (document.defaultView && document.defaultView.getComputedStyle) { if (document.defaultView && document.defaultView.getComputedStyle) {
strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule); strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
} else if (oElm.currentStyle) { } else if (oElm.currentStyle) {
strCssRule = strCssRule.replace(/\-(\w)/g, function(strMatch, p1) { strCssRule = strCssRule.replace(/-(\w)/g, function(strMatch, p1) {
return p1.toUpperCase(); return p1.toUpperCase();
}); });
strValue = oElm.currentStyle[strCssRule]; strValue = oElm.currentStyle[strCssRule];
......
/*global opener */
(function() { (function() {
'use strict'; 'use strict';
var initData = JSON.parse(document.getElementById('django-admin-popup-response-constants').dataset.popupResponse); var initData = JSON.parse(document.getElementById('django-admin-popup-response-constants').dataset.popupResponse);
......
...@@ -3,7 +3,7 @@ var actions_last_dates = {}; ...@@ -3,7 +3,7 @@ var actions_last_dates = {};
function get_litteral_shift_template_name(name) { function get_litteral_shift_template_name(name) {
var l_name = ''; var l_name = '';
if (/([ABCD]{1})([A-Za-z\.]{4}) \- ([0-9\:]+)/.exec(name)) { if (/([ABCD]{1})([A-Za-z.]{4}) - ([0-9:]+)/.exec(name)) {
try { try {
var week = RegExp.$1; var week = RegExp.$1;
var day = RegExp.$2; var day = RegExp.$2;
...@@ -31,10 +31,9 @@ function get_litteral_shift_template_name(name) { ...@@ -31,10 +31,9 @@ function get_litteral_shift_template_name(name) {
} }
function is_time_to(action, delay) { function is_time_to(action, delay = 5000) {
var answer = false; var answer = false;
var last_date = actions_last_dates[action] || 0; var last_date = actions_last_dates[action] || 0;
var delay = delay || 5000;
var d = new Date(); var d = new Date();
var now = d.getTime(); var now = d.getTime();
......
...@@ -48,7 +48,7 @@ IFCBarcodes = { ...@@ -48,7 +48,7 @@ IFCBarcodes = {
//0493...{NNDDD} (pattern) //0493...{NNDDD} (pattern)
//0493213018809 (bc) //0493213018809 (bc)
pattern_found = true; pattern_found = true;
pattern = pattern.replace(/[^0-9\.ND]/, ''); pattern = pattern.replace(/[^0-9.ND]/, '');
bc = bc.slice(0, -1); // remove original check figure bc = bc.slice(0, -1); // remove original check figure
odoo_bc = ''; odoo_bc = '';
// Read pattern character by character // Read pattern character by character
......
...@@ -34,10 +34,10 @@ function add_product(product) { ...@@ -34,10 +34,10 @@ function add_product(product) {
width: "50%", width: "50%",
render: function (data, type, full, meta) { render: function (data, type, full, meta) {
// Add tooltip with barcode over product name // Add tooltip with barcode over product name
let display_barcode = "Aucun";
if ('barcode' in full) { if ('barcode' in full) {
var display_barcode = full.barcode; display_barcode = full.barcode;
} else {
var display_barcode = "Aucun";
} }
return '<div class="tooltip">' + data return '<div class="tooltip">' + data
...@@ -132,14 +132,14 @@ function add_product(product) { ...@@ -132,14 +132,14 @@ function add_product(product) {
// Add row to table // Add row to table
var rowNode = products_table.row.add(product).draw(false) var rowNode = products_table.row.add(product).draw(false)
.node(); .node();
let onAnimationEnd = function() {
rowNode.classList.remove('blink_me');
};
// Handle blinking effect for newly added row // Handle blinking effect for newly added row
$(rowNode).addClass('blink_me'); $(rowNode).addClass('blink_me');
rowNode.addEventListener('animationend', onAnimationEnd); rowNode.addEventListener('animationend', onAnimationEnd);
rowNode.addEventListener('webkitAnimationEnd', onAnimationEnd); rowNode.addEventListener('webkitAnimationEnd', onAnimationEnd);
function onAnimationEnd(e) {
rowNode.classList.remove('blink_me');
}
} }
} catch (e) { } catch (e) {
err = {msg: e.name + ' : ' + e.message, ctx: 'add_product'}; err = {msg: e.name + ' : ' + e.message, ctx: 'add_product'};
......
...@@ -158,6 +158,7 @@ function group_action() { ...@@ -158,6 +158,7 @@ function group_action() {
// Go to products page of order with smallest id // Go to products page of order with smallest id
goto(min_id); goto(min_id);
} else if (pswd == null) { } else if (pswd == null) {
return;
} else { } else {
alert('Mauvais mot de passe !'); alert('Mauvais mot de passe !');
} }
......
...@@ -83,11 +83,11 @@ function select_product_from_bc(barcode) { ...@@ -83,11 +83,11 @@ function select_product_from_bc(barcode) {
if (found.data !== null) { if (found.data !== null) {
setLineEdition(found.data); setLineEdition(found.data);
if (found.place === 'to_process') { if (found.place === 'to_process') {
var 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);
} else { } else {
var row = table_processed.row($('#'+found.data.product_id[0])); let row = table_processed.row($('#'+found.data.product_id[0]));
remove_from_processed(row, found.data); remove_from_processed(row, found.data);
} }
...@@ -188,22 +188,22 @@ function initLists() { ...@@ -188,22 +188,22 @@ function initLists() {
// Set lists with local storage content // Set lists with local storage content
for (var i = 0; i < updatedProducts.length; i++) { for (var i = 0; i < updatedProducts.length; i++) {
var product = updatedProducts[i]; let product = updatedProducts[i];
product['row_counter'] = -1; product['row_counter'] = -1;
list_processed.push(product); list_processed.push(product);
var toProcess_index = list_to_process.findIndex(x => x.id == updatedProducts[i]['id']); let toProcess_index = list_to_process.findIndex(x => x.id == updatedProducts[i]['id']);
if (toProcess_index > -1) { if (toProcess_index > -1) {
list_to_process.splice(toProcess_index, 1); list_to_process.splice(toProcess_index, 1);
} }
} }
for (var i = 0; i < validProducts.length; i++) { for (var j = 0; j < validProducts.length; j++) {
var toProcess_index = list_to_process.findIndex(x => x.id == validProducts[i]); let toProcess_index = list_to_process.findIndex(x => x.id == validProducts[j]);
if (toProcess_index > -1) { if (toProcess_index > -1) {
var product = list_to_process[toProcess_index]; let product = list_to_process[toProcess_index];
product['row_counter'] = -1; product['row_counter'] = -1;
list_processed.push(product); list_processed.push(product);
...@@ -223,10 +223,10 @@ function initLists() { ...@@ -223,10 +223,10 @@ function initLists() {
width: "50%", width: "50%",
render: function (data, type, full, meta) { render: function (data, type, full, meta) {
// Add tooltip with barcode over product name // Add tooltip with barcode over product name
if ('barcode' in full) {
var display_barcode = full.barcode;
} else {
var display_barcode = "Aucun"; var display_barcode = "Aucun";
if ('barcode' in full) {
display_barcode = full.barcode;
} }
return '<div class="tooltip">' + data return '<div class="tooltip">' + data
...@@ -286,10 +286,10 @@ function initLists() { ...@@ -286,10 +286,10 @@ function initLists() {
width: "60%", width: "60%",
render: function (data, type, full, meta) { render: function (data, type, full, meta) {
// Add tooltip with barcode over product name // Add tooltip with barcode over product name
if ('barcode' in full) {
var display_barcode = full.barcode;
} else {
var display_barcode = "Aucun"; var display_barcode = "Aucun";
if ('barcode' in full) {
display_barcode = full.barcode;
} }
return '<div class="tooltip">' + data return '<div class="tooltip">' + data
...@@ -464,14 +464,14 @@ function add_to_toProcess(product) { ...@@ -464,14 +464,14 @@ function add_to_toProcess(product) {
// Add to table (no data binding...) // Add to table (no data binding...)
var rowNode = table_to_process.row.add(product).draw(false) var rowNode = table_to_process.row.add(product).draw(false)
.node(); .node();
var onAnimationEnd = function() {
rowNode.classList.remove('blink_me');
};
// Handle blinking effect for newly added row // Handle blinking effect for newly added row
$(rowNode).addClass('blink_me'); $(rowNode).addClass('blink_me');
rowNode.addEventListener('animationend', onAnimationEnd); rowNode.addEventListener('animationend', onAnimationEnd);
rowNode.addEventListener('webkitAnimationEnd', onAnimationEnd); rowNode.addEventListener('webkitAnimationEnd', onAnimationEnd);
function onAnimationEnd(e) {
rowNode.classList.remove('blink_me');
}
} catch (e) { } catch (e) {
err = {msg: e.name + ' : ' + e.message, ctx: 'add_to_toProcess'}; err = {msg: e.name + ' : ' + e.message, ctx: 'add_to_toProcess'};
console.error(err); console.error(err);
...@@ -494,14 +494,14 @@ function add_to_processed(product, withCounter = true) { ...@@ -494,14 +494,14 @@ function add_to_processed(product, withCounter = true) {
// Add to table (no data binding...) // Add to table (no data binding...)
var rowNode = table_processed.row.add(product).draw(false) var rowNode = table_processed.row.add(product).draw(false)
.node(); .node();
var onAnimationEnd = function() {
rowNode.classList.remove('blink_me');
};
// Handle blinking efect for newly added row // Handle blinking efect for newly added row
$(rowNode).addClass('blink_me'); $(rowNode).addClass('blink_me');
rowNode.addEventListener('animationend', onAnimationEnd); rowNode.addEventListener('animationend', onAnimationEnd);
rowNode.addEventListener('webkitAnimationEnd', onAnimationEnd); rowNode.addEventListener('webkitAnimationEnd', onAnimationEnd);
function onAnimationEnd(e) {
rowNode.classList.remove('blink_me');
}
} catch (e) { } catch (e) {
err = {msg: e.name + ' : ' + e.message, ctx: 'add_to_processed'}; err = {msg: e.name + ' : ' + e.message, ctx: 'add_to_processed'};
console.error(err); console.error(err);
...@@ -604,12 +604,11 @@ function editProductInfo (productToEdit, value = null) { ...@@ -604,12 +604,11 @@ function editProductInfo (productToEdit, value = null) {
// Check if the product is already in the 'updated' list // Check if the product is already in the 'updated' list
var index = searchUpdatedProduct(); var index = searchUpdatedProduct();
var firstUpdate = false; var firstUpdate = false;
let newValue = value;
// If 'value' parameter not set, get value from edition input // If 'value' parameter not set, get value from edition input
if (value == null) { if (value == null) {
var newValue = parseFloat(document.getElementById('edition_input').value.replace(',', '.')); newValue = parseFloat(document.getElementById('edition_input').value.replace(',', '.'));
} else {
var newValue = value;
} }
// If qty edition & Check if qty changed // If qty edition & Check if qty changed
...@@ -796,13 +795,13 @@ function pre_send(type) { ...@@ -796,13 +795,13 @@ function pre_send(type) {
if (list_to_process.length > 0) { if (list_to_process.length > 0) {
alert("Il reste des produits à traiter dans la commande."); alert("Il reste des produits à traiter dans la commande.");
} else { } else {
updateType = type; let modal_next_step = '#templates #modal_prices_validation';
updateType = type;
if (type == 'qty_valid') { if (type == 'qty_valid') {
var modal_next_step = '#templates #modal_qties_validation'; modal_next_step = '#templates #modal_qties_validation';
} else {
var modal_next_step = '#templates #modal_prices_validation';
} }
openModal($(modal_next_step).html(), data_validation, 'Confirmer', false); openModal($(modal_next_step).html(), data_validation, 'Confirmer', false);
} }
} }
...@@ -957,7 +956,7 @@ function send() { ...@@ -957,7 +956,7 @@ function send() {
} else if (list_processed[i].barcode == false || list_processed[i].barcode == null || list_processed[i].barcode == "") { } else if (list_processed[i].barcode == false || list_processed[i].barcode == null || list_processed[i].barcode == "") {
// Products with no barcode // Products with no barcode
var node = document.createElement('li'); var node = document.createElement('li');
var textNode = document.createTextNode(list_processed[i]["product_id"][1]); let textNode = document.createTextNode(list_processed[i]["product_id"][1]);
node.appendChild(textNode); node.appendChild(textNode);
document.getElementById('barcodesEmpty_list').appendChild(node); document.getElementById('barcodesEmpty_list').appendChild(node);
...@@ -983,7 +982,7 @@ function send() { ...@@ -983,7 +982,7 @@ function send() {
var span_node = document.createElement('span'); var span_node = document.createElement('span');
span_node.className = 'order_ref_reminder'; span_node.className = 'order_ref_reminder';
var textNode = document.createTextNode(orders[order_id].name); let textNode = document.createTextNode(orders[order_id].name);
span_node.appendChild(textNode); span_node.appendChild(textNode);
...@@ -1043,10 +1042,10 @@ function send() { ...@@ -1043,10 +1042,10 @@ function send() {
// Remove all groups containing these orders // Remove all groups containing these orders
for (order_id in orders) { for (order_id in orders) {
search: search:
for (var i = 0; i < grouped_orders.length; i++) { for (var h = 0; h < grouped_orders.length; h++) {
for (var j = 0; j < grouped_orders[i].length; j++) { for (var j = 0; j < grouped_orders[h].length; j++) {
if (grouped_orders[i][j] == order_id) { if (grouped_orders[h][j] == order_id) {
grouped_orders.splice(i); grouped_orders.splice(h);
break search; break search;
} }
} }
...@@ -1179,7 +1178,9 @@ $(document).ready(function() { ...@@ -1179,7 +1178,9 @@ $(document).ready(function() {
err_msg += " - Order id: " + row_data.id_po; err_msg += " - Order id: " + row_data.id_po;
err_msg += " - Product: " + row_data.product_id[1]; err_msg += " - Product: " + row_data.product_id[1];
} catch (e) {} } catch (e) {
console.log(e);
}
err = {msg: err_msg, ctx: 'datatable: table to_process'}; err = {msg: err_msg, ctx: 'datatable: table to_process'};
console.error(err); console.error(err);
...@@ -1205,7 +1206,9 @@ $(document).ready(function() { ...@@ -1205,7 +1206,9 @@ $(document).ready(function() {
err_msg += " - Order id: " + row_data.id_po; err_msg += " - Order id: " + row_data.id_po;
err_msg += " - Product: " + row_data.product_id[1]; err_msg += " - Product: " + row_data.product_id[1];
} catch (e) {} } catch (e) {
console.log(e);
}
err = {msg: err_msg, ctx: 'datatable: table processed'}; err = {msg: err_msg, ctx: 'datatable: table processed'};
console.error(err); console.error(err);
......
...@@ -17,7 +17,7 @@ var validation_msg = $('#validation_msg'), ...@@ -17,7 +17,7 @@ var validation_msg = $('#validation_msg'),
var shelf, var shelf,
parent_location = '/shelfs', parent_location = '/shelfs',
origin = "shelf", // or custom_list (create from order view) originView = "shelf", // or custom_list (create from order view)
list_to_process = [], list_to_process = [],
table_to_process, table_to_process,
table_processed, table_processed,
...@@ -72,11 +72,11 @@ function select_product_from_bc(barcode) { ...@@ -72,11 +72,11 @@ function select_product_from_bc(barcode) {
if (found !== null) { if (found !== null) {
setLineEdition(found); setLineEdition(found);
if (editing_origin === 'to_process') { if (editing_origin === 'to_process') {
var row = table_to_process.row($('tr#'+found.id)); let row = table_to_process.row($('tr#'+found.id));
remove_from_toProcess(row); remove_from_toProcess(row);
} else { } else {
var row = table_processed.row($('tr#'+found.id)); let row = table_processed.row($('tr#'+found.id));
remove_from_processed(row); remove_from_processed(row);
} }
...@@ -107,13 +107,13 @@ function handle_blinking_effect(element) { ...@@ -107,13 +107,13 @@ function handle_blinking_effect(element) {
function edit_event(clicked) { function edit_event(clicked) {
// Remove from origin table // Remove from origin table
if (editing_origin == 'to_process') { if (editing_origin == 'to_process') {
var row = table_to_process.row(clicked.parents('tr')); let row = table_to_process.row(clicked.parents('tr'));
var row_data = row.data(); let row_data = row.data();
remove_from_toProcess(row); remove_from_toProcess(row);
} else { } else {
var row = table_processed.row(clicked.parents('tr')); let row = table_processed.row(clicked.parents('tr'));
var row_data = row.data(); let row_data = row.data();
remove_from_processed(row); remove_from_processed(row);
} }
...@@ -185,7 +185,7 @@ function editProductInfo (productToEdit, value = null) { ...@@ -185,7 +185,7 @@ function editProductInfo (productToEdit, value = null) {
add_to_processed(productToEdit); add_to_processed(productToEdit);
// Update local storage // Update local storage
localStorage.setItem(origin + "_" + shelf.id, JSON.stringify(shelf)); localStorage.setItem(originView + "_" + shelf.id, JSON.stringify(shelf));
return true; return true;
} }
...@@ -220,7 +220,7 @@ function initLists() { ...@@ -220,7 +220,7 @@ function initLists() {
} }
]; ];
if (origin == 'custom_list') { if (originView == 'custom_list') {
columns_to_process.splice(1, 0, {data:"shelf_sortorder", title:"Rayon", className:"dt-body-center"}); columns_to_process.splice(1, 0, {data:"shelf_sortorder", title:"Rayon", className:"dt-body-center"});
} }
...@@ -256,7 +256,7 @@ function initLists() { ...@@ -256,7 +256,7 @@ function initLists() {
} }
]; ];
if (origin == 'custom_list') { if (originView == 'custom_list') {
columns_processed.splice(2, 0, {data:"shelf_sortorder", title:"Rayon", className:"dt-body-center"}); columns_processed.splice(2, 0, {data:"shelf_sortorder", title:"Rayon", className:"dt-body-center"});
} }
...@@ -420,7 +420,7 @@ function pre_send() { ...@@ -420,7 +420,7 @@ function pre_send() {
// Proceed with inventory: send the request to the server // Proceed with inventory: send the request to the server
function send() { function send() {
if (is_time_to('submit_inv_qties'), 5000) { if (is_time_to('submit_inv_qties')) {
// Loading on // Loading on
var wz = $('#main-waiting-zone').clone(); var wz = $('#main-waiting-zone').clone();
...@@ -430,7 +430,7 @@ function send() { ...@@ -430,7 +430,7 @@ function send() {
// Add user comments to data sent to server // Add user comments to data sent to server
shelf.user_comments = user_comments; shelf.user_comments = user_comments;
var url = "../do_" + origin + "_inventory"; var url = "../do_" + originView + "_inventory";
$.ajaxSetup({ headers: { "X-CSRFToken": getCookie('csrftoken') } }); $.ajaxSetup({ headers: { "X-CSRFToken": getCookie('csrftoken') } });
$.ajax({ $.ajax({
...@@ -455,7 +455,7 @@ function send() { ...@@ -455,7 +455,7 @@ function send() {
} }
} }
var msg = (origin == 'shelf') ? 'Retour à la liste des rayons' : 'Retour'; var msg = (originView == 'shelf') ? 'Retour à la liste des rayons' : 'Retour';
openModal(inventory_validated_msg.html(), back, msg, true, false); openModal(inventory_validated_msg.html(), back, msg, true, false);
...@@ -464,7 +464,7 @@ function send() { ...@@ -464,7 +464,7 @@ function send() {
$('#modal_closebtn_bottom').on('click', back); $('#modal_closebtn_bottom').on('click', back);
// Clear local storage before leaving // Clear local storage before leaving
localStorage.removeItem(origin + '_' + shelf.id); localStorage.removeItem(originView + '_' + shelf.id);
}, },
error: function(data) { // 500 error has been thrown error: function(data) { // 500 error has been thrown
if (typeof data.responseJSON != 'undefined' && typeof data.responseJSON.error != 'undefined') { if (typeof data.responseJSON != 'undefined' && typeof data.responseJSON.error != 'undefined') {
...@@ -489,7 +489,7 @@ function exit_adding_product() { ...@@ -489,7 +489,7 @@ function exit_adding_product() {
// Add a product that's not in the list // Add a product that's not in the list
function open_adding_product() { function open_adding_product() {
if (origin == 'shelf') { if (originView == 'shelf') {
adding_product = true; adding_product = true;
openModal(add_product_form.html(), do_add_product, 'Valider', false, true, exit_adding_product); openModal(add_product_form.html(), do_add_product, 'Valider', false, true, exit_adding_product);
...@@ -560,7 +560,7 @@ function saveIssuesReport() { ...@@ -560,7 +560,7 @@ function saveIssuesReport() {
function get_shelf_data() { function get_shelf_data() {
$.ajaxSetup({ headers: { "X-CSRFToken": getCookie('csrftoken') } }); $.ajaxSetup({ headers: { "X-CSRFToken": getCookie('csrftoken') } });
var url = (origin == 'shelf') ? '../' + shelf.id : '../get_custom_list_data?id=' + shelf.id; var url = (originView == 'shelf') ? '../' + shelf.id : '../get_custom_list_data?id=' + shelf.id;
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
...@@ -591,7 +591,7 @@ function init() { ...@@ -591,7 +591,7 @@ function init() {
initLists(); initLists();
// Set DOM // Set DOM
if (origin == "shelf") { if (originView == "shelf") {
$('#shelf_name').text(shelf.name + ' (numéro ' + shelf.sort_order + ')'); $('#shelf_name').text(shelf.name + ' (numéro ' + shelf.sort_order + ')');
} else { } else {
$('#page_title').text("Inventaire du"); $('#page_title').text("Inventaire du");
...@@ -761,17 +761,17 @@ $(document).ready(function() { ...@@ -761,17 +761,17 @@ $(document).ready(function() {
// Working on a shelf // Working on a shelf
if (pathArray.includes('shelf_inventory')) { if (pathArray.includes('shelf_inventory')) {
origin = 'shelf'; originView = 'shelf';
parent_location = '/shelfs'; parent_location = '/shelfs';
} else { } else {
origin = 'custom_list'; originView = 'custom_list';
parent_location = '/inventory/custom_lists'; parent_location = '/inventory/custom_lists';
} }
//console.log(products) //console.log(products)
// Get shelf data from local storage // Get shelf data from local storage
if (Modernizr.localstorage) { if (Modernizr.localstorage) {
var stored_shelf = JSON.parse(localStorage.getItem(origin + '_' + shelf.id)); var stored_shelf = JSON.parse(localStorage.getItem(originView + '_' + shelf.id));
if (stored_shelf != null) { if (stored_shelf != null) {
shelf = stored_shelf; shelf = stored_shelf;
......
...@@ -409,8 +409,10 @@ var recordProductsAddedShelf = function() { ...@@ -409,8 +409,10 @@ var recordProductsAddedShelf = function() {
'/shelfs/admin/add_products', '/shelfs/admin/add_products',
{bc: JSON.stringify(barcodes), shelf_id: id}, {bc: JSON.stringify(barcodes), shelf_id: id},
function(err, rData) { function(err, rData) {
let msg = 'Echec';
if (typeof rData.res.added != "undefined") { if (typeof rData.res.added != "undefined") {
var msg = "Ajout des produits réussi."; msg = "Ajout des produits réussi.";
if (typeof rData.res.missing != "undefined") { if (typeof rData.res.missing != "undefined") {
msg += "\nSauf pour :"; msg += "\nSauf pour :";
...@@ -421,8 +423,6 @@ var recordProductsAddedShelf = function() { ...@@ -421,8 +423,6 @@ var recordProductsAddedShelf = function() {
alert(msg); alert(msg);
backToMain(); backToMain();
} else { } else {
var msg = 'Echec';
if (typeof rData.res.error != "undefined") if (typeof rData.res.error != "undefined")
msg = rData.res.error; msg = rData.res.error;
else if (typeof rData.res.msg != "undefined") else if (typeof rData.res.msg != "undefined")
......
...@@ -471,7 +471,6 @@ $(document).ready(function() { ...@@ -471,7 +471,6 @@ $(document).ready(function() {
maxTime: "22:00:00", maxTime: "22:00:00",
hiddenDays: daysToHide, hiddenDays: daysToHide,
initialView: calInitialView, initialView: calInitialView,
navLinks: true,
weekNumbers: true, weekNumbers: true,
events: function(start, end, timezone, callback) { events: function(start, end, timezone, callback) {
// Load possible shifts // Load possible shifts
......
...@@ -36,6 +36,21 @@ var main_content = $('#main-content'), ...@@ -36,6 +36,21 @@ var main_content = $('#main-content'),
// Sort products div according to selected sort type // Sort products div according to selected sort type
function sort_product_divs(divs_to_sort, sort_type) { function sort_product_divs(divs_to_sort, sort_type) {
let compare_price_uom = function (a, b) {
// For products by unit : get uom price
// For products by kg : get unit price (which is price of kg, we need to do this because some of them don't have a uom price)
let a_price_uom = $(a).find("span.uom_price")
.text() == 'Unité(s)' ? parseFloat($(a).find("span.uom_price")
.text()) : parseFloat($(a).find("span.price")
.text());
let b_price_uom = $(b).find("span.uom_price")
.text() == 'Unité(s)' ? parseFloat($(b).find("span.uom_price")
.text()) : parseFloat($(b).find("span.price")
.text());
return a_price_uom > b_price_uom ? 1 : -1;
};
var sorted_products = divs_to_sort.sort(function (a, b) { var sorted_products = divs_to_sort.sort(function (a, b) {
switch (sort_type) { switch (sort_type) {
case 'name_asc': case 'name_asc':
...@@ -55,29 +70,9 @@ function sort_product_divs(divs_to_sort, sort_type) { ...@@ -55,29 +70,9 @@ function sort_product_divs(divs_to_sort, sort_type) {
.text()) < parseFloat($(b).find("span.price") .text()) < parseFloat($(b).find("span.price")
.text()) ? 1 : -1; .text()) ? 1 : -1;
case 'price_uom_asc': case 'price_uom_asc':
// For products by unit : get uom price return compare_price_uom(a, b);
// For products by kg : get unit price (which is price of kg, we need to do this because some of them don't have a uom price)
var a_price_uom = $(a).find("span.uom_price")
.text() == 'Unité(s)' ? parseFloat($(a).find("span.uom_price")
.text()) : parseFloat($(a).find("span.price")
.text());
var b_price_uom = $(b).find("span.uom_price")
.text() == 'Unité(s)' ? parseFloat($(b).find("span.uom_price")
.text()) : parseFloat($(b).find("span.price")
.text());
return a_price_uom > b_price_uom ? 1 : -1;
case 'price_uom_desc': case 'price_uom_desc':
var a_price_uom = $(a).find("span.uom_price") return compare_price_uom(b, a);
.text() == 'Unité(s)' ? parseFloat($(a).find("span.uom_price")
.text()) : parseFloat($(a).find("span.price")
.text());
var b_price_uom = $(b).find("span.uom_price")
.text() == 'Unité(s)' ? parseFloat($(b).find("span.uom_price")
.text()) : parseFloat($(b).find("span.price")
.text());
return a_price_uom < b_price_uom ? 1 : -1;
default: default:
return $(a).find(".name") return $(a).find(".name")
.text() > $(b).find(".name") .text() > $(b).find(".name")
...@@ -92,7 +87,7 @@ function djLogError(e) { ...@@ -92,7 +87,7 @@ function djLogError(e) {
try { try {
$.post('/shop/log_error', {error: JSON.stringify(e)}); $.post('/shop/log_error', {error: JSON.stringify(e)});
} catch (e) { } catch (e) {
console.log(e);
} }
} }
......
...@@ -36,7 +36,7 @@ try { ...@@ -36,7 +36,7 @@ try {
} }
for (var k=1; k<=12; k++) { for (var k=1; k<=12; k++) {
let mth = k.pad(2); let mth = k.pad(2);
var opt = $('<option>').val(mth) let opt = $('<option>').val(mth)
.text(mth); .text(mth);
if (m == mth) opt.prop('selected', true); if (m == mth) opt.prop('selected', true);
...@@ -44,7 +44,7 @@ try { ...@@ -44,7 +44,7 @@ try {
} }
for (var l=1; l<=31; l++) { for (var l=1; l<=31; l++) {
let day = l.pad(2); let day = l.pad(2);
var opt = $('<option>').val(day) let opt = $('<option>').val(day)
.text(day); .text(day);
if (d == day) opt.prop('selected', true); if (d == day) opt.prop('selected', true);
......
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