add 'find in list' functionality to 'manage places' dialog

This commit is contained in:
rlx 2011-10-03 09:52:30 +00:00
parent c624cc5082
commit f4c1f826bf
2 changed files with 50 additions and 13 deletions

View file

@ -6,19 +6,19 @@ Ox.TextList <f:Ox.Element> TextList Object
(options) -> <f> TextList Object
(options, self) -> <f> TextList Object
options <o> Options object
columns <[o]|[]>
columns <[o]|[]> Columns
# Fixme: There's probably more...
addable <b>
editable <b>
format <f>
id <s>
removable <b>
addable <b> ...
editable <b> ...
format <f> ...
id <s> ...
removable <b> ...
map <f> function that maps values to sort values
operator <s> default sort operator
title <s>
title <s> ...
unique <b> If true, this column acts as unique id
visible <b>
width <n>
visible <b> ...
width <n> ...
columnsMovable <b|false> If true, columns can be re-ordered
columnsRemovable <b|false> If true, columns are removable
columnsResizable <b|false> If true, columns are resizable

View file

@ -64,8 +64,10 @@ Ox.ListMap = function(options, self) {
},
id: 'countryCode',
resizable: false, // fixme: implement
title: '<img src="' + Ox.UI.getImageURL('symbolFlag') +
'" style="width: 10px; height: 10px; padding: 3px 1px 1px 3px"/>',
title: $('<img>').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 <f> setOption
@*/