Skip to content

Commit

Permalink
Option to hide individual geofences
Browse files Browse the repository at this point in the history
  • Loading branch information
tananaev committed Dec 29, 2024
1 parent 9f85b7b commit d1fc3ca
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/common/attributes/useGeofenceAttributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ export default (t) => useMemo(() => ({
type: 'number',
subtype: 'distance',
},
hide: {
name: t('sharedFilterMap'),
type: 'boolean',
},
}), [t]);
4 changes: 3 additions & 1 deletion src/map/MapGeofence.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
12 changes: 11 additions & 1 deletion src/settings/GeofencePage.jsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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 }})} />}

Check failure on line 82 in src/settings/GeofencePage.jsx

View workflow job for this annotation

GitHub Actions / build

A space is required before '}'
label={t('sharedFilterMap')}
/>
</AccordionDetails>
</Accordion>
<EditAttributesAccordion
Expand Down

0 comments on commit d1fc3ca

Please sign in to comment.