$
This commit is contained in:
parent
bfe501b9f9
commit
1147c68f42
1
src/components/global/selector/fd.json
Normal file
1
src/components/global/selector/fd.json
Normal file
File diff suppressed because one or more lines are too long
@ -73,10 +73,23 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
|
/**
|
||||||
|
* state: Contenant
|
||||||
|
* state -> page: Contenant des données de la section actuel
|
||||||
|
* state -> page -> curIndex: Numero de la section actuel
|
||||||
|
* state -> page -> cat: Contenant des valeurs choisit ex: option1: "BUT"
|
||||||
|
* state -> page -> name: Contenant des titres de section en fonction de ..curIndex
|
||||||
|
*
|
||||||
|
* data: Contenant des facets etc...
|
||||||
|
* */
|
||||||
state: {
|
state: {
|
||||||
page: {
|
page: {
|
||||||
curIndex: 0,
|
curIndex: 0,
|
||||||
cat: [2],
|
cat: {
|
||||||
|
option1: null,
|
||||||
|
option2: null,
|
||||||
|
option3: null
|
||||||
|
},
|
||||||
name: [
|
name: [
|
||||||
"formation",
|
"formation",
|
||||||
"filière de formation",
|
"filière de formation",
|
||||||
@ -86,10 +99,9 @@
|
|||||||
data: []
|
data: []
|
||||||
},
|
},
|
||||||
|
|
||||||
updateCat(category, value) {
|
/**
|
||||||
this.update(this.state.page.cat[category] = value)
|
* Retourner a la section n-1
|
||||||
},
|
* */
|
||||||
|
|
||||||
previousPage(){
|
previousPage(){
|
||||||
try {
|
try {
|
||||||
if(this.state.page.curIndex-1 >= 0) {
|
if(this.state.page.curIndex-1 >= 0) {
|
||||||
@ -100,9 +112,23 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
nextPage() {
|
/**
|
||||||
|
* Aller a la section n+1
|
||||||
|
* @param choice Choix fait par l'utilisateur a la section n
|
||||||
|
* todo: Faire en sorte de refaire des calls api en fonction de la section choisit (this.getSpecFor(nom_formation:String) et this.getSpecPlusFor(nom_formation:String)
|
||||||
|
* */
|
||||||
|
nextPage(choice) {
|
||||||
try {
|
try {
|
||||||
if(this.state.page.curIndex+1 <= 2 ) {
|
if(this.state.page.curIndex+1 <= 2 ) {
|
||||||
|
if(this.state.page.curIndex+1 === 0) {
|
||||||
|
this.getData()
|
||||||
|
this.update({ option1: choice })
|
||||||
|
} else if(this.state.page.curIndex+1 === 1) {
|
||||||
|
this.update({ option2: choice })
|
||||||
|
} else if(this.state.page.curIndex+1 === 2) {
|
||||||
|
this.update({ option3: choice })
|
||||||
|
}
|
||||||
|
|
||||||
this.update({ curIndex: this.state.page.curIndex++ });
|
this.update({ curIndex: this.state.page.curIndex++ });
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
@ -110,12 +136,16 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pour recuperer les données directement depuis l'API avec la facet: "fili"
|
||||||
|
* */
|
||||||
async getData() {
|
async getData() {
|
||||||
try {
|
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 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 response = await fetch(api);
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
this.update({ data: data.facet_groups[0].facets });
|
this.update({ data: data.facet_groups[0].facets });
|
||||||
|
console.log(data)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
@ -138,9 +168,16 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="selector-list-container">
|
<div id="selector-list-container">
|
||||||
<ul if={ this.state.page.curIndex == 0 } id="selector-list">
|
<ul if={ this.state.page.curIndex === 0 } id="selector-list">
|
||||||
<li each={ item in this.state.data } class="selector-list-inner">
|
<li each={ item in this.state.data } class="selector-list-inner">
|
||||||
<a onclick={ nextPage } href={`?option1=${item.name}`} class="selector-list-names">{ item.name }</a>
|
<a onclick={ () => { nextPage(item.name) } } class="selector-list-names">{ item.name }</a>
|
||||||
|
<span class="selector-list-counts">{ item.count }</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<ul if={ this.state.page.curIndex === 1 }>
|
||||||
|
<li each={ item in this.state.data } class="selector-list-inner">
|
||||||
|
<a onclick={ () => { nextPage(item.name) } } class="selector-list-names">{ item.name }</a>
|
||||||
<span class="selector-list-counts">{ item.count }</span>
|
<span class="selector-list-counts">{ item.count }</span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
Loading…
Reference in New Issue
Block a user