From 0d56c13eb2cb10c31b4df2a8cb4c9c44b3e52bd1 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Wed, 3 Dec 2014 23:10:30 +0100 Subject: [PATCH] Checkpoint commit on Add Person; testing on Dev Mono --- Logic/Structure/Organization.cs | 9 +- Site5/App_GlobalResources/GeographyNames.resx | 94 ++++++++++++++++++- Site5/App_GlobalResources/Global.resx | 16 ++++ Site5/Automation/FieldValidation.aspx.cs | 36 +++++++ Site5/Controls/v5/Base/DropDown.ascx | 8 +- Site5/Controls/v5/Base/DropDown.ascx.cs | 7 ++ Site5/Pages/v5/Swarm/AddPerson.aspx | 83 +++++++++++++--- Site5/Pages/v5/Swarm/AddPerson.aspx.cs | 52 ++++++++++ Site5/Style/v5-easyui-elements.css | 6 +- Site5/web.config | 7 ++ 10 files changed, 297 insertions(+), 21 deletions(-) diff --git a/Logic/Structure/Organization.cs b/Logic/Structure/Organization.cs index 1d0c225e..f5bef0cb 100644 --- a/Logic/Structure/Organization.cs +++ b/Logic/Structure/Organization.cs @@ -305,7 +305,14 @@ namespace Swarmops.Logic.Structure /// public Country DefaultCountry { - get { return Country.FromIdentity(DefaultCountryId); } + get + { + if (DefaultCountryId == 0) + { + return null; + } + return Country.FromIdentity(DefaultCountryId); + } } /// diff --git a/Site5/App_GlobalResources/GeographyNames.resx b/Site5/App_GlobalResources/GeographyNames.resx index 790aba2e..e8e7068f 100644 --- a/Site5/App_GlobalResources/GeographyNames.resx +++ b/Site5/App_GlobalResources/GeographyNames.resx @@ -117,9 +117,60 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Ascension Island + + + Andorra + + + Austria + + + Australia + + + Brazil + + + Germany + + + Denmark + + + Spain + + + Finland + + + Ghana + + + Norway + + + Poland + + + Sweden + + + Slovak Republic + + + San Marino + + + United Kingdom + + + United States + Eastern Europe - (East of former Iron Curtain) + (East of southern tip of Sweden, appx) Europe @@ -132,9 +183,48 @@ Nordics (Finland Denmark Norway Sweden Iceland) + + East North Central + + + East South Central + + + Mid-Atlantic + + + Midwest + + + Mountain + + + New England + + + Northeast + + + Pacific + + + South + + + South Atlantic + + + West + + + West North Central + + + West South Central + Western Europe - (West of former Iron Curtain) + (West of southern tip of Sweden, appx) World diff --git a/Site5/App_GlobalResources/Global.resx b/Site5/App_GlobalResources/Global.resx index 514733eb..a3bb60e8 100644 --- a/Site5/App_GlobalResources/Global.resx +++ b/Site5/App_GlobalResources/Global.resx @@ -808,4 +808,20 @@ Contributorship + + Female + Legal gender + + + Male + Legal gender + + + Unknown or Undisclosed + Used for gender et al + + + MM/DD/YYYY + Adapt format for culture, then translate to human-readability, not machine-readability. E.g. ÅÅÅÅ-MM-DD for Swedish. + \ No newline at end of file diff --git a/Site5/Automation/FieldValidation.aspx.cs b/Site5/Automation/FieldValidation.aspx.cs index 93da9391..56142673 100644 --- a/Site5/Automation/FieldValidation.aspx.cs +++ b/Site5/Automation/FieldValidation.aspx.cs @@ -6,6 +6,7 @@ using System.Web.Services; using System.Web.Services.Description; using System.Web.UI; using System.Web.UI.WebControls; +using Swarmops.Logic.Structure; namespace Swarmops.Frontend.Automation { @@ -23,5 +24,40 @@ namespace Swarmops.Frontend.Automation System.Diagnostics.Trace.WriteLine(input); } + + [WebMethod] + public static PostalCodeData[] GetPostalCodes(string countryCode) + { + List result = new List(); + PostalCodes codes = PostalCodes.ForCountry(countryCode); + + foreach (PostalCode code in codes) + { + PostalCodeData dataPoint = new PostalCodeData + { + Code = code.PostalCode, + Name = code.CityName + }; + + result.Add(dataPoint); + } + + return result.ToArray(); + } + + [WebMethod] + public static int GetPostalCodeLength(string countryCode) + { + Country country = Country.FromCode(countryCode); + return country.PostalCodeLength; + } } +} + + +[Serializable] +public class PostalCodeData +{ + public string Code { get; set; } + public string Name { get; set; } } \ No newline at end of file diff --git a/Site5/Controls/v5/Base/DropDown.ascx b/Site5/Controls/v5/Base/DropDown.ascx index 9315ae6d..f7604a1d 100644 --- a/Site5/Controls/v5/Base/DropDown.ascx +++ b/Site5/Controls/v5/Base/DropDown.ascx @@ -5,7 +5,13 @@ $('#<%=this.DropControl.ClientID %>').combobox({ editable: false, height: 30, - width: 300 + width: 300<% + if (!String.IsNullOrEmpty(this.OnClientChange)) + { + Response.Write(",\r\nonChange: function(newVal, oldVal) { " + this.OnClientChange + "(oldVal, newVal); }"); + } + + %> }); $('#<%=this.DropControl.ClientID %>').combobox('setValue', '<%=this.DropControl.SelectedValue%>'); diff --git a/Site5/Controls/v5/Base/DropDown.ascx.cs b/Site5/Controls/v5/Base/DropDown.ascx.cs index 72d33d86..28a345f5 100644 --- a/Site5/Controls/v5/Base/DropDown.ascx.cs +++ b/Site5/Controls/v5/Base/DropDown.ascx.cs @@ -24,5 +24,12 @@ namespace Swarmops.Frontend.Controls.v5.Base get { return this.DropControl.SelectedValue; } set { this.DropControl.SelectedValue = value; } } + + public string OnClientChange { get; set; } + + public string ClientControlID + { + get { return this.DropControl.ClientID; } + } } } \ No newline at end of file diff --git a/Site5/Pages/v5/Swarm/AddPerson.aspx b/Site5/Pages/v5/Swarm/AddPerson.aspx index 2f6b6250..541f46c2 100644 --- a/Site5/Pages/v5/Swarm/AddPerson.aspx +++ b/Site5/Pages/v5/Swarm/AddPerson.aspx @@ -1,33 +1,88 @@ <%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="AddPerson.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Swarm.AddPerson" %> +<%@ Register TagPrefix="Swarmops5" TagName="DropDown" Src="~/Controls/v5/Base/DropDown.ascx" %> + +

