diff --git a/Site5/Automation/Json-GeographiesTree.aspx.cs b/Site5/Automation/Json-GeographiesTree.aspx.cs index b8c65b24..abb18c4c 100644 --- a/Site5/Automation/Json-GeographiesTree.aspx.cs +++ b/Site5/Automation/Json-GeographiesTree.aspx.cs @@ -19,12 +19,7 @@ namespace Swarmops.Frontend.Automation int parentGeographyId = 0; - bool initialExpand = true; - - if (Request.QueryString["InitialExpand"] == "false") - { - initialExpand = false; - } + bool initialExpand = (Request.QueryString["InitialExpand"] != "false"); string parentIdString = Request.QueryString["ParentGeographyId"]; if (!string.IsNullOrEmpty (parentIdString)) @@ -37,7 +32,7 @@ namespace Swarmops.Frontend.Automation string cacheKey = "Geographies-Json-" + parentGeographyId.ToString (CultureInfo.InvariantCulture) + "-" + Thread.CurrentThread.CurrentCulture.Name; - string accountsJson = (string) Cache[cacheKey]; + string accountsJson = null; // (string) Cache[cacheKey]; if (accountsJson != null) { @@ -92,6 +87,7 @@ namespace Swarmops.Frontend.Automation foreach (TreeNode geographyNode in geoBranch) { Geography geography = geographyNode.Data; + Country country = null; string geoName = TestLocalization (geography.Name); @@ -99,7 +95,8 @@ namespace Swarmops.Frontend.Automation { // Special case for country nodes: "[NativeName] ([LocalizedName])", e.g. "Deutschland (Tyskland)" for Germany when in Swedish - string localizedCountryName = GeographyNames.ResourceManager.GetString("Country_" + _countryLookup[geography.Identity].Code); + country = _countryLookup[geography.Identity]; + string localizedCountryName = GeographyNames.ResourceManager.GetString("Country_" + country.Code); string nativeCountryName = geography.Name.Split ('(')[0].Trim(); if (localizedCountryName != nativeCountryName) @@ -115,13 +112,15 @@ namespace Swarmops.Frontend.Automation string element = string.Format ("\"id\":{0},\"text\":\"{1}\"", geography.Identity, JsonSanitize (TestLocalization (geoName))); - if (_countryLookup.ContainsKey (geography.Identity)) + if (country != null) { - // this is a country node. Populate with stuff to enable lazy-load of the tree. - Country country = _countryLookup[geography.Identity]; + // this is a country node. Populate with stuff to enable lazy-load of the tree at this point. element += ",\"children1\":\"\",\"state\":\"closed\"," + - string.Format ("\"countryId\":\"{0}\",\"countryNode\":\"{1}\"", country.Code, geography.Identity); + string.Format ("\"countryId\":\"{0}\",\"countryNode\":\"{1}\"", country.Code.ToLowerInvariant(), geography.Identity); + + // Suppress icon to reaplce with flag + element += ",\"iconCls\":\"countryNode\""; } else if (geographyNode.Children.Count > 0) { diff --git a/Site5/Controls/v5/Base/ComboGeographies.ascx b/Site5/Controls/v5/Base/ComboGeographies.ascx index 5b4dbb78..88712729 100644 --- a/Site5/Controls/v5/Base/ComboGeographies.ascx +++ b/Site5/Controls/v5/Base/ComboGeographies.ascx @@ -19,15 +19,25 @@ } else { $.getJSON("/Automation/Json-GeographiesTree.aspx?InitialExpand=false&ParentGeographyId=" + param.id, null, success); } - } - <% + }, + onSelect: function (row) { + <% if (!String.IsNullOrEmpty(this.OnClientSelect)) { - Response.Write(", onSelect: function(row) { " + this.OnClientSelect + "(row.id); }"); + Response.Write(this.OnClientSelect + "(row.id);"); } %> - }); + }, + formatter: function (row) { + // If we're at a country node, add that country's flag ahead of the country name. Replaces the folder icon (that part is done in CSS). + + if (row.countryId != null) { + return " " + row.text; + } + else return row.text; + } + }); $('#<%=this.ClientID %>_SpanGeographies span.combo input.combo-text').click(function () { $('#<%=this.ClientID %>_SpanGeographies span.combo span span.combo-arrow').click(); diff --git a/Site5/Images/Flags/gh-24px.png b/Site5/Images/Flags/gh-24px.png new file mode 100644 index 00000000..4fcc198c Binary files /dev/null and b/Site5/Images/Flags/gh-24px.png differ diff --git a/Site5/Images/Flags/gh-64px.png b/Site5/Images/Flags/gh-64px.png new file mode 100644 index 00000000..9653c86c Binary files /dev/null and b/Site5/Images/Flags/gh-64px.png differ diff --git a/Site5/Style/v5-easyui-elements.css b/Site5/Style/v5-easyui-elements.css index 17f07096..fb5ea900 100644 --- a/Site5/Style/v5-easyui-elements.css +++ b/Site5/Style/v5-easyui-elements.css @@ -127,6 +127,10 @@ div.combobox-item { } +.tree-icon.tree-folder.countryNode { + display: none; /* suppress display of node, when country flag is displayed */ +} + /* TABS */