- |
+ |
${echapperHTML(enregistrement.id)}
|
+
-
+ |
+
+ |
${echapperHTML(enregistrement.nom)}
|
+
-
+ |
${echapperHTML(enregistrement.isin)}
|
+
-
+ |
${echapperHTML(enregistrement.symbole)}
|
+
-
+ |
${creerCheckbox(enregistrement.actif)}
|
+
-
+ |
${creerCheckbox(enregistrement.afficher)}
|
+
-
- ${echapperHTML(enregistrement.updated_at)}
+ |
+ ${echapperHTML(formaterDate(enregistrement.updated_at))}
|
+
-
- ${echapperHTML(enregistrement.created_at)}
+ |
+ ${echapperHTML(formaterDate(enregistrement.created_at))}
+ |
+
+
+
+
+
+ ${creerBoutonModifier(enregistrement.id)}
|
@@ -279,13 +409,11 @@ function creerLigne(enregistrement) {
/*
* =========================================================
- * CONSTRUIRE LES FILTRES
+ * CONSTRUIRE LES OPTIONS DU FILTRE
* =========================================================
*/
function construireFiltres() {
- const filtreActuel = filtreIndice.value;
-
const indices = [
...new Set(
tousLesEnregistrements
@@ -308,6 +436,8 @@ function construireFiltres() {
});
});
+ const filtreActuel = filtreIndice.value;
+
filtreIndice.innerHTML = "";
/*
@@ -317,6 +447,7 @@ function construireFiltres() {
const optionTout = document.createElement("option");
optionTout.value = "tout";
+
optionTout.textContent = "Tout";
filtreIndice.appendChild(optionTout);
@@ -328,6 +459,7 @@ function construireFiltres() {
const optionAfficher = document.createElement("option");
optionAfficher.value = "afficher";
+
optionAfficher.textContent = "Afficher";
filtreIndice.appendChild(optionAfficher);
@@ -339,6 +471,7 @@ function construireFiltres() {
const optionInactif = document.createElement("option");
optionInactif.value = "inactif";
+
optionInactif.textContent = "Inactif";
filtreIndice.appendChild(optionInactif);
@@ -351,6 +484,7 @@ function construireFiltres() {
const option = document.createElement("option");
option.value = "indice:" + indice;
+
option.textContent = indice;
filtreIndice.appendChild(option);
@@ -364,12 +498,16 @@ function construireFiltres() {
return option.value === filtreActuel;
});
- filtreIndice.value = optionExiste ? filtreActuel : "tout";
+ if (optionExiste) {
+ filtreIndice.value = filtreActuel;
+ } else {
+ filtreIndice.value = "tout";
+ }
}
/*
* =========================================================
- * APPLIQUER LE FILTRE
+ * APPLIQUER FILTRE
* =========================================================
*/
@@ -378,20 +516,36 @@ function appliquerFiltre() {
let enregistrementsFiltres;
+ /*
+ * Tout
+ */
+
if (filtre === "tout") {
enregistrementsFiltres = tousLesEnregistrements;
+
+ /*
+ * Afficher
+ */
} else if (filtre === "afficher") {
enregistrementsFiltres = tousLesEnregistrements.filter(
function (enregistrement) {
- return Number(enregistrement.afficher) === 1;
+ return estActif(enregistrement.afficher);
},
);
+
+ /*
+ * Inactif
+ */
} else if (filtre === "inactif") {
enregistrementsFiltres = tousLesEnregistrements.filter(
function (enregistrement) {
- return Number(enregistrement.actif) === 0;
+ return !estActif(enregistrement.actif);
},
);
+
+ /*
+ * Indice
+ */
} else if (filtre.startsWith("indice:")) {
const indiceRecherche = filtre.substring("indice:".length);
@@ -403,10 +557,22 @@ function appliquerFiltre() {
);
},
);
+
+ /*
+ * Sécurité
+ */
} else {
enregistrementsFiltres = tousLesEnregistrements;
}
+ /*
+ * Toujours trier par ID croissant.
+ */
+
+ enregistrementsFiltres = [...enregistrementsFiltres].sort(function (a, b) {
+ return Number(a.id) - Number(b.id);
+ });
+
afficherDonneesFiltrees(enregistrementsFiltres);
}
@@ -424,39 +590,34 @@ function afficherDonneesFiltrees(enregistrements) {
tableauIndices.innerHTML = `