Petit bug, on ne peut pas faire de match sur un number

This commit is contained in:
Christophe 2020-03-11 21:58:22 +01:00
parent ad5f38db1a
commit a788b7df4a
2 changed files with 19 additions and 16 deletions

View file

@ -31,14 +31,16 @@ const orderBy = (arr, props, orders) =>
// transforme 03/11/2000 en 20001103 // transforme 03/11/2000 en 20001103
let re = /^(\d{2})\/(\d{2})\/(\d{2,4})$/; let re = /^(\d{2})\/(\d{2})\/(\d{2,4})$/;
let r1 = p1.match(re); if (typeof p1 !== 'number') {
if (Array.isArray(r1)) { let r1 = p1.match(re);
p1 = r1[3] + r1[2] + r1[1]; if (Array.isArray(r1)) {
} p1 = r1[3] + r1[2] + r1[1];
}
let r2 = p2.match(re); let r2 = p2.match(re);
if (Array.isArray(r2)) { if (Array.isArray(r2)) {
p2 = r2[3] + r2[2] + r2[1]; p2 = r2[3] + r2[2] + r2[1];
}
} }
acc = p1 > p2 ? 1 : p1 < p2 ? -1 : 0; acc = p1 > p2 ? 1 : p1 < p2 ? -1 : 0;
@ -88,7 +90,6 @@ let monTableau = {
}, },
computed: { computed: {
tableau: function() { tableau: function() {
console.log('computed tableau');
return this.pagination( return this.pagination(
this.table.filter(ligne => { this.table.filter(ligne => {
if (this.search) { if (this.search) {

View file

@ -45,16 +45,19 @@ var orderBy = function orderBy(arr, props, orders) {
// transforme 03/11/2000 en 20001103 // transforme 03/11/2000 en 20001103
var re = /^(\d{2})\/(\d{2})\/(\d{2,4})$/; var re = /^(\d{2})\/(\d{2})\/(\d{2,4})$/;
var r1 = p1.match(re);
if (Array.isArray(r1)) { if (typeof p1 !== 'number') {
p1 = r1[3] + r1[2] + r1[1]; var r1 = p1.match(re);
}
var r2 = p2.match(re); if (Array.isArray(r1)) {
p1 = r1[3] + r1[2] + r1[1];
}
if (Array.isArray(r2)) { var r2 = p2.match(re);
p2 = r2[3] + r2[2] + r2[1];
if (Array.isArray(r2)) {
p2 = r2[3] + r2[2] + r2[1];
}
} }
acc = p1 > p2 ? 1 : p1 < p2 ? -1 : 0; acc = p1 > p2 ? 1 : p1 < p2 ? -1 : 0;
@ -108,7 +111,6 @@ var monTableau = {
tableau: function tableau() { tableau: function tableau() {
var _this = this; var _this = this;
console.log('computed tableau');
return this.pagination(this.table.filter(function (ligne) { return this.pagination(this.table.filter(function (ligne) {
if (_this.search) { if (_this.search) {
if (!Object.values(ligne).every(function (el) { if (!Object.values(ligne).every(function (el) {