← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~martin-borho/ubuntu-weather-app/reboot-multi-locations-more-verbose into lp:ubuntu-weather-app/reboot

 

Martin Borho has proposed merging lp:~martin-borho/ubuntu-weather-app/reboot-multi-locations-more-verbose into lp:ubuntu-weather-app/reboot.

Commit message:
Area label (subtitle) for locations in AddLocationPage are now more verbose, when location name and country are not unique.

Requested reviews:
  Ubuntu Weather Developers (ubuntu-weather-dev)

For more details, see:
https://code.launchpad.net/~martin-borho/ubuntu-weather-app/reboot-multi-locations-more-verbose/+merge/253759

Area label (subtitle) for locations in AddLocationPage are now more verbose, when location name and country are not unique. 

For example if searched for New York, the respective state names are added to the country name.
-- 
Your team Ubuntu Weather Developers is requested to review the proposed merge of lp:~martin-borho/ubuntu-weather-app/reboot-multi-locations-more-verbose into lp:ubuntu-weather-app/reboot.
=== modified file 'app/ui/AddLocationPage.qml'
--- app/ui/AddLocationPage.qml	2015-03-16 13:42:08 +0000
+++ app/ui/AddLocationPage.qml	2015-03-21 15:48:38 +0000
@@ -99,8 +99,31 @@
         }
     }
 
+    // Builds a area label for the location, depending on the uniqueness of name, adminName1 and country
+    function buildAreaLabel(loc, countryCounts, a1Counts) {//, a3Counts) {
+        var label = "";
+        if(countryCounts[loc.name+loc.countryName] > 1) {
+            label += ((loc.adminName1) ? loc.adminName1.replace(/ Region$/,''):"");
+            if (loc.adminName2 && a1Counts[loc.name+loc.adminName1] > 1) {
+                // even name and adminName1 are multiple in country, add adminName2
+                label += ", "+loc.adminName2;
+            }
+        }
+        label += ((label !== "") ? ", " : "") + loc.countryName
+        return label;
+    }
+
     function appendCities(list) {
-        list.forEach(function(loc) {
+        var countryCounts = {},
+            a1Counts = {};
+        // count occurrences of name+adminName1 and name+country
+        list.forEach(function(loc) {
+            countryCounts[loc.name+loc.countryName] = (!countryCounts[loc.name+loc.countryName]) ? 1 : countryCounts[loc.name+loc.countryName]+1;
+            a1Counts[loc.name+loc.adminName1] = (!a1Counts[loc.name+loc.adminName1]) ? 1 : a1Counts[loc.name+loc.adminName1]+1;
+        });
+        // add locations to listmodel
+        list.forEach(function(loc) {
+            loc.areaLabel = buildAreaLabel(loc, countryCounts, a1Counts)
             citiesModel.append(loc);
         })
     }
@@ -197,7 +220,7 @@
                     color: UbuntuColors.lightGrey
                     elide: Text.ElideRight
                     fontSize: "xx-small"
-                    text: countryName
+                    text: areaLabel
                 }
             }
 

=== modified file 'po/com.ubuntu.weather.pot'
--- po/com.ubuntu.weather.pot	2015-03-19 10:21:28 +0000
+++ po/com.ubuntu.weather.pot	2015-03-21 15:48:38 +0000
@@ -8,7 +8,7 @@
 msgstr ""
 "Project-Id-Version: ubuntu-weather-app\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2015-03-19 10:21+0000\n"
+"POT-Creation-Date: 2015-03-21 16:43+0100\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@xxxxxx>\n"
@@ -53,19 +53,19 @@
 msgid "Search city"
 msgstr ""
 
-#: ../app/ui/AddLocationPage.qml:249
+#: ../app/ui/AddLocationPage.qml:272
 msgid "No city found"
 msgstr ""
 
-#: ../app/ui/AddLocationPage.qml:262
+#: ../app/ui/AddLocationPage.qml:285
 msgid "Couldn't load weather data, please try later again!"
 msgstr ""
 
-#: ../app/ui/AddLocationPage.qml:272
+#: ../app/ui/AddLocationPage.qml:295
 msgid "Location already added."
 msgstr ""
 
-#: ../app/ui/AddLocationPage.qml:275
+#: ../app/ui/AddLocationPage.qml:298
 msgid "OK"
 msgstr ""
 


Follow ups