@studyportals/fawkes 9.0.1-2 → 9.0.1-4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -4,7 +4,6 @@ import { FilterKeyValuesMap } from "../../../sitemap-generator-seo";
|
|
|
4
4
|
export declare class OnlyCountriesDisciplineCountryRule implements IRule {
|
|
5
5
|
private readonly countryFilterKey;
|
|
6
6
|
private readonly allowedCountryIsos;
|
|
7
|
-
private allowedCountryIds?;
|
|
8
7
|
getName(): string;
|
|
9
8
|
forSearch(dependencies: ISearchDependencies): Promise<boolean>;
|
|
10
9
|
forSitemapGenerator(filterKeyValues: FilterKeyValuesMap): Promise<boolean>;
|
|
@@ -3,20 +3,20 @@ import { CountryPresenter } from "../../presenters/CountryPresenter";
|
|
|
3
3
|
export class OnlyCountriesDisciplineCountryRule {
|
|
4
4
|
countryFilterKey = FilterKey.COUNTRY;
|
|
5
5
|
allowedCountryIsos = ['AU', 'CA', 'CN', 'FR', 'DE', 'IN', 'IE', 'IT', 'JP', 'MY', 'NL', 'NZ', 'SG', 'KR', 'CH', 'GB', 'US'];
|
|
6
|
-
allowedCountryIds;
|
|
7
6
|
getName() {
|
|
8
7
|
return 'OnlyCountriesDisciplineCountryRule';
|
|
9
8
|
}
|
|
10
9
|
forSearch(dependencies) {
|
|
11
10
|
//eslint-disable-next-line no-console
|
|
12
|
-
console.log('dependencies', dependencies.filterState);
|
|
11
|
+
console.log('dependencies', dependencies.filterState.getSelectedValuesFor(this.countryFilterKey));
|
|
13
12
|
const selectedCountry = dependencies.seoInfoBase.getFilterOptionValueBy(this.countryFilterKey, dependencies.filterState);
|
|
14
|
-
//eslint-disable-next-line no-console
|
|
15
|
-
console.log('selectedCountry', selectedCountry);
|
|
16
13
|
if (!selectedCountry) {
|
|
17
14
|
return Promise.resolve(false);
|
|
18
15
|
}
|
|
19
|
-
|
|
16
|
+
const allowedCountryIds = this.getAllowedCountryIds();
|
|
17
|
+
//eslint-disable-next-line no-console
|
|
18
|
+
console.log('allowed country ids', Array.from(allowedCountryIds));
|
|
19
|
+
return Promise.resolve(allowedCountryIds.has(selectedCountry));
|
|
20
20
|
}
|
|
21
21
|
forSitemapGenerator(filterKeyValues) {
|
|
22
22
|
const selectedCountries = filterKeyValues.get(FilterKey.COUNTRY);
|
|
@@ -30,13 +30,10 @@ export class OnlyCountriesDisciplineCountryRule {
|
|
|
30
30
|
return Promise.resolve(this.getAllowedCountryIds().has(selectedCountry));
|
|
31
31
|
}
|
|
32
32
|
getAllowedCountryIds() {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
.map((country) => country.id));
|
|
38
|
-
}
|
|
39
|
-
return this.allowedCountryIds;
|
|
33
|
+
return new Set(CountryPresenter.getInstance()
|
|
34
|
+
.getFragments()
|
|
35
|
+
.filter((country) => this.allowedCountryIsos.includes(country.iso))
|
|
36
|
+
.map((country) => country.id));
|
|
40
37
|
}
|
|
41
38
|
getDescription() {
|
|
42
39
|
return 'Country is one of the allowed countries for discipline and country pages';
|