Skip to content

Commit 07f041a

Browse files
4818 Copied Submission Map Pin Delete (#1943)
* Added fixes for duplicate * Test fixes * Sonarqube fixes * Remove Console * Remove Console * Added option to unset value propagation --------- Co-authored-by: usingtechnology <39388115+usingtechnology@users.noreply.github.com>
1 parent 8fadfb5 commit 07f041a

5 files changed

Lines changed: 21 additions & 2 deletions

File tree

app/frontend/src/components/designer/FormViewer.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ const viewerOptions = computed(() => {
189189
getFile: getFile,
190190
uploadFile: uploadFile,
191191
},
192+
map: {
193+
allowExistingFeatureChanges: properties.isDuplicate,
194+
},
192195
},
193196
evalContext: {
194197
token: tokenParsed.value,

app/frontend/tests/unit/components/designer/FormViewer.spec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ describe('FormViewer.vue', () => {
289289
props: {
290290
formId: formId,
291291
displayTitle: true,
292+
isDuplicate: false,
292293
},
293294
global: {
294295
provide: {
@@ -313,6 +314,9 @@ describe('FormViewer.vue', () => {
313314
},
314315
// pass in options for custom components to use
315316
componentOptions: {
317+
map: {
318+
allowExistingFeatureChanges: false,
319+
},
316320
simplefile: {
317321
config: appStore.config,
318322
chefsToken: wrapper.vm.getCurrentAuthHeader,

components/src/components/Map/Component.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ export default class Component extends (FieldComponent as any) {
5454

5555
constructor(component, options, data) {
5656
super(component, options, data);
57+
58+
const mapOptions = this.options?.componentOptions?.map;
59+
this.allowExistingFeatureChanges =
60+
mapOptions?.allowExistingFeatureChanges === true;
61+
5762
this.componentID = super.elementInfo().component.id;
5863
}
5964

@@ -108,7 +113,6 @@ export default class Component extends (FieldComponent as any) {
108113

109114
async loadMap() {
110115
this.mapContainer = document.getElementById(`map-${this.componentID}`);
111-
112116
if (!this.mapContainer) {
113117
if (this.mapInitializationAttempts++ < this.maxInitializationAttempts) {
114118
setTimeout(() => this.loadMap(), 200);
@@ -181,6 +185,7 @@ export default class Component extends (FieldComponent as any) {
181185
),
182186
availableBaseLayersCustom,
183187
recenterButton, // Pass recenter button setting to MapService
188+
allowExistingFeatureChanges: this.allowExistingFeatureChanges,
184189
});
185190

186191
// Now explicitly call async initialize outside constructor

components/src/components/Map/editForm/Component.edit.data.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import UseForCopy from '../../Common/UseForCopy';
2+
13
export default {
24
key: 'customData',
35
label: 'Data',
@@ -11,6 +13,7 @@ export default {
1113
tableView: false,
1214
label: 'Text/Images',
1315
},
16+
UseForCopy,
1417
{
1518
type: 'map',
1619
label: 'Default Value',

components/src/components/Map/services/MapService.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ interface MapServiceOptions {
4545
availableBaseLayers?: string[];
4646
availableBaseLayersCustom?: any[];
4747
recenterButton?: boolean; // New option for recenter button
48+
allowExistingFeatureChanges?: boolean;
4849
}
4950

5051
class MapService {
@@ -113,6 +114,7 @@ class MapService {
113114
const { map, drawnItems, drawControl } = await this.initializeMap(
114115
options
115116
);
117+
116118
this.map = map;
117119
this.drawnItems = drawnItems;
118120
this.drawControl = drawControl; // Store the draw control globally
@@ -175,8 +177,10 @@ class MapService {
175177

176178
const form = document.getElementsByClassName('formio')[0];
177179
const isDesigner = form?.classList.contains('formbuilder') ?? false;
180+
const protectExistingFeatures =
181+
!isDesigner && !options.allowExistingFeatureChanges;
178182

179-
if (!isDesigner) {
183+
if (protectExistingFeatures) {
180184
e.layers.eachLayer((layer) => {
181185
const match = this.isDefaultFeature(layer as L.Layer);
182186
if (match) {

0 commit comments

Comments
 (0)