Adding [Regular]

-  
-  
-  
-  
-  
-  
-  
-  
-  
-  
-  
+ ​
+ ​
+ ​
+ ​
+  
+ ​
+ ​
+
 
XX–
+ ... 
+  
+ ​
+ ​
+  
+ ​
diff --git a/Site5/Pages/v5/Swarm/AddPerson.aspx.cs b/Site5/Pages/v5/Swarm/AddPerson.aspx.cs index e2406fb2..f3bb4c36 100644 --- a/Site5/Pages/v5/Swarm/AddPerson.aspx.cs +++ b/Site5/Pages/v5/Swarm/AddPerson.aspx.cs @@ -1,17 +1,69 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; +using Swarmops.Logic.Structure; +// ReSharper disable once CheckNamespace namespace Swarmops.Frontend.Pages.v5.Swarm { public partial class AddPerson : PageV5Base { protected void Page_Load(object sender, EventArgs e) { + // Override style widths - (this will cause problems with a future responsive design; come back here to fix that) + this.TextPostal.Style[HtmlTextWriterStyle.Width] = "70px"; + this.TextCity.Style[HtmlTextWriterStyle.Width] = "160px"; + + if (!Page.IsPostBack) + { + Populate(); + Localize(); + + this.TextName.Focus(); + } + + this.IncludedControlsUsed = IncludedControl.JsonParameters; + } + + private void Populate() + { + Countries allCountries = Countries.GetAll(); + this.DropCountries.Items.Clear(); + + foreach (Country country in allCountries) + { + // TODO: Localize country name? + + string countryLocalName = Resources.GeographyNames.ResourceManager.GetString("Country_" + country.Code); + if (string.IsNullOrEmpty(countryLocalName)) + { + countryLocalName = country.Name + "*"; // In English + } + string countryDisplay = country.Code + " " + countryLocalName; + this.DropCountries.Items.Add(new ListItem(countryDisplay, country.Code)); + } + + if (this.CurrentOrganization.DefaultCountry != null) + { + this.DropCountries.SelectedValue = this.CurrentOrganization.DefaultCountry.Code; + } + + this.DropGenders.Items.Clear(); + this.DropGenders.Items.Add(new ListItem(Resources.Global.Global_UnknownUndisclosed, "Unknown")); + this.DropGenders.Items.Add(new ListItem(Resources.Global.Global_Female, "Female")); + this.DropGenders.Items.Add(new ListItem(Resources.Global.Global_Male, "Male")); + } + + private void Localize() + { + // TODO + + this.TextDateOfBirth.Attributes["placeholder"] = Resources.Global.Global_DateFormatShort; } } } \ No newline at end of file diff --git a/Site5/Style/v5-easyui-elements.css b/Site5/Style/v5-easyui-elements.css index 213f3266..df0a65d0 100644 --- a/Site5/Style/v5-easyui-elements.css +++ b/Site5/Style/v5-easyui-elements.css @@ -6,7 +6,7 @@ font-size:12px; margin:0; padding:0; - border:1px solid #A4BED4; + /*border:1px solid #A4BED4;*/ background:transparent; } .combo-text{ @@ -26,8 +26,8 @@ display:inline-block; vertical-align:top; position: relative; - top: 6px; - left: 2px; + top: 8px; + left: 3px; border-radius: 5px; cursor:pointer; opacity:0.4; diff --git a/Site5/web.config b/Site5/web.config index e00f7831..3e81f77d 100644 --- a/Site5/web.config +++ b/Site5/web.config @@ -26,6 +26,13 @@ + + + + + + +