From 21279148d806ac0d6af107876e885e8604aad1bf Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sun, 12 Oct 2014 13:34:37 +0200 Subject: [PATCH] Added CreateOrganization page mockup --- Basic/Types/BasicCurrency.cs | 8 +- Logic/Financial/Currencies.cs | 18 +++ Logic/Logic.csproj | 1 + Logic/Support/SingularFactory.cs | 5 +- Site5/App_GlobalResources/Global.resx | 26 ++- Site5/App_GlobalResources/Pages.Admin.resx | 149 ++++++++++++++++++ .../Automation/Json-AvailableCurrencies.aspx | 1 + .../Json-AvailableCurrencies.aspx.cs | 61 +++++++ .../iconshock-organization-add-40px.png | Bin 0 -> 3955 bytes Site5/MainMenu-v5.xml | 6 +- Site5/Pages/v5/Admin/CreateOrganization.aspx | 82 ++++++---- .../Pages/v5/Admin/CreateOrganization.aspx.cs | 71 ++++++++- 12 files changed, 381 insertions(+), 47 deletions(-) create mode 100644 Logic/Financial/Currencies.cs create mode 100644 Site5/App_GlobalResources/Pages.Admin.resx create mode 100644 Site5/Automation/Json-AvailableCurrencies.aspx create mode 100644 Site5/Automation/Json-AvailableCurrencies.aspx.cs create mode 100644 Site5/Images/PageIcons/iconshock-organization-add-40px.png diff --git a/Basic/Types/BasicCurrency.cs b/Basic/Types/BasicCurrency.cs index c29a1849..ed692da1 100644 --- a/Basic/Types/BasicCurrency.cs +++ b/Basic/Types/BasicCurrency.cs @@ -4,16 +4,16 @@ namespace Swarmops.Basic.Types { public class BasicCurrency: IHasIdentity { - public BasicCurrency (int currencyId, string code, string description, string sign) + public BasicCurrency (int currencyId, string code, string name, string sign) { this.CurrencyId = currencyId; this.Code = code; - this.Description = description; + this.Name = name; this.Sign = sign; } public BasicCurrency (BasicCurrency original) - : this (original.CurrencyId, original.Code, original.Description, original.Sign) + : this (original.CurrencyId, original.Code, original.Name, original.Sign) { // empty copy ctor } @@ -21,7 +21,7 @@ namespace Swarmops.Basic.Types public int CurrencyId { get; private set; } public string Code { get; private set; } - public string Description { get; private set; } + public string Name { get; private set; } public string Sign { get; private set; } public int Identity diff --git a/Logic/Financial/Currencies.cs b/Logic/Financial/Currencies.cs new file mode 100644 index 00000000..3d7a55ba --- /dev/null +++ b/Logic/Financial/Currencies.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Swarmops.Basic.Types; +using Swarmops.Database; +using Swarmops.Logic.Support; + +namespace Swarmops.Logic.Financial +{ + public class Currencies: PluralBase + { + public static Currencies GetAll() + { + return FromArray(SwarmDb.GetDatabaseForReading().GetCurrencies()); + } + } +} diff --git a/Logic/Logic.csproj b/Logic/Logic.csproj index a1c26923..35c496a1 100644 --- a/Logic/Logic.csproj +++ b/Logic/Logic.csproj @@ -94,6 +94,7 @@ + diff --git a/Logic/Support/SingularFactory.cs b/Logic/Support/SingularFactory.cs index 374e4c75..6b5e53c5 100644 --- a/Logic/Support/SingularFactory.cs +++ b/Logic/Support/SingularFactory.cs @@ -84,6 +84,9 @@ namespace Swarmops.Logic.Support case "Swarmops.Basic.Types.BasicSalary": return Salary.FromBasic((BasicSalary) basic); + case "Swarmops.Basic.Types.BasicCurrency": + return Currency.FromBasic((BasicCurrency) basic); + case "Swarmops.Basic.Types.Financial.BasicFinancialTransactionTagSet": return FinancialTransactionTagSet.FromBasic ((BasicFinancialTransactionTagSet) basic); @@ -131,7 +134,7 @@ namespace Swarmops.Logic.Support // ------------------ FAIL ---------------- default: - throw new NotImplementedException("Unimplemented argument type: " + argumentType); + throw new NotImplementedException("Unimplemented argument type in SingularFactory: " + argumentType); } diff --git a/Site5/App_GlobalResources/Global.resx b/Site5/App_GlobalResources/Global.resx index c352fd27..84808658 100644 --- a/Site5/App_GlobalResources/Global.resx +++ b/Site5/App_GlobalResources/Global.resx @@ -677,7 +677,7 @@ Operatives - NO IDEA SORRY - TODO + Operativehood Corps @@ -695,7 +695,7 @@ Regulars - I HAVE NO IDEA WHAT THIS SHOULD BE - TODO + Regularhood Crew @@ -715,4 +715,26 @@ Seamanship + + Create + Like "Create Organization" + + + Forces + + + Person + + + Person + + + Person + + + People + + + Personhood + \ No newline at end of file diff --git a/Site5/App_GlobalResources/Pages.Admin.resx b/Site5/App_GlobalResources/Pages.Admin.resx new file mode 100644 index 00000000..296c70f8 --- /dev/null +++ b/Site5/App_GlobalResources/Pages.Admin.resx @@ -0,0 +1,149 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Activists will be called + + + Root-level organization + + + Child of {0} + "Create org as..." + + + Create new organization as... + + + You can create a new organization either as a new standalone organization, or as a child organization of the current one. (In a child organization, everybody with responsibility in the parent organization automatically has corresponding rights and privileges.) + + + Operating currency + + + The new organization's name + + + Create New Organization + + + Regular people will be called + This can be "members", etc. + + \ No newline at end of file diff --git a/Site5/Automation/Json-AvailableCurrencies.aspx b/Site5/Automation/Json-AvailableCurrencies.aspx new file mode 100644 index 00000000..0a353acb --- /dev/null +++ b/Site5/Automation/Json-AvailableCurrencies.aspx @@ -0,0 +1 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Json-AvailableCurrencies.aspx.cs" Inherits="Swarmops.Frontend.Automation.Json_AvailableCurrencies" %> \ No newline at end of file diff --git a/Site5/Automation/Json-AvailableCurrencies.aspx.cs b/Site5/Automation/Json-AvailableCurrencies.aspx.cs new file mode 100644 index 00000000..088fe235 --- /dev/null +++ b/Site5/Automation/Json-AvailableCurrencies.aspx.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using Swarmops.Logic.Financial; +using Swarmops.Logic.Structure; + +namespace Swarmops.Frontend.Automation +{ + public partial class Json_AvailableCurrencies : DataV5Base + { + protected void Page_Load(object sender, EventArgs e) + { + GetAuthenticationDataAndCulture(); + + Response.ContentType = "application/json"; + + // Is this stuff in cache already? + + string cacheKey = "Currencies-Json-" + Thread.CurrentThread.CurrentCulture.Name; + + string currenciesJson = + (string) Cache[cacheKey]; + + if (currenciesJson != null) + { + Response.Output.WriteLine(currenciesJson); + Response.End(); + return; + } + + Currencies currencies = Currencies.GetAll(); + + List currencyStrings = new List(); + + foreach (Currency currency in currencies) + { + currencyStrings.Add(String.Format("{0} {1}|{0}", currency.Code, currency.Name)); + } + + currencyStrings.Sort(); + currenciesJson = "["; + + foreach (string currencyString in currencyStrings) + { + string[] parts = currencyString.Split('|'); + + currenciesJson += "{" + String.Format("\"label\":\"{0}\",\"code\":\"{1}\"", parts[0], parts[1]) + "},"; + } + + currenciesJson = currenciesJson.TrimEnd(',') + "]"; + + Cache.Insert(cacheKey, currenciesJson, null, DateTime.Now.AddMinutes(60), TimeSpan.Zero); + // cache lasts for sixty minutes, no sliding expiration + Response.Output.WriteLine(currenciesJson); + + Response.End(); + } + + } +} \ No newline at end of file diff --git a/Site5/Images/PageIcons/iconshock-organization-add-40px.png b/Site5/Images/PageIcons/iconshock-organization-add-40px.png new file mode 100644 index 0000000000000000000000000000000000000000..d554109f75eb4de4bbe3061a2789b9936273f667 GIT binary patch literal 3955 zcmV-(4~+1MP)IBO#E5uuK#K3JGDrB?Afwr43V*jKj#x2s+eE zxibo5R00m-Hi`~4;uehv8V!&H5@OPwPN(nQWoRbS}^MOpeK!S%ii~G~m_m*uM49%8o?u)@$BA_#2yxr?w*}JyWy{pa z;BCMIe^NkzH5V+oV)3#I$m9wfJTb&i_m44^FA)!iX-y`W$mE!uE3&w~jTIe9riKO? zwrx^=(LI|#`FzjQ`C8L;UB4oO>(Z>%*|A|Y%X=0wo-J^Ee42x=yu#%@^YF`Xa&QnA zNX4Q=Tcc<7C%)N&y}iAB`^m=_J^l5scAd}dYcv|`$(z8?Y2XF4z%?%}0<@N_YUDa#) zVI2GL&`ja*k>`JW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C(o zuH|bOnx3JMFJRP7E?&~bvYu{aNup3H@$#!j=sP*Y-M8ODI+@_9pS-~DP7adtO4v0W zS%mgf{3{{9?^BO__7jtD)W8&OyY063ee8jcJ$hnfAofV{-^ltWF$EQ`B9M^6#G45& zn7V{b(Jk(QqpwUZy=c>X)kZ9qiu4bhBAcH>uUow3lC@}-#p3z%Sl+#WMV)Q@WZ%pD zc>f`K+LCleLljCSMAsP%`sBa)%)dOe=X^V?!rHZKTeolD{=kOy8}4bF*M_KwSf)j} zR3blH;MA#8hYuV$aK}`|oNDRpT6oFICAWGa@jJ6sGdMLq%B5>oF*Y$lsZznCc*xc) z24@TO{^dL9X-iY7R!}QtGSgEZd9`ow@fUyk{p#xz)$?ruhipWgXX}xLdW!Hy;{tqg?z_P{NJ)U{(Y3=D} z{_EavJpR3J)67}?x$UB>cAV|E^4<^L({tB{@85pod+%KECS(7|{u{Nph05Eok>>ya N002ovPDHLkV1kByrNjUL literal 0 HcmV?d00001 diff --git a/Site5/MainMenu-v5.xml b/Site5/MainMenu-v5.xml index 9a61fdef..bb35567d 100644 --- a/Site5/MainMenu-v5.xml +++ b/Site5/MainMenu-v5.xml @@ -361,11 +361,11 @@ Submenu - + diff --git a/Site5/Pages/v5/Admin/CreateOrganization.aspx b/Site5/Pages/v5/Admin/CreateOrganization.aspx index 524c2dd1..eb622181 100644 --- a/Site5/Pages/v5/Admin/CreateOrganization.aspx +++ b/Site5/Pages/v5/Admin/CreateOrganization.aspx @@ -1,23 +1,55 @@ <%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="CreateOrganization.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Admin.CreateOrganization" %> -<%@ Register src="~/Controls/v5/Base/FileUpload.ascx" tagname="FileUpload" tagprefix="Swarmops5" %> <%@ Register TagPrefix="Swarmops5" TagName="ExternalScripts" Src="~/Controls/v5/UI/ExternalScripts.ascx" %> -<%@ Register TagPrefix="Swarmops5" TagName="ComboBudgets" Src="~/Controls/v5/Financial/ComboBudgets.ascx" %> - - - - @@ -27,34 +59,18 @@
​
- - - -  
- - - - - - - -  
- ​
- ​
-  
- + ​
+ ​
+ ​
+ ​
+
diff --git a/Site5/Pages/v5/Admin/CreateOrganization.aspx.cs b/Site5/Pages/v5/Admin/CreateOrganization.aspx.cs index 33c5def7..6781e141 100644 --- a/Site5/Pages/v5/Admin/CreateOrganization.aspx.cs +++ b/Site5/Pages/v5/Admin/CreateOrganization.aspx.cs @@ -1,5 +1,8 @@ using System; +using System.Collections.Generic; using System.Web; +using System.Web.UI.WebControls; +using Swarmops.Logic.Financial; namespace Swarmops.Frontend.Pages.v5.Admin { @@ -7,9 +10,9 @@ namespace Swarmops.Frontend.Pages.v5.Admin { protected void Page_Load(object sender, EventArgs e) { - this.PageTitle = Resources.Pages.Financial.FileExpenseClaim_PageTitle; - this.PageIcon = "iconshock-moneyback"; - this.InfoBoxLiteral = Resources.Pages.Financial.FileExpenseClaim_Info; + this.PageTitle = Resources.Pages.Admin.CreateOrganization_PageTitle; + this.PageIcon = "iconshock-organization-add"; + this.InfoBoxLiteral = Resources.Pages.Admin.CreateOrganization_Info; if (!Page.IsPostBack) { @@ -18,13 +21,73 @@ namespace Swarmops.Frontend.Pages.v5.Admin } + private readonly string[] _personLabels = + { + "Activist", "Person", "Sailor", "Regular", "Ambassador", "Salesperson", + "Member", "Operative", "Employee", "Customer", "Conscript", "Resident", "Citizen", "Agent" + }; + + private void Localize() { + this.LabelOrganizationName.Text = Resources.Pages.Admin.CreateOrganization_NewOrgName; + this.LabelActivistLabel.Text = Resources.Pages.Admin.CreateOrganization_ActivistTitle; + this.LabelCreateAs.Text = Resources.Pages.Admin.CreateOrganization_CreateNewOrgAs; + this.LabelNativeCurrency.Text = Resources.Pages.Admin.CreateOrganization_NewOrgCurrency; + this.LabelPersonLabel.Text = Resources.Pages.Admin.CreateOrganization_RegularTitle; + this.ButtonCreate.Text = Resources.Global.Global_Create; + + this.DropPersonLabel.Items.Clear(); + this.DropActivistLabel.Items.Clear(); + this.DropCurrencies.Items.Clear(); + this.DropCreateChild.Items.Clear(); + this.DropPersonLabel.Items.Add(new ListItem(Resources.Global.Global_SelectOne, "0")); + this.DropActivistLabel.Items.Add(new ListItem(Resources.Global.Global_SelectOne, "0")); + this.DropCurrencies.Items.Add(new ListItem(Resources.Global.Global_SelectOne, "0")); + this.DropCreateChild.Items.Add(new ListItem(Resources.Global.Global_SelectOne, "0")); + + + List localizedPersonLabels = new List(); + + foreach (string personLabel in _personLabels) + { + string localizedPersonLabel = + Resources.Global.ResourceManager.GetString("Title_" + personLabel + "_Plural"); + + localizedPersonLabels.Add(localizedPersonLabel + "|" + personLabel); + } + + localizedPersonLabels.Sort(); + + foreach (string localizedPersonLabel in localizedPersonLabels) + { + string[] parts = localizedPersonLabel.Split('|'); + this.DropPersonLabel.Items.Add(new ListItem(parts[0], parts[1])); + this.DropActivistLabel.Items.Add(new ListItem(parts[0], parts[1])); + } + + Currencies currencies = Currencies.GetAll(); + + List currencyStrings = new List(); + + foreach (Currency currency in currencies) + { + currencyStrings.Add(String.Format("{0} {1}|{0}", currency.Code, currency.Name)); + } + + currencyStrings.Sort(); + + foreach (string currencyString in currencyStrings) + { + string[] parts = currencyString.Split('|'); + + this.DropCurrencies.Items.Add(new ListItem(parts[0], parts[1])); + } } - protected void ButtonRequest_Click(object sender, EventArgs e) + protected void ButtonCreate_Click(object sender, EventArgs e) { string successMessage = string.Empty;