$
This commit is contained in:
parent
7bc56c09b5
commit
c98509523e
@ -2,7 +2,7 @@
|
|||||||
<style>
|
<style>
|
||||||
#selector {
|
#selector {
|
||||||
width: 300px;
|
width: 300px;
|
||||||
min-height: 700px;
|
min-height: 625px;
|
||||||
padding: 15px;
|
padding: 15px;
|
||||||
box-shadow: 0px 0px 3px 1px black;
|
box-shadow: 0px 0px 3px 1px black;
|
||||||
}
|
}
|
||||||
@ -53,6 +53,8 @@
|
|||||||
#selector-list-container
|
#selector-list-container
|
||||||
#selector-list
|
#selector-list
|
||||||
.selector-list-names {
|
.selector-list-names {
|
||||||
|
text-decoration: none;
|
||||||
|
color: black;
|
||||||
padding-left: 18px;
|
padding-left: 18px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,54 +72,74 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const api = "https://data.enseignementsup-recherche.gouv.fr/api/records/1.0/search/?dataset=fr-esr-parcoursup&q=&sort=tri&facet=fili&timezone=Europe%2FBerlin"
|
|
||||||
let data = []
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
async getData() {
|
state: {
|
||||||
let data = []
|
|
||||||
|
|
||||||
await fetch(api)
|
|
||||||
.then((res) => res.json())
|
|
||||||
.then((d) => {
|
|
||||||
data = d.facet_groups[0].facets
|
|
||||||
})
|
|
||||||
|
|
||||||
this.state = {
|
|
||||||
page: {
|
page: {
|
||||||
curIndex: 0,
|
curIndex: 0,
|
||||||
"name": [
|
cat: null,
|
||||||
|
name: [
|
||||||
"formation",
|
"formation",
|
||||||
"filère de formation",
|
"filière de formation",
|
||||||
"filière de formation détaillée"
|
"filière de formation détaillée"
|
||||||
]
|
],
|
||||||
|
},
|
||||||
|
data: null
|
||||||
},
|
},
|
||||||
data: data
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(this.state)
|
previousPage(){
|
||||||
|
try {
|
||||||
|
if(this.state.page.curIndex-1 >= 0) {
|
||||||
|
this.update({ curIndex: this.state.page.curIndex-- });
|
||||||
|
}
|
||||||
|
console.log(this.state.page.curIndex)
|
||||||
|
} catch(e) {
|
||||||
|
console.error(e)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
nextPage() {
|
||||||
|
try {
|
||||||
|
if(this.state.page.curIndex+1 <= 2 ) {
|
||||||
|
this.update({ curIndex: this.state.page.curIndex++ });
|
||||||
|
}
|
||||||
|
console.log(this.state.page.curIndex)
|
||||||
|
} catch(e) {
|
||||||
|
console.error(e)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
async getData() {
|
||||||
|
try {
|
||||||
|
const api = "https://data.enseignementsup-recherche.gouv.fr/api/records/1.0/search/?dataset=fr-esr-parcoursup&q=&sort=tri&facet=fili&timezone=Europe%2FBerlin";
|
||||||
|
const response = await fetch(api);
|
||||||
|
const data = await response.json();
|
||||||
|
this.update({ data: data.facet_groups[0].facets });
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
onBeforeMount() {
|
onBeforeMount() {
|
||||||
this.getData()
|
this.getData();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div id="selector">
|
<span if={ !this.state.data }>Chargement...</span>
|
||||||
|
|
||||||
|
<div if={ this.state.data } id="selector">
|
||||||
<div id="selector-top-container">
|
<div id="selector-top-container">
|
||||||
<span id="selector-top-title">
|
<span id="selector-top-title">
|
||||||
{ state.pages.name[state.pages.curIndex] }
|
{ this.state.page.name[this.state.page.curIndex] }
|
||||||
</span>
|
</span>
|
||||||
<button id="selector-top-btn">
|
<button onclick={ previousPage } id="selector-top-btn"><</button>
|
||||||
<
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="selector-list-container">
|
<div id="selector-list-container">
|
||||||
<ul id="selector-list">
|
<ul id="selector-list">
|
||||||
<li each={ item in state.data } class="selector-list-inner">
|
<li each={ item in this.state.data } class="selector-list-inner">
|
||||||
<span class="selector-list-names">{state.data.name}</span>
|
<a onclick={ nextPage } class="selector-list-names">{ item.name }</a>
|
||||||
<span class="selector-list-counts">{state.data.count}</span>
|
<span class="selector-list-counts">{ item.count }</span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user