diff --git a/src/components/global/api/Controller.js b/src/components/global/api/Controller.js index 2aa22a1..1c2bd76 100644 --- a/src/components/global/api/Controller.js +++ b/src/components/global/api/Controller.js @@ -8,27 +8,26 @@ export default class Controller { constructor(model, view) { this.model = model this.view = view - this.toload = 0 this.getData(0).then() /** * Envoyer dans le controlleur tous les events fait. - * @param { {name: string, count: int} } selection Ce qu'on va utiliser pour le &refine. + * @param { string } selection Ce qu'on va utiliser pour le &refine. * @param { string } action Retour en arriere ou aller en avant. { "previous", "next" }. * */ window.updateModel = (selection, action) => { if(this.model.getCurIndex() === 0) { log("Selector->Controller", "Ajout d'une section pour refine fili") - this.model.setCat(selection.name) + this.model.setCat(selection) } else if(this.model.getCurIndex() === 1) { log("Selector->Controller", "Ajout d'une section pour refine form_lib_voe_acc") - this.model.setSCat(selection.name) + this.model.setSCat(selection) } else if(this.model.getCurIndex() === 2) { log("Selector->Controller", "Ajout d'une section pour refine fil_lib_voe_acc") - this.model.setTCat(selection.name) + this.model.setTCat(selection) } - this.model.setPath(this.model.getCurIndex(), selection.name) + this.model.setPath(this.model.getCurIndex(), selection) if(action === "next") { this.model.nextPage() @@ -38,8 +37,7 @@ export default class Controller { log("Selector->Controller", "Action inconnue au bataillon (updateModel)") } - if(this.model.getTCat()) { - this.toload = selection.count + if(this.model.getTCat() != null) { this.getData(3).then() } else { this.getData(this.model.getCurIndex()).then() @@ -71,7 +69,7 @@ export default class Controller { }) } else if(n === 3) { log("Selector->Controller", "Requete de la liste des etablissements") - this.model.getModelData3(this.toload).then((res) => { + this.model.getModelData3().then((res) => { this.view.renderEtab(res) }) } else { diff --git a/src/components/global/api/Model.js b/src/components/global/api/Model.js index 184d4fc..4d87050 100644 --- a/src/components/global/api/Model.js +++ b/src/components/global/api/Model.js @@ -195,13 +195,12 @@ export default class Model { } /** - * Retourne la liste d'etablissement. - * @param { int } howMany Combien d'etablissement il y a - * @return { json } Les donnees demandees en JSON. + * Retourne la liste d'etablissement + * @return { json } les donnees demandees en JSON * */ - getModelData3(howMany) { + getModelData3() { if(!localStorage.getItem(`sec-etab-${this.state.page.cat}-${this.state.page.scat}-${this.state.page.tcat}`)) { - const link = `${this.state.api.link}&rows=${howMany}` + + const link = `${this.state.api.link}&rows=10000` + `&facet=${this.state.api.facet.filiaire}` + `&facet=${this.state.api.facet.formation}` + `&facet=${this.state.api.facet.spec}` + @@ -209,6 +208,8 @@ export default class Model { `&refine.${this.state.api.facet.formation}=${this.state.page.scat}` + `&refine.${this.state.api.facet.spec}=${this.state.page.tcat}` + console.log(link) + return fetch(link) .then((res) => { return res.json() @@ -217,6 +218,7 @@ export default class Model { try { if(data) { localStorage.setItem(`sec-etab-${this.state.page.cat}-${this.state.page.scat}-${this.state.page.tcat}`, JSON.stringify(data.records)) + this.state.page.tcat = null return data.records } } catch(donothing) {} @@ -224,6 +226,7 @@ export default class Model { } else { return new Promise((resolve, reject) => { resolve(JSON.parse(localStorage.getItem(`sec-etab-${this.state.page.cat}-${this.state.page.scat}-${this.state.page.tcat}`))) + this.state.page.tcat = null }) } } diff --git a/src/components/global/api/View.js b/src/components/global/api/View.js index 7eac1f1..3b5fb18 100644 --- a/src/components/global/api/View.js +++ b/src/components/global/api/View.js @@ -8,7 +8,7 @@ export default class View { this.etab = document.getElementById("etab") this.btn = document.getElementById("selector-top-btn") this.btn.onclick = () => { - this.updateMenu({name: " ", count: 0}, "previous") + this.updateMenu(" ", "previous") } log("Selector", "View 1/3") @@ -32,13 +32,7 @@ export default class View { let li = document.createElement("li") li.className = "selector-list-inner" li.onclick = () => { - this.updateMenu( - { - name: document.getElementById(`menu0-${e.name}`).innerText, - count: parseInt(document.getElementById(`menu0-${e.name}-count`).innerText) - }, - "next" - ) + this.updateMenu(document.getElementById(`menu0-${e.name}`).innerText, "next") } let name = document.createElement("a") @@ -48,7 +42,6 @@ export default class View { let count = document.createElement("span") count.innerText = e.count - count.id = `menu0-${e.name}-count` count.className = "selector-list-counts" li.appendChild(name) @@ -63,7 +56,7 @@ export default class View { /** * Pour afficher en haut a gauche le chemin courant. - * @param { array[] } path Chemin courant. + * @param { string[] } path Chemin courant. * */ renderPath(path) { this.path.innerText = `${path[0]} / ${path[1]} / ${path[2]}` @@ -75,32 +68,14 @@ export default class View { * @param { json } data La liste des etablissements. * */ renderEtab(data) { - this.etab.innerHTML = "" - let table = document.createElement("table") - let trow = document.createElement("tr") - - let th1 = document.createElement("th") - th1.innerText = "Nom" - - let th2 = document.createElement("th") - th2.innerText = "Ville" - - let th3 = document.createElement("th") - th3.innerText = "Dpt" - - let th4 = document.createElement("th") - th4.innerText = "Moyenne" - - let th5 = document.createElement("th") - th5.innerText = "Selectivite" - - trow.appendChild(th1) - trow.appendChild(th2) - trow.appendChild(th3) - trow.appendChild(th4) - trow.appendChild(th5) - table.appendChild(trow) - + this.etab.innerHTML = + "" + + " Nom" + + " Ville" + + " Dept" + + " Moyenne" + + " Selectivite" + + "" data.forEach((e) => { let etab = e.fields.g_ea_lib_vx @@ -132,15 +107,13 @@ export default class View { tr.appendChild(td4) tr.appendChild(td5) - table.appendChild(tr) + this.etab.appendChild(tr) }) - - this.etab.appendChild(table) } /** * Envoyer dans le controlleur tous les events fait. - * @param { {name: string, count: int} } selection Ce qu'on va utiliser pour le &refine. + * @param { string } selection Ce qu'on va utiliser pour le &refine. * @param { string } direction Retour en arriere ou aller en avant. { "previous", "next" } * */ updateMenu(selection, direction) { diff --git a/src/components/global/etablanalytics/etablanalytics.riot b/src/components/global/etablanalytics/etablanalytics.riot index 2e99dd8..1febc39 100644 --- a/src/components/global/etablanalytics/etablanalytics.riot +++ b/src/components/global/etablanalytics/etablanalytics.riot @@ -9,8 +9,7 @@ } etablanalytics - #etab - table { + #etab { font-size: 17px; color: white; font-weight: bold; @@ -20,7 +19,6 @@ etablanalytics #etab - table tr th { background: #344D59; @@ -32,7 +30,6 @@ etablanalytics #etab - table tr td { text-align: center; @@ -41,5 +38,15 @@ } -
+
+ + + + + + + + +
NomVilleDeptMoyenneSelectivite
+
\ No newline at end of file