-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4837 from HSLdevcom/DT-5986
feat: ui switch for including Estonia in searches
- Loading branch information
Showing
9 changed files
with
172 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const updateCountries = (actionContext, countries) => { | ||
actionContext.dispatch('UpdateCountries', countries); | ||
}; | ||
|
||
export default updateCountries; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import Store from 'fluxible/addons/BaseStore'; | ||
import { getCountries, setCountries } from './localStorage'; | ||
|
||
class CountryStore extends Store { | ||
static handlers = { | ||
UpdateCountries: 'updateCountries', | ||
}; | ||
|
||
static storeName = 'CountryStore'; | ||
|
||
countries = getCountries(); | ||
|
||
getCountries = () => { | ||
return this.countries; | ||
}; | ||
|
||
updateCountries = countries => { | ||
this.countries = countries; | ||
setCountries(countries); | ||
this.emitChange(); | ||
}; | ||
} | ||
|
||
export default CountryStore; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* eslint-disable no-param-reassign */ | ||
export const configureCountry = (config, countries) => { | ||
if (config.mainMenu.countrySelection) { | ||
const selectedCountries = countries; | ||
const keys = Object.keys(selectedCountries); | ||
let boundaries = config.additionalSearchParams.default['boundary.country']; | ||
let feedIds = [...config.feedIds]; | ||
keys.forEach(key => { | ||
const additionalFeedIds = config.additionalFeedIds[key]; | ||
if (selectedCountries[key]) { | ||
// Country selected | ||
if (config.additionalSearchParams[key]['boundary.country']) { | ||
boundaries += ','; | ||
} | ||
boundaries += config.additionalSearchParams[key]['boundary.country']; | ||
if (additionalFeedIds.every(id => feedIds.indexOf(id) < 0)) { | ||
feedIds = [...feedIds, ...additionalFeedIds]; | ||
} | ||
} else { | ||
// Country not selected | ||
feedIds = [...feedIds].filter(id => additionalFeedIds.indexOf(id) < 0); | ||
} | ||
}); | ||
if (!config.searchParams) { | ||
config.searchParams = {}; | ||
} | ||
config.searchParams = { | ||
...config.searchParams, | ||
'boundary.country': boundaries, | ||
}; | ||
config.feedIds = feedIds; | ||
} | ||
}; | ||
|
||
export default configureCountry; |