This commit is contained in:
Haïssous Kayyissa 2023-03-31 14:55:49 +02:00
commit 486d105064
11 changed files with 336 additions and 247 deletions

View File

@ -51,7 +51,6 @@
state.selectivity = Math.floor(avgSlc) 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) 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 = [ state.genreStats = [
{ {
name: "Hommes", name: "Hommes",

View File

@ -1,15 +1,15 @@
<main-controller> <main-controller>
<div class="columns"> <div class="columns">
<div class="column is-one-third"> <div class="column is-one-third">
<div class="box p-3 m-2"> <div class="box p-3 m-2" style="display: flex">
<img class="mt-1 ml-5 mr-auto" style="margin: auto;" src="./resources/logo-parcoursup.svg"/> <img class="m-auto" src="./resources/logo-parcoursup.svg"/>
</div> </div>
<search updateCourse={updateCourse}></search> <search updateCourse={updateCourse}></search>
</div> </div>
<div class="column"> <div class="column">
<fili-info schoolList={state.schoolList} course={state.course} shouldShowInfos={state.shouldShowInfos}></fili-info> <fili-info schoolList={state.schoolList} course={state.course} shouldShowInfos={state.shouldShowInfos}></fili-info>
<school popup={popup} sortList={sortList} schoolList={state.filteredSchoolList} sortFields={state.sortFields} course={state.course} shouldShowInfos={state.shouldShowInfos}></school> <school popup={popup} schoolList={state.schoolList} schoolListUpdating={state.schoolListUpdating} course={state.course} shouldShowInfos={state.shouldShowInfos}></school>
</div> </div>
</div> </div>
@ -19,45 +19,16 @@
import PAPI from '../javascript/parcoursup-link.js' 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 { export default {
sortList(sortBy) { updateCourse(course){
//Si la liste est déjà triée par la bonne catégorie, on l'inverse this.updateList(course)
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
switch (sortBy) { this.update({
case SORT_TABLE[3].id: course: course,
case SORT_TABLE[4].id: { shouldShowInfos: course != null,
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()
}, },
updateList(course) { updateList(course) {
course = course || this.state.course course = course || this.state.course
PAPI.fetchEtablissement(course.fili, course.sousfili, course.soussousfili).then((response) => { PAPI.fetchEtablissement(course.fili, course.sousfili, course.soussousfili).then((response) => {
@ -75,24 +46,20 @@
}) })
this.update({ this.update({
schoolListUpdating: true,
schoolList: response schoolList: response
}) })
this.filterSearch()
})
},
updateCourse(course){
this.updateList(course)
this.update({ this.update({
course: course, schoolListUpdating: false
sortFields: SORT_TABLE, })
shouldShowInfos: course != null,
}) })
}, },
onMounted(props, state) { onMounted(props, state) {
this.update({ this.update({
course: null, course: null,
<<<<<<< HEAD
sortBy: null, sortBy: null,
schoolList: null, schoolList: null,
sortFields: SORT_TABLE, sortFields: SORT_TABLE,
@ -133,6 +100,11 @@
popupEnabled: false popupEnabled: false
}) })
console.log("closed!") console.log("closed!")
=======
schoolList: [],
shouldShowInfos: false
})
>>>>>>> 6ed22586179f7de1d23fd1ebd68d111298170226
} }
} }
</script> </script>

View File

@ -3,9 +3,8 @@
<iframe if={false} width="100%" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" <iframe if={false} width="100%" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"
src="https://www.openstreetmap.org/export/embed.html?bbox=-14.655761718750002%2C40.56389453066509%2C13.601074218750002%2C51.754240074033525&amp;layer=mapnik" src="https://www.openstreetmap.org/export/embed.html?bbox=-14.655761718750002%2C40.56389453066509%2C13.601074218750002%2C51.754240074033525&amp;layer=mapnik"
style="border-radius: 5px;"></iframe> style="border-radius: 5px;"></iframe>
<br>
<div class="block control has-icons-left is-inline-block is-pulled-right"> <div class="block control has-icons-left is-inline-block is-pulled-right">
<input class="input" onkeyup={props.filterSearch} type="search" placeholder="Établissement"> <input class="input" onkeyup={filterSearch} type="search" placeholder="Établissement">
<span class="icon is-small is-left"> <span class="icon is-small is-left">
<i class="fas fa-search"></i> <i class="fas fa-search"></i>
</span> </span>
@ -13,16 +12,16 @@
<table class="table is-fullwidth is-hoverable"> <table class="table is-fullwidth is-hoverable">
<thead> <thead>
<tr> <tr>
<th each={sortField in props.sortFields}> <th each={sortField in sortFields}>
{sortField.name} {sortField.name}
<a id={sortField.id} onclick={() => props.sortList(sortField.id)}> <a id={sortField.id} onclick={() => sortList(sortField.id, true)}>
<span class="icon"><i class="fas fa-sort"></i></span> <span class="icon"><i class="fas fa-sort"></i></span>
</a> </a>
</th> </th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr each={school in props.schoolList}> <tr each={school in state.filteredSchoolList}>
<td><a onclick={() => props.popup(school)}>{school.fields.g_ea_lib_vx}</a></td> <td><a onclick={() => props.popup(school)}>{school.fields.g_ea_lib_vx}</a></td>
<td>{school.fields.ville_etab}</td> <td>{school.fields.ville_etab}</td>
<td>{school.fields.dep}</td> <td>{school.fields.dep}</td>
@ -32,4 +31,87 @@
</tbody> </tbody>
</table> </table>
</div> </div>
<script>
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 {
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.fields.g_ea_lib_vx.toLowerCase().includes(input.value.toLowerCase())
})
} else {
finalArray = this.state.schoolList
}
this.update({
filteredSchoolList: finalArray
})
},
sortList(sortBy, shouldUpdate) {
//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
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()
},
onBeforeUpdate(props, state) {
if (props.schoolListUpdating) {
state.schoolList = [...props.schoolList]
state.filteredSchoolList = [...state.schoolList]
if (this.$("input")) this.$("input").value = ""
}
},
onBeforeMount(props, state) {
this.state = {
sortBy: null,
schoolList: [],
filteredSchoolList: []
}
},
sortFields: SORT_TABLE
}
</script>
</school> </school>

