Skip to content

Commit

Permalink
Remove parent location filter from the service point list view (#1487)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterMuriuki authored Oct 22, 2024
1 parent bf6dad9 commit dcc3093
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export interface Props {
getColumns: (t: TFunction, getColumnSortProps: GetControlledSortProps) => Column<Dictionary>[];
pageTitle: string;
addLocationBtnRender: () => ReactNode;
showParentLocationFilter?: boolean;
}

const getSearchParamsFactory = (ourParams: URLParams) => (search: string | null) => {
Expand Down Expand Up @@ -138,6 +139,7 @@ export const BaseAllLocationListFlat: React.FC<BaseAllLocationListFlatProps> = (
fhirBaseUrl={fhirBaseURL}
updateFilterParams={updateFilterParams}
currentFilters={currentFilters}
showParentLocationFilter={props.showParentLocationFilter ?? true}
/>
<TableLayout {...tableProps} />
</Col>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,48 +10,51 @@ export interface LocationGridFilterRowRenderProps {
fhirBaseUrl: string;
updateFilterParams: (filter: FilterParamState) => void;
currentFilters: FilterParamState;
showParentLocationFilter: boolean;
}

const partOfFilterDataIdx = 'partof';
const statusFilterDataIdx = 'status';

export const LocationGridFilterRowRender = (props: LocationGridFilterRowRenderProps) => {
const { t } = useMls();
const { fhirBaseUrl, updateFilterParams, currentFilters } = props;
const { fhirBaseUrl, updateFilterParams, currentFilters, showParentLocationFilter } = 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>
{showParentLocationFilter && (
<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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export const EusmLocationListFlat: React.FC<EusmLocationListFlatProps> = (props)
addLocationBtnRender,
getColumns,
extraParamFilters: eusmPhysicalLocationsFilterParams,
showParentLocationFilter: false,
};

return <BaseAllLocationListFlat {...baseProps} />;
Expand Down

0 comments on commit dcc3093

Please sign in to comment.