Skip to content

Commit 705e51f

Browse files
committed
feat: Reports change from Select to AutoComplete where appropriate
1 parent 81ed0e3 commit 705e51f

File tree

2 files changed

+28
-22
lines changed

2 files changed

+28
-22
lines changed

modern/src/main/MainToolbar.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ const MainToolbar = ({
136136
<Autocomplete
137137
multiple
138138
limitTags={1}
139+
size="small"
139140
options={Object.values(groups).sort((a, b) => a.name.localeCompare(b.name))}
140141
getOptionLabel={(option) => option.name}
141142
value={filter.groups.map(id => groups[id])}

modern/src/reports/components/ReportFilter.jsx

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useState } from 'react';
22
import {
3-
FormControl, InputLabel, Select, MenuItem, Button, TextField, Typography,
3+
FormControl, InputLabel, Select, MenuItem, Button, TextField, Typography, Autocomplete
44
} from '@mui/material';
55
import { useDispatch, useSelector } from 'react-redux';
66
import dayjs from 'dayjs';
@@ -93,34 +93,39 @@ const ReportFilter = ({ children, handleSubmit, handleSchedule, showOnly, ignore
9393
{!ignoreDevice && (
9494
<div className={classes.filterItem}>
9595
<FormControl fullWidth>
96-
<InputLabel>{t(multiDevice ? 'deviceTitle' : 'reportDevice')}</InputLabel>
97-
<Select
98-
label={t(multiDevice ? 'deviceTitle' : 'reportDevice')}
99-
value={multiDevice ? deviceIds : deviceId || ''}
100-
onChange={(e) => dispatch(multiDevice ? devicesActions.selectIds(e.target.value) : devicesActions.selectId(e.target.value))}
96+
<Autocomplete
10197
multiple={multiDevice}
102-
>
103-
{Object.values(devices).sort((a, b) => a.name.localeCompare(b.name)).map((device) => (
104-
<MenuItem key={device.id} value={device.id}>{device.name}</MenuItem>
105-
))}
106-
</Select>
98+
limitTags={1}
99+
disableClearable
100+
size="small"
101+
options={Object.values(devices).sort((a, b) => a.name.localeCompare(b.name))}
102+
getOptionLabel={(option) => option?.name ?? ''}
103+
value={multiDevice ? deviceIds.map(did => devices[did]) : devices[deviceId] || ''}
104+
onChange={(event, newValue) => {
105+
console.log(newValue);
106+
dispatch(multiDevice ? devicesActions.selectIds(newValue.map(device => device.id)) : devicesActions.selectId(newValue?.id ?? null))
107+
}}
108+
renderInput={(params) => <TextField {...params} label={t(multiDevice ? 'deviceTitle' : 'reportDevice')} />}
109+
/>
107110
</FormControl>
108111
</div>
109112
)}
110113
{includeGroups && (
111114
<div className={classes.filterItem}>
112115
<FormControl fullWidth>
113-
<InputLabel>{t('settingsGroups')}</InputLabel>
114-
<Select
115-
label={t('settingsGroups')}
116-
value={groupIds}
117-
onChange={(e) => dispatch(reportsActions.updateGroupIds(e.target.value))}
118-
multiple
119-
>
120-
{Object.values(groups).sort((a, b) => a.name.localeCompare(b.name)).map((group) => (
121-
<MenuItem key={group.id} value={group.id}>{group.name}</MenuItem>
122-
))}
123-
</Select>
116+
<Autocomplete
117+
multiple
118+
limitTags={1}
119+
disableClearable
120+
size="small"
121+
options={Object.values(groups).sort((a, b) => a.name.localeCompare(b.name))}
122+
getOptionLabel={(option) => option?.name ?? ''}
123+
value={groupIds.map(gid => groups[gid])}
124+
onChange={(event, newValue) => {
125+
dispatch(reportsActions.updateGroupIds(newValue.map(group => group.id)))
126+
}}
127+
renderInput={(params) => <TextField {...params} label={t('settingsGroups')} />}
128+
/>
124129
</FormControl>
125130
</div>
126131
)}

0 commit comments

Comments
 (0)