From 4625b4ac36ef026a80f126a03d088941b91cdb32 Mon Sep 17 00:00:00 2001 From: rlx <0x0073@0x2620.org> Date: Sun, 10 Jun 2012 09:06:02 +0000 Subject: [PATCH] in MapEditor, update number of matches when editing name and alternative names of result places (fixes #824) --- source/Ox.UI/js/Map/MapEditor.js | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/source/Ox.UI/js/Map/MapEditor.js b/source/Ox.UI/js/Map/MapEditor.js index 323a473d..89135980 100644 --- a/source/Ox.UI/js/Map/MapEditor.js +++ b/source/Ox.UI/js/Map/MapEditor.js @@ -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();