diff --git a/js/gamutable.es6.js b/js/gamutable.es6.js
index 5fcc38b..0495776 100644
--- a/js/gamutable.es6.js
+++ b/js/gamutable.es6.js
@@ -37,11 +37,14 @@ function recupJson(d) {
return [];
}
}
-const orderBy = (arr, props, orders) =>
+const orderBy = (arr, props, orders, champ) =>
arr.sort((a, b) =>
props.reduce((acc, prop, i) => {
if (acc === 0) {
- let [p1, p2] = orders && orders[i] === 'desc' ? [b[prop], a[prop]] : [a[prop], b[prop]];
+ let [p1, p2] =
+ orders && orders[i] === 'desc'
+ ? [b[champ][prop], a[champ][prop]]
+ : [a[champ][prop], b[champ][prop]];
// passe en lowercase les String
p1 = typeof p1 === 'string' ? p1.toLowerCase() : p1;
p2 = typeof p2 === 'string' ? p2.toLowerCase() : p2;
@@ -102,6 +105,7 @@ let monTableau = {
triOrders: [],
triProps: [],
selectTr: [],
+ champ_search: 'html',
};
},
mounted() {
@@ -114,7 +118,12 @@ let monTableau = {
}
return this.pagination(
this.table.filter((ligne) =>
- Object.values(ligne).toString().toLowerCase().indexOf(this.search.toLowerCase()) < 0 ? false : true
+ Object.values(ligne[this.champ_search])
+ .toString()
+ .toLowerCase()
+ .indexOf(this.search.toLowerCase()) < 0
+ ? false
+ : true
)
);
},
@@ -148,6 +157,9 @@ let monTableau = {
Vue.set(this.table, i, data[0]);
} else {
this.table = data;
+ if (data[0].search) {
+ this.champ_search = 'search';
+ }
}
Vue.nextTick(function () {
console.timeEnd('Chargement de VueJs APRES Ajax');
@@ -182,7 +194,7 @@ let monTableau = {
this.triProps.push(col);
this.triOrders.push(sens);
}
- this.table = orderBy(this.table, this.triProps, this.triOrders);
+ this.table = orderBy(this.table, this.triProps, this.triOrders, this.champ_search);
},
ordreActif(col, sens) {
const i = this.triProps.indexOf(col);
@@ -193,7 +205,7 @@ let monTableau = {
}
},
resetTri() {
- this.table = orderBy(this.table, ['id']);
+ this.table = orderBy(this.table, ['id'], '', this.champ_search);
this.triOrders = [];
this.triProps = [];
},
@@ -230,8 +242,8 @@ let monTableau = {
-
-
+ |
+
|
diff --git a/js/gamutable.js b/js/gamutable.js
index 8f48909..77e38d1 100644
--- a/js/gamutable.js
+++ b/js/gamutable.js
@@ -49,11 +49,11 @@ function recupJson(d) {
}
}
-var orderBy = function orderBy(arr, props, orders) {
+var orderBy = function orderBy(arr, props, orders, champ) {
return arr.sort(function (a, b) {
return props.reduce(function (acc, prop, i) {
if (acc === 0) {
- var _ref = orders && orders[i] === 'desc' ? [b[prop], a[prop]] : [a[prop], b[prop]],
+ var _ref = orders && orders[i] === 'desc' ? [b[champ][prop], a[champ][prop]] : [a[champ][prop], b[champ][prop]],
_ref2 = _slicedToArray(_ref, 2),
p1 = _ref2[0],
p2 = _ref2[1]; // passe en lowercase les String
@@ -120,7 +120,8 @@ var monTableau = {
pages: [],
triOrders: [],
triProps: [],
- selectTr: []
+ selectTr: [],
+ champ_search: 'html'
};
},
mounted: function mounted() {
@@ -135,7 +136,7 @@ var monTableau = {
}
return this.pagination(this.table.filter(function (ligne) {
- return Object.values(ligne).toString().toLowerCase().indexOf(_this.search.toLowerCase()) < 0 ? false : true;
+ return Object.values(ligne[_this.champ_search]).toString().toLowerCase().indexOf(_this.search.toLowerCase()) < 0 ? false : true;
}));
}
},
@@ -176,6 +177,10 @@ var monTableau = {
Vue.set(_this2.table, i, data[0]);
} else {
_this2.table = data;
+
+ if (data[0].search) {
+ _this2.champ_search = 'search';
+ }
}
Vue.nextTick(function () {
@@ -215,7 +220,7 @@ var monTableau = {
this.triOrders.push(sens);
}
- this.table = orderBy(this.table, this.triProps, this.triOrders);
+ this.table = orderBy(this.table, this.triProps, this.triOrders, this.champ_search);
},
ordreActif: function ordreActif(col, sens) {
var i = this.triProps.indexOf(col);
@@ -227,7 +232,7 @@ var monTableau = {
}
},
resetTri: function resetTri() {
- this.table = orderBy(this.table, ['id']);
+ this.table = orderBy(this.table, ['id'], '', this.champ_search);
this.triOrders = [];
this.triProps = [];
},
@@ -243,7 +248,7 @@ var monTableau = {
}
}
},
- template: "\n\t\n\t\t
\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t
\n\t\t
\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t | \n\t\t\t\t
\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t | \n\t\t\t\t
\n\t\t\t\n\t\t
\n\t\t
\n\t\t\t
{{table.length}} \xE9l\xE9ments
\n\t\t\t\n\t\t
\n\t
"
+ template: "\n\t\n\t\t
\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t
\n\t\t
\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t | \n\t\t\t\t
\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t | \n\t\t\t\t
\n\t\t\t\n\t\t
\n\t\t
\n\t\t\t
{{table.length}} \xE9l\xE9ments
\n\t\t\t\n\t\t
\n\t
"
};
var app = new Vue({
el: '#app',
diff --git a/json_gamutable.json.html b/json_gamutable.json.html
index de2f3d2..4312454 100644
--- a/json_gamutable.json.html
+++ b/json_gamutable.json.html
@@ -35,22 +35,42 @@
})]
{
-"id": #ID_SOUSCRIPTION,
-"modif" : [(#VAL{}|json_encode)],
-"date" : [(#DATE|affdate{d/m/Y}|json_encode)],
-"statut" : [(#GET{statut}|json_encode)],
-"genre" : [(#GENRE|json_encode)],
-"nom_souscripteur" : [(#NOM_SOUSCRIPTEUR|json_encode)],
-"prenom" : [(#PRENOM|json_encode)],
-"qui": [(#VAL{}|json_encode)],
-"nbr" : [(#NOMBRE)],
-"montant_part" : [(#MONTANT_PART)],
-"montant" : [(#MONTANT)],
-"prix": [(#VAL{}|json_encode)],
-"type" : [(#TYPE|json_encode)],
-"email" : [(#VAL{#EMAIL}|json_encode)],
-"telephone" : [(#TELEPHONE|json_encode)],
-"ou": [(#VAL{}|json_encode)]
+"html": {
+ id": #ID_SOUSCRIPTION,
+ "modif" : [(#VAL{}|json_encode)],
+ "date" : [(#DATE|affdate{d/m/Y}|json_encode)],
+ "statut" : [(#GET{statut}|json_encode)],
+ "genre" : [(#GENRE|json_encode)],
+ "nom_souscripteur" : [(#NOM_SOUSCRIPTEUR|json_encode)],
+ "prenom" : [(#PRENOM|json_encode)],
+ "qui": [(#VAL{}|json_encode)],
+ "nbr" : [(#NOMBRE)],
+ "montant_part" : [(#MONTANT_PART)],
+ "montant" : [(#MONTANT)],
+ "prix": [(#VAL{}|json_encode)],
+ "type" : [(#TYPE|json_encode)],
+ "email" : [(#VAL{#EMAIL}|json_encode)],
+ "telephone" : [(#TELEPHONE|json_encode)],
+ "ou": [(#VAL{}|json_encode)]
+},
+search: {
+ id": #ID_SOUSCRIPTION,
+ "modif" : "",
+ "date" : [(#DATE|affdate{d/m/Y}|json_encode)],
+ "statut" : [(#GET{statut}|json_encode)],
+ "genre" : [(#GENRE|json_encode)],
+ "nom_souscripteur" : [(#NOM_SOUSCRIPTEUR|json_encode)],
+ "prenom" : [(#PRENOM|json_encode)],
+ "qui": "",
+ "nbr" : [(#NOMBRE)],
+ "montant_part" : [(#MONTANT_PART)],
+ "montant" : [(#MONTANT)],
+ "prix": "",
+ "type" : [(#TYPE|json_encode)],
+ "email" : [(#EMAIL|json_encode)],
+ "telephone" : [(#TELEPHONE|json_encode)],
+ "ou": ""
+}
}
]
diff --git a/paquet.xml b/paquet.xml
index fafab3c..37ec1d3 100644
--- a/paquet.xml
+++ b/paquet.xml
@@ -1,7 +1,7 @@
GamuTable
-
+
tofulm
GNU/GPL
-
+