in MapEditor, update number of matches when editing name and alternative names of result places (fixes #824)
This commit is contained in:
parent
806cbd1557
commit
4625b4ac36
1 changed files with 21 additions and 11 deletions
|
@ -561,15 +561,19 @@ Ox.MapEditor = function(options, self) {
|
|||
Ox.getObjectById(
|
||||
self.options.places, self.selectedPlace
|
||||
).name = name;
|
||||
} else if (isResult) {
|
||||
getMatches(this.values());
|
||||
} else {
|
||||
!isResult && editPlace(['name']);
|
||||
editPlace(['name']);
|
||||
}
|
||||
self.$map.value(self.selectedPlace, 'name', name);
|
||||
} else if (data.id == 'alternativeNames') {
|
||||
if (!self.isAsync) {
|
||||
// ...
|
||||
} else if (isResult) {
|
||||
getMatches(this.values());
|
||||
} else {
|
||||
!isResult && editPlace(['alternativeNames'])
|
||||
editPlace(['alternativeNames']);
|
||||
}
|
||||
self.$map.value(self.selectedPlace, 'alternativeNames', data.data.value);
|
||||
} else if (data.id == 'geoname') {
|
||||
|
@ -604,7 +608,7 @@ Ox.MapEditor = function(options, self) {
|
|||
!isResult && editPlace([data.id]);
|
||||
}
|
||||
self.$map.value(self.selectedPlace, data.id, parseFloat(data.data.value));
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.appendTo(self.$placeData);
|
||||
|
@ -932,6 +936,18 @@ Ox.MapEditor = function(options, self) {
|
|||
self.$areaKmInput.hide();
|
||||
}
|
||||
|
||||
function getMatches(place) {
|
||||
var names;
|
||||
if (self.options.hasMatches) {
|
||||
names = Ox.filter([place.name].concat(place.alternativeNames), function(name) {
|
||||
return name !== '';
|
||||
});
|
||||
self.options.getMatches(names, function(matches) {
|
||||
self.$matchesInput.value(matches);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function initList(data) {
|
||||
self.$status.html(
|
||||
Ox.formatNumber(data.items) + ' Place' + (
|
||||
|
@ -1025,8 +1041,7 @@ Ox.MapEditor = function(options, self) {
|
|||
Ox.Log('Map', 'selectPlace', place)
|
||||
var isResult = !!place.id && place.id[0] == '_',
|
||||
isUndefined = !!self.options.selected
|
||||
&& !self.$list.value(self.options.selected, 'type'),
|
||||
names;
|
||||
&& !self.$list.value(self.options.selected, 'type');
|
||||
self.selectedPlace = place.id || '';
|
||||
if (isResult && isUndefined) {
|
||||
// define undefined place
|
||||
|
@ -1055,12 +1070,7 @@ Ox.MapEditor = function(options, self) {
|
|||
showForm(place);
|
||||
if (self.options.hasMatches) {
|
||||
self.$matchesInput.value('').show();
|
||||
names = Ox.filter([place.name].concat(place.alternativeNames), function(name) {
|
||||
return name !== '';
|
||||
});
|
||||
self.options.getMatches(names, function(matches) {
|
||||
self.$matchesInput.value(matches);
|
||||
});
|
||||
getMatches(place);
|
||||
}
|
||||
self.options.mode == 'define' && self.$definePlaceButton.hide();
|
||||
self.$addPlaceButton.options({disabled: false, title: 'Add Place'}).show();
|
||||
|
|
Loading…
Reference in a new issue