Skip to content

Commit

Permalink
Merge pull request #1106 from City-of-Helsinki/UHF-10486
Browse files Browse the repository at this point in the history
UHF-10486
  • Loading branch information
hyrsky authored Nov 8, 2024
2 parents 02ce20f + 4145be0 commit 06f6f3a
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 80 deletions.
2 changes: 1 addition & 1 deletion dist/js/school-search.min.js

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions src/js/react/apps/school-search/components/ResultCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,20 @@ const ResultCard = ({
}

let languageEducation = ontologyword_ids?.reduce((acc: any, currentItem: any) => {
if ((currentItem >= 15 && currentItem <= 124) && ontologyDetailsIdsToLang[currentItem]) {
acc.push(ontologyDetailsIdsToLang[currentItem]);
}
(['a1', 'a2', 'b1', 'b2'] as const).forEach(option => {
if (ontologyDetailsIdsToLang[option][currentItem]) {
acc.push(ontologyDetailsIdsToLang[option][currentItem]);
}
});
return acc;
}, []);

// Remove duplicates.
languageEducation = [...new Set(languageEducation)];

const bilingualEducation = ontologyword_ids?.reduce((acc: any, currentItem: any) => {
if ((currentItem >= 293 && currentItem <= 911) && ontologyDetailsIdsToLang[currentItem]) {
acc.push(ontologyDetailsIdsToLang[currentItem]);
if (ontologyDetailsIdsToLang.bilingualEducation[currentItem]) {
acc.push(ontologyDetailsIdsToLang.bilingualEducation[currentItem]);
}
return acc;
}, []);
Expand Down
137 changes: 75 additions & 62 deletions src/js/react/apps/school-search/enum/LanguageEducationMap.ts
Original file line number Diff line number Diff line change
@@ -1,65 +1,78 @@
const ontologyDetailsIdsToLang: any = {
15: Drupal.t('English', {}, { context: 'TPR Ontologyword details schools' }),
16: Drupal.t('Spanish', {}, { context: 'TPR Ontologyword details schools' }),
17: Drupal.t('Hebrew', {}, { context: 'TPR Ontologyword details schools' }),
18: Drupal.t('Italian', {}, { context: 'TPR Ontologyword details schools' }),
19: Drupal.t('Chinese', {}, { context: 'TPR Ontologyword details schools' }),
20: Drupal.t('Latin', {}, { context: 'TPR Ontologyword details schools' }),
21: Drupal.t('French', {}, { context: 'TPR Ontologyword details schools' }),
22: Drupal.t('Swedish', {}, { context: 'TPR Ontologyword details schools' }),
23: Drupal.t('German', {}, { context: 'TPR Ontologyword details schools' }),
24: Drupal.t('Finnish', {}, { context: 'TPR Ontologyword details schools' }),
25: Drupal.t('Russian', {}, { context: 'TPR Ontologyword details schools' }),
26: Drupal.t('Estonian', {}, { context: 'TPR Ontologyword details schools' }),
27: Drupal.t('English', {}, { context: 'TPR Ontologyword details schools' }),
28: Drupal.t('Spanish', {}, { context: 'TPR Ontologyword details schools' }),
29: Drupal.t('Hebrew', {}, { context: 'TPR Ontologyword details schools' }),
30: Drupal.t('Italian', {}, { context: 'TPR Ontologyword details schools' }),
31: Drupal.t('Chinese', {}, { context: 'TPR Ontologyword details schools' }),
32: Drupal.t('Latin', {}, { context: 'TPR Ontologyword details schools' }),
33: Drupal.t('French', {}, { context: 'TPR Ontologyword details schools' }),
34: Drupal.t('Swedish', {}, { context: 'TPR Ontologyword details schools' }),
35: Drupal.t('German', {}, { context: 'TPR Ontologyword details schools' }),
36: Drupal.t('Finnish', {}, { context: 'TPR Ontologyword details schools' }),
37: Drupal.t('Russian', {}, { context: 'TPR Ontologyword details schools' }),
38: Drupal.t('Estonian', {}, { context: 'TPR Ontologyword details schools' }),
101: Drupal.t('English', {}, { context: 'TPR Ontologyword details schools' }),
102: Drupal.t('Spanish', {}, { context: 'TPR Ontologyword details schools' }),
103: Drupal.t('Hebrew', {}, { context: 'TPR Ontologyword details schools' }),
104: Drupal.t('Italian', {}, { context: 'TPR Ontologyword details schools' }),
105: Drupal.t('Chinese', {}, { context: 'TPR Ontologyword details schools' }),
106: Drupal.t('Latin', {}, { context: 'TPR Ontologyword details schools' }),
107: Drupal.t('French', {}, { context: 'TPR Ontologyword details schools' }),
108: Drupal.t('Swedish', {}, { context: 'TPR Ontologyword details schools' }),
109: Drupal.t('German', {}, { context: 'TPR Ontologyword details schools' }),
110: Drupal.t('Finnish', {}, { context: 'TPR Ontologyword details schools' }),
111: Drupal.t('Russian', {}, { context: 'TPR Ontologyword details schools' }),
112: Drupal.t('Estonian', {}, { context: 'TPR Ontologyword details schools' }),
113: Drupal.t('English', {}, { context: 'TPR Ontologyword details schools' }),
114: Drupal.t('Spanish', {}, { context: 'TPR Ontologyword details schools' }),
115: Drupal.t('Hebrew', {}, { context: 'TPR Ontologyword details schools' }),
116: Drupal.t('Italian', {}, { context: 'TPR Ontologyword details schools' }),
117: Drupal.t('Chinese', {}, { context: 'TPR Ontologyword details schools' }),
118: Drupal.t('Latin', {}, { context: 'TPR Ontologyword details schools' }),
119: Drupal.t('French', {}, { context: 'TPR Ontologyword details schools' }),
120: Drupal.t('Swedish', {}, { context: 'TPR Ontologyword details schools' }),
121: Drupal.t('German', {}, { context: 'TPR Ontologyword details schools' }),
122: Drupal.t('Finnish', {}, { context: 'TPR Ontologyword details schools' }),
123: Drupal.t('Russian', {}, { context: 'TPR Ontologyword details schools' }),
124: Drupal.t('Estonian', {}, { context: 'TPR Ontologyword details schools' }),
149: Drupal.t('Teaching in English', {}, { context: 'TPR Ontologyword details schools' }),
150: Drupal.t('Teaching in English', {}, { context: 'TPR Ontologyword details schools' }),
293: Drupal.t('Language immersion (English)', {}, { context: 'TPR Ontologyword details schools' }),
295: Drupal.t('Language immersion (Swedish)', {}, { context: 'TPR Ontologyword details schools' }),
297: Drupal.t('Language immersion (German)', {}, { context: 'TPR Ontologyword details schools' }),
904: Drupal.t('Finnish-English', {}, { context: 'TPR Ontologyword details schools' }),
905: Drupal.t('Finnish-Chinese', {}, { context: 'TPR Ontologyword details schools' }),
906: Drupal.t('Finnish-Spanish', {}, { context: 'TPR Ontologyword details schools' }),
907: Drupal.t('Finnish-Northern Sami', {}, { context: 'TPR Ontologyword details schools' }),
908: Drupal.t('Finnish-Estonian', {}, { context: 'TPR Ontologyword details schools' }),
909: Drupal.t('Finnish-Russian', {}, { context: 'TPR Ontologyword details schools' }),
910: Drupal.t('Language-enriched education (Finnish-English)', {}, { context: 'TPR Ontologyword details schools' }),
911: Drupal.t('Language-enriched education (Finnish-Russian)', {}, { context: 'TPR Ontologyword details schools' })
import OntologyDetailMap from '../types/OntologyDetailsMap';

const ontologyDetailsIdsToLang: OntologyDetailMap = {
a1: {
15: Drupal.t('English', {}, { context: 'TPR Ontologyword details schools' }),
16: Drupal.t('Spanish', {}, { context: 'TPR Ontologyword details schools' }),
17: Drupal.t('Hebrew', {}, { context: 'TPR Ontologyword details schools' }),
18: Drupal.t('Italian', {}, { context: 'TPR Ontologyword details schools' }),
19: Drupal.t('Chinese', {}, { context: 'TPR Ontologyword details schools' }),
20: Drupal.t('Latin', {}, { context: 'TPR Ontologyword details schools' }),
21: Drupal.t('French', {}, { context: 'TPR Ontologyword details schools' }),
22: Drupal.t('Swedish', {}, { context: 'TPR Ontologyword details schools' }),
23: Drupal.t('German', {}, { context: 'TPR Ontologyword details schools' }),
24: Drupal.t('Finnish', {}, { context: 'TPR Ontologyword details schools' }),
25: Drupal.t('Russian', {}, { context: 'TPR Ontologyword details schools' }),
26: Drupal.t('Estonian', {}, { context: 'TPR Ontologyword details schools' }),
},
a2: {
27: Drupal.t('English', {}, { context: 'TPR Ontologyword details schools' }),
28: Drupal.t('Spanish', {}, { context: 'TPR Ontologyword details schools' }),
29: Drupal.t('Hebrew', {}, { context: 'TPR Ontologyword details schools' }),
30: Drupal.t('Italian', {}, { context: 'TPR Ontologyword details schools' }),
31: Drupal.t('Chinese', {}, { context: 'TPR Ontologyword details schools' }),
32: Drupal.t('Latin', {}, { context: 'TPR Ontologyword details schools' }),
33: Drupal.t('French', {}, { context: 'TPR Ontologyword details schools' }),
34: Drupal.t('Swedish', {}, { context: 'TPR Ontologyword details schools' }),
35: Drupal.t('German', {}, { context: 'TPR Ontologyword details schools' }),
36: Drupal.t('Finnish', {}, { context: 'TPR Ontologyword details schools' }),
37: Drupal.t('Russian', {}, { context: 'TPR Ontologyword details schools' }),
38: Drupal.t('Estonian', {}, { context: 'TPR Ontologyword details schools' }),
},
b1: {
101: Drupal.t('English', {}, { context: 'TPR Ontologyword details schools' }),
102: Drupal.t('Spanish', {}, { context: 'TPR Ontologyword details schools' }),
103: Drupal.t('Hebrew', {}, { context: 'TPR Ontologyword details schools' }),
104: Drupal.t('Italian', {}, { context: 'TPR Ontologyword details schools' }),
105: Drupal.t('Chinese', {}, { context: 'TPR Ontologyword details schools' }),
106: Drupal.t('Latin', {}, { context: 'TPR Ontologyword details schools' }),
107: Drupal.t('French', {}, { context: 'TPR Ontologyword details schools' }),
108: Drupal.t('Swedish', {}, { context: 'TPR Ontologyword details schools' }),
109: Drupal.t('German', {}, { context: 'TPR Ontologyword details schools' }),
110: Drupal.t('Finnish', {}, { context: 'TPR Ontologyword details schools' }),
111: Drupal.t('Russian', {}, { context: 'TPR Ontologyword details schools' }),
112: Drupal.t('Estonian', {}, { context: 'TPR Ontologyword details schools' }),
},
b2: {
113: Drupal.t('English', {}, {context: 'TPR Ontologyword details schools'}),
114: Drupal.t('Spanish', {}, {context: 'TPR Ontologyword details schools'}),
115: Drupal.t('Hebrew', {}, {context: 'TPR Ontologyword details schools'}),
116: Drupal.t('Italian', {}, {context: 'TPR Ontologyword details schools'}),
117: Drupal.t('Chinese', {}, {context: 'TPR Ontologyword details schools'}),
118: Drupal.t('Latin', {}, {context: 'TPR Ontologyword details schools'}),
119: Drupal.t('French', {}, {context: 'TPR Ontologyword details schools'}),
120: Drupal.t('Swedish', {}, {context: 'TPR Ontologyword details schools'}),
121: Drupal.t('German', {}, {context: 'TPR Ontologyword details schools'}),
122: Drupal.t('Finnish', {}, {context: 'TPR Ontologyword details schools'}),
123: Drupal.t('Russian', {}, {context: 'TPR Ontologyword details schools'}),
124: Drupal.t('Estonian', {}, {context: 'TPR Ontologyword details schools'}),
},
bilingualEducation: {
149: Drupal.t('Teaching in English', {}, { context: 'TPR Ontologyword details schools' }),
150: Drupal.t('Teaching in English', {}, { context: 'TPR Ontologyword details schools' }),
293: Drupal.t('Language immersion (English)', {}, { context: 'TPR Ontologyword details schools' }),
295: Drupal.t('Language immersion (Swedish)', {}, { context: 'TPR Ontologyword details schools' }),
297: Drupal.t('Language immersion (German)', {}, { context: 'TPR Ontologyword details schools' }),
904: Drupal.t('Finnish-English', {}, { context: 'TPR Ontologyword details schools' }),
905: Drupal.t('Finnish-Chinese', {}, { context: 'TPR Ontologyword details schools' }),
906: Drupal.t('Finnish-Spanish', {}, { context: 'TPR Ontologyword details schools' }),
907: Drupal.t('Finnish-Northern Sami', {}, { context: 'TPR Ontologyword details schools' }),
908: Drupal.t('Finnish-Estonian', {}, { context: 'TPR Ontologyword details schools' }),
909: Drupal.t('Finnish-Russian', {}, { context: 'TPR Ontologyword details schools' }),
910: Drupal.t('Language-enriched education (Finnish-English)', {}, { context: 'TPR Ontologyword details schools' }),
911: Drupal.t('Language-enriched education (Finnish-Russian)', {}, { context: 'TPR Ontologyword details schools' }),
1041: Drupal.t('Finnish-Swedish', {}, { context: 'TPR Ontologyword details schools' }),
},
};

export default ontologyDetailsIdsToLang;
22 changes: 10 additions & 12 deletions src/js/react/apps/school-search/store.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ export const a1Atom = atom(async (get) => {

// A1 options.
return ontologywordIds?.buckets.reduce((acc: any, currentItem: any) => {
if ((currentItem.key >= 15 && currentItem.key <= 26) && ontologyDetailsIdsToLang[currentItem.key]) {
acc.push({ label: ontologyDetailsIdsToLang[currentItem.key], value: currentItem.key });
if (ontologyDetailsIdsToLang.a1[currentItem.key]) {
acc.push({ label: ontologyDetailsIdsToLang.a1[currentItem.key], value: currentItem.key });
}

return acc;
Expand All @@ -80,8 +80,8 @@ export const a2Atom = atom(async (get) => {

// A2 options.
return ontologywordIds?.buckets.reduce((acc: any, currentItem: any) => {
if ((currentItem.key >= 27 && currentItem.key <= 38) && ontologyDetailsIdsToLang[currentItem.key]) {
acc.push({ label: ontologyDetailsIdsToLang[currentItem.key], value: currentItem.key });
if (ontologyDetailsIdsToLang.a2[currentItem.key]) {
acc.push({ label: ontologyDetailsIdsToLang.a2[currentItem.key], value: currentItem.key });
}
return acc;
}, []);
Expand All @@ -97,8 +97,8 @@ export const b1Atom = atom(async (get) => {

// B1 options.
return ontologywordIds?.buckets.reduce((acc: any, currentItem: any) => {
if ((currentItem.key >= 101 && currentItem.key <= 112) && ontologyDetailsIdsToLang[currentItem.key]) {
acc.push({ label: ontologyDetailsIdsToLang[currentItem.key], value: currentItem.key });
if (ontologyDetailsIdsToLang.b1[currentItem.key]) {
acc.push({ label: ontologyDetailsIdsToLang.b1[currentItem.key], value: currentItem.key });
}
return acc;
}, []);
Expand All @@ -114,8 +114,8 @@ export const b2Atom = atom(async (get) => {

// B2 options.
return ontologywordIds?.buckets.reduce((acc: any, currentItem: any) => {
if ((currentItem.key >= 113 && currentItem.key <= 124) && ontologyDetailsIdsToLang[currentItem.key]) {
acc.push({ label: ontologyDetailsIdsToLang[currentItem.key], value: currentItem.key });
if (ontologyDetailsIdsToLang.b2[currentItem.key]) {
acc.push({ label: ontologyDetailsIdsToLang.b2[currentItem.key], value: currentItem.key });
}
return acc;
}, []);
Expand Down Expand Up @@ -146,10 +146,8 @@ export const bilingualEducationAtom = atom(async (get) => {

// Bilingual education options.
return ontologywordIds?.buckets.reduce((acc: any, currentItem: any) => {
if ((currentItem.key >= 293 && currentItem.key <= 911) || (currentItem.key >= 149 && currentItem.key <= 150) &&
ontologyDetailsIdsToLang[currentItem.key]) {

const label = ontologyDetailsIdsToLang[currentItem.key];
if (ontologyDetailsIdsToLang.bilingualEducation[currentItem.key]) {
const label = ontologyDetailsIdsToLang.bilingualEducation[currentItem.key];

// Deduplicate options.
if (!acc.some((item: any) => item.label === label)) {
Expand Down
13 changes: 13 additions & 0 deletions src/js/react/apps/school-search/types/OntologyDetailsMap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export type OntologyDetailLabels = {
[key: number]: string
}

export type OntologyDetailMap = {
a1: OntologyDetailLabels;
a2: OntologyDetailLabels;
b1: OntologyDetailLabels;
b2: OntologyDetailLabels;
bilingualEducation: OntologyDetailLabels;
};

export default OntologyDetailMap;

0 comments on commit 06f6f3a

Please sign in to comment.