From 1272fd79f428a4fc767d44acbfc6bc146856d8ed Mon Sep 17 00:00:00 2001 From: Simao Rodrigues Date: Mon, 17 Jul 2023 12:07:20 +0100 Subject: [PATCH 1/7] Fix EU/EU countries not correctly highlighted in the maps --- .../app/components/ndcs/shared/selectors.js | 32 ++++++++++++++++--- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/app/javascript/app/components/ndcs/shared/selectors.js b/app/javascript/app/components/ndcs/shared/selectors.js index f7dc56aad..b77a24da2 100644 --- a/app/javascript/app/components/ndcs/shared/selectors.js +++ b/app/javascript/app/components/ndcs/shared/selectors.js @@ -1,5 +1,5 @@ import uniq from 'lodash/uniq'; -import { europeanCountries } from 'app/data/european-countries'; +import { europeanCountries, europeSlug } from 'app/data/european-countries'; import { NO_DOCUMENT_SUBMITTED_COUNTRIES, COUNTRY_STYLES @@ -129,12 +129,34 @@ export const pathsWithStylesFunction = ( ) => { if (!indicator || !worldPaths) return []; const paths = []; - const selectedWorldPaths = showEUCountriesChecked - ? worldPaths - : worldPaths.filter(p => !europeanCountries.includes(p.properties.id)); + + const euGroupDisplayed = selectedCountriesISO.includes(europeSlug); + const allEuCountriesDisplayed = europeanCountries.every(c => + selectedCountriesISO.includes(c) + ); + + const removeEuCountriesFromPaths = + !showEUCountriesChecked && (euGroupDisplayed || allEuCountriesDisplayed); + const selectedWorldPaths = removeEuCountriesFromPaths + ? worldPaths.filter(p => !europeanCountries.includes(p.properties.id)) + : worldPaths; + + let countriesToDisplay = selectedCountriesISO; + if (euGroupDisplayed && showEUCountriesChecked) { + countriesToDisplay = selectedCountriesISO.filter(iso => iso !== europeSlug); + countriesToDisplay.push(...europeanCountries); + } + if (allEuCountriesDisplayed && !showEUCountriesChecked) { + countriesToDisplay = selectedCountriesISO.filter( + iso => !europeanCountries.includes(iso) + ); + countriesToDisplay.push(europeSlug); + } + selectedWorldPaths.forEach(path => { if (shouldShowPath(path, zoom)) { const { locations, legendBuckets } = indicator; + if (!locations) { paths.push({ ...path, @@ -161,7 +183,7 @@ export const pathsWithStylesFunction = ( } }; - if (!selectedCountriesISO.includes(iso)) { + if (!countriesToDisplay.includes(iso)) { const color = '#e8ecf5'; style.default.fill = color; style.hover.fill = color; From 84c4a83f2d085bcb424cb53dac32bbbca8d0ce1a Mon Sep 17 00:00:00 2001 From: Simao Rodrigues Date: Tue, 18 Jul 2023 13:47:54 +0100 Subject: [PATCH 2/7] Split pathsWithStylesFunction's EU related logic into separate selectors for reuse --- .../app/components/ndcs/shared/selectors.js | 65 ++++++++++++++----- 1 file changed, 50 insertions(+), 15 deletions(-) diff --git a/app/javascript/app/components/ndcs/shared/selectors.js b/app/javascript/app/components/ndcs/shared/selectors.js index b77a24da2..d4737250d 100644 --- a/app/javascript/app/components/ndcs/shared/selectors.js +++ b/app/javascript/app/components/ndcs/shared/selectors.js @@ -120,26 +120,34 @@ export const categoryIndicatorsFunction = (indicatorsParsed, category) => { return categoryIndicators; }; -export const pathsWithStylesFunction = ( - indicator, - zoom, +const getEuGroupDisplayed = selectedCountriesISO => + selectedCountriesISO.includes(europeSlug); + +const getAllEuCountriesDisplayed = selectedCountriesISO => + europeanCountries.every(c => selectedCountriesISO.includes(c)); + +const getRemoveEuCountriesFromPaths = ( showEUCountriesChecked, - worldPaths, selectedCountriesISO ) => { - if (!indicator || !worldPaths) return []; - const paths = []; + const euGroupDisplayed = getEuGroupDisplayed(selectedCountriesISO); + const allEuCountriesDisplayed = getAllEuCountriesDisplayed( + selectedCountriesISO + ); - const euGroupDisplayed = selectedCountriesISO.includes(europeSlug); - const allEuCountriesDisplayed = europeanCountries.every(c => - selectedCountriesISO.includes(c) + return ( + !showEUCountriesChecked && (euGroupDisplayed || allEuCountriesDisplayed) ); +}; - const removeEuCountriesFromPaths = - !showEUCountriesChecked && (euGroupDisplayed || allEuCountriesDisplayed); - const selectedWorldPaths = removeEuCountriesFromPaths - ? worldPaths.filter(p => !europeanCountries.includes(p.properties.id)) - : worldPaths; +export const selectedMapCountriesISOFunction = ( + showEUCountriesChecked, + selectedCountriesISO +) => { + const euGroupDisplayed = getEuGroupDisplayed(selectedCountriesISO); + const allEuCountriesDisplayed = getAllEuCountriesDisplayed( + selectedCountriesISO + ); let countriesToDisplay = selectedCountriesISO; if (euGroupDisplayed && showEUCountriesChecked) { @@ -153,6 +161,33 @@ export const pathsWithStylesFunction = ( countriesToDisplay.push(europeSlug); } + return countriesToDisplay; +}; + +export const pathsWithStylesFunction = ( + indicator, + zoom, + showEUCountriesChecked, + worldPaths, + selectedCountriesISO +) => { + if (!indicator || !worldPaths) return []; + const paths = []; + + const removeEuCountriesFromPaths = getRemoveEuCountriesFromPaths( + showEUCountriesChecked, + selectedCountriesISO + ); + + const countriesToDisplayISO = selectedMapCountriesISOFunction( + showEUCountriesChecked, + selectedCountriesISO + ); + + const selectedWorldPaths = removeEuCountriesFromPaths + ? worldPaths.filter(p => !europeanCountries.includes(p.properties.id)) + : worldPaths; + selectedWorldPaths.forEach(path => { if (shouldShowPath(path, zoom)) { const { locations, legendBuckets } = indicator; @@ -183,7 +218,7 @@ export const pathsWithStylesFunction = ( } }; - if (!countriesToDisplay.includes(iso)) { + if (!countriesToDisplayISO.includes(iso)) { const color = '#e8ecf5'; style.default.fill = color; style.hover.fill = color; From d74ff73abcf513dcc4a13dca546d1c2da62406bd Mon Sep 17 00:00:00 2001 From: Simao Rodrigues Date: Wed, 19 Jul 2023 12:06:40 +0100 Subject: [PATCH 3/7] Rename new shared NDCS selectors/functions to make it clearer what they do --- .../app/components/ndcs/shared/selectors.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/javascript/app/components/ndcs/shared/selectors.js b/app/javascript/app/components/ndcs/shared/selectors.js index d4737250d..bbb7b3ad0 100644 --- a/app/javascript/app/components/ndcs/shared/selectors.js +++ b/app/javascript/app/components/ndcs/shared/selectors.js @@ -120,18 +120,18 @@ export const categoryIndicatorsFunction = (indicatorsParsed, category) => { return categoryIndicators; }; -const getEuGroupDisplayed = selectedCountriesISO => +const getIsEUGroupDisplayed = selectedCountriesISO => selectedCountriesISO.includes(europeSlug); -const getAllEuCountriesDisplayed = selectedCountriesISO => +const getAreAllEuCountriesDisplayed = selectedCountriesISO => europeanCountries.every(c => selectedCountriesISO.includes(c)); const getRemoveEuCountriesFromPaths = ( showEUCountriesChecked, selectedCountriesISO ) => { - const euGroupDisplayed = getEuGroupDisplayed(selectedCountriesISO); - const allEuCountriesDisplayed = getAllEuCountriesDisplayed( + const euGroupDisplayed = getIsEUGroupDisplayed(selectedCountriesISO); + const allEuCountriesDisplayed = getAreAllEuCountriesDisplayed( selectedCountriesISO ); @@ -144,8 +144,8 @@ export const selectedMapCountriesISOFunction = ( showEUCountriesChecked, selectedCountriesISO ) => { - const euGroupDisplayed = getEuGroupDisplayed(selectedCountriesISO); - const allEuCountriesDisplayed = getAllEuCountriesDisplayed( + const euGroupDisplayed = getIsEUGroupDisplayed(selectedCountriesISO); + const allEuCountriesDisplayed = getAreAllEuCountriesDisplayed( selectedCountriesISO ); From ed3d8529c68d22bc77c8cd6ad217990dcc401b42 Mon Sep 17 00:00:00 2001 From: Simao Rodrigues Date: Wed, 19 Jul 2023 11:52:20 +0100 Subject: [PATCH 4/7] NDCS/LTS/Net-Zero tables now synced with the respective maps and the "Individual EU Countries" checkbox --- .../ndcs/lts-explore-map/lts-explore-map-selectors.js | 6 ++++++ .../ndcs/lts-explore-table/lts-explore-table-selectors.js | 8 ++++---- .../ndcs/ndcs-explore-map/ndcs-explore-map-selectors.js | 6 ++++++ .../ndcs-explore-table/ndcs-explore-table-selectors.js | 8 ++++---- .../ndcs/net-zero-map/net-zero-map-selectors.js | 6 ++++++ .../ndcs/net-zero-table/net-zero-table-selectors.js | 8 ++++---- 6 files changed, 30 insertions(+), 12 deletions(-) diff --git a/app/javascript/app/components/ndcs/lts-explore-map/lts-explore-map-selectors.js b/app/javascript/app/components/ndcs/lts-explore-map/lts-explore-map-selectors.js index f084cc973..651f732dd 100644 --- a/app/javascript/app/components/ndcs/lts-explore-map/lts-explore-map-selectors.js +++ b/app/javascript/app/components/ndcs/lts-explore-map/lts-explore-map-selectors.js @@ -20,6 +20,7 @@ import { TOP_EMITTERS_OPTION } from 'data/constants'; import { selectedLocationsFunction, selectedCountriesISOFunction, + selectedMapCountriesISOFunction, selectedCountriesFunction, categoryIndicatorsFunction, pathsWithStylesFunction, @@ -137,6 +138,11 @@ export const getSelectedCountriesISO = createSelector( selectedCountriesISOFunction ); +export const getSelectedMapCountriesISO = createSelector( + [getIsShowEUCountriesChecked, getSelectedCountriesISO], + selectedMapCountriesISOFunction +); + export const getCategories = createSelector(getCategoriesData, categories => !categories ? null diff --git a/app/javascript/app/components/ndcs/lts-explore-table/lts-explore-table-selectors.js b/app/javascript/app/components/ndcs/lts-explore-table/lts-explore-table-selectors.js index 0e46cde95..caf0329d1 100644 --- a/app/javascript/app/components/ndcs/lts-explore-table/lts-explore-table-selectors.js +++ b/app/javascript/app/components/ndcs/lts-explore-table/lts-explore-table-selectors.js @@ -6,7 +6,7 @@ import isEmpty from 'lodash/isEmpty'; import { replaceStringAbbr } from 'components/abbr-replace'; import { getMapIndicator, - getSelectedCountriesISO + getSelectedMapCountriesISO } from 'components/ndcs/lts-explore-map/lts-explore-map-selectors'; const getCountries = state => state.countries || null; @@ -35,8 +35,8 @@ export const getIndicatorsParsed = createSelector( ); export const tableGetSelectedData = createSelector( - [getIndicatorsParsed, getCountries, getSelectedCountriesISO], - (indicators, countries, selectedCountriesISO) => { + [getIndicatorsParsed, getCountries, getSelectedMapCountriesISO], + (indicators, countries, selectedMapCountriesISO) => { if (!indicators || !indicators.length || !indicators[0].locations) { return []; } @@ -45,7 +45,7 @@ export const tableGetSelectedData = createSelector( return Object.keys(refIndicator.locations) .map(iso => { - if (!selectedCountriesISO.includes(iso)) return null; + if (!selectedMapCountriesISO.includes(iso)) return null; const countryData = countries.find(country => country.iso_code3 === iso) || {}; const row = { diff --git a/app/javascript/app/components/ndcs/ndcs-explore-map/ndcs-explore-map-selectors.js b/app/javascript/app/components/ndcs/ndcs-explore-map/ndcs-explore-map-selectors.js index 1d8683225..332af354e 100644 --- a/app/javascript/app/components/ndcs/ndcs-explore-map/ndcs-explore-map-selectors.js +++ b/app/javascript/app/components/ndcs/ndcs-explore-map/ndcs-explore-map-selectors.js @@ -35,6 +35,7 @@ import { getSubmitted2020Isos } from 'utils/indicatorCalculations'; import { selectedLocationsFunction, selectedCountriesISOFunction, + selectedMapCountriesISOFunction, selectedCountriesFunction, categoryIndicatorsFunction, pathsWithStylesFunction, @@ -227,6 +228,11 @@ export const getSelectedCountriesISO = createSelector( selectedCountriesISOFunction ); +export const getSelectedMapCountriesISO = createSelector( + [getIsShowEUCountriesChecked, getSelectedCountriesISO], + selectedMapCountriesISOFunction +); + export const getMaximumCountries = createSelector( getSelectedCountriesISO, countries => countries.length diff --git a/app/javascript/app/components/ndcs/ndcs-explore-table/ndcs-explore-table-selectors.js b/app/javascript/app/components/ndcs/ndcs-explore-table/ndcs-explore-table-selectors.js index d9464dc51..f93b8bdbf 100644 --- a/app/javascript/app/components/ndcs/ndcs-explore-table/ndcs-explore-table-selectors.js +++ b/app/javascript/app/components/ndcs/ndcs-explore-table/ndcs-explore-table-selectors.js @@ -5,7 +5,7 @@ import { filterQuery } from 'app/utils'; import { replaceStringAbbr } from 'components/abbr-replace'; import { getMapIndicator, - getSelectedCountriesISO + getSelectedMapCountriesISO } from 'components/ndcs/ndcs-explore-map/ndcs-explore-map-selectors'; import { getIndicatorsParsed, @@ -51,8 +51,8 @@ export const getDefaultColumns = createSelector( ); export const tableGetSelectedData = createSelector( - [getIndicatorsParsed, getCountries, getSelectedCountriesISO], - (indicators, countries, selectedCountriesISO) => { + [getIndicatorsParsed, getCountries, getSelectedMapCountriesISO], + (indicators, countries, selectedMapCountriesISO) => { if ( !indicators || !indicators.length || @@ -68,7 +68,7 @@ export const tableGetSelectedData = createSelector( if (!refIndicator) return null; return Object.keys(refIndicator.locations) .map(iso => { - if (!selectedCountriesISO.includes(iso)) return null; + if (!selectedMapCountriesISO.includes(iso)) return null; const countryData = countries.find(country => country.iso_code3 === iso) || {}; const row = { diff --git a/app/javascript/app/components/ndcs/net-zero-map/net-zero-map-selectors.js b/app/javascript/app/components/ndcs/net-zero-map/net-zero-map-selectors.js index 8e0ae90c8..7a3f36d8f 100644 --- a/app/javascript/app/components/ndcs/net-zero-map/net-zero-map-selectors.js +++ b/app/javascript/app/components/ndcs/net-zero-map/net-zero-map-selectors.js @@ -21,6 +21,7 @@ import { getIsShowEUCountriesChecked } from 'components/ndcs/shared/explore-map/ import { NET_ZERO_POSITIVE_LABELS, TOP_EMITTERS_OPTION } from 'data/constants'; import { selectedLocationsFunction, + selectedMapCountriesISOFunction, selectedCountriesISOFunction, selectedCountriesFunction, categoryIndicatorsFunction, @@ -143,6 +144,11 @@ export const getSelectedCountriesISO = createSelector( selectedCountriesISOFunction ); +export const getSelectedMapCountriesISO = createSelector( + [getIsShowEUCountriesChecked, getSelectedCountriesISO], + selectedMapCountriesISOFunction +); + const getisDefaultLocationSelected = createSelector( [getSelectedLocations], isDefaultLocationSelectedFunction diff --git a/app/javascript/app/components/ndcs/net-zero-table/net-zero-table-selectors.js b/app/javascript/app/components/ndcs/net-zero-table/net-zero-table-selectors.js index f4c8d3b35..5fadf36c4 100644 --- a/app/javascript/app/components/ndcs/net-zero-table/net-zero-table-selectors.js +++ b/app/javascript/app/components/ndcs/net-zero-table/net-zero-table-selectors.js @@ -4,7 +4,7 @@ import sortBy from 'lodash/sortBy'; import isEmpty from 'lodash/isEmpty'; import { getMapIndicator, - getSelectedCountriesISO + getSelectedMapCountriesISO } from 'components/ndcs/net-zero-map/net-zero-map-selectors'; import { replaceStringAbbr } from 'components/abbr-replace'; @@ -31,8 +31,8 @@ export const getIndicatorsParsed = createSelector( ); export const tableGetSelectedData = createSelector( - [getIndicatorsParsed, getCountries, getSelectedCountriesISO], - (indicators, countries, selectedCountriesISO) => { + [getIndicatorsParsed, getCountries, getSelectedMapCountriesISO], + (indicators, countries, selectedMapCountriesISO) => { if (!indicators || !indicators.length || !indicators[0].locations) { return []; } @@ -42,7 +42,7 @@ export const tableGetSelectedData = createSelector( return Object.keys(refIndicator.locations) .map(iso => { - if (!selectedCountriesISO.includes(iso)) return null; + if (!selectedMapCountriesISO.includes(iso)) return null; const countryData = countries.find(country => country.iso_code3 === iso) || {}; const row = { From 22ca8fad01e79edeb75776ed93b224009910462e Mon Sep 17 00:00:00 2001 From: Simao Rodrigues Date: Wed, 19 Jul 2023 12:54:04 +0100 Subject: [PATCH 5/7] Add shared NDCS selector so that we know whether EU countries are displayed --- .../app/components/ndcs/shared/selectors.js | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/app/javascript/app/components/ndcs/shared/selectors.js b/app/javascript/app/components/ndcs/shared/selectors.js index bbb7b3ad0..c0cdf1651 100644 --- a/app/javascript/app/components/ndcs/shared/selectors.js +++ b/app/javascript/app/components/ndcs/shared/selectors.js @@ -126,19 +126,14 @@ const getIsEUGroupDisplayed = selectedCountriesISO => const getAreAllEuCountriesDisplayed = selectedCountriesISO => europeanCountries.every(c => selectedCountriesISO.includes(c)); +export const getIsEUDisplayedFunction = selectedCountriesISO => + getIsEUGroupDisplayed(selectedCountriesISO) || + getAreAllEuCountriesDisplayed(selectedCountriesISO); + const getRemoveEuCountriesFromPaths = ( showEUCountriesChecked, selectedCountriesISO -) => { - const euGroupDisplayed = getIsEUGroupDisplayed(selectedCountriesISO); - const allEuCountriesDisplayed = getAreAllEuCountriesDisplayed( - selectedCountriesISO - ); - - return ( - !showEUCountriesChecked && (euGroupDisplayed || allEuCountriesDisplayed) - ); -}; +) => !showEUCountriesChecked && getIsEUDisplayedFunction(selectedCountriesISO); export const selectedMapCountriesISOFunction = ( showEUCountriesChecked, From edf86fdd8df82b462c4d53d786cebf67cce3d8e6 Mon Sep 17 00:00:00 2001 From: Simao Rodrigues Date: Thu, 20 Jul 2023 11:54:21 +0100 Subject: [PATCH 6/7] Add comments to shared EU/Map shared NDCS selectors to better detail their function --- .../app/components/ndcs/shared/selectors.js | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/app/javascript/app/components/ndcs/shared/selectors.js b/app/javascript/app/components/ndcs/shared/selectors.js index c0cdf1651..cadab21ae 100644 --- a/app/javascript/app/components/ndcs/shared/selectors.js +++ b/app/javascript/app/components/ndcs/shared/selectors.js @@ -120,35 +120,56 @@ export const categoryIndicatorsFunction = (indicatorsParsed, category) => { return categoryIndicators; }; +// Get whether the EU countries are selected, checking by the 'EUU' iso code. +// eg: ['EUU', ...] const getIsEUGroupDisplayed = selectedCountriesISO => selectedCountriesISO.includes(europeSlug); +// Get whether all EU countries are selected, checking by all their individual iso codes. +// eg: ['PRT', 'ESP', ...]) const getAreAllEuCountriesDisplayed = selectedCountriesISO => europeanCountries.every(c => selectedCountriesISO.includes(c)); +// Get whether all EU countries are selected, either by the 'EUU' iso code or +// all their individual iso codes. export const getIsEUDisplayedFunction = selectedCountriesISO => getIsEUGroupDisplayed(selectedCountriesISO) || getAreAllEuCountriesDisplayed(selectedCountriesISO); +// Get wether individual EU countries paths should be removed from the map, based on both +// the "Visualize individual submissions of EU Members" checkbox and on whether all EU +// countries are selected. const getRemoveEuCountriesFromPaths = ( showEUCountriesChecked, selectedCountriesISO ) => !showEUCountriesChecked && getIsEUDisplayedFunction(selectedCountriesISO); +// This function takes the array from selectedCountriesISO as well as the value from the +// "Visualize individual submissions of EU Members" and creates a new array of iso codes +// that can be used to correctly highlight the selected countries on the map. export const selectedMapCountriesISOFunction = ( showEUCountriesChecked, selectedCountriesISO ) => { + // EU countries selected as a group ('EUU' iso code) const euGroupDisplayed = getIsEUGroupDisplayed(selectedCountriesISO); + + // All EU countries selected by their individual ISO codes const allEuCountriesDisplayed = getAreAllEuCountriesDisplayed( selectedCountriesISO ); let countriesToDisplay = selectedCountriesISO; + + // If the EU countries are displayed as a group and we want to display them individually + // on the map, then we remove the 'EUU' iso code and add the countries' individual iso codes. if (euGroupDisplayed && showEUCountriesChecked) { countriesToDisplay = selectedCountriesISO.filter(iso => iso !== europeSlug); countriesToDisplay.push(...europeanCountries); } + + // If the EU countries are displayed individually by their iso codes but we would like + // to display them as the EU group, we remove their individual iso codes and add the 'EUU' one. if (allEuCountriesDisplayed && !showEUCountriesChecked) { countriesToDisplay = selectedCountriesISO.filter( iso => !europeanCountries.includes(iso) @@ -159,6 +180,9 @@ export const selectedMapCountriesISOFunction = ( return countriesToDisplay; }; +// Based on the indicator, zoom level, the selected countries and the "Visualize individual +// submissions of EU Members" checkbox, return the paths to the map with the correct countries +// highlighted. export const pathsWithStylesFunction = ( indicator, zoom, From e776454b6194f29a2c7234963dadc54e08ab9aed Mon Sep 17 00:00:00 2001 From: Simao Rodrigues Date: Thu, 20 Jul 2023 12:19:40 +0100 Subject: [PATCH 7/7] Rename EU related Map NDCS shared selectors to be more descriptive --- .../app/components/ndcs/shared/selectors.js | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/javascript/app/components/ndcs/shared/selectors.js b/app/javascript/app/components/ndcs/shared/selectors.js index cadab21ae..b5058adb8 100644 --- a/app/javascript/app/components/ndcs/shared/selectors.js +++ b/app/javascript/app/components/ndcs/shared/selectors.js @@ -122,19 +122,19 @@ export const categoryIndicatorsFunction = (indicatorsParsed, category) => { // Get whether the EU countries are selected, checking by the 'EUU' iso code. // eg: ['EUU', ...] -const getIsEUGroupDisplayed = selectedCountriesISO => +const getIsEUGroupSelected = selectedCountriesISO => selectedCountriesISO.includes(europeSlug); // Get whether all EU countries are selected, checking by all their individual iso codes. // eg: ['PRT', 'ESP', ...]) -const getAreAllEuCountriesDisplayed = selectedCountriesISO => +const getAreAllEuCountriesSelected = selectedCountriesISO => europeanCountries.every(c => selectedCountriesISO.includes(c)); // Get whether all EU countries are selected, either by the 'EUU' iso code or // all their individual iso codes. -export const getIsEUDisplayedFunction = selectedCountriesISO => - getIsEUGroupDisplayed(selectedCountriesISO) || - getAreAllEuCountriesDisplayed(selectedCountriesISO); +export const getIsEUSelectedFunction = selectedCountriesISO => + getIsEUGroupSelected(selectedCountriesISO) || + getAreAllEuCountriesSelected(selectedCountriesISO); // Get wether individual EU countries paths should be removed from the map, based on both // the "Visualize individual submissions of EU Members" checkbox and on whether all EU @@ -142,7 +142,7 @@ export const getIsEUDisplayedFunction = selectedCountriesISO => const getRemoveEuCountriesFromPaths = ( showEUCountriesChecked, selectedCountriesISO -) => !showEUCountriesChecked && getIsEUDisplayedFunction(selectedCountriesISO); +) => !showEUCountriesChecked && getIsEUSelectedFunction(selectedCountriesISO); // This function takes the array from selectedCountriesISO as well as the value from the // "Visualize individual submissions of EU Members" and creates a new array of iso codes @@ -152,10 +152,10 @@ export const selectedMapCountriesISOFunction = ( selectedCountriesISO ) => { // EU countries selected as a group ('EUU' iso code) - const euGroupDisplayed = getIsEUGroupDisplayed(selectedCountriesISO); + const euGroupSelected = getIsEUGroupSelected(selectedCountriesISO); // All EU countries selected by their individual ISO codes - const allEuCountriesDisplayed = getAreAllEuCountriesDisplayed( + const allEuCountriesSelected = getAreAllEuCountriesSelected( selectedCountriesISO ); @@ -163,14 +163,14 @@ export const selectedMapCountriesISOFunction = ( // If the EU countries are displayed as a group and we want to display them individually // on the map, then we remove the 'EUU' iso code and add the countries' individual iso codes. - if (euGroupDisplayed && showEUCountriesChecked) { + if (euGroupSelected && showEUCountriesChecked) { countriesToDisplay = selectedCountriesISO.filter(iso => iso !== europeSlug); countriesToDisplay.push(...europeanCountries); } // If the EU countries are displayed individually by their iso codes but we would like // to display them as the EU group, we remove their individual iso codes and add the 'EUU' one. - if (allEuCountriesDisplayed && !showEUCountriesChecked) { + if (allEuCountriesSelected && !showEUCountriesChecked) { countriesToDisplay = selectedCountriesISO.filter( iso => !europeanCountries.includes(iso) );