Skip to content

Commit

Permalink
Merge pull request #760 from City-of-Helsinki/UHF-8748-add-selections…
Browse files Browse the repository at this point in the history
…-wrapper-common-component

UHF-8748: Add selections wrapper common component
  • Loading branch information
Jussiles authored Sep 5, 2023
2 parents 9c43863 + 3d0fc23 commit 3220b90
Show file tree
Hide file tree
Showing 16 changed files with 185 additions and 322 deletions.
2 changes: 1 addition & 1 deletion dist/css/styles.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/js/district-and-project-search.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/js/job-search.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/js/linkedevents.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/js/news-archive.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/js/school-search.min.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 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
@@ -1,7 +1,7 @@
import { Button, IconCross } from 'hds-react';
import { useAtomValue, useSetAtom } from 'jotai';

import FilterButton from '@/react/common/FilterButton';
import SelectionsWrapper from '@/react/common/SelectionsWrapper';
import SearchComponents from '../enum/SearchComponents';
import transformDropdownsValues from '../helpers/Params';
import { capitalize } from '../helpers/helpers';
Expand Down Expand Up @@ -44,50 +44,36 @@ const SelectionsContainer = () => {
const showProjectTypes = Boolean(urlParams.project_type?.length);

return (
<div className='hdbt-search__selections-wrapper'>
<ul className='hdbt-search__selections-container content-tags__tags'>
{showDistricts && (
<ListFilter
updater={updateDistricts}
valueKey={SearchComponents.DISTRICTS}
values={transformDropdownsValues(urlParams.districts, districtOptions)}
/>
)}
{showProjectThemes && (
<ListFilter
updater={updateThemes}
valueKey={SearchComponents.THEME}
values={transformDropdownsValues(urlParams.project_theme, themeOptions)}
/>
)}
{showProjectPhases && (
<ListFilter
updater={updatePhases}
valueKey={SearchComponents.PHASE}
values={transformDropdownsValues(urlParams.project_phase, phaseOptions)}
/>
)}
{showProjectTypes && (
<ListFilter
updater={updateTypes}
valueKey={SearchComponents.TYPE}
values={transformDropdownsValues(urlParams.project_type, typeOptions)}
/>
)}
<li className='hdbt-search__clear-all'>
<Button
aria-hidden={showClearButton ? 'false' : 'true'}
className='hdbt-search__clear-all-button'
iconLeft={<IconCross className='hdbt-search__clear-all-icon' />}
onClick={resetForm}
style={showClearButton ? {} : { visibility: 'hidden' }}
variant='supplementary'
>
{Drupal.t('Clear selections', {}, { context: 'React search: clear selections' })}
</Button>
</li>
</ul>
</div>
<SelectionsWrapper showClearButton={showClearButton} resetForm={resetForm}>
{showDistricts && (
<ListFilter
updater={updateDistricts}
valueKey={SearchComponents.DISTRICTS}
values={transformDropdownsValues(urlParams.districts, districtOptions)}
/>
)}
{showProjectThemes && (
<ListFilter
updater={updateThemes}
valueKey={SearchComponents.THEME}
values={transformDropdownsValues(urlParams.project_theme, themeOptions)}
/>
)}
{showProjectPhases && (
<ListFilter
updater={updatePhases}
valueKey={SearchComponents.PHASE}
values={transformDropdownsValues(urlParams.project_phase, phaseOptions)}
/>
)}
{showProjectTypes && (
<ListFilter
updater={updateTypes}
valueKey={SearchComponents.TYPE}
values={transformDropdownsValues(urlParams.project_type, typeOptions)}
/>
)}
</SelectionsWrapper>
);
};

Expand Down
118 changes: 52 additions & 66 deletions src/js/react/apps/job-search/containers/SelectionsContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Button, IconCross } from 'hds-react';
import { useAtomValue, useSetAtom } from 'jotai';

