-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into update-imports
- Loading branch information
Showing
26 changed files
with
1,555 additions
and
293 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 |
---|---|---|
|
@@ -2,3 +2,7 @@ | |
width: 45%; | ||
min-width: 192px; | ||
} | ||
|
||
.filter-row { | ||
margin-bottom: 16px; | ||
} |
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
86 changes: 86 additions & 0 deletions
86
packages/fhir-location-management/src/components/AllLocationListFlat/dataGridFilterRow.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,86 @@ | ||
import { ILocation } from '@smile-cdr/fhirts/dist/FHIR-R4/interfaces/ILocation'; | ||
import { Space, Select } from 'antd'; | ||
import React from 'react'; | ||
import { FilterParamState, PaginatedAsyncSelect } from '@opensrp/react-utils'; | ||
import { locationResourceType } from '@opensrp/fhir-helpers'; | ||
import { useMls } from '.././../mls'; | ||
import { Trans } from '@opensrp/i18n'; | ||
|
||
export interface LocationGridFilterRowRenderProps { | ||
fhirBaseUrl: string; | ||
updateFilterParams: (filter: FilterParamState) => void; | ||
currentFilters: FilterParamState; | ||
} | ||
|
||
const partOfFilterDataIdx = 'partof'; | ||
const statusFilterDataIdx = 'status'; | ||
|
||
export const LocationGridFilterRowRender = (props: LocationGridFilterRowRenderProps) => { | ||
const { t } = useMls(); | ||
const { fhirBaseUrl, updateFilterParams, currentFilters } = props; | ||
return ( | ||
<div className="filter-row" data-testid="filter-row"> | ||
<Space> | ||
<Trans t={t} i18nKey="parentLocationFilter"> | ||
<Space> | ||
Parent Location: | ||
<PaginatedAsyncSelect<ILocation> | ||
allowClear={true} | ||
showSearch={true} | ||
resourceType={locationResourceType} | ||
baseUrl={fhirBaseUrl} | ||
transformOption={(resource) => { | ||
return { | ||
value: resource.id as string, | ||
label: resource.name as string, | ||
ref: resource, | ||
}; | ||
}} | ||
onChange={(value) => { | ||
if (!value) { | ||
updateFilterParams({ [partOfFilterDataIdx]: undefined }); | ||
} else { | ||
updateFilterParams({ | ||
[partOfFilterDataIdx]: { | ||
paramAccessor: 'partof', | ||
rawValue: value, | ||
paramValue: value, | ||
}, | ||
}); | ||
} | ||
}} | ||
/> | ||
</Space> | ||
</Trans> | ||
<Trans t={t} i18nKey="locationStatusFilter"> | ||
<Space> | ||
Status: | ||
<Select | ||
id="location-status-filter" | ||
value={currentFilters['status']?.rawValue ?? '*'} | ||
style={{ width: 120 }} | ||
onChange={(value: string) => { | ||
if (value === '*') { | ||
updateFilterParams({ [statusFilterDataIdx]: undefined }); | ||
return; | ||
} | ||
updateFilterParams({ | ||
[statusFilterDataIdx]: { | ||
paramAccessor: 'status', | ||
rawValue: value, | ||
paramValue: value, | ||
}, | ||
}); | ||
}} | ||
options={[ | ||
{ value: 'active', label: t('Active') }, | ||
{ value: 'inactive', label: t('Inactive') }, | ||
{ value: '*', label: t('Show all') }, | ||
]} | ||
/> | ||
</Space> | ||
</Trans> | ||
</Space> | ||
</div> | ||
); | ||
}; |
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
Oops, something went wrong.