From 7e2718e00d1f121c162a077782459f8d49b92dd4 Mon Sep 17 00:00:00 2001 From: tofulm Date: Tue, 10 Nov 2020 12:12:12 +0100 Subject: [PATCH] repare si champ vide --- js/gamutable.es6.js | 40 +++++++++++++------- js/gamutable.js | 89 ++++++++++++++++++++++++++------------------- 2 files changed, 78 insertions(+), 51 deletions(-) diff --git a/js/gamutable.es6.js b/js/gamutable.es6.js index 46a6105..ec223f4 100644 --- a/js/gamutable.es6.js +++ b/js/gamutable.es6.js @@ -242,8 +242,18 @@ let monTableau = { if (!Array.isArray(colValue)) { colValue = [colValue]; } - if (colValue.filter((w) => w.length > 0).length) { - if (colValue.filter((w) => w.length > 0).indexOf(ligne.search[colName]) === -1) { + let TcolValue = []; + colValue.forEach((s) => { + if (Number.isInteger(s)) { + TcolValue.push(s); + } + if (s.length > 0) { + TcolValue.push(s); + } + }); + + if (TcolValue.length) { + if (TcolValue.indexOf(ligne.html[colName]) === -1) { rsearch = false; } } @@ -283,17 +293,19 @@ let monTableau = { // Si on veut filtrer la liste des options dynamique en fonction // du tri du tableau // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - //this.filtreCol.forEach((col) => { - //let Tval = ['']; - //this.tableau.forEach((t) => { - //let valCol = t.search[col]; - //if (Tval.indexOf(valCol) === -1) { - //Tval.push(valCol); - //this.filtreColValOk = true; - //} - //}); - //this.filtreColVal[col] = Tval; - //}); + if (this.filtrecolmulti === 'non') { + this.filtreCol.forEach((col) => { + let Tval = ['']; + this.tableau.forEach((t) => { + let valCol = t.html[col]; + if (Tval.indexOf(valCol) === -1) { + Tval.push(valCol); + this.filtreColValOk = true; + } + }); + this.filtreColVal[col] = Tval; + }); + } }, }, methods: { @@ -360,7 +372,7 @@ let monTableau = { this.filtreCol.forEach((col) => { let Tval = ['']; this.table.forEach((t) => { - let valCol = t.search[col]; + let valCol = t.html[col]; if (Tval.indexOf(valCol) === -1) { Tval.push(valCol); } diff --git a/js/gamutable.js b/js/gamutable.js index f0f1316..fed99f7 100644 --- a/js/gamutable.js +++ b/js/gamutable.js @@ -295,12 +295,19 @@ var monTableau = { colValue = [colValue]; } - if (colValue.filter(function (w) { - return w.length > 0; - }).length) { - if (colValue.filter(function (w) { - return w.length > 0; - }).indexOf(ligne.search[colName]) === -1) { + var TcolValue = []; + colValue.forEach(function (s) { + if (Number.isInteger(s)) { + TcolValue.push(s); + } + + if (s.length > 0) { + TcolValue.push(s); + } + }); + + if (TcolValue.length) { + if (TcolValue.indexOf(ligne.html[colName]) === -1) { rsearch = false; } } @@ -330,21 +337,29 @@ var monTableau = { }].concat(_toConsumableArray(this.table)); localStorage.setItem(this.nameLocalStorage, JSON.stringify($table)); }, - tableau: function tableau() {// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + tableau: function tableau() { + var _this3 = this; + + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Si on veut filtrer la liste des options dynamique en fonction // du tri du tableau // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - //this.filtreCol.forEach((col) => { - //let Tval = ['']; - //this.tableau.forEach((t) => { - //let valCol = t.search[col]; - //if (Tval.indexOf(valCol) === -1) { - //Tval.push(valCol); - //this.filtreColValOk = true; - //} - //}); - //this.filtreColVal[col] = Tval; - //}); + if (this.filtrecolmulti === 'non') { + this.filtreCol.forEach(function (col) { + var Tval = ['']; + + _this3.tableau.forEach(function (t) { + var valCol = t.html[col]; + + if (Tval.indexOf(valCol) === -1) { + Tval.push(valCol); + _this3.filtreColValOk = true; + } + }); + + _this3.filtreColVal[col] = Tval; + }); + } } }, methods: { @@ -360,7 +375,7 @@ var monTableau = { return ''; }, chargerJson: function chargerJson(id) { - var _this3 = this; + var _this4 = this; var url = this.apiuri; @@ -396,56 +411,56 @@ var monTableau = { return response.json(); }).then(function (data) { var config = data.shift(); - _this3.header = config.header; + _this4.header = config.header; if (config.crayons !== undefined) { - _this3.crayons = config.crayons; + _this4.crayons = config.crayons; } if (config.classes !== undefined) { - _this3.classes = config.classes; + _this4.classes = config.classes; } if (parseInt(id) > 0) { if (data.length > 0) { - var i = trouver_index(_this3.table, id); - _this3.table[i] = data[0]; + var i = trouver_index(_this4.table, id); + _this4.table[i] = data[0]; } else { - var _i2 = trouver_index(_this3.table, id); + var _i2 = trouver_index(_this4.table, id); - _this3.table.splice(_i2, 1); + _this4.table.splice(_i2, 1); } } else { - _this3.table = data; + _this4.table = data; if (data[0] && data[0].search) { - _this3.champ_search = 'search'; + _this4.champ_search = 'search'; } } if (config.filtreCol !== undefined) { - _this3.filtreCol = config.filtreCol; + _this4.filtreCol = config.filtreCol; - _this3.filtreCol.forEach(function (col) { + _this4.filtreCol.forEach(function (col) { var Tval = ['']; - _this3.table.forEach(function (t) { - var valCol = t.search[col]; + _this4.table.forEach(function (t) { + var valCol = t.html[col]; if (Tval.indexOf(valCol) === -1) { Tval.push(valCol); } }); - _this3.filtreColVal[col] = Tval; + _this4.filtreColVal[col] = Tval; }); } Vue.nextTick(function () { - _this3.chargement = false; + _this4.chargement = false; if ($_id > 0) { - _this3.selectLigne($_id, 'id'); + _this4.selectLigne($_id, 'id'); var _url = new URL(window.location); @@ -530,7 +545,7 @@ var monTableau = { } }, exportCSV: function exportCSV() { - var _this4 = this; + var _this5 = this; var $csv = []; var $header = []; @@ -540,7 +555,7 @@ var monTableau = { }); $tableau = this.tableau.reduce(function (acc, ligne) { var $uneLigne = []; - Object.values(ligne[_this4.champcsv]).forEach(function (l) { + Object.values(ligne[_this5.champcsv]).forEach(function (l) { return $uneLigne.push(l); }); return [].concat(_toConsumableArray(acc), [[].concat($uneLigne)]);