Ver Fonte

HUE-2735 [search] Support 2-letter country code in gradient map widget

Added an ISO 3166 alpha2 to alpha3 conversion function
Enrico Berti há 10 anos atrás
pai
commit
e65a8b2

+ 1 - 1
apps/search/src/search/templates/search.mako

@@ -1859,7 +1859,7 @@ function mapChartDataTransformer(data) {
     item.counts = item.pivot ? item.pivot[0].count : item.count; // unused yet
     item.is2d = item.pivot ? true : false; // unused yet
     _data.push({
-      label: item.value,
+      label: data.scope == "world" ? HueGeo.getISOAlpha3(item.value) : item.value,
       value: item.pivot ? item.pivot[0].fq_values : item.count,
       obj: item
     });

+ 4 - 0
desktop/core/src/desktop/static/desktop/js/hue.geo.js

@@ -282,6 +282,10 @@ var HueGeo = {
     }
     return null;
   },
+  getISOAlpha3: function (code) {
+    var _country = HueGeo.getCountryFromCode(code);
+    return _country ? _country.alpha3 : "ATA";
+  },
   getCity: function (city, callback) {
     var api = new NominatimAPI();
     api.lookupCity(city, function (rawdata) {