la recherche devient insensible à la casse

This commit is contained in:
Christophe 2020-05-06 23:37:47 +02:00
parent c57fc2155d
commit ef82382f33
3 changed files with 32 additions and 37 deletions

1
.gitignore vendored
View file

@ -1 +1,2 @@
node_modules node_modules
yarn.lock

View file

@ -1,5 +1,5 @@
jQuery(function() { jQuery(function () {
$('#app').on('click', '.url_action', function(e) { $('#app').on('click', '.url_action', function (e) {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
let url = $(this).attr('href'); let url = $(this).attr('href');
@ -7,8 +7,8 @@ jQuery(function() {
console.time('Chargement de VueJs APRES Ajax'); console.time('Chargement de VueJs APRES Ajax');
$.ajax({ $.ajax({
url: url, url: url,
async: true async: true,
}).done(function() { }).done(function () {
if (parseInt(id) > 0) { if (parseInt(id) > 0) {
app.rechargerJson(id); app.rechargerJson(id);
} else { } else {
@ -17,14 +17,14 @@ jQuery(function() {
}); });
}); });
$('#app').on('click', '.modalbox', function(e) { $('#app').on('click', '.modalbox', function (e) {
e.preventDefault(); e.preventDefault();
let url = $(this).attr('href'); let url = $(this).attr('href');
url += '&var_zajax=content'; url += '&var_zajax=content';
$.modalbox(url); $.modalbox(url);
}); });
$('#app').on('click', '.mediabox', function(e) { $('#app').on('click', '.mediabox', function (e) {
e.preventDefault(); e.preventDefault();
let href = $(this).attr('href'); let href = $(this).attr('href');
$.fn.mediabox({ href }); $.fn.mediabox({ href });
@ -69,7 +69,7 @@ const orderBy = (arr, props, orders) =>
); );
console.time('Chargement de VueJS AVANT Ajax'); console.time('Chargement de VueJS AVANT Ajax');
console.time('Chargement de VueJs APRES Ajax'); console.time('Chargement de VueJs APRES Ajax');
Vue.nextTick(function() { Vue.nextTick(function () {
console.timeEnd('Chargement de VueJS AVANT Ajax'); console.timeEnd('Chargement de VueJS AVANT Ajax');
}); });
@ -77,19 +77,19 @@ let monTableau = {
props: { props: {
tparpage: { tparpage: {
type: Array, type: Array,
default: function() { default: function () {
return [10, 20, 50, 'Tous']; return [10, 20, 50, 'Tous'];
} },
}, },
apiuri: { apiuri: {
type: String, type: String,
required: true required: true,
}, },
objet: { objet: {
type: String type: String,
}
}, },
data: function() { },
data: function () {
return { return {
table: [], table: [],
header: [], header: [],
@ -101,26 +101,24 @@ let monTableau = {
pages: [], pages: [],
triOrders: [], triOrders: [],
triProps: [], triProps: [],
selectTr: [] selectTr: [],
}; };
}, },
mounted() { mounted() {
this.chargerJson(); this.chargerJson();
}, },
computed: { computed: {
tableau: function() { tableau: function () {
return this.pagination( return this.pagination(
this.table.filter(ligne => { this.table.filter((ligne) => {
if (this.search) { if (this.search) {
if (!Object.values(ligne).every(el => el.indexOf(this.search))) { return Object.values(ligne).toString().toLowerCase().indexOf(this.search) < 0 ? false : true;
return ligne;
}
} else { } else {
return ligne; return true;
} }
}) })
); );
} },
}, },
watch: { watch: {
tableau() { tableau() {
@ -132,7 +130,7 @@ let monTableau = {
} else { } else {
this.parPage = e; this.parPage = e;
} }
} },
}, },
methods: { methods: {
chargerJson(id) { chargerJson(id) {
@ -141,22 +139,22 @@ let monTableau = {
url += '&id=' + id; url += '&id=' + id;
} }
fetch(url) fetch(url)
.then(response => response.json()) .then((response) => response.json())
.then(data => { .then((data) => {
let config = data.shift(); let config = data.shift();
this.header = config.header; this.header = config.header;
this.crayons = config.crayons; this.crayons = config.crayons;
if (parseInt(id) > 0) { if (parseInt(id) > 0) {
let i = this.table.findIndex(ligne => ligne.id === parseInt(id)); let i = this.table.findIndex((ligne) => ligne.id === parseInt(id));
Vue.set(this.table, i, data[0]); Vue.set(this.table, i, data[0]);
} else { } else {
this.table = data; this.table = data;
} }
Vue.nextTick(function() { Vue.nextTick(function () {
console.timeEnd('Chargement de VueJs APRES Ajax'); console.timeEnd('Chargement de VueJs APRES Ajax');
}); });
}) })
.catch(error => console.log(error)); .catch((error) => console.log(error));
}, },
setPages() { setPages() {
let nombreDePages = Math.ceil(this.table.length / this.parPage); let nombreDePages = Math.ceil(this.table.length / this.parPage);
@ -209,7 +207,7 @@ let monTableau = {
this.selectTr.push(id); this.selectTr.push(id);
} }
} }
} },
}, },
template: ` template: `
<div class="gamutable"> <div class="gamutable">
@ -255,7 +253,7 @@ let monTableau = {
</div> </div>
</div> </div>
</div> </div>
</div>` </div>`,
}; };
let app = new Vue({ let app = new Vue({
@ -264,6 +262,6 @@ let app = new Vue({
methods: { methods: {
rechargerJson(id) { rechargerJson(id) {
this.$refs.montableau.chargerJson(id); this.$refs.montableau.chargerJson(id);
} },
} },
}); });

View file

@ -132,13 +132,9 @@ var monTableau = {
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) { return Object.values(ligne).toString().toLowerCase().indexOf(_this.search) < 0 ? false : true;
return el.indexOf(_this.search);
})) {
return ligne;
}
} else { } else {
return ligne; return true;
} }
})); }));
} }