Skip to content

Commit

Permalink
Fix/DEV-230 (#697)
Browse files Browse the repository at this point in the history
* PS-339 [FIX] Ensure Form buttons line up (#681)

* ID-4527 [FIX] Adjust custom button to be in line with form fields (#680)

* Adjust custom button to be in line with form fields

* ID-4527 [FIX] Adjust custom button to be in line with form fields

* PS-53 [FIX] Ensure Rich text field is rendered in Drag and drop accordion of Add fields overlay after switching between settings tabs (#682)

* Revert "PS-53 [FIX] Ensure Rich text field is rendered in Drag and drop accor…" (#687)

This reverts commit 51a8ad5.

* DEV-219 [FIX] Add custom width setting for Address field (#685)

* Ensures Map pin is displayed when loading form with the selected address

* remove unnecessary return

* Remove repeated code

---------

Co-authored-by: ysolodka <[email protected]>
  • Loading branch information
armine-fliplet and ysolodka authored Dec 13, 2024
1 parent b203ea7 commit 699becd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
51 changes: 29 additions & 22 deletions js/components/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,6 @@ Fliplet.FormBuilder.field('map', {
this.mapAddressField.change(this.onChange);
},
onChange: function(value) {
if (this.readonly) {
return;
}

if (!value) {
this.mapField.clear();

Expand All @@ -206,8 +202,18 @@ Fliplet.FormBuilder.field('map', {
}

if (this.suggestionSelected && this.lastChosenAutocompleteValue === value.trim()) {
this.value = this.mapField.getTotalAddress();
this.updateAddressSuggestions();
const timeout = this.mapField.getGeocoder() ? 0 : 3000;

setTimeout(() => {
const address = this.mapField.getTotalAddress();

if (address) {
this.value = address;
}

this.updateAddressSuggestions();
this.$emit('_input', this.name, this.value, false, true);
}, timeout);
} else if (this.mapField.checkIfAddressChangedByDragging()) {
this.updateAddressSuggestions();
this.mapField.checkIfAddressChangedByDragging(false);
Expand All @@ -216,6 +222,7 @@ Fliplet.FormBuilder.field('map', {
latLong: `${this.mapField.get().lat}/${this.mapField.get().lng}`
};
this.suggestionSelected = false;
this.$emit('_input', this.name, this.value, false, true);
} else {
if (suggestions.length === 1 && value.trim() !== '') {
if (this.addressSuggestions.length && this.addressSuggestions[0].label === 'Select location on map') {
Expand All @@ -229,9 +236,8 @@ Fliplet.FormBuilder.field('map', {

this.addressSuggestions = suggestions;
this.suggestionSelected = false;
this.$emit('_input', this.name, this.value, false, true);
}

this.$emit('_input', this.name, this.value, false, true);
});
},
onReset: function() {
Expand Down Expand Up @@ -261,24 +267,25 @@ Fliplet.FormBuilder.field('map', {

if (val.address && val.address.label) {
val = {
address: val.address.label
address: val.address.label,
latLong: null
};
}

if (val.address && !this.suggestionSelected && !this.lastChosenAutocompleteValue && !this.readonly) {
if (val.latLong) {
this.mapAddressField.set(val.address);
this.mapField.set(val.address);
} else {
this.mapAddressField.set(val.address);
}

this.suggestionSelected = true;
this.lastChosenAutocompleteValue = val.address;
this.addressSuggestions = [];
this.isSelectOnMapClicked = true;
if (val.address && !this.suggestionSelected && !this.lastChosenAutocompleteValue) {
setTimeout(() => {
if (val.latLong) {
this.mapAddressField.set(val.address);
this.mapField.set(val.address);
} else {
this.mapAddressField.set(val.address);
}

return;
this.suggestionSelected = true;
this.lastChosenAutocompleteValue = val.address;
this.addressSuggestions = [];
this.isSelectOnMapClicked = true;
}, 1000);
}

if (val.address === '' && !this.readonly && !this.autoCollectUserLocation) {
Expand Down
7 changes: 0 additions & 7 deletions js/libs/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -585,13 +585,6 @@ Fliplet().then(function() {
}
}

if (field._type === 'flMap') {
field.value = progress[field.name] || {
address: '',
latLong: null
};
}

setTimeout(function() {
if (progress && !isEditMode) {
var savedValue = progress[field.name];
Expand Down

0 comments on commit 699becd

Please sign in to comment.