From 5f18a9fcbd20b1efb7ba53221b43278798eee5b4 Mon Sep 17 00:00:00 2001 From: "pro.boooooo" Date: Sun, 12 Mar 2023 01:04:17 +0100 Subject: [PATCH] $ --- src/components/global/api/Model.js | 40 ++++++++++++++++-------------- src/components/global/api/View.js | 6 ++--- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/src/components/global/api/Model.js b/src/components/global/api/Model.js index 8735edd..7253743 100644 --- a/src/components/global/api/Model.js +++ b/src/components/global/api/Model.js @@ -116,7 +116,7 @@ export default class Model { getModelData0() { if(!localStorage.getItem(`sec0`)) { const link = `${ this.state.api.link }&rows=0` + - `&facet=${this.state.api.facet.filiaire}` + `&facet=${encodeURIComponent(this.state.api.facet.filiaire)}` return fetch(link) .then((res) => res.json()) @@ -142,10 +142,10 @@ export default class Model { getModelData1() { if(!localStorage.getItem(`sec1-${this.state.page.cat}`)) { const link = `${this.state.api.link}&rows=0` + - `&facet=${this.state.api.facet.filiaire}` + - `&facet=${this.state.api.facet.formation}` + - `&facet=${this.state.api.facet.spec}` + - `&refine.${this.state.api.facet.filiaire}=${this.state.page.cat}` + `&facet=${encodeURIComponent(this.state.api.facet.filiaire)}` + + `&facet=${encodeURIComponent(this.state.api.facet.formation)}` + + `&facet=${encodeURIComponent(this.state.api.facet.spec)}` + + `&refine.${encodeURIComponent(this.state.api.facet.filiaire)}=${encodeURIComponent(this.state.page.cat)}` return fetch(link) .then((res) => res.json()) @@ -172,11 +172,13 @@ export default class Model { getModelData2() { if(!localStorage.getItem(`sec2-${this.state.page.cat}-${this.state.page.scat}`)) { const link = `${this.state.api.link}&rows=0` + - `&facet=${this.state.api.facet.filiaire}` + - `&facet=${this.state.api.facet.formation}` + - `&facet=${this.state.api.facet.spec}` + - `&refine.${this.state.api.facet.filiaire}=${this.state.page.cat}` + - `&refine.${this.state.api.facet.formation}=${this.state.page.scat}` + `&facet=${encodeURIComponent(this.state.api.facet.filiaire)}` + + `&facet=${encodeURIComponent(this.state.api.facet.formation)}` + + `&facet=${encodeURIComponent(this.state.api.facet.spec)}` + + `&refine.${encodeURIComponent(this.state.api.facet.filiaire)}=${encodeURIComponent(this.state.page.cat)}` + + `&refine.${encodeURIComponent(this.state.api.facet.formation)}=${encodeURIComponent(this.state.page.scat)}` + + console.log(link) return fetch(link) .then((res) => res.json()) @@ -202,13 +204,12 @@ export default class Model { 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=10000` + - `&facet=${this.state.api.facet.filiaire}` + - `&facet=${this.state.api.facet.formation}` + - `&facet=${this.state.api.facet.spec}` + - `&refine.${this.state.api.facet.filiaire}=${this.state.page.cat}` + - `&refine.${this.state.api.facet.formation}=${this.state.page.scat}` + - `&refine.${this.state.api.facet.spec}=${this.state.page.tcat}` - console.log(link) + `&facet=${encodeURIComponent(this.state.api.facet.filiaire)}` + + `&facet=${encodeURIComponent(this.state.api.facet.formation)}` + + `&facet=${encodeURIComponent(this.state.api.facet.spec)}` + + `&refine.${encodeURIComponent(this.state.api.facet.filiaire)}=${encodeURIComponent(this.state.page.cat)}` + + `&refine.${encodeURIComponent(this.state.api.facet.formation)}=${encodeURIComponent(this.state.page.scat)}` + + `&refine.${encodeURIComponent(this.state.api.facet.spec)}=${encodeURIComponent(this.state.page.tcat)}` return fetch(link) .then((res) => { @@ -217,7 +218,10 @@ export default class Model { .then((data) => { try { if(data) { - localStorage.setItem(`sec-etab-${this.state.page.cat}-${this.state.page.scat}-${this.state.page.tcat}`, JSON.stringify(data.records)) + if(this.state.page.tcat) { + 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 } diff --git a/src/components/global/api/View.js b/src/components/global/api/View.js index 6142cd3..e3f812f 100644 --- a/src/components/global/api/View.js +++ b/src/components/global/api/View.js @@ -9,6 +9,7 @@ export default class View { this.stat = document.getElementById("generalytics") this.etab = document.getElementById("etablanalytics-list") this.btn = document.getElementById("selector-top-btn") + this.btn.onclick = () => { this.updateMenu(" ", "previous") } @@ -28,8 +29,8 @@ export default class View { if(title || data) { data.forEach((e) => { let elem = document.createElement("selectorfragment") - elem.onclick = () => { - this.updateMenu(document.getElementById(`menu0-${e.name}`).innerText, "next") + elem.onclick = async () => { + await this.updateMenu(document.getElementById(`menu0-${e.name}`).innerText, "next") } riot.mount(elem, { @@ -242,7 +243,6 @@ export default class View { b += e.fields.acc_b tb += e.fields.acc_tb tbf += e.fields.acc_tbf - console.log(e.fields.lien_form_sup) }) let tot = p + ab + b + tb + tbf