ProjetRIOT/components/main-controller.riot

112 lines
3.9 KiB
Plaintext
Raw Normal View History

2023-03-28 13:42:53 +02:00
<main-controller>
<div class="columns">
<div class="column is-one-third">
2023-03-31 11:36:19 +02:00
<div class="box p-3 m-2" style="display: flex">
2023-03-31 11:37:06 +02:00
<img class="m-auto" src="./resources/logo-parcoursup.svg"/>
2023-03-28 16:17:29 +02:00
</div>
2023-03-29 22:01:50 +02:00
<search updateCourse={updateCourse}></search>
2023-03-28 13:42:53 +02:00
</div>
<div class="column">
<fili-info schoolList={state.schoolList} course={state.course} shouldShowInfos={state.shouldShowInfos}></fili-info>
2023-03-31 14:55:49 +02:00
<school popup={popup} schoolList={state.schoolList} schoolListUpdating={state.schoolListUpdating} course={state.course} shouldShowInfos={state.shouldShowInfos}></school>
2023-03-28 13:42:53 +02:00
</div>
</div>
2023-03-31 14:54:13 +02:00
<school-info closeWindow={closePopup} popupEnabled={state.popupEnabled} school={state.school}></school-info>
2023-03-28 13:42:53 +02:00
<script>
import PAPI from '../javascript/parcoursup-link.js'
export default {
2023-03-31 14:22:25 +02:00
updateCourse(course){
this.updateList(course)
2023-03-31 14:22:25 +02:00
this.update({
course: course,
shouldShowInfos: course != null,
})
},
2023-03-31 14:22:25 +02:00
updateList(course) {
course = course || this.state.course
PAPI.fetchEtablissement(course.fili, course.sousfili, course.soussousfili).then((response) => {
response.forEach(etablissement => {
// calcul la moyenne
let pct_sansmention = etablissement.fields.pct_sansmention
let pct_AB = etablissement.fields.pct_ab
let pct_B = etablissement.fields.pct_b
let pct_TB = etablissement.fields.pct_tb
let pct_TBF = etablissement.fields.pct_tbf
// 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
2023-03-31 14:22:25 +02:00
})
this.update({
2023-03-31 14:22:25 +02:00
schoolListUpdating: true,
schoolList: response
2023-03-31 14:22:25 +02:00
})
2023-03-31 14:22:25 +02:00
this.update({
schoolListUpdating: false
})
})
},
onMounted(props, state) {
this.update({
course: null,
2023-03-31 14:55:49 +02:00
<<<<<<< HEAD
sortBy: null,
schoolList: null,
sortFields: SORT_TABLE,
2023-03-31 11:34:14 +02:00
filteredSchoolList: null,
2023-03-31 14:54:13 +02:00
shouldShowInfos: false,
school: null,
popupEnabled: false
2023-03-29 22:01:50 +02:00
})
2023-03-31 11:34:14 +02:00
},
filterSearch() {
let input = this.$("input")
if (!input) return
let finalArray = []
//On évite de trier avant d'avoir plus de 1 lettres.
if (input.value.length > 1) {
finalArray = this.state.schoolList.filter((item) => {
return item.name.toLowerCase().includes(input.value.toLowerCase())
})
} else {
finalArray = this.state.schoolList
}
this.update({
filteredSchoolList: finalArray
})
2023-03-31 14:54:13 +02:00
},
popup(school){
this.update({
school: school,
popupEnabled: true
})
console.log("popup!")
},
closePopup(){
this.update({
popupEnabled: false
})
console.log("closed!")
2023-03-31 14:55:49 +02:00
=======
2023-03-31 14:22:25 +02:00
schoolList: [],
shouldShowInfos: false
2023-03-29 22:01:50 +02:00
})
2023-03-31 14:55:49 +02:00
>>>>>>> 6ed22586179f7de1d23fd1ebd68d111298170226
2023-03-29 22:01:50 +02:00
}
2023-03-28 13:42:53 +02:00
}
</script>
</main-controller>