diff --git a/parcoursup/app.riot b/parcoursup/app.riot index 0760a8a..53c72c6 100644 --- a/parcoursup/app.riot +++ b/parcoursup/app.riot @@ -27,9 +27,8 @@
-
+
-
-
+ +
+
+ +

Formations sélectionnées

-
+

{ f.nom }

+

Ville : { f.ville }

Filière : { f.filiere }

Taux d'accès : { f.tauxAcces }%

+

Profil admis : - Général { f.pctGeneral }% / Techno { f.pctTechno }% / Pro { f.pctPro }% + Général { f.pctGeneral }% / + Techno { f.pctTechno }% / + Pro { f.pctPro }%

+

Estimation : { estimateFormation(f) }

+ +
@@ -84,7 +101,22 @@ selected: null, selectedFormations: [], note: 12, - serie: 'general' + serie: 'general', + sortBy: 'nom' + }, + + onMounted() { + const saved = localStorage.getItem('selectionFormations') + + if (saved) { + try { + this.update({ + selectedFormations: JSON.parse(saved) + }) + } catch (e) { + console.error(e) + } + } }, async launchSearch(query) { @@ -101,8 +133,7 @@ if (data.results) { for (let i = 0; i < data.results.length; i++) { const raw = data.results[i] - const formation = window.createFormation(raw) - formations.push(formation) + formations.push(window.createFormation(raw)) } } @@ -125,6 +156,12 @@ }) }, + backToList() { + this.update({ + selected: null + }) + }, + addToSelection(index) { const formation = this.state.results[index] const selection = [...this.state.selectedFormations] @@ -140,62 +177,69 @@ if (!exists) { selection.push(formation) this.update({ selectedFormations: selection }) + localStorage.setItem('selectionFormations', JSON.stringify(selection)) } }, - backToList() { + removeFromSelection(id) { + const newSelection = [] + + for (let i = 0; i < this.state.selectedFormations.length; i++) { + const f = this.state.selectedFormations[i] + + if (f.id !== id) { + newSelection.push(f) + } + } + this.update({ - selected: null + selectedFormations: newSelection }) + + localStorage.setItem('selectionFormations', JSON.stringify(newSelection)) }, - updateNote(event) { - this.update({ - note: Number(event.target.value) - }) + updateNote(e) { + this.update({ note: Number(e.target.value) }) }, - updateSerie(event) { - this.update({ - serie: event.target.value - }) + updateSerie(e) { + this.update({ serie: e.target.value }) }, - estimateFormation(formation) { + updateSort(e) { + this.update({ sortBy: e.target.value }) + }, + + getSortedSelection() { + const selection = [...this.state.selectedFormations] + + if (this.state.sortBy === 'taux') { + selection.sort((a, b) => b.tauxAcces - a.tauxAcces) + } else if (this.state.sortBy === 'ville') { + selection.sort((a, b) => a.ville.localeCompare(b.ville)) + } else { + selection.sort((a, b) => a.nom.localeCompare(b.nom)) + } + + return selection + }, + + estimateFormation(f) { let score = 0 - if (formation.tauxAcces >= 50) { - score += 2 - } else if (formation.tauxAcces >= 20) { - score += 1 - } + if (f.tauxAcces >= 50) score += 2 + else if (f.tauxAcces >= 20) score += 1 - if (this.state.note >= 15) { - score += 2 - } else if (this.state.note >= 12) { - score += 1 - } + if (this.state.note >= 15) score += 2 + else if (this.state.note >= 12) score += 1 - if (this.state.serie === 'general' && formation.pctGeneral >= 50) { - score += 2 - } - - if (this.state.serie === 'techno' && formation.pctTechno >= 20) { - score += 2 - } - - if (this.state.serie === 'pro' && formation.pctPro >= 15) { - score += 2 - } - - if (score >= 5) { - return 'Favorable' - } - - if (score >= 3) { - return 'Possible' - } + if (this.state.serie === 'general' && f.pctGeneral >= 50) score += 2 + if (this.state.serie === 'techno' && f.pctTechno >= 20) score += 2 + if (this.state.serie === 'pro' && f.pctPro >= 15) score += 2 + if (score >= 5) return 'Favorable' + if (score >= 3) return 'Possible' return 'Difficile' } } diff --git a/parcoursup/style.css b/parcoursup/style.css index 296703f..9ee9dc6 100644 --- a/parcoursup/style.css +++ b/parcoursup/style.css @@ -74,6 +74,20 @@ body { border: none; border-top: 1px solid #ddd; } + + .compare-controls { + display: flex; + gap: 20px; + flex-wrap: wrap; + margin-bottom: 15px; + } + + .compare-controls input, + .compare-controls select { + padding: 8px; + font-size: 14px; + min-width: 140px; + } .detail-card h2, .detail-card h3 { @@ -83,7 +97,7 @@ body { .detail-card p { margin: 8px 0; } - + .map-box { overflow: hidden; } @@ -94,6 +108,20 @@ body { border-radius: 6px; } + .compare-controls { + display: flex; + gap: 20px; + flex-wrap: wrap; + margin-bottom: 15px; + } + + .compare-controls input, + .compare-controls select { + padding: 8px; + font-size: 14px; + min-width: 140px; + } + .message { padding: 12px; background: white;