From 8d346c0be07cacb9fe2334a261f06d595f7db347 Mon Sep 17 00:00:00 2001
From: Earlopain <14981592+Earlopain@users.noreply.github.com>
Date: Wed, 2 Apr 2025 15:36:43 +0200
Subject: [PATCH] Add position deletion button to route report
Use this to delete wrong data
---
src/reports/RouteReportPage.jsx | 15 +++++++++++++++
src/reports/common/useReportStyles.js | 6 ++++++
src/settings/components/CollectionActions.jsx | 14 ++++++++------
3 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/src/reports/RouteReportPage.jsx b/src/reports/RouteReportPage.jsx
index db791b43..4b40827f 100644
--- a/src/reports/RouteReportPage.jsx
+++ b/src/reports/RouteReportPage.jsx
@@ -24,6 +24,8 @@ import MapCamera from '../map/MapCamera';
import MapGeofence from '../map/MapGeofence';
import scheduleReport from './common/scheduleReport';
import MapScale from '../map/MapScale';
+import { useRestriction } from '../common/util/permissions';
+import CollectionActions from '../settings/components/CollectionActions';
const RouteReportPage = () => {
const navigate = useNavigate();
@@ -33,6 +35,7 @@ const RouteReportPage = () => {
const positionAttributes = usePositionAttributes(t);
const devices = useSelector((state) => state.devices.items);
+ const readonly = useRestriction('readonly');
const [available, setAvailable] = useState([]);
const [columns, setColumns] = useState(['fixTime', 'latitude', 'longitude', 'speed', 'address']);
@@ -136,6 +139,7 @@ const RouteReportPage = () => {
{t('sharedDevice')}
{columns.map((key) => ({positionAttributes[key]?.name || key}))}
+
@@ -162,6 +166,17 @@ const RouteReportPage = () => {
/>
))}
+
+ {
+ // NOTE: Gets called when an item was removed
+ setItems(items.filter((position) => position.id !== item.id));
+ }}
+ />
+
)) : ()}
diff --git a/src/reports/common/useReportStyles.js b/src/reports/common/useReportStyles.js
index e09c8695..e4ca09e9 100644
--- a/src/reports/common/useReportStyles.js
+++ b/src/reports/common/useReportStyles.js
@@ -46,4 +46,10 @@ export default makeStyles((theme) => ({
flexGrow: 1,
overflow: 'hidden',
},
+ actionCellPadding: {
+ '&.MuiTableCell-body': {
+ paddingTop: 0,
+ paddingBottom: 0,
+ },
+ },
}));
diff --git a/src/settings/components/CollectionActions.jsx b/src/settings/components/CollectionActions.jsx
index 666052d5..88e91c48 100644
--- a/src/settings/components/CollectionActions.jsx
+++ b/src/settings/components/CollectionActions.jsx
@@ -65,7 +65,7 @@ const CollectionActions = ({
))}
{!readonly && (
<>
-
+ {editPath && }
>
)}
@@ -82,11 +82,13 @@ const CollectionActions = ({
))}
{!readonly && (
<>
-
-
-
-
-
+ {editPath && (
+
+
+
+
+
+ )}