Simplify school types and persist selected schools
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:
Tudor
2026-01-12 15:55:23 +00:00
parent 708fbe83a0
commit 1a9341eaf4
5 changed files with 106 additions and 32 deletions

View File

@@ -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">