-
Notifications
You must be signed in to change notification settings - Fork 3
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 #920 from City-of-Helsinki/UHF-9530-linked-events-…
…keywords UHF-9576 linked events keywords
- Loading branch information
Showing
13 changed files
with
118 additions
and
9 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
44 changes: 44 additions & 0 deletions
44
src/js/react/apps/linkedevents/components/TopicsFilter.tsx
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,44 @@ | ||
import { Select } from 'hds-react'; | ||
import { useAtomValue, useAtom, useSetAtom } from 'jotai'; | ||
|
||
import { topicsAtom, topicSelectionAtom, updateParamsAtom} from '../store'; | ||
import SearchComponents from '../enum/SearchComponents'; | ||
import ApiKeys from '../enum/ApiKeys'; | ||
|
||
function TopicsFilter() { | ||
const topics = useAtomValue(topicsAtom); | ||
const [topicSelection, setTopicsFilter] = useAtom(topicSelectionAtom); | ||
const updateParams = useSetAtom(updateParamsAtom); | ||
|
||
const onChange = (value: any) => { | ||
setTopicsFilter(value); | ||
updateParams({ [ApiKeys.KEYWORDS]: value.map((topic: any) => topic.value).join(',') }); | ||
}; | ||
|
||
const selectLabel: string = Drupal.t('Event topic', {}, { context: 'React search: topics filter' }); | ||
|
||
return ( | ||
<div className='hdbt-search__filter event-form__filter--topics'> | ||
<Select | ||
className='hdbt-search__dropdown' | ||
clearButtonAriaLabel={Drupal.t('Clear @label selection', {'@label': selectLabel}, { context: 'React search clear selection label' })} | ||
label={selectLabel} | ||
multiselect | ||
// @ts-ignore | ||
options={topics} | ||
value={topicSelection} | ||
id={SearchComponents.TOPICS} | ||
onChange={onChange} | ||
placeholder={Drupal.t('All topics', {}, { context: 'React search: topics filter' })} | ||
selectedItemRemoveButtonAriaLabel={Drupal.t('Remove item', {}, { context: 'React search: remove item aria label' })} | ||
theme={{ | ||
'--focus-outline-color': 'var(--hdbt-color-black)', | ||
'--multiselect-checkbox-background-selected': 'var(--hdbt-color-black)', | ||
'--placeholder-color': 'var(--hdbt-color-black)', | ||
}} | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
export default TopicsFilter; |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export const ApiKeys = { | ||
KEYWORDS: 'keyword_OR', | ||
FREE: 'is_free', | ||
LOCATION: 'location', | ||
PAGESIZE: 'page_size', | ||
|
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
const SearchComponents = { | ||
TOPICS: 'topics', | ||
LOCATION: 'location', | ||
DATE: 'date', | ||
END_DISABLED: 'end_disabled', | ||
|
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,7 @@ | ||
|
||
export type Topic = { | ||
value: string, | ||
label: string | ||
}; | ||
|
||
export default Topic; |
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