diff --git a/src/frontend/src/components/DialogTaskActions.jsx b/src/frontend/src/components/DialogTaskActions.jsx index 6f499d9360..606b67c149 100755 --- a/src/frontend/src/components/DialogTaskActions.jsx +++ b/src/frontend/src/components/DialogTaskActions.jsx @@ -206,13 +206,13 @@ export default function Dialog({ taskId, feature, map, view }) { type="submit" className="fmtm-font-bold !fmtm-rounded fmtm-text-sm !fmtm-py-2 !fmtm-w-full fmtm-flex fmtm-justify-center" onClick={() => { - // XForm name is constructed from lower case project title with underscores - const projectName = projectInfo.title.toLowerCase().split(' ').join('_'); - const projectCategory = projectInfo.xform_category; - const formName = `${projectName}_${projectCategory}`; - document.location.href = `odkcollect://form/${formName}?task_id=${taskId}`; - // TODO add this to each feature popup to pre-load a selected entity - // document.location.href = `odkcollect://form/${formName}?${geomFieldName}=${entityId}`; + const xformId = projectInfo.xform_id; + + try { + document.location.href = `odkcollect://form/${xformId}?task_id=${taskId}`; + } catch (error) { + document.location.href = 'https://play.google.com/store/apps/details?id=org.odk.collect.android'; + } }} /> diff --git a/src/frontend/src/components/ProjectDetailsV2/FeatureSelectionPopup.tsx b/src/frontend/src/components/ProjectDetailsV2/FeatureSelectionPopup.tsx index cf8310f727..ef9f942ad8 100644 --- a/src/frontend/src/components/ProjectDetailsV2/FeatureSelectionPopup.tsx +++ b/src/frontend/src/components/ProjectDetailsV2/FeatureSelectionPopup.tsx @@ -15,10 +15,11 @@ type TaskFeatureSelectionProperties = { }; type TaskFeatureSelectionPopupPropType = { + taskId: number; featureProperties: TaskFeatureSelectionProperties | null; }; -const TaskFeatureSelectionPopup = ({ featureProperties }: TaskFeatureSelectionPopupPropType) => { +const TaskFeatureSelectionPopup = ({ taskId, featureProperties }: TaskFeatureSelectionPopupPropType) => { const dispatch = CoreModules.useAppDispatch(); const taskModalStatus = CoreModules.useAppSelector((state) => state.project.taskModalStatus); const projectInfo = CoreModules.useAppSelector((state) => state.project.projectInfo); @@ -84,19 +85,20 @@ const TaskFeatureSelectionPopup = ({ featureProperties }: TaskFeatureSelectionPo type="submit" className="fmtm-font-bold !fmtm-rounded fmtm-text-sm !fmtm-py-2 !fmtm-w-full fmtm-flex fmtm-justify-center" onClick={() => { - // XForm name is constructed from lower case project title with underscores - const projectName = projectInfo.title.toLowerCase().split(' ').join('_'); - const projectCategory = projectInfo.xform_category; - const formName = `${projectName}_${projectCategory}`; + const xformId = projectInfo.xform_id; const entity = entityOsmMap.find((x) => x.osm_id === featureProperties?.osm_id); const entityUuid = entity ? entity.id : null; - if (!formName || !entityUuid) { + if (!xformId || !entityUuid) { return; } - document.location.href = `odkcollect://form/${formName}?existing=${entityUuid}`; + try { + document.location.href = `odkcollect://form/${xformId}?task_id=${taskId}&existing=${entityUuid}`; + } catch (error) { + document.location.href = 'https://play.google.com/store/apps/details?id=org.odk.collect.android'; + } }} /> diff --git a/src/frontend/src/views/ProjectDetailsV2.tsx b/src/frontend/src/views/ProjectDetailsV2.tsx index 37a449f8b6..0173227bd8 100644 --- a/src/frontend/src/views/ProjectDetailsV2.tsx +++ b/src/frontend/src/views/ProjectDetailsV2.tsx @@ -573,7 +573,9 @@ const Home = () => { } /> )} - {selectedTaskFeature != undefined && } + {selectedTaskFeature != undefined && ( + + )} ); };