From e194991e78812e3ee3ccbe364541d2e96b63bb28 Mon Sep 17 00:00:00 2001 From: DoiMayank Date: Wed, 2 Oct 2024 00:47:45 +0530 Subject: [PATCH 1/3] Rename everywehre resizableCircle to resizeableCircle --- cypress/integration/circle.spec.js | 16 ++++++++-------- leaflet-geoman.d.ts | 2 +- src/js/Draw/L.PM.Draw.Circle.js | 2 +- src/js/Draw/L.PM.Draw.js | 2 +- src/js/Edit/L.PM.Edit.Circle.js | 2 +- src/js/Edit/L.PM.Edit.js | 2 +- src/js/L.PM.Map.js | 4 ++-- src/js/Mixins/Dragging.js | 4 ++-- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/cypress/integration/circle.spec.js b/cypress/integration/circle.spec.js index 343a501c..64f6a591 100644 --- a/cypress/integration/circle.spec.js +++ b/cypress/integration/circle.spec.js @@ -348,10 +348,10 @@ describe('Draw Circle', () => { }); }); - it('creates circles (non-resizableCircle)', () => { + it('creates circles (non-resizeableCircle)', () => { cy.window().then(({ map }) => { map.pm.setGlobalOptions({ - resizableCircle: false, + resizeableCircle: false, continueDrawing: true, }); }); @@ -373,9 +373,9 @@ describe('Draw Circle', () => { cy.hasCircleLayers(3); }); - it('disable dragging correctly (non-resizableCircle)', () => { + it('disable dragging correctly (non-resizeableCircle)', () => { cy.window().then(({ map }) => { - map.pm.setGlobalOptions({ resizableCircle: false }); + map.pm.setGlobalOptions({ resizeableCircle: false }); }); cy.toolbarButton('circle') @@ -397,9 +397,9 @@ describe('Draw Circle', () => { }); }); - it('deletes no circles by right-click (non-resizableCircle)', () => { + it('deletes no circles by right-click (non-resizeableCircle)', () => { cy.window().then(({ map }) => { - map.pm.setGlobalOptions({ resizableCircle: false }); + map.pm.setGlobalOptions({ resizeableCircle: false }); }); cy.toolbarButton('circle') @@ -421,9 +421,9 @@ describe('Draw Circle', () => { cy.hasCircleLayers(1); }); - it('change color of circleMarker while drawing (non-resizableCircle)', () => { + it('change color of circleMarker while drawing (non-resizeableCircle)', () => { cy.window().then(({ map }) => { - map.pm.setGlobalOptions({ resizableCircle: false }); + map.pm.setGlobalOptions({ resizeableCircle: false }); }); cy.toolbarButton('circle') diff --git a/leaflet-geoman.d.ts b/leaflet-geoman.d.ts index f1fca0f2..f72aff97 100644 --- a/leaflet-geoman.d.ts +++ b/leaflet-geoman.d.ts @@ -1297,7 +1297,7 @@ declare module 'leaflet' { editable?: boolean; /** Enables radius editing while drawing a Circle (default:true). */ - resizableCircle?: boolean; + resizeableCircle?: boolean; /** Enables radius editing while drawing a CircleMarker (default:false). */ resizeableCircleMarker?: boolean; diff --git a/src/js/Draw/L.PM.Draw.Circle.js b/src/js/Draw/L.PM.Draw.Circle.js index 9020cbb1..0fc9aebb 100644 --- a/src/js/Draw/L.PM.Draw.Circle.js +++ b/src/js/Draw/L.PM.Draw.Circle.js @@ -8,7 +8,7 @@ Draw.Circle = Draw.CircleMarker.extend({ this._BaseCircleClass = L.Circle; this._minRadiusOption = 'minRadiusCircle'; this._maxRadiusOption = 'maxRadiusCircle'; - this._editableOption = 'resizableCircle'; + this._editableOption = 'resizeableCircle'; this._defaultRadius = 100; }, _extendingEnable() {}, diff --git a/src/js/Draw/L.PM.Draw.js b/src/js/Draw/L.PM.Draw.js index 1efa1928..20847f24 100644 --- a/src/js/Draw/L.PM.Draw.js +++ b/src/js/Draw/L.PM.Draw.js @@ -28,7 +28,7 @@ const Draw = L.Class.extend({ minRadiusCircleMarker: null, maxRadiusCircleMarker: null, resizeableCircleMarker: false, - resizableCircle: true, + resizeableCircle: true, markerEditable: true, continueDrawing: false, snapSegment: true, diff --git a/src/js/Edit/L.PM.Edit.Circle.js b/src/js/Edit/L.PM.Edit.Circle.js index e68fc704..91dafc38 100644 --- a/src/js/Edit/L.PM.Edit.Circle.js +++ b/src/js/Edit/L.PM.Edit.Circle.js @@ -8,7 +8,7 @@ Edit.Circle = Edit.CircleMarker.extend({ this._minRadiusOption = 'minRadiusCircle'; this._maxRadiusOption = 'maxRadiusCircle'; - this._editableOption = 'resizableCircle'; + this._editableOption = 'resizeableCircle'; // create polygon around the circle border this._updateHiddenPolyCircle(); }, diff --git a/src/js/Edit/L.PM.Edit.js b/src/js/Edit/L.PM.Edit.js index 288aec65..b86a3d7d 100644 --- a/src/js/Edit/L.PM.Edit.js +++ b/src/js/Edit/L.PM.Edit.js @@ -27,7 +27,7 @@ const Edit = L.Class.extend({ addVertexValidation: undefined, moveVertexValidation: undefined, resizeableCircleMarker: false, - resizableCircle: true, + resizeableCircle: true, }, setOptions(options) { L.Util.setOptions(this, options); diff --git a/src/js/L.PM.Map.js b/src/js/L.PM.Map.js index 0871c131..572fecb8 100644 --- a/src/js/L.PM.Map.js +++ b/src/js/L.PM.Map.js @@ -152,8 +152,8 @@ const Map = L.Class.extend({ let reenableCircle = false; if ( this.map.pm.Draw.Circle.enabled() && - !!this.map.pm.Draw.Circle.options.resizableCircle !== - !!options.resizableCircle + !!this.map.pm.Draw.Circle.options.resizeableCircle !== + !!options.resizeableCircle ) { this.map.pm.Draw.Circle.disable(); reenableCircle = true; diff --git a/src/js/Mixins/Dragging.js b/src/js/Mixins/Dragging.js index 630477a8..2d7c4de4 100644 --- a/src/js/Mixins/Dragging.js +++ b/src/js/Mixins/Dragging.js @@ -198,7 +198,7 @@ const DragMixin = { if (this._layer instanceof L.CircleMarker) { let _editableOption = 'resizeableCircleMarker'; if (this._layer instanceof L.Circle) { - _editableOption = 'resizableCircle'; + _editableOption = 'resizeableCircle'; } if (this.options.snappable && !fromLayerSync && !layersToSyncFound) { @@ -369,7 +369,7 @@ const DragMixin = { if ( (this._layer instanceof L.Circle && - this._layer.options.resizableCircle) || + this._layer.options.resizeableCircle) || (this._layer instanceof L.CircleMarker && this._layer.options.resizeableCircleMarker) ) { From e3b808960c3e502600b935c7120d9c648faeacef Mon Sep 17 00:00:00 2001 From: DoiMayank Date: Sun, 13 Oct 2024 21:11:21 +0530 Subject: [PATCH 2/3] Extend event handlers to support custom properties in TypeScript - Created a BaseEventType with source and custom properties. - Extended event-specific types from the base type to ensure consistency. - Updated the _fire method in Events.js to merge custom payload with source. --- leaflet-geoman.d.ts | 9 +++++++-- src/js/Mixins/Events.js | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/leaflet-geoman.d.ts b/leaflet-geoman.d.ts index f72aff97..524e98ab 100644 --- a/leaflet-geoman.d.ts +++ b/leaflet-geoman.d.ts @@ -1776,10 +1776,15 @@ declare module 'leaflet' { /** * ROTATE MODE MAP EVENT HANDLERS */ - export type GlobalRotateModeToggledEventHandler = (e: { + export type BaseEventHandler = (e: { + source: any; + custom?: Record; + }) => void; + + export type GlobalRotateModeToggledEventHandler = BaseEventHandler & { enabled: boolean; map: L.Map; - }) => void; + }; /** * UNION MODE MAP EVENT HANDLERS diff --git a/src/js/Mixins/Events.js b/src/js/Mixins/Events.js index addf5d5d..e05b443c 100644 --- a/src/js/Mixins/Events.js +++ b/src/js/Mixins/Events.js @@ -1,4 +1,4 @@ -import merge from 'lodash/merge'; +// import merge from 'lodash/merge'; const EventMixin = { // Draw Events @@ -698,7 +698,7 @@ const EventMixin = { // private (very private) fire function __fire(fireLayer, type, payload, source, customPayload = {}) { - payload = merge(payload, customPayload, { source }); + payload = { ...payload, ...customPayload, source }; L.PM.Utils._fireEvent(fireLayer, type, payload); }, }; From d0ad0ce1754bd8d0b8a34785c4cd5b515bec8c93 Mon Sep 17 00:00:00 2001 From: DoiMayank Date: Sun, 13 Oct 2024 21:17:29 +0530 Subject: [PATCH 3/3] Extend event handlers to support custom properties in TypeScript --- src/js/Mixins/Events.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/Mixins/Events.js b/src/js/Mixins/Events.js index e05b443c..15cef29f 100644 --- a/src/js/Mixins/Events.js +++ b/src/js/Mixins/Events.js @@ -1,4 +1,4 @@ -// import merge from 'lodash/merge'; +import merge from 'lodash/merge'; const EventMixin = { // Draw Events @@ -698,7 +698,7 @@ const EventMixin = { // private (very private) fire function __fire(fireLayer, type, payload, source, customPayload = {}) { - payload = { ...payload, ...customPayload, source }; + payload = merge({}, payload, customPayload, { source }); L.PM.Utils._fireEvent(fireLayer, type, payload); }, };