fix marker duplication bug when editing a newly added place
This commit is contained in:
parent
a0b1e0eab4
commit
8fc5297f39
4 changed files with 34 additions and 1 deletions
|
|
@ -123,6 +123,16 @@ Ox.Map = function(options, self) {
|
|||
that.resizeMap();
|
||||
},
|
||||
places: function() {
|
||||
console.log('MAP OPTIONS.PLACES UPDATE - Processing places array, count:', self.options.places ? self.options.places.length : 0);
|
||||
console.trace('MAP OPTIONS.PLACES UPDATE - Stack trace');
|
||||
|
||||
// Prevent rebuilding places while editing to avoid breaking references
|
||||
var editingPlace = getSelectedPlace();
|
||||
if (editingPlace && editingPlace.editing) {
|
||||
console.log('MAP OPTIONS.PLACES UPDATE - Skipping rebuild because place is being edited:', editingPlace.id);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Ox.isArray(self.options.places)) {
|
||||
self.options.places.forEach(function(place) {
|
||||
if (Ox.isUndefined(place.id)) {
|
||||
|
|
@ -248,6 +258,8 @@ Ox.Map = function(options, self) {
|
|||
});
|
||||
|
||||
//FIXME: duplicated in update
|
||||
console.log('MAP INIT - Processing places array (duplicated code), count:', self.options.places ? self.options.places.length : 0);
|
||||
console.trace('MAP INIT - Stack trace');
|
||||
if (Ox.isArray(self.options.places)) {
|
||||
self.options.places.forEach(function(place) {
|
||||
if (Ox.isUndefined(place.id)) {
|
||||
|
|
@ -1727,7 +1739,12 @@ Ox.Map = function(options, self) {
|
|||
that.value = function(id, key, value) {
|
||||
// fixme: should be like the corresponding List/TableList/etc value function
|
||||
Ox.Log('Map', 'Map.value', id, key, value);
|
||||
getPlaceById(id).options(key, value);
|
||||
var place = getPlaceById(id);
|
||||
if (!place) {
|
||||
console.error('Map.value - place not found for id:', id, 'Available places:', Object.keys(self.options.places || {}));
|
||||
return;
|
||||
}
|
||||
place.options(key, value);
|
||||
if (id == self.options.selected) {
|
||||
if (key == 'name') {
|
||||
self.$placeControls.name.options({title: value});
|
||||
|
|
|
|||
|
|
@ -306,7 +306,9 @@ Ox.MapMarker = function(options) {
|
|||
() -> <f> edit marker, returns MapMarker
|
||||
@*/
|
||||
that.edit = function() {
|
||||
console.log('MAPMARKER.EDIT - before setOptions, marker on map?', that.marker._map !== null);
|
||||
setOptions();
|
||||
console.log('MAPMARKER.EDIT - after setOptions, marker on map?', that.marker._map !== null);
|
||||
that.marker.on('dragstart', dragstart);
|
||||
that.marker.on('drag', drag);
|
||||
that.marker.on('dragend', dragend);
|
||||
|
|
|
|||
|
|
@ -41,6 +41,13 @@ Ox.MapPlace = function(options) {
|
|||
Ox.forEach(options, function(val, key) {
|
||||
that[key] = val;
|
||||
});
|
||||
|
||||
// Ensure editable is set for existing places that might not have this property
|
||||
if (that.editable === undefined) {
|
||||
that.editable = true;
|
||||
}
|
||||
|
||||
console.log('MAPPLACE CONSTRUCTOR - Creating place with ID:', that.id, 'name:', that.name);
|
||||
|
||||
update();
|
||||
|
||||
|
|
|
|||
|
|
@ -225,11 +225,18 @@ Ox.MapRectangle = function(options) {
|
|||
setOptions();
|
||||
|
||||
function click(e) {
|
||||
console.log('RECTANGLE CLICK DEBUG:');
|
||||
console.log('- map.editable:', that.map.options('editable'));
|
||||
console.log('- place.editable:', that.place.editable);
|
||||
console.log('- place.editing:', that.place.editing);
|
||||
console.log('- place object:', that.place);
|
||||
|
||||
if (
|
||||
that.map.options('editable')
|
||||
&& that.place.editable
|
||||
&& !that.place.editing
|
||||
) {
|
||||
console.log('- Calling place.edit()');
|
||||
that.place.edit();
|
||||
} else if (that.map.getKey() == 'meta') {
|
||||
that.place.submit();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue