From 6195f8c15b0ce26763852ab5bb4a4c75a784ea57 Mon Sep 17 00:00:00 2001 From: Collin Beczak <88843144+CollinBeczak@users.noreply.github.com> Date: Wed, 13 Nov 2024 17:25:10 -0600 Subject: [PATCH] add re-select task button in rapid iframe (#2490) * add button to reselect task in tapid iframe --- .../Widgets/TaskMapWidget/Messages.js | 5 +++++ .../TaskMapWidget/RapidEditor/RapidEditor.jsx | 19 ++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/components/Widgets/TaskMapWidget/Messages.js b/src/components/Widgets/TaskMapWidget/Messages.js index 0d184d8f3..dc0d3c5ed 100644 --- a/src/components/Widgets/TaskMapWidget/Messages.js +++ b/src/components/Widgets/TaskMapWidget/Messages.js @@ -23,4 +23,9 @@ export default defineMessages({ id: "Widgets.TaskMapWidget.rapidFailed", defaultMessage: "Widget Failed! Geometries Null!", }, + + reselectTask: { + id: "Widgets.TaskMapWidget.reselectTask", + defaultMessage: "Re-Select Task", + }, }) diff --git a/src/components/Widgets/TaskMapWidget/RapidEditor/RapidEditor.jsx b/src/components/Widgets/TaskMapWidget/RapidEditor/RapidEditor.jsx index a572604f3..5319cb04f 100644 --- a/src/components/Widgets/TaskMapWidget/RapidEditor/RapidEditor.jsx +++ b/src/components/Widgets/TaskMapWidget/RapidEditor/RapidEditor.jsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from 'react'; +import React, { useState, useEffect, useRef } from 'react'; import { useDispatch } from 'react-redux'; import _get from 'lodash/get'; @@ -10,6 +10,8 @@ import WithSearch from '../../../HOCs/WithSearch/WithSearch'; import useHash from '../../../../hooks/UseHash'; import { SET_RAPIDEDITOR } from '../../../../services/RapidEditor/RapidEditor'; import BusySpinner from '../../../BusySpinner/BusySpinner'; +import { FormattedMessage } from 'react-intl'; +import messages from './../Messages'; /** * Generate the initial URL hash for the Rapid editor. @@ -42,6 +44,7 @@ const RapidEditor = ({ token, task, mapBounds, comment }) => { const dispatch = useDispatch(); const [isLoading, setIsLoading] = useState(true); const [error, setError] = useState(null); + const iframeRef = useRef(null); // Create a ref for the iframe let initialHash = generateStartingHash({ task, mapBounds, comment }); let [, setHash] = useHash(); @@ -63,8 +66,21 @@ const RapidEditor = ({ token, task, mapBounds, comment }) => { initialHash += `&token=${token}`; } + const handleResetHash = () => { + if (iframeRef.current) { + iframeRef.current.contentWindow.location.hash = initialHash; + } + }; + return (
+ {isLoading && (
@@ -74,6 +90,7 @@ const RapidEditor = ({ token, task, mapBounds, comment }) => {
Error: {error.message}
)}