View File

@ -9,11 +9,11 @@
<script> <script>
const DEFAULT_CLASSES = "progress is-small m-2 mt-auto mb-auto" const DEFAULT_CLASSES = "progress is-small m-2 mt-auto mb-auto"
const COLOR_CLASSES = [ const COLOR_CLASSES = [
"is-link", "is-danger",
"is-info",
"is-success",
"is-warning", "is-warning",
"is-danger" "is-success",
"is-info",
"is-link"
] ]

File diff suppressed because one or more lines are too long

View File

@ -17,7 +17,9 @@ class PAPI {
} }
static async fetchFiliere(filiere) { static async fetchFiliere(filiere) {
if (localStorage.getItem("fili." + filiere)) return JSON.parse(localStorage.getItem("fili." + 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 url = `${PAPI.searchURL}&rows=0&sort=tri&facet=form_lib_voe_acc&refine.fili=${filiere}`;
url = url.replace("+", "%2B");
let request = await fetch(url);
let result = await request.json(); let result = await request.json();
let response = result["facet_groups"][0]["facets"]; let response = result["facet_groups"][0]["facets"];
localStorage.setItem("fili." + filiere, JSON.stringify(response)); localStorage.setItem("fili." + filiere, JSON.stringify(response));
@ -25,7 +27,9 @@ class PAPI {
} }
static async fetchSpecialites(filiere, specialite) { static async fetchSpecialites(filiere, specialite) {
if (localStorage.getItem(`spe.${filiere}.${specialite}`)) return JSON.parse(localStorage.getItem(`spe.${filiere}.${specialite}`)); if (localStorage.getItem(`spe.${filiere}.${specialite}`)) return JSON.parse(localStorage.getItem(`spe.${filiere}.${specialite}`));
let request = await fetch(`${PAPI.searchURL}&rows=0&sort=tri&facet=fil_lib_voe_acc&refine.form_lib_voe_acc=${specialite}&refine.fili=${filiere}`); let url = `${PAPI.searchURL}&rows=0&sort=tri&facet=fil_lib_voe_acc&refine.form_lib_voe_acc=${specialite}&refine.fili=${filiere}`;
url = url.replace("+", "%2B");
let request = await fetch(url);
let result = await request.json(); let result = await request.json();
let response = result["facet_groups"][0]["facets"]; let response = result["facet_groups"][0]["facets"];
localStorage.setItem(`spe.${filiere}.${specialite}`, JSON.stringify(response)); localStorage.setItem(`spe.${filiere}.${specialite}`, JSON.stringify(response));
@ -33,7 +37,9 @@ class PAPI {
} }
static async fetchEtablissement(filiere, sousfiliere, soussousfiliere) { static async fetchEtablissement(filiere, sousfiliere, soussousfiliere) {
if (localStorage.getItem(`eta.${filiere}.${sousfiliere}.${soussousfiliere}`)) return JSON.parse(localStorage.getItem(`eta.${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}&rows=10000&refine.fil_lib_voe_acc=${soussousfiliere}&refine.form_lib_voe_acc=${sousfiliere}&refine.fili=${filiere}`); let url = `${PAPI.searchURL}&rows=10000&refine.fil_lib_voe_acc=${soussousfiliere}&refine.form_lib_voe_acc=${sousfiliere}&refine.fili=${filiere}`;
url = url.replace("+", "%2B");
let request = await fetch(url);
let result = await request.json(); let result = await request.json();
let response = result["records"]; let response = result["records"];
localStorage.setItem(`eta.${filiere}.${sousfiliere}.${soussousfiliere}`, JSON.stringify(response)); localStorage.setItem(`eta.${filiere}.${sousfiliere}.${soussousfiliere}`, JSON.stringify(response));
@ -41,52 +47,15 @@ class PAPI {
} }
} }
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"
}];
var mainController = { var mainController = {
css: null, css: null,
exports: { exports: {
sortList(sortBy) { updateCourse(course) {
//Si la liste est déjà triée par la bonne catégorie, on l'inverse this.updateList(course);
if (sortBy == this.state.sortBy) { this.update({
this.state.filteredSchoolList.reverse(); course: course,
} shouldShowInfos: course != null
//Sinon on l'ordonne par la nouvelle catégorie (ascendant par défaut)
else {
this.state.sortBy = sortBy;
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();
}, },
updateList(course) { updateList(course) {
course = course || this.state.course; course = course || this.state.course;
@ -104,48 +73,23 @@ var mainController = {
etablissement.fields.moyenne = (pct_TBF * 19 + pct_TB * 17 + pct_B * 15 + pct_AB * 13 + pct_sansmention * 11) / 100; etablissement.fields.moyenne = (pct_TBF * 19 + pct_TB * 17 + pct_B * 15 + pct_AB * 13 + pct_sansmention * 11) / 100;
}); });
this.update({ this.update({
schoolListUpdating: true,
schoolList: response schoolList: response
}); });
this.filterSearch();
});
},
updateCourse(course) {
this.updateList(course);
this.update({ this.update({
course: course, schoolListUpdating: false
sortFields: SORT_TABLE, });
shouldShowInfos: course != null
}); });
}, },
onMounted(props, state) { onMounted(props, state) {
this.update({ this.update({
course: null, course: null,
sortBy: null, schoolList: [],
schoolList: null,
sortFields: SORT_TABLE,
filteredSchoolList: null,
shouldShowInfos: false shouldShowInfos: false
}); });
},
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
});
} }
}, },
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div class="columns"><div class="column is-one-third"><div class="box p-3 m-2"><img class="mt-1 ml-5 mr-auto" style="margin: auto;" src="./resources/logo-parcoursup.svg"/></div><search expr71="expr71"></search></div><div class="column"><fili-info expr72="expr72"></fili-info><school expr73="expr73"></school></div></div><school-info expr74="expr74"></school-info>', [{ template: (template, expressionTypes, bindingTypes, getComponent) => template('<div class="columns"><div class="column is-one-third"><div class="box p-3 m-2" style="display: flex"><img class="m-auto" src="./resources/logo-parcoursup.svg"/></div><search expr643="expr643"></search></div><div class="column"><fili-info expr644="expr644"></fili-info><school expr645="expr645"></school></div></div><school-info expr646="expr646"></school-info>', [{
type: bindingTypes.TAG, type: bindingTypes.TAG,
getComponent: getComponent, getComponent: getComponent,
evaluate: _scope => 'search', evaluate: _scope => 'search',
@ -155,8 +99,8 @@ var mainController = {
name: 'updateCourse', name: 'updateCourse',
evaluate: _scope => _scope.updateCourse evaluate: _scope => _scope.updateCourse
}], }],
redundantAttribute: 'expr71', redundantAttribute: 'expr643',
selector: '[expr71]' selector: '[expr643]'
}, { }, {
type: bindingTypes.TAG, type: bindingTypes.TAG,
getComponent: getComponent, getComponent: getComponent,
@ -175,25 +119,21 @@ var mainController = {
name: 'shouldShowInfos', name: 'shouldShowInfos',
evaluate: _scope => _scope.state.shouldShowInfos evaluate: _scope => _scope.state.shouldShowInfos
}], }],
redundantAttribute: 'expr72', redundantAttribute: 'expr644',
selector: '[expr72]' selector: '[expr644]'
}, { }, {
type: bindingTypes.TAG, type: bindingTypes.TAG,
getComponent: getComponent, getComponent: getComponent,
evaluate: _scope => 'school', evaluate: _scope => 'school',
slots: [], slots: [],
attributes: [{ attributes: [{
type: expressionTypes.ATTRIBUTE,
name: 'sortList',
evaluate: _scope => _scope.sortList
}, {
type: expressionTypes.ATTRIBUTE, type: expressionTypes.ATTRIBUTE,
name: 'schoolList', name: 'schoolList',
evaluate: _scope => _scope.state.filteredSchoolList evaluate: _scope => _scope.state.schoolList
}, { }, {
type: expressionTypes.ATTRIBUTE, type: expressionTypes.ATTRIBUTE,
name: 'sortFields', name: 'schoolListUpdating',
evaluate: _scope => _scope.state.sortFields evaluate: _scope => _scope.state.schoolListUpdating
}, { }, {
type: expressionTypes.ATTRIBUTE, type: expressionTypes.ATTRIBUTE,
name: 'course', name: 'course',
@ -203,16 +143,16 @@ var mainController = {
name: 'shouldShowInfos', name: 'shouldShowInfos',
evaluate: _scope => _scope.state.shouldShowInfos evaluate: _scope => _scope.state.shouldShowInfos
}], }],
redundantAttribute: 'expr73', redundantAttribute: 'expr645',
selector: '[expr73]' selector: '[expr645]'
}, { }, {
type: bindingTypes.TAG, type: bindingTypes.TAG,
getComponent: getComponent, getComponent: getComponent,
evaluate: _scope => 'school-info', evaluate: _scope => 'school-info',
slots: [], slots: [],
attributes: [], attributes: [],
redundantAttribute: 'expr74', redundantAttribute: 'expr646',
selector: '[expr74]' selector: '[expr646]'
}]), }]),
name: 'main-controller' name: 'main-controller'
}; };

