Shift parent -> enfant

This commit is contained in:
HORVILLE 2023-03-31 14:22:25 +02:00
parent ac30b03c51
commit 6ed2258617
9 changed files with 299 additions and 257 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

@ -9,7 +9,7 @@
<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 sortList={sortList} schoolList={state.filteredSchoolList} sortFields={state.sortFields} course={state.course} shouldShowInfos={state.shouldShowInfos}></school> <school 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,49 +46,22 @@
}) })
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
})
} }
} }
</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>{school.fields.g_ea_lib_vx}</td> <td>{school.fields.g_ea_lib_vx}</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

@ -14,7 +14,6 @@ var filiInfo = {
state.capacity = Math.floor(avgCap); state.capacity = Math.floor(avgCap);
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",
short: "H", short: "H",
@ -76,54 +75,54 @@ var filiInfo = {
}]; }];
} }
}, },
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div expr26="expr26" class="box p-1 m-2"></div>', [{ template: (template, expressionTypes, bindingTypes, getComponent) => template('<div expr7="expr7" class="box p-1 m-2"></div>', [{
type: bindingTypes.IF, type: bindingTypes.IF,
evaluate: _scope => _scope.props.shouldShowInfos, evaluate: _scope => _scope.props.shouldShowInfos,
redundantAttribute: 'expr26', redundantAttribute: 'expr7',
selector: '[expr26]', selector: '[expr7]',
template: template('<h1 class="title is-4 m-2"><span expr27="expr27" style="color: #485FC7;"> </span> / \n <span expr28="expr28" style="color: #485FC7;"> </span> / \n <span expr29="expr29" style="color: #485FC7;"> </span></h1><div class="box mt-2" style="background-color: #EAEAEA; margin: auto; width: 60%;"><p>Moyenne des admis<span expr30="expr30" class="is-pulled-right"> </span></p><p>Nombre de formations<span expr31="expr31" class="is-pulled-right"> </span></p><p>Capacité<span expr32="expr32" class="is-pulled-right"> </span></p><title-progress expr33="expr33" max="100"></title-progress></div><div class="m-4"><line-graph expr34="expr34" title="Répartition par genre" style="height: 6rem;"></line-graph></div><div class="m-4"><line-graph expr35="expr35" title="Répartition par bac" style="height: 6rem;"></line-graph></div><div class="m-4"><line-graph expr36="expr36" title="Répartition par mention au bac" style="height: 6rem;"></line-graph></div>', [{ template: template('<h1 class="title is-4 m-2"><span expr8="expr8" style="color: #485FC7;"> </span> / \r\n <span expr9="expr9" style="color: #485FC7;"> </span> / \r\n <span expr10="expr10" style="color: #485FC7;"> </span></h1><div class="box mt-2" style="background-color: #EAEAEA; margin: auto; width: 60%;"><p>Moyenne des admis<span expr11="expr11" class="is-pulled-right"> </span></p><p>Nombre de formations<span expr12="expr12" class="is-pulled-right"> </span></p><p>Capacité<span expr13="expr13" class="is-pulled-right"> </span></p><title-progress expr14="expr14" max="100"></title-progress></div><div class="m-4"><line-graph expr15="expr15" title="Répartition par genre" style="height: 6rem;"></line-graph></div><div class="m-4"><line-graph expr16="expr16" title="Répartition par bac" style="height: 6rem;"></line-graph></div><div class="m-4"><line-graph expr17="expr17" title="Répartition par mention au bac" style="height: 6rem;"></line-graph></div>', [{
redundantAttribute: 'expr27', redundantAttribute: 'expr8',
selector: '[expr27]', selector: '[expr8]',
expressions: [{ expressions: [{
type: expressionTypes.TEXT, type: expressionTypes.TEXT,
childNodeIndex: 0, childNodeIndex: 0,
evaluate: _scope => _scope.props.course.fili evaluate: _scope => _scope.props.course.fili
}] }]
}, { }, {
redundantAttribute: 'expr28', redundantAttribute: 'expr9',
selector: '[expr28]', selector: '[expr9]',
expressions: [{ expressions: [{
type: expressionTypes.TEXT, type: expressionTypes.TEXT,
childNodeIndex: 0, childNodeIndex: 0,
evaluate: _scope => _scope.props.course.sousfili evaluate: _scope => _scope.props.course.sousfili
}] }]
}, { }, {
redundantAttribute: 'expr29', redundantAttribute: 'expr10',
selector: '[expr29]', selector: '[expr10]',
expressions: [{ expressions: [{
type: expressionTypes.TEXT, type: expressionTypes.TEXT,
childNodeIndex: 0, childNodeIndex: 0,
evaluate: _scope => _scope.props.course.soussousfili evaluate: _scope => _scope.props.course.soussousfili
}] }]
}, { }, {
redundantAttribute: 'expr30', redundantAttribute: 'expr11',
selector: '[expr30]', selector: '[expr11]',
expressions: [{ expressions: [{
type: expressionTypes.TEXT, type: expressionTypes.TEXT,
childNodeIndex: 0, childNodeIndex: 0,
evaluate: _scope => _scope.state.average evaluate: _scope => _scope.state.average
}] }]
}, { }, {
redundantAttribute: 'expr31', redundantAttribute: 'expr12',
selector: '[expr31]', selector: '[expr12]',
expressions: [{ expressions: [{
type: expressionTypes.TEXT, type: expressionTypes.TEXT,
childNodeIndex: 0, childNodeIndex: 0,
evaluate: _scope => _scope.state.courseNumber evaluate: _scope => _scope.state.courseNumber
}] }]
}, { }, {
redundantAttribute: 'expr32', redundantAttribute: 'expr13',
selector: '[expr32]', selector: '[expr13]',
expressions: [{ expressions: [{
type: expressionTypes.TEXT, type: expressionTypes.TEXT,
childNodeIndex: 0, childNodeIndex: 0,
@ -143,8 +142,8 @@ var filiInfo = {
name: 'value', name: 'value',
evaluate: _scope => _scope.state.selectivity evaluate: _scope => _scope.state.selectivity
}], }],
redundantAttribute: 'expr33', redundantAttribute: 'expr14',
selector: '[expr33]' selector: '[expr14]'
}, { }, {
type: bindingTypes.TAG, type: bindingTypes.TAG,
getComponent: getComponent, getComponent: getComponent,
@ -155,8 +154,8 @@ var filiInfo = {
name: 'data', name: 'data',
evaluate: _scope => _scope.state.genreStats evaluate: _scope => _scope.state.genreStats
}], }],
redundantAttribute: 'expr34', redundantAttribute: 'expr15',
selector: '[expr34]' selector: '[expr15]'
}, { }, {
type: bindingTypes.TAG, type: bindingTypes.TAG,
getComponent: getComponent, getComponent: getComponent,
@ -167,8 +166,8 @@ var filiInfo = {
name: 'data', name: 'data',
evaluate: _scope => _scope.state.bacStats evaluate: _scope => _scope.state.bacStats
}], }],
redundantAttribute: 'expr35', redundantAttribute: 'expr16',
selector: '[expr35]' selector: '[expr16]'
}, { }, {
type: bindingTypes.TAG, type: bindingTypes.TAG,
getComponent: getComponent, getComponent: getComponent,
@ -179,8 +178,8 @@ var filiInfo = {
name: 'data', name: 'data',
evaluate: _scope => _scope.state.mentionStats evaluate: _scope => _scope.state.mentionStats
}], }],
redundantAttribute: 'expr36', redundantAttribute: 'expr17',
selector: '[expr36]' selector: '[expr17]'
}]) }])
}]), }]),
name: 'fili-info' name: 'fili-info'

