diff --git a/components/fili-info.riot b/components/fili-info.riot index bfaad86..0d74496 100644 --- a/components/fili-info.riot +++ b/components/fili-info.riot @@ -51,7 +51,6 @@ state.selectivity = Math.floor(avgSlc) let pctFemmes = Math.round(list.reduce((s, e) => s + (e.fields.pct_f || 0), 0) / list.filter((e) => e.fields.pct_f).length) - console.log(pctFemmes) state.genreStats = [ { name: "Hommes", diff --git a/components/main-controller.riot b/components/main-controller.riot index dc9ac93..b629701 100644 --- a/components/main-controller.riot +++ b/components/main-controller.riot @@ -1,15 +1,15 @@
-
- +
+
- +
@@ -19,45 +19,16 @@ import PAPI from '../javascript/parcoursup-link.js' - const SORT_TABLE = [ - {name: "Nom", id: "g_ea_lib_vx"}, - {name: "Ville", id: "ville_etab"}, - {name: "Département", id: "dep"}, - {name: "Moyenne", id: "moyenne"}, - {name: "Sélectivité", id: "taux_acces_ens"} - ] - export default { - sortList(sortBy) { - //Si la liste est déjà triée par la bonne catégorie, on l'inverse - if (sortBy == this.state.sortBy) { - this.state.filteredSchoolList.reverse() - } - //Sinon on l'ordonne par la nouvelle catégorie (ascendant par défaut) - else { - this.state.sortBy = sortBy + updateCourse(course){ + this.updateList(course) - switch (sortBy) { - case SORT_TABLE[3].id: - case SORT_TABLE[4].id: { - this.state.filteredSchoolList.sort((a, b) => { - if (a.fields[sortBy] > b.fields[sortBy]) return 1 - else return -1 - }) - break - } - - default: { - this.state.filteredSchoolList.sort((a, b) => { - return (a.fields[sortBy]).localeCompare(b.fields[sortBy]) - }) - break - } - } - } - - this.update() + this.update({ + course: course, + shouldShowInfos: course != null, + }) }, + updateList(course) { course = course || this.state.course PAPI.fetchEtablissement(course.fili, course.sousfili, course.soussousfili).then((response) => { @@ -72,27 +43,23 @@ // On prend la moyenne des moyennes comprises dans la mention // Exemple : Assez bien est entre 12 et 14 donc 13. etablissement.fields.moyenne = ((pct_TBF*19)+(pct_TB*17)+(pct_B*15)+(pct_AB*13)+(pct_sansmention*11))/100 - }) + }) + + this.update({ + schoolListUpdating: true, + schoolList: response + }) this.update({ - schoolList: response - }) - this.filterSearch() - }) - }, - updateCourse(course){ - this.updateList(course) - - this.update({ - course: course, - sortFields: SORT_TABLE, - shouldShowInfos: course != null, + schoolListUpdating: false + }) }) }, onMounted(props, state) { this.update({ course: null, +<<<<<<< HEAD sortBy: null, schoolList: null, sortFields: SORT_TABLE, @@ -133,6 +100,11 @@ popupEnabled: false }) console.log("closed!") +======= + schoolList: [], + shouldShowInfos: false + }) +>>>>>>> 6ed22586179f7de1d23fd1ebd68d111298170226 } } diff --git a/components/school.riot b/components/school.riot index a92d00c..820d912 100644 --- a/components/school.riot +++ b/components/school.riot @@ -3,9 +3,8 @@ -
- + @@ -13,16 +12,16 @@ - - + @@ -32,4 +31,87 @@
+ {sortField.name} - props.sortList(sortField.id)}> + sortList(sortField.id, true)}>
props.popup(school)}>{school.fields.g_ea_lib_vx} {school.fields.ville_etab} {school.fields.dep}
+ + \ No newline at end of file diff --git a/components/title-progress.riot b/components/title-progress.riot index 4d05895..a7000a8 100644 --- a/components/title-progress.riot +++ b/components/title-progress.riot @@ -9,11 +9,11 @@