Commit 2be6b9fe by François

Ajustement Eslint avec node v14.16.1 et maj de quelques fichiers qui étaient avec des warning

parent f4c92c1c
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
"main": "index.js", "main": "index.js",
"dependencies": {}, "dependencies": {},
"devDependencies": { "devDependencies": {
"eslint": "^7.16.0" "eslint": "^7.24.0"
}, },
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1",
......
...@@ -50,11 +50,11 @@ function set_local_storage(order_data) { ...@@ -50,11 +50,11 @@ function set_local_storage(order_data) {
} }
/* /*
* Remove from local storage orders that have a wrong status * Remove from local storage orders that have a wrong status
* (-> order has been updated elsewhere) * (-> order has been updated elsewhere)
*/ */
function clean_local_storage() { function clean_local_storage() {
var stored_order = null var stored_order = null;
// Loop through local storage // Loop through local storage
for (key of Object.keys(localStorage)) { for (key of Object.keys(localStorage)) {
...@@ -64,19 +64,20 @@ function clean_local_storage() { ...@@ -64,19 +64,20 @@ function clean_local_storage() {
// Loop through orders in table to find match // Loop through orders in table to find match
var i = 0; var i = 0;
var found = false; var found = false;
while (i < table_orders.rows().data().length && !found) { while (i < table_orders.rows().data().length && !found) {
var uptodate_order = table_orders.rows(i).data()[0] var uptodate_order = table_orders.rows(i).data()[0];
// If status in local storage is wrong // If status in local storage is wrong
if (stored_order.id == uptodate_order.id if (stored_order.id == uptodate_order.id
&& stored_order.reception_status != uptodate_order.reception_status) { && stored_order.reception_status != uptodate_order.reception_status) {
// Remove from local storage // Remove from local storage
localStorage.removeItem("order_" + uptodate_order.id); localStorage.removeItem("order_" + uptodate_order.id);
// Evolution: warn user (order modified elsewhere, local data has been deleted) // Evolution: warn user (order modified elsewhere, local data has been deleted)
found = true; found = true;
} }
i++; i++;
} }
...@@ -111,7 +112,7 @@ function create_groups_from_server_data() { ...@@ -111,7 +112,7 @@ function create_groups_from_server_data() {
} }
// Add server groups to stored groups // Add server groups to stored groups
grouped_orders = grouped_orders.concat(server_stored_groups) grouped_orders = grouped_orders.concat(server_stored_groups);
localStorage.setItem('grouped_orders', JSON.stringify(grouped_orders)); localStorage.setItem('grouped_orders', JSON.stringify(grouped_orders));
} }
...@@ -120,7 +121,7 @@ function create_groups_from_server_data() { ...@@ -120,7 +121,7 @@ function create_groups_from_server_data() {
*/ */
function extract_grouped_orders() { function extract_grouped_orders() {
var saved_grouped_orders = JSON.parse(localStorage.getItem('grouped_orders')); var saved_grouped_orders = JSON.parse(localStorage.getItem('grouped_orders'));
var groups_to_delete = [] // indexes var groups_to_delete = []; // indexes
// if there are grouped orders // if there are grouped orders
if (saved_grouped_orders != null) { if (saved_grouped_orders != null) {
...@@ -146,7 +147,7 @@ function extract_grouped_orders() { ...@@ -146,7 +147,7 @@ function extract_grouped_orders() {
// No order found, delete group and skip the rest // No order found, delete group and skip the rest
if (g.length == 0) { if (g.length == 0) {
groups_to_delete.push(group_index) groups_to_delete.push(group_index);
continue; continue;
} }
...@@ -163,12 +164,12 @@ function extract_grouped_orders() { ...@@ -163,12 +164,12 @@ function extract_grouped_orders() {
} }
if (g[0].reception_status == 'False') { if (g[0].reception_status == 'False') {
group_row += "<button class='btn--primary' onClick='group_goto(" group_row += "<button class='btn--primary' onClick='group_goto("
+ saved_groups.length + saved_groups.length
+ ")'>Compter les produits</button>"; + ")'>Compter les produits</button>";
} else { } else {
group_row += "<button class='btn--success' onClick='group_goto(" group_row += "<button class='btn--success' onClick='group_goto("
+ saved_groups.length + saved_groups.length
+ ")'>Mettre à jour les prix</button>"; + ")'>Mettre à jour les prix</button>";
} }
...@@ -181,7 +182,7 @@ function extract_grouped_orders() { ...@@ -181,7 +182,7 @@ function extract_grouped_orders() {
if (groups_to_delete.length > 0) { if (groups_to_delete.length > 0) {
for (index of groups_to_delete) { for (index of groups_to_delete) {
saved_grouped_orders.splice(index, 1) saved_grouped_orders.splice(index, 1);
} }
localStorage.setItem('grouped_orders', JSON.stringify(saved_grouped_orders)); localStorage.setItem('grouped_orders', JSON.stringify(saved_grouped_orders));
} }
...@@ -265,7 +266,7 @@ function group_action() { ...@@ -265,7 +266,7 @@ function group_action() {
for (var i = 0; i < selected_data.length; i++) { for (var i = 0; i < selected_data.length; i++) {
group_ids.push(selected_data[i].id); group_ids.push(selected_data[i].id);
} }
// Notify server that group is created // Notify server that group is created
$.ajax({ $.ajax({
type: "POST", type: "POST",
...@@ -307,14 +308,14 @@ function group_action() { ...@@ -307,14 +308,14 @@ function group_action() {
error: function(data) { error: function(data) {
if (data != null && data.status == 409) { if (data != null && data.status == 409) {
alert("Un groupe a déjà été formé sur un autre poste " alert("Un groupe a déjà été formé sur un autre poste "
+ "avec au moins l'une des commandes sélectionnées. Merci de rafraichir la page.") + "avec au moins l'une des commandes sélectionnées. Merci de rafraichir la page.");
} }
} }
}); });
} else { } else {
alert("Le local storage n'est pas disponible. Merci de contacter un.e salarié.e !") alert("Le local storage n'est pas disponible. Merci de contacter un.e salarié.e !");
} }
} else if (pswd == null) { } else if (pswd == null) {
...@@ -326,7 +327,7 @@ function group_action() { ...@@ -326,7 +327,7 @@ function group_action() {
$(document).ready(function() { $(document).ready(function() {
openModal() openModal();
$.ajaxSetup({ headers: { "X-CSRFToken": getCookie('csrftoken') } }); $.ajaxSetup({ headers: { "X-CSRFToken": getCookie('csrftoken') } });
...@@ -397,10 +398,10 @@ $(document).ready(function() { ...@@ -397,10 +398,10 @@ $(document).ready(function() {
iDisplayLength: 25, iDisplayLength: 25,
language: {url : '/static/js/datatables/french.json'}, language: {url : '/static/js/datatables/french.json'},
initComplete: function(settings, json) { // After data is loaded initComplete: function(settings, json) { // After data is loaded
clean_local_storage() clean_local_storage();
create_groups_from_server_data() create_groups_from_server_data();
extract_grouped_orders() extract_grouped_orders();
closeModal() closeModal();
} }
}); });
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
* Ecran de rechreche d'un article sur le nom et sur le code barre */ * Ecran de rechreche d'un article sur le nom et sur le code barre */
var table_article; var table_article = null;
var dataSet =[]; var dataSet =[];
var csrftoken; var csrftoken = '';
// lance la recherche sur le nom des l'article // lance la recherche sur le nom des l'article
function search_table_article() { function search_table_article() {
...@@ -30,7 +30,7 @@ $(document).ready(function() { ...@@ -30,7 +30,7 @@ $(document).ready(function() {
{ {
data:"image_small", data:"image_small",
"title":"Photo", "title":"Photo",
"render": function (data, type, full, meta) { "render": function (data, type, full) {
debut = '<button id="page1" type="button" data-toggle="modal" data-target=".modal" data-remote=' + full.id + ' class="btn btn-primary">'; debut = '<button id="page1" type="button" data-toggle="modal" data-target=".modal" data-remote=' + full.id + ' class="btn btn-primary">';
fin = "</button>"; fin = "</button>";
...@@ -41,14 +41,14 @@ $(document).ready(function() { ...@@ -41,14 +41,14 @@ $(document).ready(function() {
{data:"name", "title":"Article", "width": "50%"}, {data:"name", "title":"Article", "width": "50%"},
{data:"qty_available", "title":"En Stock", "width": "10%"}, {data:"qty_available", "title":"En Stock", "width": "10%"},
{data:"uom_id", {data:"uom_id",
"render":function (data, type, row) { "render":function (data) {
return data[1]; return data[1];
}, },
"title":"Unité", "width":"5%"}, "title":"Unité", "width":"5%"},
{data:"reception_status", {data:"reception_status",
"title":"Rupture", "className":"dt-body-center", "title":"Rupture", "className":"dt-body-center",
"render": function (data, type, full, meta) { "render": function (data, type, full) {
if (full.qty_available > 0) { if (full.qty_available > 0) {
return "<div><button id='bt_change' href='#'>Rupture</button></div>"; return "<div><button id='bt_change' href='#'>Rupture</button></div>";
} else { } else {
...@@ -135,7 +135,7 @@ $(document).ready(function() { ...@@ -135,7 +135,7 @@ $(document).ready(function() {
}); });
// Lancement de la rupture sur l'article choisie // Lancement de la rupture sur l'article choisie
function ruptureArticle(test) { function ruptureArticle() {
var jIdArcticle = { 'idArticle': selArctileData.id, 'uom_id' : selArctileData.uom_id[0] }; var jIdArcticle = { 'idArticle': selArctileData.id, 'uom_id' : selArctileData.uom_id[0] };
...@@ -148,7 +148,7 @@ function ruptureArticle(test) { ...@@ -148,7 +148,7 @@ function ruptureArticle(test) {
contentType: "application/json; charset=utf-8", contentType: "application/json; charset=utf-8",
data: JSON.stringify(jIdArcticle), data: JSON.stringify(jIdArcticle),
success: function(data) { success: function() {
document.location.href = "/stock/listArticleBreaking"; document.location.href = "/stock/listArticleBreaking";
}, },
...@@ -159,7 +159,7 @@ function ruptureArticle(test) { ...@@ -159,7 +159,7 @@ function ruptureArticle(test) {
}); });
} }
var selArctileData; var selArctileData = null;
// Fenetre de validation sur l'article // Fenetre de validation sur l'article
......
...@@ -64,7 +64,7 @@ $(document).on('click', '#dp_Search', function() { ...@@ -64,7 +64,7 @@ $(document).on('click', '#dp_Search', function() {
search_table_article(); search_table_article();
}); });
var csrftoken; var csrftoken = '';
$(document).ready(function() { $(document).ready(function() {
csrftoken = getCookie('csrftoken'); csrftoken = getCookie('csrftoken');
...@@ -98,7 +98,7 @@ function actionButton (vUrl, jIdArcticle, followPage) { ...@@ -98,7 +98,7 @@ function actionButton (vUrl, jIdArcticle, followPage) {
traditional: true, traditional: true,
contentType: "application/json; charset=utf-8", contentType: "application/json; charset=utf-8",
data: JSON.stringify(jIdArcticle), data: JSON.stringify(jIdArcticle),
success: function(data) { success: function() {
document.location.href = followPage; document.location.href = followPage;
}, },
error: function(resultat, statut, erreur) { error: function(resultat, statut, erreur) {
...@@ -108,7 +108,7 @@ function actionButton (vUrl, jIdArcticle, followPage) { ...@@ -108,7 +108,7 @@ function actionButton (vUrl, jIdArcticle, followPage) {
}); });
} }
var selArctileData; var selArctileData = null;
// Fenetre de validation sur l'article // Fenetre de validation sur l'article
......
...@@ -15,7 +15,7 @@ $(document).ready(function() { ...@@ -15,7 +15,7 @@ $(document).ready(function() {
{data:"name", "title":"Article", "width": "50%"}, {data:"name", "title":"Article", "width": "50%"},
{data:"maxdate", {data:"maxdate",
"render":function (data, type, row) { "render":function (data) {
my = new Date(data); my = new Date(data);
return my.toLocaleDateString() +" " + my.toLocaleTimeString(); return my.toLocaleDateString() +" " + my.toLocaleTimeString();
...@@ -23,7 +23,7 @@ $(document).ready(function() { ...@@ -23,7 +23,7 @@ $(document).ready(function() {
"title":"Date", "width":"15%"}, "title":"Date", "width":"15%"},
{data:"maxdate", {data:"maxdate",
"render":function (data, type, row) { "render":function (data) {
my = new Date(data); my = new Date(data);
var today = new Date(); var today = new Date();
...@@ -37,7 +37,7 @@ $(document).ready(function() { ...@@ -37,7 +37,7 @@ $(document).ready(function() {
{data:"purchase_ok", "width":"5%", {data:"purchase_ok", "width":"5%",
"title":"Achetable", "className":"dt-body-center", "title":"Achetable", "className":"dt-body-center",
"render": function (data, type, full, meta) { "render": function (data) {
if (data == true) { if (data == true) {
return '<div><input type="checkbox" id="bt_dontPurchase" checked><div>'; return '<div><input type="checkbox" id="bt_dontPurchase" checked><div>';
...@@ -48,14 +48,14 @@ $(document).ready(function() { ...@@ -48,14 +48,14 @@ $(document).ready(function() {
}, },
{data:"reception_status", "width":"5%", {data:"reception_status", "width":"5%",
"title":"Rupture", "className":"dt-body-center", "title":"Rupture", "className":"dt-body-center",
"render": function (data, type, full, meta) { "render": function () {
return "<div><button id='bt_change' href='#'>Stock à 0</button></div>"; return "<div><button id='bt_change' href='#'>Stock à 0</button></div>";
} }
}, },
{data:"reception_status", "width":"5%", {data:"reception_status", "width":"5%",
"title":"Archive", "className":"dt-body-center", "title":"Archive", "className":"dt-body-center",
"render": function (data, type, full, meta) { "render": function () {
return "<div><button id='bt_archive' href='#'>Archive</button></div>"; return "<div><button id='bt_archive' href='#'>Archive</button></div>";
} }
} }
...@@ -103,7 +103,7 @@ $(document).on('click', '#dp_Search', function() { ...@@ -103,7 +103,7 @@ $(document).on('click', '#dp_Search', function() {
search_table_article(); search_table_article();
}); });
var csrftoken; var csrftoken ='';
$(document).ready(function() { $(document).ready(function() {
csrftoken = getCookie('csrftoken'); csrftoken = getCookie('csrftoken');
...@@ -137,7 +137,7 @@ function actionButton (vUrl, jIdArcticle, followPage) { ...@@ -137,7 +137,7 @@ function actionButton (vUrl, jIdArcticle, followPage) {
traditional: true, traditional: true,
contentType: "application/json; charset=utf-8", contentType: "application/json; charset=utf-8",
data: JSON.stringify(jIdArcticle), data: JSON.stringify(jIdArcticle),
success: function(data) { success: function() {
document.location.href = followPage; document.location.href = followPage;
}, },
error: function(resultat, statut, erreur) { error: function(resultat, statut, erreur) {
...@@ -147,7 +147,7 @@ function actionButton (vUrl, jIdArcticle, followPage) { ...@@ -147,7 +147,7 @@ function actionButton (vUrl, jIdArcticle, followPage) {
}); });
} }
var selArctileData; var selArctileData = null;
// Fenetre de validation sur l'article // Fenetre de validation sur l'article
......
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