improve listmap editing functionality
This commit is contained in:
parent
02442a24f7
commit
b17e8a783b
6 changed files with 48 additions and 35 deletions
|
@ -829,7 +829,13 @@ Ox.Input = function(options, self) {
|
||||||
|
|
||||||
// fixme: deprecate, options are enough
|
// fixme: deprecate, options are enough
|
||||||
that.value = function() {
|
that.value = function() {
|
||||||
return self.$input.hasClass('OxPlaceholder') ? '' : self.$input.val();
|
var value = self.$input.hasClass('OxPlaceholder') ? '' : self.$input.val();
|
||||||
|
if (self.options.type == 'float') {
|
||||||
|
value = parseFloat(value);
|
||||||
|
} else if (self.options.type == 'int') {
|
||||||
|
value = parseInt(value); // cannot have leading zero
|
||||||
|
}
|
||||||
|
return value;
|
||||||
};
|
};
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
|
|
|
@ -1216,6 +1216,7 @@ Ox.List = function(options, self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateSort(map) {
|
function updateSort(map) {
|
||||||
|
Ox.print('start sort')
|
||||||
var key = self.options.sort[0].key,
|
var key = self.options.sort[0].key,
|
||||||
operator = self.options.sort[0].operator;
|
operator = self.options.sort[0].operator;
|
||||||
if (self.listLength > 1) {
|
if (self.listLength > 1) {
|
||||||
|
@ -1237,13 +1238,13 @@ Ox.List = function(options, self) {
|
||||||
getPositions();
|
getPositions();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Ox.print('end sort')
|
||||||
}
|
}
|
||||||
|
|
||||||
self.setOption = function(key, value) {
|
self.setOption = function(key, value) {
|
||||||
Ox.print('list setOption', key, value);
|
//Ox.print('list setOption', key, value);
|
||||||
if (key == 'items') {
|
if (key == 'items') {
|
||||||
if (Ox.typeOf(value) == 'array') {
|
if (Ox.typeOf(value) == 'array') {
|
||||||
loadItems();
|
|
||||||
updateSort();
|
updateSort();
|
||||||
} else {
|
} else {
|
||||||
updateQuery();
|
updateQuery();
|
||||||
|
|
|
@ -351,6 +351,7 @@ Ox.TextList = function(options, self) {
|
||||||
width: getItemWidth() + 'px'
|
width: getItemWidth() + 'px'
|
||||||
});
|
});
|
||||||
self.visibleColumns.forEach(function(v, i) {
|
self.visibleColumns.forEach(function(v, i) {
|
||||||
|
//Ox.print(data[v.id], '(--value--)')
|
||||||
var clickable = Ox.isBoolean(v.clickable) ? v.clickable : v.clickable(data),
|
var clickable = Ox.isBoolean(v.clickable) ? v.clickable : v.clickable(data),
|
||||||
editable = Ox.isBoolean(v.editable) ? v.editable : v.editable(data),
|
editable = Ox.isBoolean(v.editable) ? v.editable : v.editable(data),
|
||||||
$cell = $('<div>')
|
$cell = $('<div>')
|
||||||
|
@ -626,7 +627,7 @@ Ox.TextList = function(options, self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.setOption = function(key, value) {
|
self.setOption = function(key, value) {
|
||||||
Ox.print('---------------------------- TextList setOption', key, value)
|
//Ox.print('---------------------------- TextList setOption', key, value)
|
||||||
if (key == 'items') {
|
if (key == 'items') {
|
||||||
that.$body.options(key, value);
|
that.$body.options(key, value);
|
||||||
} else if (key == 'paste') {
|
} else if (key == 'paste') {
|
||||||
|
|
|
@ -110,33 +110,6 @@ Ox.ListMap = function(options, self) {
|
||||||
visible: true,
|
visible: true,
|
||||||
width: 192
|
width: 192
|
||||||
},
|
},
|
||||||
{
|
|
||||||
align: 'right',
|
|
||||||
format: {type: 'area', args: [0]},
|
|
||||||
id: 'area',
|
|
||||||
operator: '-',
|
|
||||||
title: 'Area',
|
|
||||||
visible: true,
|
|
||||||
width: 128
|
|
||||||
},
|
|
||||||
{
|
|
||||||
align: 'right',
|
|
||||||
format: toFixed,
|
|
||||||
id: 'lat',
|
|
||||||
operator: '+',
|
|
||||||
title: 'Latitude',
|
|
||||||
visible: true,
|
|
||||||
width: 96
|
|
||||||
},
|
|
||||||
{
|
|
||||||
align: 'right',
|
|
||||||
format: toFixed,
|
|
||||||
id: 'lng',
|
|
||||||
operator: '+',
|
|
||||||
title: 'Longitude',
|
|
||||||
visible: true,
|
|
||||||
width: 96
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
align: 'right',
|
align: 'right',
|
||||||
format: toFixed,
|
format: toFixed,
|
||||||
|
@ -172,6 +145,33 @@ Ox.ListMap = function(options, self) {
|
||||||
visible: false,
|
visible: false,
|
||||||
width: 96
|
width: 96
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
align: 'right',
|
||||||
|
format: toFixed,
|
||||||
|
id: 'lat',
|
||||||
|
operator: '+',
|
||||||
|
title: 'Latitude',
|
||||||
|
visible: true,
|
||||||
|
width: 96
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align: 'right',
|
||||||
|
format: toFixed,
|
||||||
|
id: 'lng',
|
||||||
|
operator: '+',
|
||||||
|
title: 'Longitude',
|
||||||
|
visible: true,
|
||||||
|
width: 96
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align: 'right',
|
||||||
|
format: {type: 'area', args: [0]},
|
||||||
|
id: 'area',
|
||||||
|
operator: '-',
|
||||||
|
title: 'Area',
|
||||||
|
visible: true,
|
||||||
|
width: 128
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: 'user',
|
id: 'user',
|
||||||
operator: '+',
|
operator: '+',
|
||||||
|
@ -347,6 +347,7 @@ Ox.ListMap = function(options, self) {
|
||||||
label: 'Area',
|
label: 'Area',
|
||||||
labelWidth: 80,
|
labelWidth: 80,
|
||||||
textAlign: 'right',
|
textAlign: 'right',
|
||||||
|
type: 'float',
|
||||||
width: 240
|
width: 240
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
|
@ -374,10 +375,13 @@ Ox.ListMap = function(options, self) {
|
||||||
self.$map.newPlace();
|
self.$map.newPlace();
|
||||||
self.$placeButton.options({title: 'Add Place'})
|
self.$placeButton.options({title: 'Add Place'})
|
||||||
} else if (title == 'Add Place') {
|
} else if (title == 'Add Place') {
|
||||||
var place = self.$placeForm.values();
|
var place = self.$placeForm.values(),
|
||||||
|
country = Ox.getCountryByGeoname(place.geoname);
|
||||||
|
place.countryCode = country ? country.code : '';
|
||||||
place.id = self.selectedPlace.substr(1); // fixme: safe?
|
place.id = self.selectedPlace.substr(1); // fixme: safe?
|
||||||
self.options.places.push(place);
|
self.options.places.push(place);
|
||||||
self.$map.addPlace(place);
|
self.$map.addPlace(place);
|
||||||
|
//self.$placeButton.options({title: 'Please Wait...'})
|
||||||
self.$list.options({items: Ox.clone(self.options.places)});
|
self.$list.options({items: Ox.clone(self.options.places)});
|
||||||
self.$list.options({selected: [place.id]});
|
self.$list.options({selected: [place.id]});
|
||||||
//self.$list.addItem(place);
|
//self.$list.addItem(place);
|
||||||
|
|
|
@ -407,13 +407,14 @@ Ox.Map = function(options, self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function addPlaceToPlaces(data) {
|
function addPlaceToPlaces(data) {
|
||||||
var place = getSelectedPlace();
|
var place = getSelectedPlace(),
|
||||||
|
country = Ox.getCountryByGeoname(place.geoname);
|
||||||
if (self.options.selected == place.id) {
|
if (self.options.selected == place.id) {
|
||||||
self.options.selected = place.id.substr(1);
|
self.options.selected = place.id.substr(1);
|
||||||
}
|
}
|
||||||
place.id = place.id.substr(1); // fixme: NOT SAFE!
|
place.id = place.id.substr(1); // fixme: NOT SAFE!
|
||||||
Ox.extend(place, data);
|
Ox.extend(place, data);
|
||||||
place.countryCode = Ox.getCountryByGeoname(place.geoname).code;
|
place.countryCode = country ? country.code : '';
|
||||||
place.marker.update();
|
place.marker.update();
|
||||||
self.places.push(place);
|
self.places.push(place);
|
||||||
self.resultPlace = null;
|
self.resultPlace = null;
|
||||||
|
|
|
@ -67,7 +67,7 @@ Ox.MapPlace = function(options) {
|
||||||
Ox.EARTH_CIRCUMFERENCE / 360;
|
Ox.EARTH_CIRCUMFERENCE / 360;
|
||||||
that.sizeEastWest = (that.east + (that.west > that.east ? 360 : 0) - that.west) *
|
that.sizeEastWest = (that.east + (that.west > that.east ? 360 : 0) - that.west) *
|
||||||
Ox.getMetersPerDegree(that.lat);
|
Ox.getMetersPerDegree(that.lat);
|
||||||
that.size = Ox.getArea(
|
that.area = Ox.getArea(
|
||||||
{lat: that.south, lng: that.west},
|
{lat: that.south, lng: that.west},
|
||||||
{lat: that.north, lng: that.east}
|
{lat: that.north, lng: that.east}
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue