From f4c1f826bf5bfd65421fbf03cfe0dbf5b9496717 Mon Sep 17 00:00:00 2001 From: rlx <0x0073@0x2620.org> Date: Mon, 3 Oct 2011 09:52:30 +0000 Subject: [PATCH] add 'find in list' functionality to 'manage places' dialog --- source/Ox.UI/js/List/Ox.TextList.js | 18 ++++++------ source/Ox.UI/js/Map/Ox.ListMap.js | 45 ++++++++++++++++++++++++++--- 2 files changed, 50 insertions(+), 13 deletions(-) diff --git a/source/Ox.UI/js/List/Ox.TextList.js b/source/Ox.UI/js/List/Ox.TextList.js index b775edbe..abd22397 100644 --- a/source/Ox.UI/js/List/Ox.TextList.js +++ b/source/Ox.UI/js/List/Ox.TextList.js @@ -6,19 +6,19 @@ Ox.TextList TextList Object (options) -> TextList Object (options, self) -> TextList Object options Options object - columns <[o]|[]> + columns <[o]|[]> Columns # Fixme: There's probably more... - addable - editable - format - id - removable + addable ... + editable ... + format ... + id ... + removable ... map function that maps values to sort values operator default sort operator - title + title ... unique If true, this column acts as unique id - visible - width + visible ... + width ... columnsMovable If true, columns can be re-ordered columnsRemovable If true, columns are removable columnsResizable If true, columns are resizable diff --git a/source/Ox.UI/js/Map/Ox.ListMap.js b/source/Ox.UI/js/Map/Ox.ListMap.js index 6d6ec226..d567040f 100644 --- a/source/Ox.UI/js/Map/Ox.ListMap.js +++ b/source/Ox.UI/js/Map/Ox.ListMap.js @@ -64,8 +64,10 @@ Ox.ListMap = function(options, self) { }, id: 'countryCode', resizable: false, // fixme: implement - title: '', + title: $('').attr({ + src: Ox.UI.getImageURL('symbolFlag') + // fixme: why does this not work? it does in folderBrowserList + }), visible: true, width: 16 }, @@ -228,12 +230,26 @@ Ox.ListMap = function(options, self) { ], overlap: 'right', type: 'image' + }) + .bindEvent({ + change: function(data) { + var key = data.selected[0].id, + value = self.$findInput.value(); + value && updateList(key, value); + } }), self.$findInput = Ox.Input({ clear: true, placeholder: 'Find in List', width: 234 }) + .bindEvent({ + submit: function(data) { + var key = self.$findSelect.value(), + value = data.value; + updateList(key, value); + } + }) ] }) .css({float: 'right', margin: '4px'}) @@ -432,11 +448,11 @@ Ox.ListMap = function(options, self) { id: 'type', items: [ {id: 'country', title: 'Country'}, - {id: 'region', title: 'Region'}, + {id: 'region', title: 'Region'}, // administative (Kansas) or colloquial (Midwest) {id: 'city', title: 'City'}, {id: 'borough', title: 'Borough'}, {id: 'street', title: 'Street'}, // streets, squares, bridges, tunnels, ... - {id: 'building', title: 'Building'}, + {id: 'building', title: 'Building'}, // airports, stations, stadiums, military installations, ... {id: 'feature', title: 'Feature'} // continents, islands, rivers, lakes, seas, oceans, ... ], label: 'Type', @@ -756,6 +772,27 @@ Ox.ListMap = function(options, self) { return Ox.isNumber(val) ? val.toFixed(8) : val; // fixme: why can a string be passed ?? } + function updateList(key, value) { + var query = { + conditions: Ox.merge( + ['all', 'name'].indexOf(key) > -1 + ? [{key: 'name', value: value, operator: '='}] : [], + ['all', 'alternativeNames'].indexOf(key) > -1 + ? [{key: 'alternativeNames', value: value, operator: '='}] : [], + ['all', 'geoname'].indexOf(key) > -1 + ? [{key: 'geoname', value: value, operator: '='}] : [] + ), + operator: key == 'all' ? '|' : '&' + }; + self.$list.options({ + items: function(data, callback) { + return pandora.api.findPlaces(Ox.extend(data, { + query: query + }), callback); + } + }); + } + /*@ setOption setOption @*/