diff --git a/.gitignore b/.gitignore index 3c3629e..239ecff 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules +yarn.lock diff --git a/js/gamutable.es6.js b/js/gamutable.es6.js index 8d23ae5..24204aa 100644 --- a/js/gamutable.es6.js +++ b/js/gamutable.es6.js @@ -1,5 +1,5 @@ -jQuery(function() { - $('#app').on('click', '.url_action', function(e) { +jQuery(function () { + $('#app').on('click', '.url_action', function (e) { e.preventDefault(); e.stopPropagation(); let url = $(this).attr('href'); @@ -7,8 +7,8 @@ jQuery(function() { console.time('Chargement de VueJs APRES Ajax'); $.ajax({ url: url, - async: true - }).done(function() { + async: true, + }).done(function () { if (parseInt(id) > 0) { app.rechargerJson(id); } else { @@ -17,14 +17,14 @@ jQuery(function() { }); }); - $('#app').on('click', '.modalbox', function(e) { + $('#app').on('click', '.modalbox', function (e) { e.preventDefault(); let url = $(this).attr('href'); url += '&var_zajax=content'; $.modalbox(url); }); - $('#app').on('click', '.mediabox', function(e) { + $('#app').on('click', '.mediabox', function (e) { e.preventDefault(); let href = $(this).attr('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 APRES Ajax'); -Vue.nextTick(function() { +Vue.nextTick(function () { console.timeEnd('Chargement de VueJS AVANT Ajax'); }); @@ -77,19 +77,19 @@ let monTableau = { props: { tparpage: { type: Array, - default: function() { + default: function () { return [10, 20, 50, 'Tous']; - } + }, }, apiuri: { type: String, - required: true + required: true, }, objet: { - type: String - } + type: String, + }, }, - data: function() { + data: function () { return { table: [], header: [], @@ -101,26 +101,24 @@ let monTableau = { pages: [], triOrders: [], triProps: [], - selectTr: [] + selectTr: [], }; }, mounted() { this.chargerJson(); }, computed: { - tableau: function() { + tableau: function () { return this.pagination( - this.table.filter(ligne => { + this.table.filter((ligne) => { if (this.search) { - if (!Object.values(ligne).every(el => el.indexOf(this.search))) { - return ligne; - } + return Object.values(ligne).toString().toLowerCase().indexOf(this.search) < 0 ? false : true; } else { - return ligne; + return true; } }) ); - } + }, }, watch: { tableau() { @@ -132,7 +130,7 @@ let monTableau = { } else { this.parPage = e; } - } + }, }, methods: { chargerJson(id) { @@ -141,22 +139,22 @@ let monTableau = { url += '&id=' + id; } fetch(url) - .then(response => response.json()) - .then(data => { + .then((response) => response.json()) + .then((data) => { let config = data.shift(); this.header = config.header; this.crayons = config.crayons; 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]); } else { this.table = data; } - Vue.nextTick(function() { + Vue.nextTick(function () { console.timeEnd('Chargement de VueJs APRES Ajax'); }); }) - .catch(error => console.log(error)); + .catch((error) => console.log(error)); }, setPages() { let nombreDePages = Math.ceil(this.table.length / this.parPage); @@ -209,7 +207,7 @@ let monTableau = { this.selectTr.push(id); } } - } + }, }, template: `
@@ -255,7 +253,7 @@ let monTableau = {
- ` + `, }; let app = new Vue({ @@ -264,6 +262,6 @@ let app = new Vue({ methods: { rechargerJson(id) { this.$refs.montableau.chargerJson(id); - } - } + }, + }, }); diff --git a/js/gamutable.js b/js/gamutable.js index 08eff1a..d2b5f84 100644 --- a/js/gamutable.js +++ b/js/gamutable.js @@ -132,13 +132,9 @@ var monTableau = { return this.pagination(this.table.filter(function (ligne) { if (_this.search) { - if (!Object.values(ligne).every(function (el) { - return el.indexOf(_this.search); - })) { - return ligne; - } + return Object.values(ligne).toString().toLowerCase().indexOf(_this.search) < 0 ? false : true; } else { - return ligne; + return true; } })); }