$
This commit is contained in:
parent
aaf5fa3aba
commit
563864e461
@ -8,26 +8,27 @@ 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 { string } selection Ce qu'on va utiliser pour le &refine.
|
||||
* @param { {name: string, count: int} } 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)
|
||||
this.model.setCat(selection.name)
|
||||
} else if(this.model.getCurIndex() === 1) {
|
||||
log("Selector->Controller", "Ajout d'une section pour refine form_lib_voe_acc")
|
||||
this.model.setSCat(selection)
|
||||
this.model.setSCat(selection.name)
|
||||
} else if(this.model.getCurIndex() === 2) {
|
||||
log("Selector->Controller", "Ajout d'une section pour refine fil_lib_voe_acc")
|
||||
this.model.setTCat(selection)
|
||||
this.model.setTCat(selection.name)
|
||||
}
|
||||
|
||||
this.model.setPath(this.model.getCurIndex(), selection)
|
||||
this.model.setPath(this.model.getCurIndex(), selection.name)
|
||||
|
||||
if(action === "next") {
|
||||
this.model.nextPage()
|
||||
@ -38,6 +39,7 @@ export default class Controller {
|
||||
}
|
||||
|
||||
if(this.model.getTCat()) {
|
||||
this.toload = selection.count
|
||||
this.getData(3).then()
|
||||
} else {
|
||||
this.getData(this.model.getCurIndex()).then()
|
||||
@ -69,8 +71,7 @@ export default class Controller {
|
||||
})
|
||||
} else if(n === 3) {
|
||||
log("Selector->Controller", "Requete de la liste des etablissements")
|
||||
this.model.getModelData3().then((res) => {
|
||||
console.log(res)
|
||||
this.model.getModelData3(this.toload).then((res) => {
|
||||
this.view.renderEtab(res)
|
||||
})
|
||||
} else {
|
||||
|
@ -195,12 +195,13 @@ export default class Model {
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne la liste d'etablissement
|
||||
* @return { json } les donnees demandees en JSON
|
||||
* Retourne la liste d'etablissement.
|
||||
* @param { int } howMany Combien d'etablissement il y a
|
||||
* @return { json } Les donnees demandees en JSON.
|
||||
* */
|
||||
getModelData3() {
|
||||
getModelData3(howMany) {
|
||||
if(!localStorage.getItem(`sec-etab-${this.state.page.cat}-${this.state.page.scat}-${this.state.page.tcat}`)) {
|
||||
const link = `${this.state.api.link}&rows=100` +
|
||||
const link = `${this.state.api.link}&rows=${howMany}` +
|
||||
`&facet=${this.state.api.facet.filiaire}` +
|
||||
`&facet=${this.state.api.facet.formation}` +
|
||||
`&facet=${this.state.api.facet.spec}` +
|
||||
@ -208,12 +209,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) => {
|
||||
|
||||
console.log(res)
|
||||
return res.json()
|
||||
})
|
||||
.then((data) => {
|
||||
|
@ -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("", "previous")
|
||||
this.updateMenu({name: " ", count: 0}, "previous")
|
||||
}
|
||||
|
||||
log("Selector", "View 1/3")
|
||||
@ -32,7 +32,13 @@ export default class View {
|
||||
let li = document.createElement("li")
|
||||
li.className = "selector-list-inner"
|
||||
li.onclick = () => {
|
||||
this.updateMenu(document.getElementById(`menu0-${e.name}`).innerText, "next")
|
||||
this.updateMenu(
|
||||
{
|
||||
name: document.getElementById(`menu0-${e.name}`).innerText,
|
||||
count: parseInt(document.getElementById(`menu0-${e.name}-count`).innerText)
|
||||
},
|
||||
"next"
|
||||
)
|
||||
}
|
||||
|
||||
let name = document.createElement("a")
|
||||
@ -42,6 +48,7 @@ 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)
|
||||
@ -54,11 +61,19 @@ export default class View {
|
||||
log("Selector->View", "Donnees recuperer OK !")
|
||||
}
|
||||
|
||||
/**
|
||||
* Pour afficher en haut a gauche le chemin courant.
|
||||
* @param { array[] } path Chemin courant.
|
||||
* */
|
||||
renderPath(path) {
|
||||
this.path.innerText = `${path[0]} / ${path[1]} / ${path[2]}`
|
||||
log("Loc->View", `Chemin change ${path}`)
|
||||
}
|
||||
|
||||
/**
|
||||
* Pour afficher en bas a gauche la liste.
|
||||
* @param { json } data La liste des etablissements.
|
||||
* */
|
||||
renderEtab(data) {
|
||||
this.etab.innerHTML = ""
|
||||
let table = document.createElement("table")
|
||||
@ -125,7 +140,7 @@ export default class View {
|
||||
|
||||
/**
|
||||
* Envoyer dans le controlleur tous les events fait.
|
||||
* @param { string } selection Ce qu'on va utiliser pour le &refine.
|
||||
* @param { {name: string, count: int} } selection Ce qu'on va utiliser pour le &refine.
|
||||
* @param { string } direction Retour en arriere ou aller en avant. { "previous", "next" }
|
||||
* */
|
||||
updateMenu(selection, direction) {
|
||||
|
Loading…
Reference in New Issue
Block a user