début tri tableau

This commit is contained in:
Haïssous Kayyissa 2023-03-30 17:26:23 +02:00
parent 7807b3f881
commit 0613632b24
4 changed files with 128 additions and 49 deletions

View File

@ -13,11 +13,11 @@
<table class="table is-fullwidth is-hoverable">
<thead>
<tr>
<th><abbr title="name">Nom</abbr></th>
<th><abbr title="city">Ville</abbr></th>
<th><abbr title="dept">Dpt</abbr></th>
<th><abbr title="moyenne">Moyenne</abbr></th>
<th><abbr title="selectivite">Sélectivité</abbr></th>
<th><abbr title="name">Nom</abbr></th><a id="g_ea_lib_vx" onclick={sort}><span class="icon"><i class="fas fa-sort"></i></span></a>
<th><abbr title="city">Ville</abbr></th><a id="ville_etab" onclick={sort}><span class="icon"><i class="fas fa-sort"></i></span></a>
<th><abbr title="dept">Dpt</abbr></th><a id="dep" onclick={sort}><span class="icon"><i class="fas fa-sort"></i></span></a>
<th><abbr title="moyenne">Moyenne</abbr></th><a id="moyenne" onclick={sort}><span class="icon"><i class="fas fa-sort"></i></span></a>
<th><abbr title="selectivite">Sélectivité</abbr></th><a id="taux_acces_ens" onclick={sort}><span class="icon"><i class="fas fa-sort"></i></span></a>
</tr>
</thead>
<tbody>
@ -44,10 +44,10 @@
onBeforeMount(props, state) {
state = {
items: null,
breakCycle: false
breakCycle: false,
ascOrder: true
}
},
onUpdated(props, state) {
if (!props.shouldShowInfos || state.breakCycle) return
fetchEtablissement(props.course).then((response) => {
@ -70,6 +70,17 @@
})
state.breakCycle = false
})
},
sort(e){
console.log("sort")
console.log(e.target)
if (this.state.ascOrder){
this.state.items.sort((etablissement1, etablissement2)=>etablissement2.fields[order]-etablissement1.fields[order]))
} else {
this.state.items.sort((etablissement1, etablissement2)=>etablissement1.fields[order]-etablissement2.fields[order]))
}
this.state.ascOrder=!this.state.ascOrder
this.update()
}
}
}

View File

@ -6,6 +6,7 @@
<link rel="stylesheet" href="style/parcoursup.css">
<script src="riot.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.9.3/css/bulma.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.9.0/css/all.min.css" integrity="sha512-q3eWabyZPc1XTCmF+8/LuE1ozpg5xxn7iO89yfSOd5/oKvyqLngoNGsx8jq92Y8eXJ/IRxQbEC+FGSYxtk2oiw==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<script src="loader.js" type="module"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/riot/7.1.0/riot+compiler.min.js" integrity="sha512-sSGKGR9MvL0bUx3CScaBb56crXwspwDkL/JnB0IrLFQfw3uvSUlITQtsTtDZctshhv5wdwIt+qZeN8zThRF4Dw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
</head>

File diff suppressed because one or more lines are too long

View File

