$
This commit is contained in:
parent
4cbf6418ce
commit
607729c848
@ -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") {
|
||||
|
@ -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}`)))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user