Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions src/assets/js/alter_dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,16 @@ function initGeographyTypingAnimation() {

// Check if geography is selected and update visibility
function checkSelection() {
// Don't show animation if select is disabled (no pathogen selected)
if (selectElement.disabled) {
typingElement.style.display = 'none';
if (timeoutId) {
clearTimeout(timeoutId);
timeoutId = null;
}
return;
}

if (selectElement.value && selectElement.value !== '') {
typingElement.style.display = 'none';
if (timeoutId) {
Expand Down Expand Up @@ -842,12 +852,34 @@ function initGeographyTypingAnimation() {
}, 500);
}

// Update geography select enabled/disabled state based on pathogen selection
function updateGeographySelectState() {
const pathogenSelect = document.getElementById('pathogenSelect');
const geographySelect = document.getElementById('geographySelect');

if (!pathogenSelect || !geographySelect) {
return;
}

const hasPathogen = pathogenSelect.value && pathogenSelect.value !== '';

// Enable or disable geography select based on pathogen selection
geographySelect.disabled = !hasPathogen;

// If pathogen is cleared, also clear geography selection
if (!hasPathogen && geographySelect.value) {
geographySelect.value = '';
}
}

// Initialize dashboard when DOM is loaded
let dashboard;
document.addEventListener('DOMContentLoaded', function() {
dashboard = new AlterDashboard();
initPathogenTypingAnimation();
initGeographyTypingAnimation();
// Initialize geography select state based on pathogen selection
updateGeographySelectState();
});

// Handle pathogen change - reset geography select and submit form
Expand All @@ -862,6 +894,10 @@ function handlePathogenChange() {
if (geographySelect) {
geographySelect.value = '';
}

// Update geography select state before submitting
updateGeographySelectState();

// Show loader before submitting form
const loader = document.getElementById('pageLoader');
if (loader) {
Expand Down
2 changes: 1 addition & 1 deletion src/templates/alternative_interface/alter_dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ <h1 class="hero-title">Respiratory Diseases Dashboard</h1>
</div>
<span class="filter-label">in</span>
<div style="position: relative; display: inline-block; width: 100%;">
<select class="form-select filter-select" id="geographySelect" name="geography" onchange="handleGeographyChange()" style="position: relative;">
<select class="form-select filter-select" id="geographySelect" name="geography" onchange="handleGeographyChange()" style="position: relative;" {% if not selected_pathogen %}disabled{% endif %}>
<option value=""></option>
{% for geography in available_geos %}
<optgroup label="{{ geography.text }}">
Expand Down
Loading