This commit is contained in:
HORVILLE 2023-03-26 23:22:05 +02:00
commit e13c298e92
3 changed files with 16 additions and 64 deletions

View File

@ -1,6 +1,6 @@
<search> <search>
<label> <label>
<input oninput={searchF} type="input" placeholder= {state.formation}> <input onkeydown={searchF} type="input" placeholder= {state.formation}>
<div id="list-formations"> <div id="list-formations">
<ul> <ul>
<li each={item in this.state.items}> <li each={item in this.state.items}>
@ -25,21 +25,26 @@
// initial state // initial state
this.state = { this.state = {
formation: props.formation, formation: props.formation,
items: null items: null,
allitems: null
} }
formation().then((response) => { formation().then((response) => {
this.update({ this.update({
items: response items: response,
allitems: response
}) })
}) })
console.log(this.state.items)
}, },
searchF(){ searchF(e){
formation().then((response) => { let responseFiltered=[]
this.update({ this.state.allitems.forEach(formation => {
items: response if (formation.name.includes(e.target.value)) {
}) responseFiltered.push(formation)
}) }
});
this.update({
items: responseFiltered
})
console.log(this.state.items) console.log(this.state.items)
} }
} }

View File

@ -1,52 +0,0 @@
<formation>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.9.3/css/bulma.min.css">
<table class="table is-fullwidth is-hoverable">
<tbody1>
<tr >
<th></th>
<th></th>
</tr>
</tbody1>
</table>
<script>
async function formation (){
let result = await fetch("https://data.enseignementsup-recherche.gouv.fr/api/records/1.0/search/?dataset=fr-esr-parcoursup&q=&sort=tri&facet=fili&timezone=Europe%2FBerlin")
let resultats = await result.json()
console.log(result)
console.log(resultats)
let base=[]
let filieretable=[]
let filieredetail=[]
let table = resultats["facet_groups"][0]["facets"]
console.log(table)
const tableBody = document.querySelector("tbody1")
for(tes of table){
const tableRow = document.createElement("tr")
const formationCell = document.createElement("td")
let texteformation = document.createTextNode(tes.name)
formationCell.appendChild(texteformation)
tableRow.appendChild(formationCell)
const nombredeplaceCell = document.createElement("td")
const nombredeplace = document.createTextNode(tes.count)
nombredeplaceCell.appendChild(nombredeplace)
tableRow.appendChild(nombredeplaceCell)
tableBody.appendChild(tableRow)
}
}
export default{
onMounted(){
formation()
}
}
</script>
</formation>

View File

@ -17,8 +17,7 @@
riot.compile().then(() => { riot.compile().then(() => {
riot.mount('search', { riot.mount('search', {
formation:'Formation', formation:'Formation',
items: null, items: null
text: null
}) })
}) })
</script>--> </script>-->