-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
141 additions
and
7 deletions.
There are no files selected for viewing
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
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,25 @@ | ||
import { ColumnFilterValue } from 'src/components/SearchBar/types'; | ||
import { SearchBarColumn } from 'src/components/SearchBar/SearchBarColumn'; | ||
import { S } from './styles'; | ||
import { FilterDropdownProps } from 'antd/lib/table/interface'; | ||
|
||
interface Props extends FilterDropdownProps { | ||
filter: ColumnFilterValue; | ||
onChange: (value: ColumnFilterValue['value'], key: string) => void; | ||
} | ||
|
||
export function TableFilter(props: Props) { | ||
const { filter, onChange, close } = props; | ||
|
||
return ( | ||
<S.Filter> | ||
<SearchBarColumn | ||
columnFilterValue={filter} | ||
onChange={(value, key) => { | ||
onChange(value, key); | ||
close(); | ||
}} | ||
/> | ||
</S.Filter> | ||
); | ||
} |
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,38 @@ | ||
import styled from 'styled-components'; | ||
|
||
export const S = { | ||
Filter: styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
padding: 8px; | ||
border-radius: 8px; | ||
box-shadow: | ||
0px 6px 16px 0px ${({ theme }) => theme.neutral.dividers}, | ||
0px 3px 6px -4px ${({ theme }) => theme.neutral.border}, | ||
0px 9px 28px 8px ${({ theme }) => theme.neutral.background}; | ||
min-width: 240px; | ||
.ant-input-search, | ||
.ant-picker, | ||
.react-select__control { | ||
width: 100%; | ||
} | ||
.react-select__menu { | ||
position: static; | ||
} | ||
.react-select__menu { | ||
box-shadow: none; | ||
padding: 8px 4px 4px; | ||
margin: 8px -8px -8px; | ||
border-top: 1px solid ${({ theme }) => theme.neutral.dividers}; | ||
border-radius: 0; | ||
width: auto; | ||
} | ||
.react-select__menu-list { | ||
padding: 0; | ||
} | ||
`, | ||
}; |
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,35 @@ | ||
import { Bundle, Resource } from 'fhir/r4b'; | ||
import { ColumnsType, ColumnType } from 'antd/lib/table'; | ||
import { ColumnFilterValue } from 'src/components/SearchBar/types'; | ||
import { TableFilter } from './TableFilter'; | ||
import { FilterDropdownProps } from 'antd/lib/table/interface'; | ||
import _ from 'lodash'; | ||
|
||
export type RecordType<R extends Resource> = { resource: R; bundle: Bundle }; | ||
|
||
interface Props<R extends Resource> { | ||
tableColumns: ColumnsType<RecordType<R>>; | ||
filters: ColumnFilterValue[]; | ||
onChange: (value: ColumnFilterValue['value'], key: string) => void; | ||
} | ||
|
||
export function populateTableColumnsWithFiltersAndSorts<R extends Resource>( | ||
props: Props<R>, | ||
): ColumnsType<RecordType<R>> { | ||
const { tableColumns, filters, onChange } = props; | ||
const result = tableColumns.map((column) => { | ||
const filter = filters.find((f) => f.column.id === column.key); | ||
|
||
const updatedColumn: ColumnType<RecordType<R>> = { | ||
...column, | ||
filtered: !_.isUndefined(filter?.value) && !_.isNull(filter?.value) && filter?.value === '', | ||
filterDropdown: filter | ||
? (props: FilterDropdownProps) => <TableFilter {...props} filter={filter} onChange={onChange} /> | ||
: undefined, | ||
}; | ||
|
||
return updatedColumn; | ||
}); | ||
|
||
return result; | ||
} |
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