Skip to content

Commit

Permalink
Merge pull request #2750 from okauppinen/statsgrid-fixes
Browse files Browse the repository at this point in the history
Statsgrid fixes
  • Loading branch information
ZakarFin authored Nov 27, 2024
2 parents 28fb8a5 + 61c97aa commit 6ff8b36
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
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

0 comments on commit 6ff8b36

Please sign in to comment.