opti code search
This commit is contained in:
parent
d4112402c1
commit
2a60706e63
@ -15,24 +15,15 @@
|
|||||||
|
|
||||||
const searchURL = `https://data.enseignementsup-recherche.gouv.fr/api/records/1.0/search/?dataset=fr-esr-parcoursup&timezone=Europe%2FBerlin`
|
const searchURL = `https://data.enseignementsup-recherche.gouv.fr/api/records/1.0/search/?dataset=fr-esr-parcoursup&timezone=Europe%2FBerlin`
|
||||||
|
|
||||||
async function fetchFiliere0() {
|
async function fetchFiliere(state) {
|
||||||
let request = await fetch(`${searchURL}&rows=0&sort=tri&facet=fili`)
|
if (state.sousfili){
|
||||||
let result = await request.json()
|
var request = await fetch(`${searchURL}&rows=0&sort=tri&facet=fil_lib_voe_acc&refine.form_lib_voe_acc=${state.sousfili}`)
|
||||||
|
} else if (state.fili&&!state.sousfili){
|
||||||
return result["facet_groups"][0]["facets"]
|
var request = await fetch(`${searchURL}&rows=0&sort=tri&facet=form_lib_voe_acc&refine.fili=${state.fili}`)
|
||||||
|
} else if (!state.fili&&!state.sousfili){
|
||||||
|
var request = await fetch(`${searchURL}&rows=0&sort=tri&facet=fili`)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchFiliere1(filiere) {
|
|
||||||
let request = await fetch(`${searchURL}&rows=0&sort=tri&facet=form_lib_voe_acc&refine.fili=${filiere}`)
|
|
||||||
let result = await request.json()
|
let result = await request.json()
|
||||||
|
|
||||||
return result["facet_groups"][0]["facets"]
|
|
||||||
}
|
|
||||||
|
|
||||||
async function fetchFiliere2(sousfiliere) {
|
|
||||||
let request = await fetch(`${searchURL}&rows=0&sort=tri&facet=fil_lib_voe_acc&refine.form_lib_voe_acc=${sousfiliere}`)
|
|
||||||
let result = await request.json()
|
|
||||||
|
|
||||||
return result["facet_groups"][0]["facets"]
|
return result["facet_groups"][0]["facets"]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +38,7 @@
|
|||||||
fili: null,
|
fili: null,
|
||||||
sousfili: null
|
sousfili: null
|
||||||
}
|
}
|
||||||
fetchFiliere0().then((response) => {
|
fetchFiliere(this.state).then((response) => {
|
||||||
this.update({
|
this.update({
|
||||||
items: response,
|
items: response,
|
||||||
allitems: response
|
allitems: response
|
||||||
@ -72,26 +63,19 @@
|
|||||||
placeholder: "Filière de formation détaillée",
|
placeholder: "Filière de formation détaillée",
|
||||||
sousfili: fili,
|
sousfili: fili,
|
||||||
})
|
})
|
||||||
fetchFiliere2(this.state.sousfili).then((response) => {
|
|
||||||
this.update({
|
|
||||||
allitems: response,
|
|
||||||
items: response
|
|
||||||
})
|
|
||||||
})
|
|
||||||
console.log(this.state.items)
|
|
||||||
} else if (this.state.placeholder="Formation"){
|
} else if (this.state.placeholder="Formation"){
|
||||||
this.update({
|
this.update({
|
||||||
placeholder: "Filière de formation",
|
placeholder: "Filière de formation",
|
||||||
fili: fili
|
fili: fili
|
||||||
})
|
})
|
||||||
fetchFiliere1(this.state.fili).then((response) => {
|
}
|
||||||
|
fetchFiliere(this.state).then((response) => {
|
||||||
this.update({
|
this.update({
|
||||||
allitems: response,
|
allitems: response,
|
||||||
items: response
|
items: response
|
||||||
})
|
})
|
||||||
console.log(this.state.items)
|
console.log(this.state.items)
|
||||||
})
|
})
|
||||||
}
|
|
||||||
},
|
},
|
||||||
back(){
|
back(){
|
||||||
console.log("back")
|
console.log("back")
|
||||||
@ -100,29 +84,21 @@
|
|||||||
placeholder: "Formation",
|
placeholder: "Formation",
|
||||||
fili: null,
|
fili: null,
|
||||||
})
|
})
|
||||||
fetchFiliere0().then((response) => {
|
|
||||||
this.update({
|
|
||||||
allitems: response,
|
|
||||||
items: response
|
|
||||||
})
|
|
||||||
})
|
|
||||||
console.log(this.state.items)
|
|
||||||
} else if (this.state.placeholder="Filière de formation détaillée"){
|
} else if (this.state.placeholder="Filière de formation détaillée"){
|
||||||
this.update({
|
this.update({
|
||||||
placeholder: "Filière de formation",
|
placeholder: "Filière de formation",
|
||||||
sousfili: null
|
sousfili: null
|
||||||
})
|
})
|
||||||
fetchFiliere1(this.state.fili).then((response) => {
|
}
|
||||||
|
fetchFiliere(this.state).then((response) => {
|
||||||
this.update({
|
this.update({
|
||||||
allitems: response,
|
allitems: response,
|
||||||
items: response
|
items: response
|
||||||
})
|
})
|
||||||
console.log(this.state.items)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
const searchURL = `https://data.enseignementsup-recherche.gouv.fr/api/records/1.0/search/?dataset=fr-esr-parcoursup&timezone=Europe%2FBerlin`;
|
const searchURL = `https://data.enseignementsup-recherche.gouv.fr/api/records/1.0/search/?dataset=fr-esr-parcoursup&timezone=Europe%2FBerlin`;
|
||||||
async function fetchFiliere0() {
|
async function fetchFiliere(state) {
|
||||||
let request = await fetch(`${searchURL}&rows=0&sort=tri&facet=fili`);
|
if (state.sousfili) {
|
||||||
let result = await request.json();
|
await fetch(`${searchURL}&rows=0&sort=tri&facet=fil_lib_voe_acc&refine.form_lib_voe_acc=${sousfiliere}`);
|
||||||
return result["facet_groups"][0]["facets"];
|
} else if (state.fili & !state.sousfili) {
|
||||||
}
|
await fetch(`${searchURL}&rows=0&sort=tri&facet=form_lib_voe_acc&refine.fili=${filiere}`);
|
||||||
async function fetchFiliere1(filiere) {
|
} else if (!state.fili & !state.sousfili) {
|
||||||
let request = await fetch(`${searchURL}&rows=0&sort=tri&facet=form_lib_voe_acc&refine.fili=${filiere}`);
|
await fetch(`${searchURL}&rows=0&sort=tri&facet=fili`);
|
||||||
let result = await request.json();
|
} else {
|
||||||
return result["facet_groups"][0]["facets"];
|
console.log("ta verif elle pue");
|
||||||
}
|
}
|
||||||
async function fetchFiliere2(sousfiliere) {
|
|
||||||
let request = await fetch(`${searchURL}&rows=0&sort=tri&facet=fil_lib_voe_acc&refine.form_lib_voe_acc=${sousfiliere}`);
|
|
||||||
let result = await request.json();
|
let result = await request.json();
|
||||||
return result["facet_groups"][0]["facets"];
|
return result["facet_groups"][0]["facets"];
|
||||||
}
|
}
|
||||||
@ -25,9 +23,9 @@ var search = {
|
|||||||
items: null,
|
items: null,
|
||||||
allitems: null,
|
allitems: null,
|
||||||
fili: null,
|
fili: null,
|
||||||
button: "disabled"
|
sousfili: null
|
||||||
};
|
};
|
||||||
fetchFiliere0().then(response => {
|
fetchFiliere(this.state).then(response => {
|
||||||
this.update({
|
this.update({
|
||||||
items: response,
|
items: response,
|
||||||
allitems: response
|
allitems: response
|
||||||
@ -50,9 +48,9 @@ var search = {
|
|||||||
if (this.state.placeholder === "Filière de formation") {
|
if (this.state.placeholder === "Filière de formation") {
|
||||||
this.update({
|
this.update({
|
||||||
placeholder: "Filière de formation détaillée",
|
placeholder: "Filière de formation détaillée",
|
||||||
fili: fili
|
sousfili: fili
|
||||||
});
|
});
|
||||||
fetchFiliere2(this.state.fili).then(response => {
|
fetchFiliere(this.state).then(response => {
|
||||||
this.update({
|
this.update({
|
||||||
allitems: response,
|
allitems: response,
|
||||||
items: response
|
items: response
|
||||||
@ -64,7 +62,7 @@ var search = {
|
|||||||
placeholder: "Filière de formation",
|
placeholder: "Filière de formation",
|
||||||
fili: fili
|
fili: fili
|
||||||
});
|
});
|
||||||
fetchFiliere1(this.state.fili).then(response => {
|
fetchFiliere(this.state).then(response => {
|
||||||
this.update({
|
this.update({
|
||||||
allitems: response,
|
allitems: response,
|
||||||
items: response
|
items: response
|
||||||
@ -75,6 +73,31 @@ var search = {
|
|||||||
},
|
},
|
||||||
back() {
|
back() {
|
||||||
console.log("back");
|
console.log("back");
|
||||||
|
if (this.state.placeholder === "Filière de formation") {
|
||||||
|
this.update({
|
||||||
|
placeholder: "Formation",
|
||||||
|
fili: null
|
||||||
|
});
|
||||||
|
fetchFiliere(state).then(response => {
|
||||||
|
this.update({
|
||||||
|
allitems: response,
|
||||||
|
items: response
|
||||||
|
});
|
||||||
|
});
|
||||||
|
console.log(this.state.items);
|
||||||
|
} else if (this.state.placeholder = "Filière de formation détaillée") {
|
||||||
|
this.update({
|
||||||
|
placeholder: "Filière de formation",
|
||||||
|
sousfili: null
|
||||||
|
});
|
||||||
|
fetchFiliere(this.state).then(response => {
|
||||||
|
this.update({
|
||||||
|
allitems: response,
|
||||||
|
items: response
|
||||||
|
});
|
||||||
|
console.log(this.state.items);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -97,10 +120,6 @@ var search = {
|
|||||||
type: expressionTypes.EVENT,
|
type: expressionTypes.EVENT,
|
||||||
name: 'onclick',
|
name: 'onclick',
|
||||||
evaluate: _scope => _scope.back
|
evaluate: _scope => _scope.back
|
||||||
}, {
|
|
||||||
type: expressionTypes.ATTRIBUTE,
|
|
||||||
name: 'this.state.button',
|
|
||||||
evaluate: _scope => _scope.state.button
|
|
||||||
}]
|
}]
|
||||||
}, {
|
}, {
|
||||||
type: bindingTypes.EACH,
|
type: bindingTypes.EACH,
|
||||||
|
Loading…
Reference in New Issue
Block a user