better behaviour when editing (only send changed key/value pairs, only reload list if sort order is affected)
This commit is contained in:
parent
03f368c7b8
commit
1eebdf3805
2 changed files with 16 additions and 10 deletions
|
@ -60,8 +60,11 @@ Ox.load('Geo', function() {
|
|||
},
|
||||
editPlace: function(data, callback) {
|
||||
var place = Ox.getObjectById(places, data.id);
|
||||
place = Ox.extend(place, data, {
|
||||
geonameSort: getGeonameSort(data.geoname)
|
||||
Ox.forEach(data, function(value, key) {
|
||||
place[key] = value;
|
||||
if (key == 'geoname') {
|
||||
place.geonameSort = getGeonameSort(place.geoname);
|
||||
}
|
||||
});
|
||||
callback({
|
||||
result: {code: 200, text: 'OK'}
|
||||
|
|
|
@ -347,7 +347,7 @@ Ox.ListMap = function(options, self) {
|
|||
self.options.places, self.selectedPlace
|
||||
).name = data.value;
|
||||
} else {
|
||||
editPlace();
|
||||
editPlace(['name']);
|
||||
}
|
||||
self.$map.value(self.selectedPlace, 'name', data.value);
|
||||
}
|
||||
|
@ -363,7 +363,6 @@ Ox.ListMap = function(options, self) {
|
|||
country = Ox.getCountryByGeoname(geoname),
|
||||
countryCode = country ? country.code : '',
|
||||
isResult = self.selectedPlace[0] == '_';
|
||||
Ox.print('IS RESULT?', isResult, self.selectedPlace)
|
||||
if (!isResult) {
|
||||
self.$list.value(self.selectedPlace, 'geoname', geoname);
|
||||
self.$list.value(self.selectedPlace, 'countryCode', countryCode);
|
||||
|
@ -376,7 +375,7 @@ Ox.ListMap = function(options, self) {
|
|||
if (!self.isAsync) {
|
||||
|
||||
} else {
|
||||
editPlace();
|
||||
editPlace(['geoname']);
|
||||
}
|
||||
}
|
||||
}),
|
||||
|
@ -574,11 +573,15 @@ Ox.ListMap = function(options, self) {
|
|||
self.$placeButton.options({title: 'Remove Place'});
|
||||
}
|
||||
|
||||
function editPlace() {
|
||||
self.options.editPlace(Ox.extend(self.$placeForm.values(), {
|
||||
id: self.selectedPlace
|
||||
}), function() {
|
||||
self.$list.reloadList();
|
||||
function editPlace(keys) {
|
||||
values = Ox.filter(self.$placeForm.values(), function(values, key) {
|
||||
return keys.indexOf(key) > -1;
|
||||
});
|
||||
values.id = self.selectedPlace;
|
||||
self.options.editPlace(values, function() {
|
||||
if (keys.indexOf(self.$list.options('sort')[0].key) > -1) {
|
||||
self.$list.reloadList();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue