Skip to content

Commit f0e22c3

Browse files
author
Luke Edwards
committed
BUG Fix changes being detected on value initialisation
1 parent a8e3683 commit f0e22c3

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

client/js/GoogleMapField.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,22 @@
4444

4545
latField.val(latCoord);
4646
lngField.val(lngCoord);
47-
updateBounds();
47+
updateBounds(init);
4848

49+
// Mark form as changed if this isn't initialisation
4950
if (!init) {
50-
// Mark as changed(?)
5151
$('.cms-edit-form').addClass('changed');
5252
}
5353
}
5454

55-
function updateZoom() {
55+
function updateZoom(init) {
5656
zoomField.val(map.getZoom());
57+
// Mark form as changed if this isn't initialisation
58+
if (!init) {
59+
$('.cms-edit-form').addClass('changed');
60+
}
5761
}
58-
62+
5963
function updateBounds() {
6064
var bounds = JSON.stringify(map.getBounds().toJSON());
6165
boundsField.val(bounds);
@@ -101,7 +105,7 @@
101105
// Populate the fields to the current centre
102106
google.maps.event.addListenerOnce(map, 'idle', function(){
103107
updateField(map.getCenter(), true);
104-
updateZoom();
108+
updateZoom(init);
105109
});
106110

107111
google.maps.event.addListener(marker, 'dragend', centreOnMarker);

src/GoogleMapField.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,24 +108,24 @@ public function setupChildren() {
108108
$name.'[Latitude]',
109109
'Lat',
110110
$this->recordFieldData('Latitude')
111-
)->addExtraClass('googlemapfield-latfield');
111+
)->addExtraClass('googlemapfield-latfield no-detect-changes');
112112

113113
$this->lngField = HiddenField::create(
114114
$name.'[Longitude]',
115115
'Lng',
116116
$this->recordFieldData('Longitude')
117-
)->addExtraClass('googlemapfield-lngfield');
117+
)->addExtraClass('googlemapfield-lngfield no-detect-changes');
118118

119119
$this->zoomField = HiddenField::create(
120120
$name.'[Zoom]',
121121
'Zoom',
122122
$this->recordFieldData('Zoom')
123-
)->addExtraClass('googlemapfield-zoomfield');
123+
)->addExtraClass('googlemapfield-zoomfield no-detect-changes');
124124
$this->boundsField = HiddenField::create(
125125
$name.'[Bounds]',
126126
'Bounds',
127127
$this->recordFieldData('Bounds')
128-
)->addExtraClass('googlemapfield-boundsfield');
128+
)->addExtraClass('googlemapfield-boundsfield no-detect-changes');
129129
$this->children = new FieldList(
130130
$this->latField,
131131
$this->lngField,

0 commit comments

Comments
 (0)