From 9dce55c45f9218d5eaf08d1ab785945803d1c2d2 Mon Sep 17 00:00:00 2001 From: horville Date: Fri, 31 Mar 2023 11:36:19 +0200 Subject: [PATCH 1/2] Fix marge logo --- components/main-controller.riot | 4 ++-- components/title-progress.riot | 8 ++++---- javascript/parcoursup-link.js | 17 +++++++++++++---- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/components/main-controller.riot b/components/main-controller.riot index ee6ad4d..bdfbe49 100644 --- a/components/main-controller.riot +++ b/components/main-controller.riot @@ -1,8 +1,8 @@
-
- +
+
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 @@ diff --git a/components/school.riot b/components/school.riot index 63bee5c..1384ff6 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)}>
{school.fields.g_ea_lib_vx} {school.fields.ville_etab} {school.fields.dep}
+ + \ No newline at end of file diff --git a/javascript/fili-info.js b/javascript/fili-info.js index 9943a22..66b8e64 100644 --- a/javascript/fili-info.js +++ b/javascript/fili-info.js @@ -14,7 +14,6 @@ var filiInfo = { state.capacity = Math.floor(avgCap); 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", short: "H", @@ -76,54 +75,54 @@ var filiInfo = { }]; } }, - template: (template, expressionTypes, bindingTypes, getComponent) => template('
', [{ + template: (template, expressionTypes, bindingTypes, getComponent) => template('
', [{ type: bindingTypes.IF, evaluate: _scope => _scope.props.shouldShowInfos, - redundantAttribute: 'expr26', - selector: '[expr26]', - template: template('

/ \n / \n

Moyenne des admis

Nombre de formations

Capacité

', [{ - redundantAttribute: 'expr27', - selector: '[expr27]', + redundantAttribute: 'expr7', + selector: '[expr7]', + template: template('

/ \r\n / \r\n

Moyenne des admis

Nombre de formations

Capacité

', [{ + redundantAttribute: 'expr8', + selector: '[expr8]', expressions: [{ type: expressionTypes.TEXT, childNodeIndex: 0, evaluate: _scope => _scope.props.course.fili }] }, { - redundantAttribute: 'expr28', - selector: '[expr28]', + redundantAttribute: 'expr9', + selector: '[expr9]', expressions: [{ type: expressionTypes.TEXT, childNodeIndex: 0, evaluate: _scope => _scope.props.course.sousfili }] }, { - redundantAttribute: 'expr29', - selector: '[expr29]', + redundantAttribute: 'expr10', + selector: '[expr10]', expressions: [{ type: expressionTypes.TEXT, childNodeIndex: 0, evaluate: _scope => _scope.props.course.soussousfili }] }, { - redundantAttribute: 'expr30', - selector: '[expr30]', + redundantAttribute: 'expr11', + selector: '[expr11]', expressions: [{ type: expressionTypes.TEXT, childNodeIndex: 0, evaluate: _scope => _scope.state.average }] }, { - redundantAttribute: 'expr31', - selector: '[expr31]', + redundantAttribute: 'expr12', + selector: '[expr12]', expressions: [{ type: expressionTypes.TEXT, childNodeIndex: 0, evaluate: _scope => _scope.state.courseNumber }] }, { - redundantAttribute: 'expr32', - selector: '[expr32]', + redundantAttribute: 'expr13', + selector: '[expr13]', expressions: [{ type: expressionTypes.TEXT, childNodeIndex: 0, @@ -143,8 +142,8 @@ var filiInfo = { name: 'value', evaluate: _scope => _scope.state.selectivity }], - redundantAttribute: 'expr33', - selector: '[expr33]' + redundantAttribute: 'expr14', + selector: '[expr14]' }, { type: bindingTypes.TAG, getComponent: getComponent, @@ -155,8 +154,8 @@ var filiInfo = { name: 'data', evaluate: _scope => _scope.state.genreStats }], - redundantAttribute: 'expr34', - selector: '[expr34]' + redundantAttribute: 'expr15', + selector: '[expr15]' }, { type: bindingTypes.TAG, getComponent: getComponent, @@ -167,8 +166,8 @@ var filiInfo = { name: 'data', evaluate: _scope => _scope.state.bacStats }], - redundantAttribute: 'expr35', - selector: '[expr35]' + redundantAttribute: 'expr16', + selector: '[expr16]' }, { type: bindingTypes.TAG, getComponent: getComponent, @@ -179,8 +178,8 @@ var filiInfo = { name: 'data', evaluate: _scope => _scope.state.mentionStats }], - redundantAttribute: 'expr36', - selector: '[expr36]' + redundantAttribute: 'expr17', + selector: '[expr17]' }]) }]), name: 'fili-info' diff --git a/javascript/main-controller.js b/javascript/main-controller.js index 8fe35c4..e3c20e5 100644 --- a/javascript/main-controller.js +++ b/javascript/main-controller.js @@ -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 = { css: null, exports: { - 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; - 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(); + updateCourse(course) { + this.updateList(course); + this.update({ + course: course, + shouldShowInfos: course != null + }); }, updateList(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; }); this.update({ + schoolListUpdating: true, schoolList: response }); - this.filterSearch(); - }); - }, - updateCourse(course) { - this.updateList(course); - this.update({ - course: course, - sortFields: SORT_TABLE, - shouldShowInfos: course != null + this.update({ + schoolListUpdating: false + }); }); }, onMounted(props, state) { this.update({ course: null, - sortBy: null, - schoolList: null, - sortFields: SORT_TABLE, - filteredSchoolList: null, + schoolList: [], 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('
', [{ + template: (template, expressionTypes, bindingTypes, getComponent) => template('
', [{ type: bindingTypes.TAG, getComponent: getComponent, evaluate: _scope => 'search', @@ -161,8 +99,8 @@ var mainController = { name: 'updateCourse', evaluate: _scope => _scope.updateCourse }], - redundantAttribute: 'expr59', - selector: '[expr59]' + redundantAttribute: 'expr643', + selector: '[expr643]' }, { type: bindingTypes.TAG, getComponent: getComponent, @@ -181,25 +119,21 @@ var mainController = { name: 'shouldShowInfos', evaluate: _scope => _scope.state.shouldShowInfos }], - redundantAttribute: 'expr60', - selector: '[expr60]' + redundantAttribute: 'expr644', + selector: '[expr644]' }, { type: bindingTypes.TAG, getComponent: getComponent, evaluate: _scope => 'school', slots: [], attributes: [{ - type: expressionTypes.ATTRIBUTE, - name: 'sortList', - evaluate: _scope => _scope.sortList - }, { type: expressionTypes.ATTRIBUTE, name: 'schoolList', - evaluate: _scope => _scope.state.filteredSchoolList + evaluate: _scope => _scope.state.schoolList }, { type: expressionTypes.ATTRIBUTE, - name: 'sortFields', - evaluate: _scope => _scope.state.sortFields + name: 'schoolListUpdating', + evaluate: _scope => _scope.state.schoolListUpdating }, { type: expressionTypes.ATTRIBUTE, name: 'course', @@ -209,16 +143,16 @@ var mainController = { name: 'shouldShowInfos', evaluate: _scope => _scope.state.shouldShowInfos }], - redundantAttribute: 'expr61', - selector: '[expr61]' + redundantAttribute: 'expr645', + selector: '[expr645]' }, { type: bindingTypes.TAG, getComponent: getComponent, evaluate: _scope => 'school-info', slots: [], attributes: [], - redundantAttribute: 'expr62', - selector: '[expr62]' + redundantAttribute: 'expr646', + selector: '[expr646]' }]), name: 'main-controller' }; diff --git a/javascript/school-info.js b/javascript/school-info.js index a0428be..cebda7f 100644 --- a/javascript/school-info.js +++ b/javascript/school-info.js @@ -10,14 +10,14 @@ var schoolInfo = { this.update(); } }, - template: (template, expressionTypes, bindingTypes, getComponent) => template('
', [{ + template: (template, expressionTypes, bindingTypes, getComponent) => template('
', [{ type: bindingTypes.IF, evaluate: _scope => _scope.state.enabled, - redundantAttribute: 'expr23', - selector: '[expr23]', - template: template('

', [{ - redundantAttribute: 'expr24', - selector: '[expr24]', + redundantAttribute: 'expr29', + selector: '[expr29]', + template: template('

', [{ + redundantAttribute: 'expr30', + selector: '[expr30]', expressions: [{ type: expressionTypes.EVENT, name: 'onclick', @@ -29,8 +29,8 @@ var schoolInfo = { evaluate: _scope => 'line-graph', slots: [], attributes: [], - redundantAttribute: 'expr25', - selector: '[expr25]' + redundantAttribute: 'expr31', + selector: '[expr31]' }]) }]), name: 'school-info' diff --git a/javascript/school.js b/javascript/school.js index cc77ec9..f5f3a6f 100644 --- a/javascript/school.js +++ b/javascript/school.js @@ -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 = { css: null, - exports: null, - template: (template, expressionTypes, bindingTypes, getComponent) => template('
', [{ + exports: { + 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('
', [{ type: bindingTypes.IF, evaluate: _scope => _scope.props.shouldShowInfos, - redundantAttribute: 'expr44', - selector: '[expr44]', - template: template('
', [{ + redundantAttribute: 'expr680', + selector: '[expr680]', + template: template('
', [{ type: bindingTypes.IF, evaluate: _scope => false, - redundantAttribute: 'expr45', - selector: '[expr45]', + redundantAttribute: 'expr681', + selector: '[expr681]', template: template(null, []) }, { - redundantAttribute: 'expr46', - selector: '[expr46]', + redundantAttribute: 'expr682', + selector: '[expr682]', expressions: [{ type: expressionTypes.EVENT, name: 'onkeyup', - evaluate: _scope => _scope.props.filterSearch + evaluate: _scope => _scope.filterSearch }] }, { type: bindingTypes.EACH, getKey: null, condition: null, - template: template(' ', [{ + template: template(' ', [{ expressions: [{ type: expressionTypes.TEXT, childNodeIndex: 0, evaluate: _scope => [_scope.sortField.name].join('') }] }, { - redundantAttribute: 'expr48', - selector: '[expr48]', + redundantAttribute: 'expr684', + selector: '[expr684]', expressions: [{ type: expressionTypes.ATTRIBUTE, name: 'id', @@ -40,45 +118,45 @@ var school = { }, { type: expressionTypes.EVENT, name: 'onclick', - evaluate: _scope => () => _scope.props.sortList(_scope.sortField.id) + evaluate: _scope => () => _scope.sortList(_scope.sortField.id, true) }] }]), - redundantAttribute: 'expr47', - selector: '[expr47]', + redundantAttribute: 'expr683', + selector: '[expr683]', itemName: 'sortField', indexName: null, - evaluate: _scope => _scope.props.sortFields + evaluate: _scope => _scope.sortFields }, { type: bindingTypes.EACH, getKey: null, condition: null, - template: template(' ', [{ - redundantAttribute: 'expr50', - selector: '[expr50]', + template: template(' ', [{ + redundantAttribute: 'expr686', + selector: '[expr686]', expressions: [{ type: expressionTypes.TEXT, childNodeIndex: 0, evaluate: _scope => _scope.school.fields.g_ea_lib_vx }] }, { - redundantAttribute: 'expr51', - selector: '[expr51]', + redundantAttribute: 'expr687', + selector: '[expr687]', expressions: [{ type: expressionTypes.TEXT, childNodeIndex: 0, evaluate: _scope => _scope.school.fields.ville_etab }] }, { - redundantAttribute: 'expr52', - selector: '[expr52]', + redundantAttribute: 'expr688', + selector: '[expr688]', expressions: [{ type: expressionTypes.TEXT, childNodeIndex: 0, evaluate: _scope => _scope.school.fields.dep }] }, { - redundantAttribute: 'expr53', - selector: '[expr53]', + redundantAttribute: 'expr689', + selector: '[expr689]', expressions: [{ type: expressionTypes.TEXT, childNodeIndex: 0, @@ -94,14 +172,14 @@ var school = { name: 'value', evaluate: _scope => _scope.school.fields.taux_acces_ens }], - redundantAttribute: 'expr54', - selector: '[expr54]' + redundantAttribute: 'expr690', + selector: '[expr690]' }]), - redundantAttribute: 'expr49', - selector: '[expr49]', + redundantAttribute: 'expr685', + selector: '[expr685]', itemName: 'school', indexName: null, - evaluate: _scope => _scope.props.schoolList + evaluate: _scope => _scope.state.filteredSchoolList }]) }]), name: 'school' diff --git a/javascript/search.js b/javascript/search.js index dac6114..6dda895 100644 --- a/javascript/search.js +++ b/javascript/search.js @@ -17,7 +17,9 @@ class PAPI { } 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 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 response = result["facet_groups"][0]["facets"]; localStorage.setItem("fili." + filiere, JSON.stringify(response)); @@ -25,7 +27,9 @@ class PAPI { } static async fetchSpecialites(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 response = result["facet_groups"][0]["facets"]; localStorage.setItem(`spe.${filiere}.${specialite}`, JSON.stringify(response)); @@ -33,7 +37,9 @@ class PAPI { } 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}&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 response = result["records"]; localStorage.setItem(`eta.${filiere}.${sousfiliere}.${soussousfiliere}`, JSON.stringify(response)); @@ -144,9 +150,9 @@ var search = { this.updateList(); } }, - template: (template, expressionTypes, bindingTypes, getComponent) => template('
', [{ - redundantAttribute: 'expr14', - selector: '[expr14]', + template: (template, expressionTypes, bindingTypes, getComponent) => template('
', [{ + redundantAttribute: 'expr32', + selector: '[expr32]', expressions: [{ type: expressionTypes.EVENT, name: 'onkeyup', @@ -157,8 +163,8 @@ var search = { evaluate: _scope => _scope.state.placeholder }] }, { - redundantAttribute: 'expr15', - selector: '[expr15]', + redundantAttribute: 'expr33', + selector: '[expr33]', expressions: [{ type: expressionTypes.ATTRIBUTE, name: 'disabled', @@ -172,9 +178,9 @@ var search = { type: bindingTypes.EACH, getKey: null, condition: null, - template: template('', [{ - redundantAttribute: 'expr17', - selector: '[expr17]', + template: template('', [{ + redundantAttribute: 'expr35', + selector: '[expr35]', expressions: [{ type: expressionTypes.ATTRIBUTE, name: 'disabled', @@ -185,24 +191,24 @@ var search = { evaluate: _scope => () => _scope.cruiseForward(_scope.item.name) }] }, { - redundantAttribute: 'expr18', - selector: '[expr18]', + redundantAttribute: 'expr36', + selector: '[expr36]', expressions: [{ type: expressionTypes.TEXT, childNodeIndex: 0, evaluate: _scope => _scope.item.name }] }, { - redundantAttribute: 'expr19', - selector: '[expr19]', + redundantAttribute: 'expr37', + selector: '[expr37]', expressions: [{ type: expressionTypes.TEXT, childNodeIndex: 0, evaluate: _scope => _scope.item.count }] }]), - redundantAttribute: 'expr16', - selector: '[expr16]', + redundantAttribute: 'expr34', + selector: '[expr34]', itemName: 'item', indexName: null, evaluate: _scope => _scope.state.items diff --git a/javascript/title-progress.js b/javascript/title-progress.js index 2820b5f..6cea26b 100644 --- a/javascript/title-progress.js +++ b/javascript/title-progress.js @@ -1,5 +1,5 @@ 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 = { css: null, exports: { @@ -25,11 +25,11 @@ var titleProgress = { state.class = this.computeClasses(); } }, - template: (template, expressionTypes, bindingTypes, getComponent) => template('
', [{ + template: (template, expressionTypes, bindingTypes, getComponent) => template('
', [{ type: bindingTypes.IF, evaluate: _scope => _scope.props.title, - redundantAttribute: 'expr20', - selector: '[expr20]', + redundantAttribute: 'expr4', + selector: '[expr4]', template: template(' ', [{ expressions: [{ type: expressionTypes.TEXT, @@ -38,16 +38,16 @@ var titleProgress = { }] }]) }, { - redundantAttribute: 'expr21', - selector: '[expr21]', + redundantAttribute: 'expr5', + selector: '[expr5]', expressions: [{ type: expressionTypes.TEXT, childNodeIndex: 0, evaluate: _scope => _scope.calcPct() }] }, { - redundantAttribute: 'expr22', - selector: '[expr22]', + redundantAttribute: 'expr6', + selector: '[expr6]', expressions: [{ type: expressionTypes.ATTRIBUTE, name: 'value',