Simplify school types and persist selected schools
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m1s
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m1s
- Add runtime normalization of cryptic school type codes to user-friendly names (e.g., AC/ACC/ACCS -> "Academy", CY/CYS -> "Community") - Update SCHOOL_TYPE_MAP in schemas.py with consolidated mappings - Add normalize_school_type() and get_school_type_codes_for_filter() helpers - Persist selected schools in localStorage across page refreshes - Move "Add to Compare" button from modal footer to header Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -345,6 +345,9 @@ function handleRoute() {
|
||||
document.addEventListener("DOMContentLoaded", init);
|
||||
|
||||
async function init() {
|
||||
// Load selected schools from localStorage first
|
||||
loadSelectedSchoolsFromStorage();
|
||||
|
||||
try {
|
||||
// Load filters and metrics in parallel (single request for filters)
|
||||
const [filtersData, metricsData] = await Promise.all([
|
||||
@@ -376,6 +379,9 @@ async function init() {
|
||||
// Initialize tooltip manager
|
||||
tooltipManager = new TooltipManager();
|
||||
|
||||
// Render any previously selected schools
|
||||
renderSelectedSchools();
|
||||
|
||||
// Handle initial route
|
||||
handleRoute();
|
||||
|
||||
@@ -1544,14 +1550,38 @@ function addToComparison(school) {
|
||||
}
|
||||
|
||||
state.selectedSchools.push(school);
|
||||
saveSelectedSchoolsToStorage();
|
||||
renderSelectedSchools();
|
||||
}
|
||||
|
||||
function removeFromComparison(urn) {
|
||||
state.selectedSchools = state.selectedSchools.filter((s) => s.urn !== urn);
|
||||
saveSelectedSchoolsToStorage();
|
||||
renderSelectedSchools();
|
||||
}
|
||||
|
||||
function saveSelectedSchoolsToStorage() {
|
||||
try {
|
||||
localStorage.setItem("selectedSchools", JSON.stringify(state.selectedSchools));
|
||||
} catch (e) {
|
||||
console.warn("Failed to save to localStorage:", e);
|
||||
}
|
||||
}
|
||||
|
||||
function loadSelectedSchoolsFromStorage() {
|
||||
try {
|
||||
const stored = localStorage.getItem("selectedSchools");
|
||||
if (stored) {
|
||||
const schools = JSON.parse(stored);
|
||||
if (Array.isArray(schools)) {
|
||||
state.selectedSchools = schools;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn("Failed to load from localStorage:", e);
|
||||
}
|
||||
}
|
||||
|
||||
function showEmptyState(container, message) {
|
||||
container.innerHTML = `
|
||||
<div class="empty-state">
|
||||
|
||||
@@ -330,6 +330,7 @@
|
||||
<h2 id="modal-school-name"></h2>
|
||||
<div class="modal-meta" id="modal-meta"></div>
|
||||
<div class="modal-details" id="modal-details"></div>
|
||||
<button class="btn btn-primary" id="add-to-compare">Add to Compare</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="modal-chart-container">
|
||||
@@ -341,9 +342,6 @@
|
||||
<div class="modal-map" id="modal-map"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-primary" id="add-to-compare">Add to Compare</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1088,6 +1088,10 @@ body {
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
.modal-header .btn {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.modal-details .modal-age-range {
|
||||
color: var(--text-muted);
|
||||
}
|
||||
@@ -1165,12 +1169,6 @@ body {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.modal-footer {
|
||||
padding: 1.5rem 2rem;
|
||||
border-top: 1px solid var(--border-color);
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
/* Buttons */
|
||||
.btn {
|
||||
|
||||
Reference in New Issue
Block a user