Skip to content

Commit 5be5e29

Browse files
authored
Merge pull request #280 from cmu-delphi/development
Development
2 parents 1a97f3d + 54642db commit 5be5e29

File tree

4 files changed

+61
-37
lines changed

4 files changed

+61
-37
lines changed

src/assets/css/custom_styles.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,3 +299,7 @@ tr:not(.odd-row) > .dtfc-fixed-end {
299299
display: block;
300300
}
301301
}
302+
303+
#location_search {
304+
height: 38px !important;
305+
}

src/assets/js/selectedIndicatorsModal.js

Lines changed: 51 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -429,37 +429,32 @@ window.addEventListener('load', function() {
429429
try {
430430
const parsed = JSON.parse(stored);
431431
if (Array.isArray(parsed) && parsed.length > 0) {
432-
if (typeof relatedIndicators !== 'undefined') {
433-
const validIndicators = parsed.filter(storedInd => {
434-
return relatedIndicators.some(relInd =>
435-
relInd.source === storedInd.data_source &&
436-
relInd.name === storedInd.indicator
437-
);
438-
});
432+
parsed.forEach(ind => {
433+
checkedIndicatorMembers.push(ind);
434+
updateSelectedIndicators(
435+
ind.data_source,
436+
ind.display_name,
437+
ind.indicator_set,
438+
ind.indicator
439+
);
439440

440-
validIndicators.forEach(ind => {
441-
checkedIndicatorMembers.push(ind);
442-
updateSelectedIndicators(
443-
ind.data_source,
444-
ind.display_name,
445-
ind.indicator_set,
446-
ind.indicator
447-
);
448-
449-
if (ind._endpoint !== "covidcast" && !indicatorHandler.nonCovidcastIndicatorSets.includes(ind.indicator_set)) {
450-
indicatorHandler.nonCovidcastIndicatorSets.push(ind.indicator_set);
451-
}
452-
});
453-
454-
indicatorHandler.indicators = checkedIndicatorMembers;
455-
456-
if (checkedIndicatorMembers.length > 0) {
457-
$("#showSelectedIndicatorsButton").show();
458-
459-
if (typeof table !== 'undefined' && typeof relatedIndicators !== 'undefined') {
441+
if (ind._endpoint !== "covidcast" && !indicatorHandler.nonCovidcastIndicatorSets.includes(ind.indicator_set)) {
442+
indicatorHandler.nonCovidcastIndicatorSets.push(ind.indicator_set);
443+
}
444+
});
445+
446+
indicatorHandler.indicators = checkedIndicatorMembers;
447+
448+
if (checkedIndicatorMembers.length > 0) {
449+
$("#showSelectedIndicatorsButton").show();
450+
451+
if (typeof expandSelectedRows === 'function') {
452+
expandSelectedRows();
453+
} else {
454+
// Fallback inline implementation if function not found (though we will define it below)
455+
if (typeof table !== 'undefined' && typeof relatedIndicators !== 'undefined' && relatedIndicators) {
460456
const selectedSetIds = new Set();
461457

462-
// Map selected indicators (which store set NAME) to set IDs using relatedIndicators
463458
checkedIndicatorMembers.forEach(member => {
464459
const match = relatedIndicators.find(ri =>
465460
ri.source === member.data_source &&
@@ -481,7 +476,7 @@ window.addEventListener('load', function() {
481476
}
482477
});
483478
}
484-
}
479+
}
485480
}
486481
}
487482
} catch (e) {
@@ -490,3 +485,30 @@ window.addEventListener('load', function() {
490485
sessionStorage.removeItem('checkedIndicatorMembers');
491486
}
492487
});
488+
489+
function expandSelectedRows() {
490+
if (typeof table !== 'undefined' && typeof relatedIndicators !== 'undefined' && relatedIndicators && Array.isArray(relatedIndicators) && typeof checkedIndicatorMembers !== 'undefined') {
491+
const selectedSetIds = new Set();
492+
493+
checkedIndicatorMembers.forEach(member => {
494+
const match = relatedIndicators.find(ri =>
495+
ri.source === member.data_source &&
496+
ri.name === member.indicator
497+
);
498+
if (match) {
499+
selectedSetIds.add(String(match.indicator_set));
500+
}
501+
});
502+
503+
table.rows().every(function() {
504+
const tr = $(this.node());
505+
const rowId = String(tr.data('id'));
506+
507+
if (selectedSetIds.has(rowId)) {
508+
if (!this.child.isShown()) {
509+
tr.find('td.dt-control').trigger('click');
510+
}
511+
}
512+
});
513+
}
514+
}

src/templates/indicatorsets/indicatorSetsFilters.html

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -391,14 +391,7 @@
391391
$(document).ready(function() {
392392
const geoValues = {{ geographic_granularities|safe }};
393393
var urlParams = JSON.parse(JSON.stringify({{ url_params_dict|safe }}));
394-
const locationSearchValues = geoValues.map(group => ({
395-
...group,
396-
children: group.children.map(child => ({
397-
...child,
398-
id: child.id
399-
}))
400-
}));
401-
initSelect2('location_search', locationSearchValues);
394+
initSelect2('location_search', geoValues);
402395
if (urlParams.location_search != "") {
403396
var locationSearch = urlParams.location_search;
404397
$("#location_search").val(locationSearch).trigger("change.select2");

src/templates/indicatorsets/indicatorSetsTable.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,11 @@
387387
}
388388
});
389389
}
390+
391+
// Expand rows for selected indicators if any
392+
if (typeof expandSelectedRows === 'function') {
393+
expandSelectedRows();
394+
}
390395

391396
if (numOfTimeseries > 0) {
392397
totalRowsSpan.innerHTML = `Showing <b>${relatedIndicators.length}</b> distinct ${pluralize(relatedIndicators.length, 'indicator')} (arranged in <b>${table.page.info().recordsTotal}</b> ${pluralize(table.page.info().recordsTotal, 'set')}), including <b>${numberWithCommas(numOfTimeseries)}</b> Delphi-hosted time series across numerous locations.`;

0 commit comments

Comments
 (0)