Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Statsgrid fixes #2750

Merged
merged 3 commits into from
Nov 27, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ class IndicatorFormController extends StateHandler {
}

async saveData () {
this.updateState({ loading: true });
const { dataByRegions, regionset, selection } = this.getState();

const data = {};
Expand All @@ -182,6 +181,7 @@ class IndicatorFormController extends StateHandler {
return;
}
try {
this.updateState({ loading: true });
const indicator = this.getFullIndicator();
await saveIndicatorData(indicator, data, regionset);
const indicatorInfo = `Indicator: ${indicator.id}, selection: ${selection}, regionset: ${regionset}.`;
Expand Down
12 changes: 8 additions & 4 deletions bundles/statistics/statsgrid/handler/SearchHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,9 @@ class SearchController extends AsyncStateHandler {
params.regionsets.forEach(rs => regionsets.add(rs));
params.selectors.forEach((selector) => {
const existing = combinedSelectors.find(s => s.id === selector.id);
// Note: selectors may come from metadata cache, don't mess up cached data
if (!existing) {
combinedSelectors.push(selector);
combinedSelectors.push({ ...selector });
} else {
const values = existing.values.map(s => s.value);
const newValues = selector.values.filter(v => !values.includes(v.value));
Expand Down Expand Up @@ -374,12 +375,15 @@ class SearchController extends AsyncStateHandler {
const multiSelections = [];
Object.keys(selections).forEach(key => {
const metaSelector = metadata.selectors.find(selector => selector.id === key);
// use metadata for validity check. Params have combined selectors.
const checkAllowed = value => metaSelector.values.find(obj => obj.value === value);
if (!metaSelector) {
indSearchValues.error = 'indicatorMetadataError';
// Only allowed selections are used for get/add indicator
// multi indicator selections may have selection which is missing from single indicator selectors
// skip selection and don't add error
return;
}
// use metadata for validity check. Params have combined selectors.
const checkAllowed = value => metaSelector.values.find(obj => obj.value === value);

const values = selections[key];
// single
if (!Array.isArray(values)) {
Expand Down