View File

@ -26,7 +26,10 @@ class PAPI {
if (localStorage.getItem("fili." + filiere)) return JSON.parse(localStorage.getItem("fili." + 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 url = `${PAPI.searchURL}&rows=0&sort=tri&facet=form_lib_voe_acc&refine.fili=${filiere}`
url = url.replace("+", "%2B")
let request = await fetch(url)
let result = await request.json() let result = await request.json()
let response = result["facet_groups"][0]["facets"] let response = result["facet_groups"][0]["facets"]
@ -39,7 +42,10 @@ class PAPI {
if (localStorage.getItem(`spe.${filiere}.${specialite}`)) return JSON.parse(localStorage.getItem(`spe.${filiere}.${specialite}`)) if (localStorage.getItem(`spe.${filiere}.${specialite}`)) return JSON.parse(localStorage.getItem(`spe.${filiere}.${specialite}`))
let request = await fetch(`${PAPI.searchURL}&rows=0&sort=tri&facet=fil_lib_voe_acc&refine.form_lib_voe_acc=${specialite}&refine.fili=${filiere}`) let url = `${PAPI.searchURL}&rows=0&sort=tri&facet=fil_lib_voe_acc&refine.form_lib_voe_acc=${specialite}&refine.fili=${filiere}`
url = url.replace("+", "%2B")
let request = await fetch(url)
let result = await request.json() let result = await request.json()
let response = result["facet_groups"][0]["facets"] let response = result["facet_groups"][0]["facets"]
@ -52,7 +58,10 @@ class PAPI {
if (localStorage.getItem(`eta.${filiere}.${sousfiliere}.${soussousfiliere}`)) return JSON.parse(localStorage.getItem(`eta.${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}&rows=10000&refine.fil_lib_voe_acc=${soussousfiliere}&refine.form_lib_voe_acc=${sousfiliere}&refine.fili=${filiere}`) let url = `${PAPI.searchURL}&rows=10000&refine.fil_lib_voe_acc=${soussousfiliere}&refine.form_lib_voe_acc=${sousfiliere}&refine.fili=${filiere}`
url = url.replace("+", "%2B")
let request = await fetch(url)
let result = await request.json() let result = await request.json()
let response = result["records"] let response = result["records"]

View File

@ -10,14 +10,14 @@ var schoolInfo = {
this.update(); this.update();
} }
}, },
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div expr23="expr23" style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; background: #000000DD;"></div>', [{ template: (template, expressionTypes, bindingTypes, getComponent) => template('<div expr29="expr29" style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; background: #000000DD;"></div>', [{
type: bindingTypes.IF, type: bindingTypes.IF,
evaluate: _scope => _scope.state.enabled, evaluate: _scope => _scope.state.enabled,
redundantAttribute: 'expr23', redundantAttribute: 'expr29',
selector: '[expr23]', selector: '[expr29]',
template: template('<div style="position: absolute; top: 10%; left: 10%; width: 80%; height: 80%; background: #FFFFFF"><button expr24="expr24" class="delete is-medium">X</button><p><h2></h2></p><line-graph expr25="expr25" style="height: 90px; margin: 10px;"></line-graph></div>', [{ template: template('<div style="position: absolute; top: 10%; left: 10%; width: 80%; height: 80%; background: #FFFFFF"><button expr30="expr30" class="delete is-medium">X</button><p><h2></h2></p><line-graph expr31="expr31" style="height: 90px; margin: 10px;"></line-graph></div>', [{
redundantAttribute: 'expr24', redundantAttribute: 'expr30',
selector: '[expr24]', selector: '[expr30]',
expressions: [{ expressions: [{
type: expressionTypes.EVENT, type: expressionTypes.EVENT,
name: 'onclick', name: 'onclick',
@ -29,8 +29,8 @@ var schoolInfo = {
evaluate: _scope => 'line-graph', evaluate: _scope => 'line-graph',
slots: [], slots: [],
attributes: [], attributes: [],
redundantAttribute: 'expr25', redundantAttribute: 'expr31',
selector: '[expr25]' selector: '[expr31]'
}]) }])
}]), }]),
name: 'school-info' name: 'school-info'

View File

@ -1,38 +1,116 @@
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"
}];
var school = { var school = {
css: null, css: null,
exports: null, exports: {
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div expr52="expr52" class="box p-2 m-2" disabled></div>', [{ 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.fields.g_ea_lib_vx.toLowerCase().includes(input.value.toLowerCase());
});
} else {
finalArray = this.state.schoolList;
}
this.update({
filteredSchoolList: finalArray
});
},
sortList(sortBy, shouldUpdate) {
//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;
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();
},
onBeforeUpdate(props, state) {
if (props.schoolListUpdating) {
state.schoolList = [...props.schoolList];
state.filteredSchoolList = [...state.schoolList];
if (this.$("input")) this.$("input").value = "";
}
},
onBeforeMount(props, state) {
this.state = {
sortBy: null,
schoolList: [],
filteredSchoolList: []
};
},
sortFields: SORT_TABLE
},
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div expr680="expr680" class="box p-2 m-2" disabled></div>', [{
type: bindingTypes.IF, type: bindingTypes.IF,
evaluate: _scope => _scope.props.shouldShowInfos, evaluate: _scope => _scope.props.shouldShowInfos,
redundantAttribute: 'expr52', redundantAttribute: 'expr680',
selector: '[expr52]', selector: '[expr680]',
template: template('<iframe expr53="expr53" width="100%" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://www.openstreetmap.org/export/embed.html?bbox=-14.655761718750002%2C40.56389453066509%2C13.601074218750002%2C51.754240074033525&amp;layer=mapnik" style="border-radius: 5px;"></iframe><br/><div class="block control has-icons-left is-inline-block is-pulled-right"><input expr54="expr54" class="input" type="search" placeholder="Établissement"/><span class="icon is-small is-left"><i class="fas fa-search"></i></span></div><table class="table is-fullwidth is-hoverable"><thead><tr><th expr55="expr55"></th></tr></thead><tbody><tr expr57="expr57"></tr></tbody></table>', [{ template: template('<iframe expr681="expr681" width="100%" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://www.openstreetmap.org/export/embed.html?bbox=-14.655761718750002%2C40.56389453066509%2C13.601074218750002%2C51.754240074033525&amp;layer=mapnik" style="border-radius: 5px;"></iframe><div class="block control has-icons-left is-inline-block is-pulled-right"><input expr682="expr682" class="input" type="search" placeholder="Établissement"/><span class="icon is-small is-left"><i class="fas fa-search"></i></span></div><table class="table is-fullwidth is-hoverable"><thead><tr><th expr683="expr683"></th></tr></thead><tbody><tr expr685="expr685"></tr></tbody></table>', [{
type: bindingTypes.IF, type: bindingTypes.IF,
evaluate: _scope => false, evaluate: _scope => false,
redundantAttribute: 'expr53', redundantAttribute: 'expr681',
selector: '[expr53]', selector: '[expr681]',
template: template(null, []) template: template(null, [])
}, { }, {
redundantAttribute: 'expr54', redundantAttribute: 'expr682',
selector: '[expr54]', selector: '[expr682]',
expressions: [{ expressions: [{
type: expressionTypes.EVENT, type: expressionTypes.EVENT,
name: 'onkeyup', name: 'onkeyup',
evaluate: _scope => _scope.props.filterSearch evaluate: _scope => _scope.filterSearch
}] }]
}, { }, {
type: bindingTypes.EACH, type: bindingTypes.EACH,
getKey: null, getKey: null,
condition: null, condition: null,
template: template(' <a expr56="expr56"><span class="icon"><i class="fas fa-sort"></i></span></a>', [{ template: template(' <a expr684="expr684"><span class="icon"><i class="fas fa-sort"></i></span></a>', [{
expressions: [{ expressions: [{
type: expressionTypes.TEXT, type: expressionTypes.TEXT,
childNodeIndex: 0, childNodeIndex: 0,
evaluate: _scope => [_scope.sortField.name].join('') evaluate: _scope => [_scope.sortField.name].join('')
}] }]
}, { }, {
redundantAttribute: 'expr56', redundantAttribute: 'expr684',
selector: '[expr56]', selector: '[expr684]',
expressions: [{ expressions: [{
type: expressionTypes.ATTRIBUTE, type: expressionTypes.ATTRIBUTE,
name: 'id', name: 'id',
@ -40,45 +118,49 @@ var school = {
}, { }, {
type: expressionTypes.EVENT, type: expressionTypes.EVENT,
name: 'onclick', name: 'onclick',
evaluate: _scope => () => _scope.props.sortList(_scope.sortField.id) evaluate: _scope => () => _scope.sortList(_scope.sortField.id, true)
}] }]
}]), }]),
redundantAttribute: 'expr55', redundantAttribute: 'expr683',
selector: '[expr55]', selector: '[expr683]',
itemName: 'sortField', itemName: 'sortField',
indexName: null, indexName: null,
evaluate: _scope => _scope.props.sortFields evaluate: _scope => _scope.sortFields
}, { }, {
type: bindingTypes.EACH, type: bindingTypes.EACH,
getKey: null, getKey: null,
condition: null, condition: null,
template: template('<td expr58="expr58"> </td><td expr59="expr59"> </td><td expr60="expr60"> </td><td expr61="expr61"> </td><td><title-progress expr62="expr62" max="100" style="margin: auto"></title-progress></td>', [{ template: template('<td><a expr686="expr686"> </a></td><td expr687="expr687"> </td><td expr688="expr688"> </td><td expr689="expr689"> </td><td><title-progress expr690="expr690" max="100" style="margin: auto"></title-progress></td>', [{
redundantAttribute: 'expr58', redundantAttribute: 'expr686',
selector: '[expr58]', selector: '[expr686]',
expressions: [{ expressions: [{
type: expressionTypes.TEXT, type: expressionTypes.TEXT,
childNodeIndex: 0, childNodeIndex: 0,
evaluate: _scope => _scope.school.fields.g_ea_lib_vx evaluate: _scope => _scope.school.fields.g_ea_lib_vx
}, {
type: expressionTypes.EVENT,
name: 'onclick',
evaluate: _scope => () => _scope.props.popup(_scope.school)
}] }]
}, { }, {
redundantAttribute: 'expr59', redundantAttribute: 'expr687',
selector: '[expr59]', selector: '[expr687]',
expressions: [{ expressions: [{
type: expressionTypes.TEXT, type: expressionTypes.TEXT,
childNodeIndex: 0, childNodeIndex: 0,
evaluate: _scope => _scope.school.fields.ville_etab evaluate: _scope => _scope.school.fields.ville_etab
}] }]
}, { }, {
redundantAttribute: 'expr60', redundantAttribute: 'expr688',
selector: '[expr60]', selector: '[expr688]',
expressions: [{ expressions: [{
type: expressionTypes.TEXT, type: expressionTypes.TEXT,
childNodeIndex: 0, childNodeIndex: 0,
evaluate: _scope => _scope.school.fields.dep evaluate: _scope => _scope.school.fields.dep
}] }]
}, { }, {
redundantAttribute: 'expr61', redundantAttribute: 'expr689',
selector: '[expr61]', selector: '[expr689]',
expressions: [{ expressions: [{
type: expressionTypes.TEXT, type: expressionTypes.TEXT,
childNodeIndex: 0, childNodeIndex: 0,
@ -94,14 +176,14 @@ var school = {
name: 'value', name: 'value',
evaluate: _scope => _scope.school.fields.taux_acces_ens evaluate: _scope => _scope.school.fields.taux_acces_ens
}], }],
redundantAttribute: 'expr62', redundantAttribute: 'expr690',
selector: '[expr62]' selector: '[expr690]'
}]), }]),
redundantAttribute: 'expr57', redundantAttribute: 'expr685',
selector: '[expr57]', selector: '[expr685]',
itemName: 'school', itemName: 'school',
indexName: null, indexName: null,
evaluate: _scope => _scope.props.schoolList evaluate: _scope => _scope.state.filteredSchoolList
}]) }])
}]), }]),
name: 'school' name: 'school'