View File

@ -47,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;
@ -110,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(); this.update({
}); schoolListUpdating: false
}, });
updateCourse(course) {
this.updateList(course);
this.update({
course: course,
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" style="display: flex"><img class="m-auto" src="./resources/logo-parcoursup.svg"/></div><search expr59="expr59"></search></div><div class="column"><fili-info expr60="expr60"></fili-info><school expr61="expr61"></school></div></div><school-info expr62="expr62"></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',
@ -161,8 +99,8 @@ var mainController = {
name: 'updateCourse', name: 'updateCourse',
evaluate: _scope => _scope.updateCourse evaluate: _scope => _scope.updateCourse
}], }],
redundantAttribute: 'expr59', redundantAttribute: 'expr643',
selector: '[expr59]' selector: '[expr643]'
}, { }, {
type: bindingTypes.TAG, type: bindingTypes.TAG,
getComponent: getComponent, getComponent: getComponent,
@ -181,25 +119,21 @@ var mainController = {
name: 'shouldShowInfos', name: 'shouldShowInfos',
evaluate: _scope => _scope.state.shouldShowInfos evaluate: _scope => _scope.state.shouldShowInfos
}], }],
redundantAttribute: 'expr60', redundantAttribute: 'expr644',
selector: '[expr60]' 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',
@ -209,16 +143,16 @@ var mainController = {
name: 'shouldShowInfos', name: 'shouldShowInfos',
evaluate: _scope => _scope.state.shouldShowInfos evaluate: _scope => _scope.state.shouldShowInfos
}], }],
redundantAttribute: 'expr61', redundantAttribute: 'expr645',
selector: '[expr61]' 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: 'expr62', redundantAttribute: 'expr646',
selector: '[expr62]' selector: '[expr646]'
}]), }]),
name: 'main-controller' name: 'main-controller'
}; };

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 expr44="expr44" 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: 'expr44', redundantAttribute: 'expr680',
selector: '[expr44]', selector: '[expr680]',
template: template('<iframe expr45="expr45" 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 expr46="expr46" 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 expr47="expr47"></th></tr></thead><tbody><tr expr49="expr49"></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: 'expr45', redundantAttribute: 'expr681',
selector: '[expr45]', selector: '[expr681]',
template: template(null, []) template: template(null, [])
}, { }, {
redundantAttribute: 'expr46', redundantAttribute: 'expr682',
selector: '[expr46]', 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 expr48="expr48"><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: 'expr48', redundantAttribute: 'expr684',
selector: '[expr48]', selector: '[expr684]',
expressions: [{ expressions: [{
type: expressionTypes.ATTRIBUTE, type: expressionTypes.ATTRIBUTE,
name: 'id', name: 'id',
@ -40,45 +118,45 @@ 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: 'expr47', redundantAttribute: 'expr683',
selector: '[expr47]', 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 expr50="expr50"> </td><td expr51="expr51"> </td><td expr52="expr52"> </td><td expr53="expr53"> </td><td><title-progress expr54="expr54" max="100" style="margin: auto"></title-progress></td>', [{ template: template('<td expr686="expr686"> </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: 'expr50', redundantAttribute: 'expr686',
selector: '[expr50]', 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
}] }]
}, { }, {
redundantAttribute: 'expr51', redundantAttribute: 'expr687',
selector: '[expr51]', 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: 'expr52', redundantAttribute: 'expr688',
selector: '[expr52]', 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: 'expr53', redundantAttribute: 'expr689',
selector: '[expr53]', selector: '[expr689]',
expressions: [{ expressions: [{
type: expressionTypes.TEXT, type: expressionTypes.TEXT,
childNodeIndex: 0, childNodeIndex: 0,
@ -94,14 +172,14 @@ var school = {
name: 'value', name: 'value',
evaluate: _scope => _scope.school.fields.taux_acces_ens evaluate: _scope => _scope.school.fields.taux_acces_ens
}], }],
redundantAttribute: 'expr54', redundantAttribute: 'expr690',
selector: '[expr54]' selector: '[expr690]'
}]), }]),
redundantAttribute: 'expr49', redundantAttribute: 'expr685',
selector: '[expr49]', 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 expr32="expr32" class="input" type="input"/><button expr33="expr33" class="button ml-1">&lt;</button></div><div id="list-formations"><ul><li expr34="expr34" class="m-1"></li></ul></div></div>', [{
redundantAttribute: 'expr14', redundantAttribute: 'expr32',
selector: '[expr14]', selector: '[expr32]',
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: 'expr33',
selector: '[expr15]', selector: '[expr33]',
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 expr35="expr35" 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 expr36="expr36"> </strong></span><div style="margin-left: auto;"></div><span expr37="expr37" class="tag is-primary mt-auto mb-auto"> </span></div></button>', [{
redundantAttribute: 'expr17', redundantAttribute: 'expr35',
selector: '[expr17]', selector: '[expr35]',
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: 'expr36',
selector: '[expr18]', selector: '[expr36]',
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: 'expr37',
selector: '[expr19]', selector: '[expr37]',
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: 'expr34',
selector: '[expr16]', selector: '[expr34]',
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 expr4="expr4"></span><span expr5="expr5" class="ml-1"> </span><progress expr6="expr6" 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: 'expr4',
selector: '[expr20]', selector: '[expr4]',
template: template(' ', [{ template: template(' ', [{
expressions: [{ expressions: [{
type: expressionTypes.TEXT, type: expressionTypes.TEXT,
@ -38,16 +38,16 @@ var titleProgress = {
}] }]
}]) }])
}, { }, {
redundantAttribute: 'expr21', redundantAttribute: 'expr5',
selector: '[expr21]', selector: '[expr5]',
expressions: [{ expressions: [{
type: expressionTypes.TEXT, type: expressionTypes.TEXT,
childNodeIndex: 0, childNodeIndex: 0,
evaluate: _scope => _scope.calcPct() evaluate: _scope => _scope.calcPct()
}] }]
}, { }, {
redundantAttribute: 'expr22', redundantAttribute: 'expr6',
selector: '[expr22]', selector: '[expr6]',
expressions: [{ expressions: [{
type: expressionTypes.ATTRIBUTE, type: expressionTypes.ATTRIBUTE,
name: 'value', name: 'value',