Skip to content

Commit ab587b2

Browse files
authored
Merge pull request #225 from cmu-delphi/staging
Staging
2 parents b39d5d7 + 75b4c28 commit ab587b2

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

src/assets/js/alter_dashboard.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,16 @@ function initGeographyTypingAnimation() {
789789

790790
// Check if geography is selected and update visibility
791791
function checkSelection() {
792+
// Don't show animation if select is disabled (no pathogen selected)
793+
if (selectElement.disabled) {
794+
typingElement.style.display = 'none';
795+
if (timeoutId) {
796+
clearTimeout(timeoutId);
797+
timeoutId = null;
798+
}
799+
return;
800+
}
801+
792802
if (selectElement.value && selectElement.value !== '') {
793803
typingElement.style.display = 'none';
794804
if (timeoutId) {
@@ -842,12 +852,34 @@ function initGeographyTypingAnimation() {
842852
}, 500);
843853
}
844854

855+
// Update geography select enabled/disabled state based on pathogen selection
856+
function updateGeographySelectState() {
857+
const pathogenSelect = document.getElementById('pathogenSelect');
858+
const geographySelect = document.getElementById('geographySelect');
859+
860+
if (!pathogenSelect || !geographySelect) {
861+
return;
862+
}
863+
864+
const hasPathogen = pathogenSelect.value && pathogenSelect.value !== '';
865+
866+
// Enable or disable geography select based on pathogen selection
867+
geographySelect.disabled = !hasPathogen;
868+
869+
// If pathogen is cleared, also clear geography selection
870+
if (!hasPathogen && geographySelect.value) {
871+
geographySelect.value = '';
872+
}
873+
}
874+
845875
// Initialize dashboard when DOM is loaded
846876
let dashboard;
847877
document.addEventListener('DOMContentLoaded', function() {
848878
dashboard = new AlterDashboard();
849879
initPathogenTypingAnimation();
850880
initGeographyTypingAnimation();
881+
// Initialize geography select state based on pathogen selection
882+
updateGeographySelectState();
851883
});
852884

853885
// Handle pathogen change - reset geography select and submit form
@@ -862,6 +894,10 @@ function handlePathogenChange() {
862894
if (geographySelect) {
863895
geographySelect.value = '';
864896
}
897+
898+
// Update geography select state before submitting
899+
updateGeographySelectState();
900+
865901
// Show loader before submitting form
866902
const loader = document.getElementById('pageLoader');
867903
if (loader) {

src/templates/alternative_interface/alter_dashboard.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ <h1 class="hero-title">Respiratory Diseases Dashboard</h1>
9191
</div>
9292
<span class="filter-label">in</span>
9393
<div style="position: relative; display: inline-block; width: 100%;">
94-
<select class="form-select filter-select" id="geographySelect" name="geography" onchange="handleGeographyChange()" style="position: relative;">
94+
<select class="form-select filter-select" id="geographySelect" name="geography" onchange="handleGeographyChange()" style="position: relative;" {% if not selected_pathogen %}disabled{% endif %}>
9595
<option value=""></option>
9696
{% for geography in available_geos %}
9797
<optgroup label="{{ geography.text }}">

0 commit comments

Comments
 (0)