Skip to content

Commit

Permalink
fix: project creation draw and max boundary area (#1157)
Browse files Browse the repository at this point in the history
* fix uploadArea: areaValidation for fileUpload, draw hide if selectionType uploadFile, draw available if AOI reset

* fix stepSwitcher: remove cursor-pointer on step hover

* fix projctDetails: link to setting ODK server placed on Here text
  • Loading branch information
NSUWAL123 authored Feb 1, 2024
1 parent 5ef1914 commit f0ea999
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const VectorLayer = ({
getTaskStatusStyle,
layerProperties,
rotation,
getAOIArea,
}) => {
const [vectorLayer, setVectorLayer] = useState(null);
useEffect(() => () => map && vectorLayer && map.removeLayer(vectorLayer), [map, vectorLayer]);
Expand Down Expand Up @@ -135,6 +136,7 @@ const VectorLayer = ({
});
map.addInteraction(draw);
return () => {
map.removeInteraction(draw);
// map.removeInteraction(snap);
};
}, [map, vectorLayer, onDraw]);
Expand Down Expand Up @@ -299,6 +301,13 @@ const VectorLayer = ({
}
}, [rotation, map, geojson]);

useEffect(() => {
if (!vectorLayer || !getAOIArea) return;
const geometry = vectorLayer.getSource().getFeatures()?.[0].getGeometry();
const area = formatArea(geometry);
getAOIArea(area);
}, [vectorLayer, getAOIArea]);

// ROTATE MAP ACCORDING TO ORIENTATION
// useEffect(() => {
// if (!map) return;
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/components/common/StepSwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const StepSwitcher = ({ data, flag, switchSteps }) => {
<div
className={`${
currentStep.step === index ? 'currentstep-pointer' : ''
} lg:fmtm-w-7 lg:fmtm-h-7 xl:fmtm-w-9 xl:fmtm-h-9 fmtm-rounded-full fmtm-flex fmtm-justify-center fmtm-items-center fmtm-border-[0.15rem] fmtm-border-primaryRed hover:fmtm-cursor-pointer ${
} lg:fmtm-w-7 lg:fmtm-h-7 xl:fmtm-w-9 xl:fmtm-h-9 fmtm-rounded-full fmtm-flex fmtm-justify-center fmtm-items-center fmtm-border-[0.15rem] fmtm-border-primaryRed ${
currentStep.step >= index ? 'fmtm-bg-primaryRed' : 'fmtm-bg-transparent'
}`}
onClick={() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,17 @@ const ProjectDetailsForm = ({ flag }) => {
information about your project.
</span>
<span>To complete the first step, you will need the login credentials of ODK Central Server.</span>{' '}
<div className="fmtm-flex fmtm-flex-col">
<span>
Here are the instructions for setting up a Central ODK Server on Digital Ocean, if you haven’t already.
</span>
<div>
<a
href="https://docs.getodk.org/central-install-digital-ocean/"
className="fmtm-text-blue-600 hover:fmtm-text-blue-700 fmtm-cursor-pointer fmtm-underline"
className="fmtm-text-blue-600 hover:fmtm-text-blue-700 fmtm-cursor-pointer fmtm-w-fit"
target="_"
>
https://docs.getodk.org/central-install-digital-ocean/
Here{' '}
</a>
<span>
are the instructions for setting up a Central ODK Server on Digital Ocean, if you haven’t already.
</span>
</div>
</div>
</div>
Expand Down
20 changes: 13 additions & 7 deletions src/frontend/src/components/createnewproject/UploadArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -297,20 +297,26 @@ const UploadArea = ({ flag, geojsonFile, setGeojsonFile, setCustomLineUpload, se
<NewDefineAreaMap
drawToggle={drawToggle}
uploadedOrDrawnGeojsonFile={drawnGeojson}
onDraw={(geojson, area) => {
handleCustomChange('drawnGeojson', geojson);
dispatch(CreateProjectActions.SetDrawnGeojson(JSON.parse(geojson)));
dispatch(CreateProjectActions.SetTotalAreaSelection(area));
setGeojsonFile(null);
}}
onDraw={
drawnGeojson || uploadAreaSelection === 'upload_file'
? null
: (geojson, area) => {
handleCustomChange('drawnGeojson', geojson);
dispatch(CreateProjectActions.SetDrawnGeojson(JSON.parse(geojson)));
dispatch(CreateProjectActions.SetTotalAreaSelection(area));
setGeojsonFile(null);
}
}
onModify={(geojson, area) => {
handleCustomChange('drawnGeojson', geojson);
dispatch(CreateProjectActions.SetDrawnGeojson(JSON.parse(geojson)));
dispatch(CreateProjectActions.SetTotalAreaSelection(area));
dispatch(CreateProjectActions.ClearProjectStepState(formValues));
setCustomLineUpload(null);
setCustomPolygonUpload(null);
setGeojsonFile(null);
}}
getAOIArea={(area) => {
dispatch(CreateProjectActions.SetTotalAreaSelection(area));
}}
/>
</div>
Expand Down
5 changes: 4 additions & 1 deletion src/frontend/src/views/NewDefineAreaMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ type NewDefineAreaMapProps = {
uploadedOrDrawnGeojsonFile: GeoJSONFeatureTypes;
buildingExtractedGeojson?: GeoJSONFeatureTypes;
lineExtractedGeojson?: GeoJSONFeatureTypes;
onDraw?: (geojson: any, area: number) => void;
onDraw?: ((geojson: any, area: number) => void) | null;
onModify?: ((geojson: any, area?: number) => void) | null;
hasEditUndo?: boolean;
getAOIArea?: ((area?: number) => void) | null;
};
const NewDefineAreaMap = ({
drawToggle,
Expand All @@ -25,6 +26,7 @@ const NewDefineAreaMap = ({
onDraw,
onModify,
hasEditUndo,
getAOIArea,
}: NewDefineAreaMapProps) => {
const { mapRef, map } = useOLMap({
// center: fromLonLat([85.3, 27.7]),
Expand Down Expand Up @@ -71,6 +73,7 @@ const NewDefineAreaMap = ({
onDraw={onDraw}
onModify={onModify}
zoomToLayer
getAOIArea={getAOIArea}
/>
)}

Expand Down

0 comments on commit f0ea999

Please sign in to comment.