Skip to content
This repository has been archived by the owner on Oct 1, 2019. It is now read-only.

Commit

Permalink
Change geotag autosuggest rendering function
Browse files Browse the repository at this point in the history
New format: `<name>, <area name (code for US)>, <country name> (<type>)`
  • Loading branch information
voidxnull committed Sep 11, 2016
1 parent d496f3e commit 2f3b3e5
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/components/add-tag-modal/form/geotag/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,26 @@ export default class GeotagSelect extends Component {
_getSuggestionValue = (geotag) => geotag.name;

_renderSuggestion(geotag) {
let name = geotag.name;
const additionalInfo = [];
let geotagType = geotag.type;
if (geotagType == 'AdminDivision1') {
geotagType = 'Admin. Division';
}

const names = [geotag.name];

if (!isEmpty(geotag.admin1)) {
additionalInfo.push(geotag.admin1.name);
if (geotag.country_code == 'US') {
names.push(geotag.admin1_code);
} else {
names.push(geotag.admin1.name);
}
}

if (!isEmpty(geotag.country)) {
additionalInfo.push(geotag.country.name);
}

if (additionalInfo.length > 0) {
name += ` (${additionalInfo.join(', ')})`;
names.push(geotag.country.name);
}

return name;
return `${names.join(', ')} (${geotagType})`;
}

_handleSelect = (event, { suggestion }) => {
Expand Down

0 comments on commit 2f3b3e5

Please sign in to comment.