Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UHF-9459: new option for school search filter #932

Merged
merged 5 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/js/school-search.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const FeatureFormContainer = () => {
params.b1 = b1Selection.map((selection: OptionType) => selection.value);
params.b2 = b2Selection.map((selection: OptionType) => selection.value);
params.weighted_education = weightedSelection.map((selection: OptionType) => selection.value);
params.bilingual_education = bilingualSelection.map((selection: OptionType) => selection.value);
params.bilingual_education = bilingualSelection.flatMap((selection: OptionType) => selection.value.split(','));

setParams(params);
};
Expand Down
2 changes: 2 additions & 0 deletions src/js/react/apps/school-search/enum/LanguageEducationMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ const ontologyDetailsIdsToLang: any = {
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' }),
Expand Down
52 changes: 32 additions & 20 deletions src/js/react/apps/school-search/store.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,14 @@ export const a1Atom = atom(async (get) => {
return [];
}

const a1options = ontologywordIds?.buckets.reduce((acc: any, currentItem: any) => {
// 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 });
}

return acc;
}, []);

return a1options;
});
export const a1SelectionAtom = atom<OptionType[]>([] as OptionType[]);

Expand All @@ -79,14 +78,13 @@ export const a2Atom = atom(async (get) => {
return [];
}

const a2options = ontologywordIds?.buckets.reduce((acc: any, currentItem: any) => {
// 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 });
}
return acc;
}, []);

return a2options;
});
export const a2SelectionAtom = atom<OptionType[]>([] as OptionType[]);

Expand All @@ -97,14 +95,13 @@ export const b1Atom = atom(async (get) => {
return [];
}

const b1options = ontologywordIds?.buckets.reduce((acc: any, currentItem: any) => {
// 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 });
}
return acc;
}, []);

return b1options;
});
export const b1SelectionAtom = atom<OptionType[]>([] as OptionType[]);

Expand All @@ -115,14 +112,13 @@ export const b2Atom = atom(async (get) => {
return [];
}

const b2options = ontologywordIds?.buckets.reduce((acc: any, currentItem: any) => {
// 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 });
}
return acc;
}, []);

return b2options;
});
export const b2SelectionAtom = atom<OptionType[]>([] as OptionType[]);

Expand All @@ -133,12 +129,11 @@ export const weightedEducationAtom = atom(async (get) => {
return [];
}

const weightedOptions = ontologywordClarifications?.buckets.reduce((acc: any, currentItem: any) => {
// Weighted options.
return ontologywordClarifications?.buckets.reduce((acc: any, currentItem: any) => {
acc.push({ label: currentItem.key, value: currentItem.key });
return acc;
}, []);

return weightedOptions;
});
export const weightedEducationSelectionAtom = atom<OptionType[]>([] as OptionType[]);

Expand All @@ -149,14 +144,31 @@ export const bilingualEducationAtom = atom(async (get) => {
return [];
}

const bilingualOptions = ontologywordIds?.buckets.reduce((acc: any, currentItem: any) => {
if ((currentItem.key >= 293 && currentItem.key <= 911) && ontologyDetailsIdsToLang[currentItem.key]) {
acc.push({ label: ontologyDetailsIdsToLang[currentItem.key], value: currentItem.key });
// 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];

// Deduplicate options.
if (!acc.some((item: any) => item.label === label)) {
const option: OptionType = {
label,
value: currentItem.key,
};

// Combined keys.
if ((currentItem.key >= 149 && currentItem.key <= 150)) {
option.value = '149,150';
}

acc.push(option);
}
}

return acc;
}, []);

return bilingualOptions;
});
export const bilingualEducationSelectionAtom = atom<OptionType[]>([] as OptionType[]);

Expand Down
Loading