diff --git a/src/pages/upload/MapPreview.tsx b/src/pages/upload/MapPreview.tsx index ef62406..510920c 100644 --- a/src/pages/upload/MapPreview.tsx +++ b/src/pages/upload/MapPreview.tsx @@ -27,6 +27,7 @@ export const MapPreview: React.FC<{ fetchCache: FetchCache | undefined; bboxFromOsmPatch: Bbox | undefined; setFocusedFeatureId(id: string | number): void; + removeFeatureFromPatch(id: string | number): Promise; moveNode: | ((feature: OsmPatchFeature, lat: number, lng: number) => void) | false; @@ -36,6 +37,7 @@ export const MapPreview: React.FC<{ fetchCache, bboxFromOsmPatch, setFocusedFeatureId, + removeFeatureFromPatch, moveNode, }) => { const allowEdit = !!moveNode; @@ -104,6 +106,15 @@ export const MapPreview: React.FC<{ click: () => setFocusedFeatureId(feature.id!), dragstart: () => setFocusedFeatureId(feature.id!), dragend: (event) => onDragEnd(event, feature), + dblclick: async () => { + if ( + // this is not for end users, so the UX can be a bit crude + // eslint-disable-next-line no-restricted-globals, no-alert + confirm('u want to remove this feature from the diff?') + ) { + await removeFeatureFromPatch(feature.id!); + } + }, }} draggable={allowEdit && !feature.properties.__action} /> diff --git a/src/pages/upload/Upload.tsx b/src/pages/upload/Upload.tsx index 105f6d9..73213a4 100644 --- a/src/pages/upload/Upload.tsx +++ b/src/pages/upload/Upload.tsx @@ -89,6 +89,13 @@ const UploadInner: React.FC = () => { } } + async function removeFeatureFromPatch(id: string) { + await rebuildOsmChange({ + ...osmPatch!, + features: osmPatch!.features.filter((feature) => feature.id !== id), + }); + } + async function onFileUpload(files: FileList | null) { if (!files?.length) { // the user unselected the current file, so reset @@ -313,6 +320,7 @@ const UploadInner: React.FC = () => { osmPatch={osmPatch} bboxFromOsmPatch={bboxFromOsmPatch} setFocusedFeatureId={setFocusedFeatureId} + removeFeatureFromPatch={removeFeatureFromPatch} moveNode={allowEdit && moveNode} /> @@ -321,6 +329,7 @@ const UploadInner: React.FC = () => { ) : ( Select a feature to view more details diff --git a/src/pages/upload/components/DiffForFeature.tsx b/src/pages/upload/components/DiffForFeature.tsx index 32b0d0d..cbce41c 100644 --- a/src/pages/upload/components/DiffForFeature.tsx +++ b/src/pages/upload/components/DiffForFeature.tsx @@ -15,7 +15,8 @@ const EMPTY_CELL =  ; export const DiffForFeature: React.FC<{ feature: OsmPatchFeature; original: OsmFeature | undefined; -}> = ({ feature, original }) => { + removeFeatureFromPatch(id: string | number): Promise; +}> = ({ feature, original, removeFeatureFromPatch }) => { const tag2link = useTag2link(); const { user: me } = useContext(AuthContext); @@ -42,7 +43,14 @@ export const DiffForFeature: React.FC<{
{action ? ( <> - {type} {id} – + {type} {id} –{' '} + {' '} + ) : ( <>🆕 {feature.id}