From d1846d34898b08c4865b80587c10ff19338796e2 Mon Sep 17 00:00:00 2001 From: tofulm Date: Thu, 14 Apr 2022 12:21:33 +0200 Subject: [PATCH] Double Corrections sur le filtrage select : * si le champ est un entier * si le champ est une string, on veut la corresponance exacte --- js/gamutable.es6.js | 37 +++++++++++++++++++++++++++++++------ js/gamutable.js | 27 +++++++++++++++++++++++++-- 2 files changed, 56 insertions(+), 8 deletions(-) diff --git a/js/gamutable.es6.js b/js/gamutable.es6.js index 7efc74d..770ec98 100644 --- a/js/gamutable.es6.js +++ b/js/gamutable.es6.js @@ -307,14 +307,39 @@ let monTableau = { }); if (TcolValue.length) { if (this.filtreColType[colName] === 'select') { - if ( - TcolValue.toString().indexOf( - ligne[this.champ_search][colName].toString().toLowerCase() - ) === -1 || - !ligne[this.champ_search][colName].toString().toLowerCase() - ) { + let Trsearch = TcolValue.some((uneValeur) => { + if (Number.isInteger(uneValeur)) { + if (parseInt(ligne[this.champ_search][colName]) === uneValeur) { + return true; + } + } else { + if ( + uneValeur.indexOf( + ligne[this.champ_search][colName] + .toString() + .toLowerCase() + .toString() + ) === -1 || + !ligne[this.champ_search][colName].toString().toLowerCase() + ) { + let toto = 1; + } else { + return true; + } + } + }); + if (!Trsearch) { rsearch = false; } + // if ( + // TcolValue.toString().indexOf( + // ligne[this.champ_search][colName].toString().toLowerCase() + // ) === -1 || + // !ligne[this.champ_search][colName].toString().toLowerCase() + // ) { + // console.log(ligne[this.champ_search][colName].toString().toLowerCase()); + // rsearch = false; + // } } else { if ( ligne[this.champ_search][colName] diff --git a/js/gamutable.js b/js/gamutable.js index 85890ec..c7e0bc2 100644 --- a/js/gamutable.js +++ b/js/gamutable.js @@ -365,9 +365,32 @@ var monTableau = { if (TcolValue.length) { if (_this2.filtreColType[colName] === 'select') { - if (TcolValue.toString().indexOf(ligne[_this2.champ_search][colName].toString().toLowerCase()) === -1 || !ligne[_this2.champ_search][colName].toString().toLowerCase()) { + var Trsearch = TcolValue.some(function (uneValeur) { + if (Number.isInteger(uneValeur)) { + if (parseInt(ligne[_this2.champ_search][colName]) === uneValeur) { + return true; + } + } else { + if (uneValeur.indexOf(ligne[_this2.champ_search][colName].toString().toLowerCase().toString()) === -1 || !ligne[_this2.champ_search][colName].toString().toLowerCase()) { + var toto = 1; + } else { + return true; + } + } + }); + + if (!Trsearch) { rsearch = false; - } + } // if ( + // TcolValue.toString().indexOf( + // ligne[this.champ_search][colName].toString().toLowerCase() + // ) === -1 || + // !ligne[this.champ_search][colName].toString().toLowerCase() + // ) { + // console.log(ligne[this.champ_search][colName].toString().toLowerCase()); + // rsearch = false; + // } + } else { if (ligne[_this2.champ_search][colName].toString().toLowerCase().indexOf(TcolValue.toString()) === -1) { rsearch = false;