From 7eb6f5831274d9e948091f893447f4b74a847a6f Mon Sep 17 00:00:00 2001 From: rolux Date: Mon, 30 May 2011 09:21:11 +0200 Subject: [PATCH] allow for editing lat/lng/s/w/n/e via map --- source/Ox.UI/js/List/Ox.TextList.js | 33 +++++++++++--------- source/Ox.UI/js/Map/Ox.ListMap.js | 19 ++++++----- source/Ox.UI/js/Map/Ox.MapMarker.js | 2 +- source/Ox.UI/js/Map/Ox.MapRectangleMarker.js | 1 + 4 files changed, 32 insertions(+), 23 deletions(-) diff --git a/source/Ox.UI/js/List/Ox.TextList.js b/source/Ox.UI/js/List/Ox.TextList.js index f1afb597..1b9079d6 100644 --- a/source/Ox.UI/js/List/Ox.TextList.js +++ b/source/Ox.UI/js/List/Ox.TextList.js @@ -392,26 +392,28 @@ Ox.TextList = function(options, self) { borderRightWidth: (self.options.columnsVisible ? 1 : 0) + 'px', textAlign: v.align }) - .html(v.id in data ? formatValue(data[v.id], v.format) : '') + .html(v.id in data ? formatValue(v.id, data[v.id]) : '') .appendTo($item); }); - function formatValue(value, format) { - if (value === null) { - value = ''; - } else if (format) { - value = Ox.isObject(format) ? - Ox['format' + Ox.toTitleCase(format.type)] - .apply(this, $.merge([value], format.args)) : - format(value); - } else if (Ox.isArray(value)) { - value = value.join(', '); - } - return value; - } //Math.random() < 0.01 && Ox.print('item', data, $item); return $item; } + function formatValue(key, value) { + var format = self.format[key]; + if (value === null) { + value = ''; + } else if (format) { + value = Ox.isObject(format) ? + Ox['format' + Ox.toTitleCase(format.type)] + .apply(this, $.merge([value], format.args)) : + format(value); + } else if (Ox.isArray(value)) { + value = value.join(', '); + } + return value; + } + function dragstartColumn(id, e) { self.drag = { startX: e.clientX, @@ -846,7 +848,8 @@ Ox.TextList = function(options, self) { return that.$body.value(id, key); } else { that.$body.value(id, key, value); - $cell && $cell.html(column.format ? column.format(value) : value); + Ox.print('? ? ?', column, column.format) + $cell && $cell.html(formatValue(key, value)); if (key == self.options.sort[0].key) { that.$body.sort(); } diff --git a/source/Ox.UI/js/Map/Ox.ListMap.js b/source/Ox.UI/js/Map/Ox.ListMap.js index 67f8e299..dd6cc0a8 100644 --- a/source/Ox.UI/js/Map/Ox.ListMap.js +++ b/source/Ox.UI/js/Map/Ox.ListMap.js @@ -283,14 +283,13 @@ Ox.ListMap = function(options, self) { that.triggerEvent('addplace', data); }, */ - changeplace: function(event, data) { - // fixme: is there a changeplace event in Map??? - self.$placeForm.values(Ox.map(data, function(val, key) { - // fixme: no size key anymore - return key == 'size' ? Ox.formatArea(val) : val; - })).show(); + changeplace: function(data) { + self.$placeForm.values(data).show(); }, - geocode: function(event, data) { + changeplaceend: function(data) { + editPlace(['lat', 'lng', 'south', 'west', 'north', 'east', 'area']); + }, + geocode: function(data) { that.triggerEvent('geocode', data); }, resize: function() { @@ -581,6 +580,12 @@ Ox.ListMap = function(options, self) { self.options.editPlace(values, function() { if (keys.indexOf(self.$list.options('sort')[0].key) > -1) { self.$list.reloadList(); + } else { + Ox.forEach(values, function(value, key) { + if (key != 'id') { + self.$list.value(values.id, key, value); + } + }); } }); } diff --git a/source/Ox.UI/js/Map/Ox.MapMarker.js b/source/Ox.UI/js/Map/Ox.MapMarker.js index 2fa83922..2078fb42 100644 --- a/source/Ox.UI/js/Map/Ox.MapMarker.js +++ b/source/Ox.UI/js/Map/Ox.MapMarker.js @@ -79,7 +79,7 @@ Ox.MapMarker = function(options) { } function dragend(e) { - + that.map.triggerEvent('changeplaceend', that.place); } function getMarkerImage(options, callback) { diff --git a/source/Ox.UI/js/Map/Ox.MapRectangleMarker.js b/source/Ox.UI/js/Map/Ox.MapRectangleMarker.js index 957b7e9d..06e7b567 100644 --- a/source/Ox.UI/js/Map/Ox.MapRectangleMarker.js +++ b/source/Ox.UI/js/Map/Ox.MapRectangleMarker.js @@ -83,6 +83,7 @@ Ox.MapRectangleMarker = function(options, self) { that.place.marker.update(); that.place.rectangle.update(); } + that.map.triggerEvent('changeplaceend', that.place); } /*@