mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 01:02:58 +00:00
Filter taginfo by country code prefix
taginfo returns results that match anywhere within the string. So in Canada, you might get results like US:CA:SF. This change filters out such results.
This commit is contained in:
@@ -367,7 +367,7 @@
|
||||
},
|
||||
"cycle_network": {
|
||||
"key": "cycle_network",
|
||||
"type": "combo",
|
||||
"type": "networkCombo",
|
||||
"label": "Network"
|
||||
},
|
||||
"cycleway": {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"key": "cycle_network",
|
||||
"type": "combo",
|
||||
"type": "networkCombo",
|
||||
"label": "Network"
|
||||
}
|
||||
@@ -140,7 +140,8 @@ export function combo(field, context) {
|
||||
function setTaginfoValues(q, callback) {
|
||||
var fn = isMulti ? 'multikeys' : 'values';
|
||||
var query = (isMulti ? field.key : '') + q;
|
||||
if (isNetwork && countryCode && countryCode.indexOf(q.toLowerCase()) === 0) {
|
||||
var hasCountryPrefix = isNetwork && countryCode && countryCode.indexOf(q.toLowerCase()) === 0;
|
||||
if (hasCountryPrefix) {
|
||||
query = countryCode + ':';
|
||||
}
|
||||
context.taginfo()[fn]({
|
||||
@@ -150,6 +151,11 @@ export function combo(field, context) {
|
||||
query: query
|
||||
}, function(err, data) {
|
||||
if (err) return;
|
||||
if (hasCountryPrefix) {
|
||||
data = _.filter(data, function(d) {
|
||||
return d.value.toLowerCase().indexOf(countryCode + ':') === 0;
|
||||
});
|
||||
}
|
||||
comboData = _.map(data, function(d) {
|
||||
var k = d.value;
|
||||
if (isMulti) k = k.replace(field.key, '');
|
||||
|
||||
Reference in New Issue
Block a user