Skip to content

Commit

Permalink
add disableEdit prop to MapPreview, rename disableEdit to disableDraw…
Browse files Browse the repository at this point in the history
… so we can allow edit specifically to be disabled
  • Loading branch information
Ben Adams authored and Ben Adams committed Nov 7, 2023
1 parent 63afb75 commit 8c414ec
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/components/MapPreview/MapPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const MapPreview = ({
mapRef,
useMapEffect,
disableDraw = true,
disableEdit = false,
drawControlOptions,
onDrawCreated,
onDrawEdited,
Expand Down Expand Up @@ -180,7 +181,8 @@ const MapPreview = ({
<figure className="map-preview">
<Map {...mapSettings}>
<MapPreviewDraw
disableEditControls={disableDraw}
disableDrawControls={disableDraw}
disableEditControls={disableEdit}
onCreated={handleOnDraw}
onEdited={handleOnEditDraw}
featureRef={featureRef}
Expand Down Expand Up @@ -313,6 +315,7 @@ MapPreview.propTypes = {
useMapEffect: PropTypes.func,
shapeOptions: PropTypes.object,
disableDraw: PropTypes.bool,
disableEdit: PropTypes.bool,
drawControlOptions: PropTypes.object,
onDrawCreated: PropTypes.func,
onDrawEdited: PropTypes.func,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ stories.add(STORY_NAME, () => {
displayAccessRequests={false}
displayAOIDetails={false}
disableDraw={false}
disableEdit={false}
onDrawCreated={handleOnDraw}
onDrawEdited={handleOnEdit}
featureRef={featureRef}
Expand Down
6 changes: 4 additions & 2 deletions src/components/MapPreviewDraw/MapPreviewDraw.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const MapPreviewDraw = ({
forwardedRef,
onCreated,
onEdited,
disableDrawControls = false,
disableEditControls = false,
controlOptions,
shapeOptions,
Expand Down Expand Up @@ -99,15 +100,15 @@ const MapPreviewDraw = ({
return (
<FeatureGroup featureGroup={featureGroup} ref={featureRef}>
{children}
{!disableEditControls && (
{!disableDrawControls && (
<>
<EditControl
position="bottomright"
onCreated={handleOnCreated}
onEdited={handleOnEdited}
draw={drawOptions}
edit={{
edit: true,
edit: !disableEditControls,
remove: false
}}
/>
Expand All @@ -127,6 +128,7 @@ MapPreviewDraw.propTypes = {
forwardedRef: PropTypes.object,
onCreated: PropTypes.func,
onEdited: PropTypes.func,
disableDrawControls: PropTypes.bool,
disableEditControls: PropTypes.bool,
controlOptions: PropTypes.object,
shapeOptions: PropTypes.object,
Expand Down

0 comments on commit 8c414ec

Please sign in to comment.