From 607729c84848dc68a03a64d31835dbe2d6850e1b Mon Sep 17 00:00:00 2001 From: "pro.boooooo" Date: Wed, 8 Mar 2023 23:57:59 +0100 Subject: [PATCH] $ --- .../global/selector/api/Controller.js | 5 ++++- src/components/global/selector/api/Model.js | 19 ++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/components/global/selector/api/Controller.js b/src/components/global/selector/api/Controller.js index aaa2deb..bfd23fe 100644 --- a/src/components/global/selector/api/Controller.js +++ b/src/components/global/selector/api/Controller.js @@ -16,8 +16,11 @@ export default class Controller { * */ window.updateModel = (selection, action) => { if(this.model.getCurIndex() === 0) { - log("Selector->Controller", "Ajout d'une section pour refine") + log("Selector->Controller", "Ajout d'une section pour refine fili") 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) } if(action === "next") { diff --git a/src/components/global/selector/api/Model.js b/src/components/global/selector/api/Model.js index 41b3f9d..d358798 100644 --- a/src/components/global/selector/api/Model.js +++ b/src/components/global/selector/api/Model.js @@ -14,6 +14,7 @@ export default class Model { page: { curIndex: 0, /* section n.0 -> n.2. */ cat: null, + scat: null, path: ["", "", ""], name: [ "formation", @@ -53,12 +54,19 @@ export default class Model { } /** - * @param v La valeur du refine + * @param v La valeur du refine "fili" * */ setCat(v) { this.state.page.cat = v } + /** + * @param v la valeur du refine "form_lib_voe_acc" + * */ + setSCat(v) { + this.state.page.scat = v + } + /** * Retourne la section 0 + l'enregistre dans le local storage * @return les donnees demandees en JSON @@ -119,18 +127,19 @@ export default class Model { * @return les donnees demandees en JSON * */ getModelData2() { - if(!localStorage.getItem(`sec2-${this.state.page.cat}`)) { + if(!localStorage.getItem(`sec2-${this.state.page.cat}-${this.state.page.scat}`)) { const link = `${this.state.api.link}` + `&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.filiaire}=${this.state.page.cat}` + + `&refine.${this.state.api.facet.formation}=${this.state.page.scat}` return fetch(link) .then((res) => res.json()) .then((data) => { if(data) { - localStorage.setItem(`sec2-${this.state.page.cat}`, JSON.stringify(data.facet_groups[2].facets)) + localStorage.setItem(`sec2-${this.state.page.cat}-${this.state.page.scat}`, JSON.stringify(data.facet_groups[2].facets)) return data.facet_groups[2].facets } else { return null @@ -138,7 +147,7 @@ export default class Model { }) } else { return new Promise((resolve, reject) => { - resolve(JSON.parse(localStorage.getItem(`sec2-${this.state.page.cat}`))) + resolve(JSON.parse(localStorage.getItem(`sec2-${this.state.page.cat}-${this.state.page.scat}`))) }) } }