From 70d15a4ecd73c894c462a7dd70c79d4a99e113d6 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 23 Apr 2023 08:28:57 -0700 Subject: Geofences position attribute --- modern/src/common/attributes/usePositionAttributes.js | 4 ++++ modern/src/common/components/GeofencesValue.js | 9 +++++++++ modern/src/common/components/PositionValue.js | 6 ++++++ 3 files changed, 19 insertions(+) create mode 100644 modern/src/common/components/GeofencesValue.js (limited to 'modern/src/common') diff --git a/modern/src/common/attributes/usePositionAttributes.js b/modern/src/common/attributes/usePositionAttributes.js index 81497938..90905395 100644 --- a/modern/src/common/attributes/usePositionAttributes.js +++ b/modern/src/common/attributes/usePositionAttributes.js @@ -68,6 +68,10 @@ export default (t) => useMemo(() => ({ type: 'string', property: true, }, + geofenceIds: { + name: t('sharedGeofences'), + property: true, + }, raw: { name: t('positionRaw'), type: 'string', diff --git a/modern/src/common/components/GeofencesValue.js b/modern/src/common/components/GeofencesValue.js new file mode 100644 index 00000000..4808a8a2 --- /dev/null +++ b/modern/src/common/components/GeofencesValue.js @@ -0,0 +1,9 @@ +import { useSelector } from 'react-redux'; + +const GeofencesValue = ({ geofenceIds }) => { + const geofences = useSelector((state) => state.geofences.items); + + return geofenceIds.map((id) => geofences[id]?.name).join(', '); +}; + +export default GeofencesValue; diff --git a/modern/src/common/components/PositionValue.js b/modern/src/common/components/PositionValue.js index a819a018..a6b38e31 100644 --- a/modern/src/common/components/PositionValue.js +++ b/modern/src/common/components/PositionValue.js @@ -9,6 +9,7 @@ import { useAttributePreference, usePreference } from '../util/preferences'; import { useTranslation } from './LocalizationProvider'; import { useAdministrator } from '../util/permissions'; import AddressValue from './AddressValue'; +import GeofencesValue from './GeofencesValue'; const PositionValue = ({ position, property, attribute }) => { const t = useTranslation(); @@ -83,6 +84,11 @@ const PositionValue = ({ position, property, attribute }) => { return ({t('sharedInfoTitle')}); } return ''; + case 'geofenceIds': + if (value) { + return (); + } + return ''; default: return formatValue(value); } -- cgit v1.2.3