listmap bugfixes

This commit is contained in:
rolux 2011-05-24 18:08:52 +02:00
parent 314fcc7b0a
commit 9967d31396
2 changed files with 21 additions and 10 deletions

View file

@ -1080,6 +1080,7 @@ Ox.List = function(options, self) {
function setSelected(ids) {
// fixme: can't use selectNone here,
// since it'd trigger a select event
Ox.print('setSelected', ids)
self.$items.forEach(function($item, pos) {
if (isSelected(pos)) {
self.selected.splice(self.selected.indexOf(pos), 1);
@ -1089,6 +1090,7 @@ Ox.List = function(options, self) {
});
ids.forEach(function(id, i) {
var pos = getPositionById(id);
Ox.print('pushing', pos, 'onto self.selected')
self.selected.push(pos);
!Ox.isUndefined(self.$items[pos]) &&
self.$items[pos].addClass('OxSelected');
@ -1217,6 +1219,7 @@ Ox.List = function(options, self) {
}
function updateSelected() {
Ox.print('updateSelected')
var oldSelectedIds = getSelectedIds(),
newSelectedIds = [];
Ox.forEach(self.options.items, function(item) {

View file

@ -38,8 +38,10 @@ Ox.ListMap = function(options, self) {
{
addable: false, // fixme: implement
id: 'id',
title: 'Id',
unique: true,
visible: false
visible: false,
width: 64
},
{
format: function(value) {
@ -301,8 +303,9 @@ Ox.ListMap = function(options, self) {
width: 240
}).bindEvent({
change: function(data) {
var isResult = self.selectedPlace[0] == '_';
Ox.getObjectById(self.options.places, self.selectedPlace).name = data.value;
self.$list.value(self.selectedPlace, 'name', data.value);
!isResult && self.$list.value(self.selectedPlace, 'name', data.value);
self.$map.value(self.selectedPlace, 'name', data.value);
}
}),
@ -313,12 +316,17 @@ Ox.ListMap = function(options, self) {
width: 240
}).bindEvent({
change: function(data) {
Ox.getObjectById(self.options.places, self.selectedPlace).geoname = data.value;
self.$list.value(self.selectedPlace, 'geoname', data.value);
self.$map.value(self.selectedPlace, 'geoname', data.value);
self.$placeTitleName.options({
title: data.value
var geoname = data.value,
country = Ox.getCountryByGeoname(geoname),
countryCode = country ? country.code : 'NTHH',
isResult = self.selectedPlace[0] == '_';
//Ox.getObjectById(self.options.places, self.selectedPlace).geoname = geoname;
!isResult && self.$list.value(self.selectedPlace, 'geoname', geoname);
//self.$map.value(self.selectedPlace, 'geoname', geoname);
self.$placeTitleFlag.attr({
src: Ox.PATH + 'Ox.Geo/png/icons/16/' + countryCode + '.png'
});
self.$placeTitleName.options({title: geoname});
}
}),
Ox.ArrayInput({
@ -384,6 +392,7 @@ Ox.ListMap = function(options, self) {
.bindEvent({
click: function() {
var title = self.$placeButton.options('title');
// fixme: these should be separate functions
if (title == 'New Place') {
self.$map.newPlace();
self.$placeButton.options({title: 'Add Place'})
@ -393,11 +402,10 @@ Ox.ListMap = function(options, self) {
place.countryCode = country ? country.code : '';
place.id = self.selectedPlace.substr(1); // fixme: safe?
self.options.places.push(place);
//self.options.places[Ox.getPositionById(self.options.places, self.selectedPlace)] = place;
self.$map.addPlace(place);
//self.$placeButton.options({title: 'Please Wait...'})
self.$list.options({items: Ox.clone(self.options.places)});
self.$list.options({selected: [place.id]});
//self.$list.addItem(place);
self.$placeButton.options({title: 'Remove Place'})
} else if (title == 'Remove Place') {
var index = Ox.getPositionById(self.options.places, self.selectedPlace);
@ -567,6 +575,7 @@ Ox.ListMap = function(options, self) {
code = country ? country.code : 'NTHH';
if (place.id) {
isResult = place.id[0] == '_';
//isResult && self.options.places.push(place);
self.selectedPlace = place.id;
place.id[0] != '_' && self.$list.options({
selected: place.id ? [place.id] : []
@ -576,7 +585,6 @@ Ox.ListMap = function(options, self) {
});
self.$placeTitleName.options({title: place.geoname || ''});
self.$placeTitle.show();
Ox.print('>>>>', place)
self.$placeForm.values(Ox.map(place, function(val, key) {
return key == 'size' ? Ox.formatArea(val) : val;
})).show();