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
4 changes: 4 additions & 0 deletions src/assets/css/custom_styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -299,3 +299,7 @@ tr:not(.odd-row) > .dtfc-fixed-end {
display: block;
}
}

#location_search {
height: 38px !important;
}
80 changes: 51 additions & 29 deletions src/assets/js/selectedIndicatorsModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,37 +429,32 @@ window.addEventListener('load', function() {
try {
const parsed = JSON.parse(stored);
if (Array.isArray(parsed) && parsed.length > 0) {
if (typeof relatedIndicators !== 'undefined') {
const validIndicators = parsed.filter(storedInd => {
return relatedIndicators.some(relInd =>
relInd.source === storedInd.data_source &&
relInd.name === storedInd.indicator
);
});
parsed.forEach(ind => {
checkedIndicatorMembers.push(ind);
updateSelectedIndicators(
ind.data_source,
ind.display_name,
ind.indicator_set,
ind.indicator
);

validIndicators.forEach(ind => {
checkedIndicatorMembers.push(ind);
updateSelectedIndicators(
ind.data_source,
ind.display_name,
ind.indicator_set,
ind.indicator
);

if (ind._endpoint !== "covidcast" && !indicatorHandler.nonCovidcastIndicatorSets.includes(ind.indicator_set)) {
indicatorHandler.nonCovidcastIndicatorSets.push(ind.indicator_set);
}
});

indicatorHandler.indicators = checkedIndicatorMembers;

if (checkedIndicatorMembers.length > 0) {
$("#showSelectedIndicatorsButton").show();

if (typeof table !== 'undefined' && typeof relatedIndicators !== 'undefined') {
if (ind._endpoint !== "covidcast" && !indicatorHandler.nonCovidcastIndicatorSets.includes(ind.indicator_set)) {
indicatorHandler.nonCovidcastIndicatorSets.push(ind.indicator_set);
}
});

indicatorHandler.indicators = checkedIndicatorMembers;

if (checkedIndicatorMembers.length > 0) {
$("#showSelectedIndicatorsButton").show();

if (typeof expandSelectedRows === 'function') {
expandSelectedRows();
} else {
// Fallback inline implementation if function not found (though we will define it below)
if (typeof table !== 'undefined' && typeof relatedIndicators !== 'undefined' && relatedIndicators) {
const selectedSetIds = new Set();

// Map selected indicators (which store set NAME) to set IDs using relatedIndicators
checkedIndicatorMembers.forEach(member => {
const match = relatedIndicators.find(ri =>
ri.source === member.data_source &&
Expand All @@ -481,7 +476,7 @@ window.addEventListener('load', function() {
}
});
}
}
}
}
}
} catch (e) {
Expand All @@ -490,3 +485,30 @@ window.addEventListener('load', function() {
sessionStorage.removeItem('checkedIndicatorMembers');
}
});

function expandSelectedRows() {
if (typeof table !== 'undefined' && typeof relatedIndicators !== 'undefined' && relatedIndicators && Array.isArray(relatedIndicators) && typeof checkedIndicatorMembers !== 'undefined') {
const selectedSetIds = new Set();

checkedIndicatorMembers.forEach(member => {
const match = relatedIndicators.find(ri =>
ri.source === member.data_source &&
ri.name === member.indicator
);
if (match) {
selectedSetIds.add(String(match.indicator_set));
}
});

table.rows().every(function() {
const tr = $(this.node());
const rowId = String(tr.data('id'));

if (selectedSetIds.has(rowId)) {
if (!this.child.isShown()) {
tr.find('td.dt-control').trigger('click');
}
}
});
}
}
9 changes: 1 addition & 8 deletions src/templates/indicatorsets/indicatorSetsFilters.html
Original file line number Diff line number Diff line change
Expand Up @@ -391,14 +391,7 @@
$(document).ready(function() {
const geoValues = {{ geographic_granularities|safe }};
var urlParams = JSON.parse(JSON.stringify({{ url_params_dict|safe }}));
const locationSearchValues = geoValues.map(group => ({
...group,
children: group.children.map(child => ({
...child,
id: child.id
}))
}));
initSelect2('location_search', locationSearchValues);
initSelect2('location_search', geoValues);
if (urlParams.location_search != "") {
var locationSearch = urlParams.location_search;
$("#location_search").val(locationSearch).trigger("change.select2");
Expand Down
5 changes: 5 additions & 0 deletions src/templates/indicatorsets/indicatorSetsTable.html
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,11 @@
}
});
}

// Expand rows for selected indicators if any
if (typeof expandSelectedRows === 'function') {
expandSelectedRows();
}

if (numOfTimeseries > 0) {
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.`;
Expand Down
Loading