import SelectionsWrapper from '@/react/common/SelectionsWrapper';
import FilterButton from '@/react/common/FilterButton';
import SearchComponents from '../enum/SearchComponents';
import { getLanguageLabel } from '../helpers/Language';
Expand Down Expand Up @@ -42,71 +42,57 @@ const SelectionsContainer = () => {
const showEmployment = Boolean(urlParams.employment?.length && urlParams.employment?.length > 0);

return (
<div className='job-search-form__selections-wrapper'>
<ul className='job-search-form__selections-container content-tags__tags'>
{showTaskAreas && (
<ListFilter
updater={updateTaskAreas}
valueKey={SearchComponents.TASK_AREAS}
values={transformDropdownsValues(urlParams.task_areas, taskAreaOptions)}
/>
)}
{showEmployment && (
<ListFilter
updater={updateEmploymentOptions}
valueKey={SearchComponents.EMPLOYMENT}
values={transformDropdownsValues(urlParams.employment, employmentOptions)}
/>
)}
{urlParams.language && (
<SingleFilter
label={getLanguageLabel(urlParams.language)}
atom={languageSelectionAtom}
valueKey={SearchComponents.LANGUAGE}
/>
)}
{urlParams.continuous && (
<CheckboxFilterPill
label={Drupal.t('Open-ended vacancies', {}, { context: 'Job search' })}
atom={continuousAtom}
valueKey={SearchComponents.CONTINUOUS}
/>
)}
{urlParams.internship && (
<CheckboxFilterPill
label={Drupal.t('Practical training', {}, { context: 'Job search' })}
atom={internshipAtom}
valueKey={SearchComponents.INTERNSHIPS}
/>
)}
{urlParams.summer_jobs && (
<CheckboxFilterPill
label={Drupal.t('Summer jobs', {}, { context: 'Job search' })}
atom={summerJobsAtom}
valueKey={SearchComponents.SUMMER_JOBS}
/>
)}
{urlParams.youth_summer_jobs && (
<CheckboxFilterPill
label={Drupal.t('Summer jobs for young people', {}, { context: 'Job search' })}
atom={youthSummerJobsAtom}
valueKey={SearchComponents.YOUTH_SUMMER_JOBS}
/>
)}
<li className='job-search-form__clear-all'>
<Button
aria-hidden={showClearButton ? 'false' : 'true'}
className='job-search-form__clear-all-button'
iconLeft={<IconCross className='job-search-form__clear-all-icon' />}
onClick={resetForm}
style={showClearButton ? {} : { visibility: 'hidden' }}
variant='supplementary'
>
{Drupal.t('Clear selections', {}, { context: 'Job search clear selections' })}
</Button>
</li>
</ul>
</div>
<SelectionsWrapper showClearButton={showClearButton} resetForm={resetForm}>
{showTaskAreas && (
<ListFilter
updater={updateTaskAreas}
valueKey={SearchComponents.TASK_AREAS}
values={transformDropdownsValues(urlParams.task_areas, taskAreaOptions)}
/>
)}
{showEmployment && (
<ListFilter
updater={updateEmploymentOptions}
valueKey={SearchComponents.EMPLOYMENT}
values={transformDropdownsValues(urlParams.employment, employmentOptions)}
/>
)}
{urlParams.language && (
<SingleFilter
label={getLanguageLabel(urlParams.language)}
atom={languageSelectionAtom}
valueKey={SearchComponents.LANGUAGE}
/>
)}
{urlParams.continuous && (
<CheckboxFilterPill
label={Drupal.t('Open-ended vacancies', {}, { context: 'Job search' })}
atom={continuousAtom}
valueKey={SearchComponents.CONTINUOUS}
/>
)}
{urlParams.internship && (
<CheckboxFilterPill
label={Drupal.t('Practical training', {}, { context: 'Job search' })}
atom={internshipAtom}
valueKey={SearchComponents.INTERNSHIPS}
/>
)}
{urlParams.summer_jobs && (
<CheckboxFilterPill
label={Drupal.t('Summer jobs', {}, { context: 'Job search' })}
atom={summerJobsAtom}
valueKey={SearchComponents.SUMMER_JOBS}
/>
)}
{urlParams.youth_summer_jobs && (
<CheckboxFilterPill
label={Drupal.t('Summer jobs for young people', {}, { context: 'Job search' })}
atom={youthSummerJobsAtom}
valueKey={SearchComponents.YOUTH_SUMMER_JOBS}
/>
)}
</SelectionsWrapper>
);
};

Expand Down
Loading

0 comments on commit 3220b90

Please sign in to comment.