View File

@ -17,7 +17,9 @@ class PAPI {
} }
static async fetchFiliere(filiere) { static async fetchFiliere(filiere) {
if (localStorage.getItem("fili." + filiere)) return JSON.parse(localStorage.getItem("fili." + 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 url = `${PAPI.searchURL}&rows=0&sort=tri&facet=form_lib_voe_acc&refine.fili=${filiere}`;
url = url.replace("+", "%2B");
let request = await fetch(url);
let result = await request.json(); let result = await request.json();
let response = result["facet_groups"][0]["facets"]; let response = result["facet_groups"][0]["facets"];
localStorage.setItem("fili." + filiere, JSON.stringify(response)); localStorage.setItem("fili." + filiere, JSON.stringify(response));
@ -25,7 +27,9 @@ class PAPI {
} }
static async fetchSpecialites(filiere, specialite) { static async fetchSpecialites(filiere, specialite) {
if (localStorage.getItem(`spe.${filiere}.${specialite}`)) return JSON.parse(localStorage.getItem(`spe.${filiere}.${specialite}`)); if (localStorage.getItem(`spe.${filiere}.${specialite}`)) return JSON.parse(localStorage.getItem(`spe.${filiere}.${specialite}`));
let request = await fetch(`${PAPI.searchURL}&rows=0&sort=tri&facet=fil_lib_voe_acc&refine.form_lib_voe_acc=${specialite}&refine.fili=${filiere}`); let url = `${PAPI.searchURL}&rows=0&sort=tri&facet=fil_lib_voe_acc&refine.form_lib_voe_acc=${specialite}&refine.fili=${filiere}`;
url = url.replace("+", "%2B");
let request = await fetch(url);
let result = await request.json(); let result = await request.json();
let response = result["facet_groups"][0]["facets"]; let response = result["facet_groups"][0]["facets"];
localStorage.setItem(`spe.${filiere}.${specialite}`, JSON.stringify(response)); localStorage.setItem(`spe.${filiere}.${specialite}`, JSON.stringify(response));
@ -33,7 +37,9 @@ class PAPI {
} }
static async fetchEtablissement(filiere, sousfiliere, soussousfiliere) { static async fetchEtablissement(filiere, sousfiliere, soussousfiliere) {
if (localStorage.getItem(`eta.${filiere}.${sousfiliere}.${soussousfiliere}`)) return JSON.parse(localStorage.getItem(`eta.${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}&rows=10000&refine.fil_lib_voe_acc=${soussousfiliere}&refine.form_lib_voe_acc=${sousfiliere}&refine.fili=${filiere}`); let url = `${PAPI.searchURL}&rows=10000&refine.fil_lib_voe_acc=${soussousfiliere}&refine.form_lib_voe_acc=${sousfiliere}&refine.fili=${filiere}`;
url = url.replace("+", "%2B");
let request = await fetch(url);
let result = await request.json(); let result = await request.json();
let response = result["records"]; let response = result["records"];
localStorage.setItem(`eta.${filiere}.${sousfiliere}.${soussousfiliere}`, JSON.stringify(response)); localStorage.setItem(`eta.${filiere}.${sousfiliere}.${soussousfiliere}`, JSON.stringify(response));
@ -144,9 +150,9 @@ var search = {
this.updateList(); this.updateList();
} }
}, },
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div class="box p-1 m-2"><div class="columns m-1"><input expr14="expr14" class="input" type="input"/><button expr15="expr15" class="button ml-1">&lt;</button></div><div id="list-formations"><ul><li expr16="expr16" class="m-1"></li></ul></div></div>', [{ template: (template, expressionTypes, bindingTypes, getComponent) => template('<div class="box p-1 m-2"><div class="columns m-1"><input expr31="expr31" class="input" type="input"/><button expr32="expr32" class="button ml-1">&lt;</button></div><div id="list-formations"><ul><li expr33="expr33" class="m-1"></li></ul></div></div>', [{
redundantAttribute: 'expr14', redundantAttribute: 'expr31',
selector: '[expr14]', selector: '[expr31]',
expressions: [{ expressions: [{
type: expressionTypes.EVENT, type: expressionTypes.EVENT,
name: 'onkeyup', name: 'onkeyup',
@ -157,8 +163,8 @@ var search = {
evaluate: _scope => _scope.state.placeholder evaluate: _scope => _scope.state.placeholder
}] }]
}, { }, {
redundantAttribute: 'expr15', redundantAttribute: 'expr32',
selector: '[expr15]', selector: '[expr32]',
expressions: [{ expressions: [{
type: expressionTypes.ATTRIBUTE, type: expressionTypes.ATTRIBUTE,
name: 'disabled', name: 'disabled',
@ -172,9 +178,9 @@ var search = {
type: bindingTypes.EACH, type: bindingTypes.EACH,
getKey: null, getKey: null,
condition: null, condition: null,
template: template('<button expr17="expr17" class="button is-fullwidth p-2" style="white-space: unset"><div style="display: flex; width: 100%"><span class="mt-auto mb-auto" style="font-size: 0.75em; text-align: left; "><strong expr18="expr18"> </strong></span><div style="margin-left: auto;"></div><span expr19="expr19" class="tag is-primary mt-auto mb-auto"> </span></div></button>', [{ template: template('<button expr34="expr34" class="button is-fullwidth p-2" style="white-space: unset"><div style="display: flex; width: 100%"><span class="mt-auto mb-auto" style="font-size: 0.75em; text-align: left; "><strong expr35="expr35"> </strong></span><div style="margin-left: auto;"></div><span expr36="expr36" class="tag is-primary mt-auto mb-auto"> </span></div></button>', [{
redundantAttribute: 'expr17', redundantAttribute: 'expr34',
selector: '[expr17]', selector: '[expr34]',
expressions: [{ expressions: [{
type: expressionTypes.ATTRIBUTE, type: expressionTypes.ATTRIBUTE,
name: 'disabled', name: 'disabled',
@ -185,24 +191,24 @@ var search = {
evaluate: _scope => () => _scope.cruiseForward(_scope.item.name) evaluate: _scope => () => _scope.cruiseForward(_scope.item.name)
}] }]
}, { }, {
redundantAttribute: 'expr18', redundantAttribute: 'expr35',
selector: '[expr18]', selector: '[expr35]',
expressions: [{ expressions: [{
type: expressionTypes.TEXT, type: expressionTypes.TEXT,
childNodeIndex: 0, childNodeIndex: 0,
evaluate: _scope => _scope.item.name evaluate: _scope => _scope.item.name
}] }]
}, { }, {
redundantAttribute: 'expr19', redundantAttribute: 'expr36',
selector: '[expr19]', selector: '[expr36]',
expressions: [{ expressions: [{
type: expressionTypes.TEXT, type: expressionTypes.TEXT,
childNodeIndex: 0, childNodeIndex: 0,
evaluate: _scope => _scope.item.count evaluate: _scope => _scope.item.count
}] }]
}]), }]),
redundantAttribute: 'expr16', redundantAttribute: 'expr33',
selector: '[expr16]', selector: '[expr33]',
itemName: 'item', itemName: 'item',
indexName: null, indexName: null,
evaluate: _scope => _scope.state.items evaluate: _scope => _scope.state.items

View File

@ -1,5 +1,5 @@
const DEFAULT_CLASSES = "progress is-small m-2 mt-auto mb-auto"; const DEFAULT_CLASSES = "progress is-small m-2 mt-auto mb-auto";
const COLOR_CLASSES = ["is-link", "is-info", "is-success", "is-warning", "is-danger"]; const COLOR_CLASSES = ["is-danger", "is-warning", "is-success", "is-info", "is-link"];
var titleProgress = { var titleProgress = {
css: null, css: null,
exports: { exports: {
@ -25,11 +25,11 @@ var titleProgress = {
state.class = this.computeClasses(); state.class = this.computeClasses();
} }
}, },
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div style="display: flex;"><span expr20="expr20"></span><span expr21="expr21" class="ml-1"> </span><progress expr22="expr22" style="box-shadow: 0 0.5em 1em -0.125em rgb(10 10 10 / 10%), 0 0 0 1px rgb(10 10 10 / 2%);"></progress></div>', [{ template: (template, expressionTypes, bindingTypes, getComponent) => template('<div style="display: flex;"><span expr664="expr664"></span><span expr665="expr665" class="ml-1"> </span><progress expr666="expr666" style="box-shadow: 0 0.5em 1em -0.125em rgb(10 10 10 / 10%), 0 0 0 1px rgb(10 10 10 / 2%);"></progress></div>', [{
type: bindingTypes.IF, type: bindingTypes.IF,
evaluate: _scope => _scope.props.title, evaluate: _scope => _scope.props.title,
redundantAttribute: 'expr20', redundantAttribute: 'expr664',
selector: '[expr20]', selector: '[expr664]',
template: template(' ', [{ template: template(' ', [{
expressions: [{ expressions: [{
type: expressionTypes.TEXT, type: expressionTypes.TEXT,
@ -38,16 +38,16 @@ var titleProgress = {
}] }]
}]) }])
}, { }, {
redundantAttribute: 'expr21', redundantAttribute: 'expr665',
selector: '[expr21]', selector: '[expr665]',
expressions: [{ expressions: [{
type: expressionTypes.TEXT, type: expressionTypes.TEXT,
childNodeIndex: 0, childNodeIndex: 0,
evaluate: _scope => _scope.calcPct() evaluate: _scope => _scope.calcPct()
}] }]
}, { }, {
redundantAttribute: 'expr22', redundantAttribute: 'expr666',
selector: '[expr22]', selector: '[expr666]',
expressions: [{ expressions: [{
type: expressionTypes.ATTRIBUTE, type: expressionTypes.ATTRIBUTE,
name: 'value', name: 'value',