@ -8,24 +8,36 @@ class PAPI {
static timezone = "Europe%2FBerlin";
static searchURL = `https://data.enseignementsup-recherche.gouv.fr/api/records/1.0/search/?dataset=${PAPI.dataset}&timezone=${PAPI.timezone}`;
static async fetchFilieres() {
if (localStorage.getItem("filis")) return JSON.parse(localStorage.getItem("filis"));
let request = await fetch(`${PAPI.searchURL}&rows=0&sort=tri&facet=fili`);
let result = await request.json();
return result["facet_groups"][0]["facets"];
let response = result["facet_groups"][0]["facets"];
localStorage.setItem("filis", JSON.stringify(response));
return response;
}
static async fetchFiliere(filiere) {
if (localStorage.getItem("fili." + filiere)) return JSON.parse(localStorage.getItem("fili." + filiere));
let request = await fetch(`${PAPI.searchURL}&rows=0&sort=tri&facet=form_lib_voe_acc&refine.fili=${filiere}`);
let result = await request.json();
return result["facet_groups"][0]["facets"];
let response = result["facet_groups"][0]["facets"];
localStorage.setItem("fili." + filiere, JSON.stringify(response));
return response;
}
static async fetchSpecialites(specialite) {
if (localStorage.getItem("spe." + specialite)) return JSON.parse(localStorage.getItem("spe." + specialite));
let request = await fetch(`${PAPI.searchURL}&rows=0&sort=tri&facet=fil_lib_voe_acc&refine.form_lib_voe_acc=${specialite}`);
let result = await request.json();
return result["facet_groups"][0]["facets"];
let response = result["facet_groups"][0]["facets"];
localStorage.setItem("spe." + specialite, JSON.stringify(response));
return response;
}
static async fetchEtablissement(filiere, sousfiliere, soussousfiliere) {
if (localStorage.getItem(`eta.${filiere}.${sousfiliere}.${soussousfiliere}`)) return JSON.parse(localStorage.getItem(`eta.${filiere}.${sousfiliere}.${soussousfiliere}`));
let request = await fetch(`${PAPI.searchURL}&refine.fil_lib_voe_acc=${soussousfiliere}&refine.form_lib_voe_acc=${sousfiliere}&refine.fili=${filiere}`);
let result = await request.json();
return result["records"];
let response = result["records"];
localStorage.setItem(`eta.${filiere}.${sousfiliere}.${soussousfiliere}`, JSON.stringify(response));
return response;
}
}
@ -132,9 +144,9 @@ var search = {
this.updateList();
}
},
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div class="box p-1 m-2"><div class="columns m-1"><input expr1400="expr1400" class="input" type="input"/><button expr1401="expr1401" class="button ml-1">&lt;</button></div><div id="list-formations"><ul><li expr1402="expr1402" class="m-1"></li></ul></div></div>', [{
redundantAttribute: 'expr1400',
selector: '[expr1400]',
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div class="box p-1 m-2"><div class="columns m-1"><input expr626="expr626" class="input" type="input"/><button expr627="expr627" class="button ml-1">&lt;</button></div><div id="list-formations"><ul><li expr628="expr628" class="m-1"></li></ul></div></div>', [{
redundantAttribute: 'expr626',
selector: '[expr626]',
expressions: [{
type: expressionTypes.EVENT,
name: 'onkeyup',
@ -145,8 +157,8 @@ var search = {
evaluate: _scope => _scope.state.placeholder
}]
}, {
redundantAttribute: 'expr1401',
selector: '[expr1401]',
redundantAttribute: 'expr627',
selector: '[expr627]',
expressions: [{
type: expressionTypes.ATTRIBUTE,
name: 'disabled',
@ -160,9 +172,9 @@ var search = {
type: bindingTypes.EACH,
getKey: null,
condition: null,
template: template('<button expr1403="expr1403" class="button is-fullwidth p-2"><span style="font-size: .75em; max-size: 90%"><strong expr1404="expr1404"> </strong></span><div style="margin-left: auto;"></div><span expr1405="expr1405" class="tag is-primary"> </span></button>', [{
redundantAttribute: 'expr1403',
selector: '[expr1403]',
template: template('<button expr629="expr629" class="button is-fullwidth p-2"><span style="font-size: .75em; max-size: 90%"><strong expr630="expr630"> </strong></span><div style="margin-left: auto;"></div><span expr631="expr631" class="tag is-primary"> </span></button>', [{
redundantAttribute: 'expr629',
selector: '[expr629]',
expressions: [{
type: expressionTypes.ATTRIBUTE,
name: 'disabled',
@ -173,24 +185,24 @@ var search = {
evaluate: _scope => () => _scope.cruiseForward(_scope.item.name)
}]
}, {
redundantAttribute: 'expr1404',
selector: '[expr1404]',
redundantAttribute: 'expr630',
selector: '[expr630]',
expressions: [{
type: expressionTypes.TEXT,
childNodeIndex: 0,
evaluate: _scope => _scope.item.name
}]
}, {
redundantAttribute: 'expr1405',
selector: '[expr1405]',
redundantAttribute: 'expr631',
selector: '[expr631]',
expressions: [{
type: expressionTypes.TEXT,
childNodeIndex: 0,
evaluate: _scope => _scope.item.count
}]
}]),
redundantAttribute: 'expr1402',
selector: '[expr1402]',
redundantAttribute: 'expr628',
selector: '[expr628]',
itemName: 'item',
indexName: null,
evaluate: _scope => _scope.state.items