Option to hide individual geofences

This commit is contained in:
Anton Tananaev 2024-12-29 11:16:09 -08:00
parent 9f85b7b16d
commit d1fc3cafba
3 changed files with 18 additions and 2 deletions

View File

@ -15,4 +15,8 @@ export default (t) => useMemo(() => ({
type: 'number',
subtype: 'distance',
},
hide: {
name: t('sharedFilterMap'),
type: 'boolean',
},
}), [t]);

View File

@ -83,7 +83,9 @@ const MapGeofence = () => {
if (mapGeofences) {
map.getSource(id)?.setData({
type: 'FeatureCollection',
features: Object.values(geofences).map((geofence) => geofenceToFeature(theme, geofence)),
features: Object.values(geofences)
.filter((geofence) => !geofence.attributes.hide)
.map((geofence) => geofenceToFeature(theme, geofence)),
});
}
}, [mapGeofences, geofences]);

View File

@ -1,7 +1,13 @@
import React, { useState } from 'react';
import { useDispatch } from 'react-redux';
import {
Accordion, AccordionSummary, AccordionDetails, Typography, TextField,
Accordion,
AccordionSummary,
AccordionDetails,
Typography,
TextField,
FormControlLabel,
Checkbox,
} from '@mui/material';
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
import EditItemView from './components/EditItemView';
@ -72,6 +78,10 @@ const GeofencePage = () => {
endpoint="/api/calendars"
label={t('sharedCalendar')}
/>
<FormControlLabel
control={<Checkbox checked={item.attributes.hide} onChange={(e) => setItem({ ...item, attributes: { ...item.attributes, hide: e.target.checked }})} />}
label={t('sharedFilterMap')}
/>
</AccordionDetails>
</Accordion>
<EditAttributesAccordion