From e937a23cca60759e80d7a76d93dc7604e9ee4056 Mon Sep 17 00:00:00 2001 From: Olli Kauppinen Date: Wed, 27 Nov 2024 12:12:05 +0200 Subject: [PATCH 1/3] set loading after data exists check --- bundles/statistics/statsgrid/handler/IndicatorFormHandler.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/statistics/statsgrid/handler/IndicatorFormHandler.js b/bundles/statistics/statsgrid/handler/IndicatorFormHandler.js index 385cf57451..e7fe17d1fd 100644 --- a/bundles/statistics/statsgrid/handler/IndicatorFormHandler.js +++ b/bundles/statistics/statsgrid/handler/IndicatorFormHandler.js @@ -163,7 +163,6 @@ class IndicatorFormController extends StateHandler { } async saveData () { - this.updateState({ loading: true }); const { dataByRegions, regionset, selection } = this.getState(); const data = {}; @@ -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}.`; From 1678a9426006db96b0a8925d164276fa8af045b4 Mon Sep 17 00:00:00 2001 From: Olli Kauppinen Date: Wed, 27 Nov 2024 13:02:34 +0200 Subject: [PATCH 2/3] create copy from seletor --- bundles/statistics/statsgrid/handler/SearchHandler.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bundles/statistics/statsgrid/handler/SearchHandler.js b/bundles/statistics/statsgrid/handler/SearchHandler.js index 4b5b657036..9920d03757 100644 --- a/bundles/statistics/statsgrid/handler/SearchHandler.js +++ b/bundles/statistics/statsgrid/handler/SearchHandler.js @@ -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)); From 61c97aae48ddd32a0156753e73cf6ee6d9977e8b Mon Sep 17 00:00:00 2001 From: Olli Kauppinen Date: Wed, 27 Nov 2024 14:20:24 +0200 Subject: [PATCH 3/3] don't add error if metadata selector is missing --- bundles/statistics/statsgrid/handler/SearchHandler.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bundles/statistics/statsgrid/handler/SearchHandler.js b/bundles/statistics/statsgrid/handler/SearchHandler.js index 9920d03757..deb39b07eb 100644 --- a/bundles/statistics/statsgrid/handler/SearchHandler.js +++ b/bundles/statistics/statsgrid/handler/SearchHandler.js @@ -375,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)) {