Checkpoint commit on Add Person; testing on Dev Mono

This commit is contained in:
Rick Falkvinge
2014-12-03 23:10:30 +01:00
parent 3fa6f3ffbe
commit 0d56c13eb2
10 changed files with 297 additions and 21 deletions
+8 -1
View File
@@ -305,7 +305,14 @@ namespace Swarmops.Logic.Structure
/// </summary>
public Country DefaultCountry
{
get { return Country.FromIdentity(DefaultCountryId); }
get
{
if (DefaultCountryId == 0)
{
return null;
}
return Country.FromIdentity(DefaultCountryId);
}
}
/// <summary>
+92 -2
View File
@@ -117,9 +117,60 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Country_AC" xml:space="preserve">
<value>Ascension Island</value>
</data>
<data name="Country_AD" xml:space="preserve">
<value>Andorra</value>
</data>
<data name="Country_AT" xml:space="preserve">
<value>Austria</value>
</data>
<data name="Country_AU" xml:space="preserve">
<value>Australia</value>
</data>
<data name="Country_BR" xml:space="preserve">
<value>Brazil</value>
</data>
<data name="Country_DE" xml:space="preserve">
<value>Germany</value>
</data>
<data name="Country_DK" xml:space="preserve">
<value>Denmark</value>
</data>
<data name="Country_ES" xml:space="preserve">
<value>Spain</value>
</data>
<data name="Country_FI" xml:space="preserve">
<value>Finland</value>
</data>
<data name="Country_GH" xml:space="preserve">
<value>Ghana</value>
</data>
<data name="Country_NO" xml:space="preserve">
<value>Norway</value>
</data>
<data name="Country_PL" xml:space="preserve">
<value>Poland</value>
</data>
<data name="Country_SE" xml:space="preserve">
<value>Sweden</value>
</data>
<data name="Country_SK" xml:space="preserve">
<value>Slovak Republic</value>
</data>
<data name="Country_SM" xml:space="preserve">
<value>San Marino</value>
</data>
<data name="Country_UK" xml:space="preserve">
<value>United Kingdom</value>
</data>
<data name="Country_US" xml:space="preserve">
<value>United States</value>
</data>
<data name="EasternEurope" xml:space="preserve">
<value>Eastern Europe</value>
<comment>(East of former Iron Curtain)</comment>
<comment>(East of southern tip of Sweden, appx)</comment>
</data>
<data name="Europe" xml:space="preserve">
<value>Europe</value>
@@ -132,9 +183,48 @@
<value>Nordics</value>
<comment>(Finland Denmark Norway Sweden Iceland)</comment>
</data>
<data name="USA_EastNorthCentral" xml:space="preserve">
<value>East North Central</value>
</data>
<data name="USA_EastSouthCentral" xml:space="preserve">
<value>East South Central</value>
</data>
<data name="USA_MidAtlantic" xml:space="preserve">
<value>Mid-Atlantic</value>
</data>
<data name="USA_Midwest" xml:space="preserve">
<value>Midwest</value>
</data>
<data name="USA_Mountain" xml:space="preserve">
<value>Mountain</value>
</data>
<data name="USA_NewEngland" xml:space="preserve">
<value>New England</value>
</data>
<data name="USA_Northeast" xml:space="preserve">
<value>Northeast</value>
</data>
<data name="USA_Pacific" xml:space="preserve">
<value>Pacific</value>
</data>
<data name="USA_South" xml:space="preserve">
<value>South</value>
</data>
<data name="USA_SouthAtlantic" xml:space="preserve">
<value>South Atlantic</value>
</data>
<data name="USA_West" xml:space="preserve">
<value>West</value>
</data>
<data name="USA_WestNorthCentral" xml:space="preserve">
<value>West North Central</value>
</data>
<data name="USA_WestSouthCentral" xml:space="preserve">
<value>West South Central</value>
</data>
<data name="WesternEurope" xml:space="preserve">
<value>Western Europe</value>
<comment>(West of former Iron Curtain)</comment>
<comment>(West of southern tip of Sweden, appx)</comment>
</data>
<data name="World" xml:space="preserve">
<value>World</value>
+16
View File
@@ -808,4 +808,20 @@
<data name="Title_Contributor_Ship" xml:space="preserve">
<value>Contributorship</value>
</data>
<data name="Global_Female" xml:space="preserve">
<value>Female</value>
<comment>Legal gender</comment>
</data>
<data name="Global_Male" xml:space="preserve">
<value>Male</value>
<comment>Legal gender</comment>
</data>
<data name="Global_UnknownUndisclosed" xml:space="preserve">
<value>Unknown or Undisclosed</value>
<comment>Used for gender et al</comment>
</data>
<data name="Global_DateFormatShort" xml:space="preserve">
<value>MM/DD/YYYY</value>
<comment>Adapt format for culture, then translate to human-readability, not machine-readability. E.g. ÅÅÅÅ-MM-DD for Swedish.</comment>
</data>
</root>
+36
View File
@@ -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<PostalCodeData> result = new List<PostalCodeData>();
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; }
}
+7 -1
View File
@@ -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%>');
+7
View File
@@ -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; }
}
}
}
+69 -14
View File
@@ -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" %>
<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderHead" Runat="Server">
<script type="text/javascript" language="javascript">
$(document).ready(function() {
UpdatePostalPrefix('XX', $('#<%=DropCountries.ClientControlID%>').val());
$('#<%=this.TextPostal.ClientID%>').on ('input', function() {
var currentPostalCode = $('#<%=this.TextPostal.ClientID%>').val();
if (currentPostalCode in postalCodeLookup) {
$('#<%=this.TextCity.ClientID%>').attr("disabled","disabled").val(postalCodeLookup[currentPostalCode]);
$('#<%=this.TextDateOfBirth.ClientID%>').focus();
}
});
alert('bah');
});
function UpdatePostalPrefix(oldValue, newValue) {
$('#SpanCountryPrefix').text(newValue);
// Get postal code data for country. Heavy op; should not be done from mobile
var jsonData = {};
jsonData.countryCode = newValue;
alert(newValue);
$.ajax({
type: "POST",
url: "/Automation/FieldValidation.aspx/GetPostalCodes",
data: $.toJSON(jsonData),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
postalCodeLookup = {};
msg.d.forEach(function (element, index, array) {
postalCodeLookup[element.Code] = element.Name;
});
},
error: function (msg) {
console.log(msg);
postalCodeLookup = {};
}
});
}
var postalCodeLookup = {};
var postalCodeLength = 0
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="PlaceHolderMain" Runat="Server">
<h2>Adding [Regular]</h2>
<div class="entryFields">
&nbsp;<br />
&nbsp;<br />
&nbsp;<br />
&nbsp;<br />
&nbsp;<br />
&nbsp;<br />
&nbsp;<br />
&nbsp;<br />
&nbsp;<br />
&nbsp;<br />
&nbsp;<br />
<asp:TextBox runat="server" ID="TextName" />&#8203;<br/>
<Swarmops5:DropDown runat="server" OnClientChange="UpdatePostalPrefix" ID="DropCountries"/>&#8203;<br/>
<asp:TextBox runat="server" ID="TextMail" />&#8203;<br/>
<asp:TextBox runat="server" ID="TextPhone" />&#8203;<br/>
&nbsp;<br/>
<asp:TextBox runat="server" ID="TextStreet1" />&#8203;<br/>
<asp:TextBox runat="server" ID="TextStreet2" />&#8203;<br/>
<div style="float:right;margin-right:5px"><asp:TextBox runat="server" ID="TextPostal" />&nbsp;<asp:TextBox runat="server" ID="TextCity" /></div><div style="width:40px;overflow:hidden"><span id="SpanCountryPrefix">XX</span>&ndash;</div>
<span id="spanDetectedGeo">...</span>&nbsp;<br/>
&nbsp;<br/>
<asp:TextBox runat="server" ID="TextDateOfBirth" />&#8203;<br/>
<Swarmops5:DropDown runat="server" ID="DropGenders" />&#8203;<br/>
&nbsp;<br/>
<asp:Label ID="LabelExpiry" runat="server" Text="YYYY-MM-DD" />&#8203;<br/>
</div>
<div class="entryLabels">
Name<br />
Name (First Last)<br />
Country<br />
Mail<br />
Phone<br />
<h2>ADDRESS</h2>
Street 1<br />
Street 2<br />
Postal Code, City<br />
Country<br />
<span id="SpanGeoDetected">Geography detected</span><span id="SpanGeoSelect" style="display:none">Select Geograhpy</span><br />
<h2>DEMOGRAPHIC DATA</h2>
Date of Birth<br />
Legal gender<br />
Geography detected<br />
<h2>SIGNING UP AS</h2>
[Regular] until<br />
</div>
</asp:Content>
+52
View File
@@ -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;
}
}
}
+3 -3
View File
@@ -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;
+7
View File
@@ -26,6 +26,13 @@
</authorization>
<pages controlRenderingCompatibilityVersion="4.0" clientIDMode="AutoID"/>
</system.web>
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="50000000"/>
</webServices>
</scripting>
</system.web.extensions>
<system.data>
<DbProviderFactories>
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.2.2.0, Culture=neutral"/>