Skip to content

Commit dded2b3

Browse files
committed
[DOP-22569] Add filter by Dataset.location_type
1 parent 4fd4d57 commit dded2b3

File tree

4 files changed

+54
-26
lines changed

4 files changed

+54
-26
lines changed

src/components/dataset/DatasetRaList.tsx

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,20 @@
11
import { ReactElement } from "react";
2-
import {
3-
List,
4-
TextField,
5-
DatagridConfigurable,
6-
SearchInput,
7-
minLength,
8-
useTranslate,
9-
} from "react-admin";
2+
import { List, TextField, DatagridConfigurable } from "react-admin";
103
import { ListActions } from "@/components/base";
114
import {
125
LocationRaNameWithLinkField,
136
LocationRaTypeWithIconField,
147
} from "@/components/location";
8+
import DatasetRaListFilters from "./DatasetRaListFilters";
159

1610
const DatasetRaList = (): ReactElement => {
17-
const translate = useTranslate();
18-
19-
const datasetFilters = [
20-
<SearchInput
21-
key="search_query"
22-
source="search_query"
23-
alwaysOn
24-
validate={minLength(3)}
25-
placeholder={translate(
26-
"resources.datasets.filters.search_query.placeholder",
27-
)}
28-
/>,
29-
];
30-
3111
return (
3212
<List
33-
actions={<ListActions />}
34-
filters={datasetFilters}
13+
actions={
14+
<ListActions>
15+
<DatasetRaListFilters />
16+
</ListActions>
17+
}
3518
resource="datasets"
3619
storeKey={false}
3720
>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { FilterLiveForm, minLength } from "react-admin";
2+
3+
import { Box, InputAdornment } from "@mui/material";
4+
import SearchIcon from "@mui/icons-material/Search";
5+
import { TextInput } from "react-admin";
6+
import { LocationRaTypeFilter } from "@/components/location";
7+
8+
const DatasetRaListFilters = () => {
9+
return (
10+
<FilterLiveForm>
11+
<Box display="flex" alignItems="flex-end">
12+
<Box component="span" mr={2} sx={{ flex: "0.2" }}>
13+
<LocationRaTypeFilter />
14+
</Box>
15+
16+
<Box component="span" mr={2} sx={{ flex: "0.3 1 1" }}>
17+
{/* Not using SearchInput here because it doesn't match styles with other filters */}
18+
<TextInput
19+
source="search_query"
20+
InputProps={{
21+
endAdornment: (
22+
<InputAdornment position="end">
23+
<SearchIcon color="disabled" />
24+
</InputAdornment>
25+
),
26+
}}
27+
validate={minLength(3)}
28+
label="resources.datasets.filters.search_query.label"
29+
helperText="resources.datasets.filters.search_query.helperText"
30+
/>
31+
</Box>
32+
</Box>
33+
</FilterLiveForm>
34+
);
35+
};
36+
37+
export default DatasetRaListFilters;

src/i18n/en.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,13 @@ const customEnglishMessages: TranslationMessages = {
9999
lineage: "Lineage",
100100
},
101101
filters: {
102+
location_type: {
103+
label: "Location Type",
104+
helperText: "Only selected",
105+
},
102106
search_query: {
103107
label: "Search",
104-
placeholder: "Filter by name or address",
108+
helperText: "Filter by name or address",
105109
},
106110
},
107111
},

src/i18n/ru.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,13 @@ const customRussianMessages: TranslationMessages = {
9999
lineage: "Линедж",
100100
},
101101
filters: {
102+
location_type: {
103+
label: "Тип расположения",
104+
helperText: "Только выбранные",
105+
},
102106
search_query: {
103107
label: "Поиск",
104-
placeholder: "Фильтр по имени или адресу",
108+
helperText: "Фильтр по имени или адресу",
105109
},
106110
},
107111
},

0 commit comments

Comments
 (0)