From 258f5a017a198ca387c6ed395293c757c90b4f7a Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sat, 15 Nov 2014 05:58:14 +0100 Subject: [PATCH] Abstracted included jQuery plugin controls --- Site5/App_Code/CommonV5Base.cs | 9 ++++ Site5/App_Code/MasterV5Base.cs | 1 + Site5/App_Code/PageV5Base.cs | 6 +++ Site5/Controls/v5/Base/FileUpload.ascx | 2 +- Site5/Controls/v5/UI/IncludedScripts.ascx | 5 +++ Site5/Controls/v5/UI/IncludedScripts.ascx.cs | 41 +++++++++++++++++++ Site5/Master-v5.master | 3 ++ Site5/Master-v5.master.cs | 1 + Site5/Pages/v5/Admin/EditOrganization.aspx | 38 ++++++++++++++--- Site5/Pages/v5/Admin/EditOrganization.aspx.cs | 18 +++++++- .../Pages/v5/Financial/FileExpenseClaim.aspx | 4 -- .../v5/Financial/FileExpenseClaim.aspx.cs | 2 + 12 files changed, 119 insertions(+), 11 deletions(-) create mode 100644 Site5/Controls/v5/UI/IncludedScripts.ascx create mode 100644 Site5/Controls/v5/UI/IncludedScripts.ascx.cs diff --git a/Site5/App_Code/CommonV5Base.cs b/Site5/App_Code/CommonV5Base.cs index d5d1d05a..f03b666d 100644 --- a/Site5/App_Code/CommonV5Base.cs +++ b/Site5/App_Code/CommonV5Base.cs @@ -144,3 +144,12 @@ public enum EasyUIControl ValidateBox = 0x4000000, Window = 0x8000000 }; + + +[Flags] +public enum IncludedControl +{ + Unknown = 0, + FileUpload = 0x00000001, + SwitchButton = 0x00000002 +}; \ No newline at end of file diff --git a/Site5/App_Code/MasterV5Base.cs b/Site5/App_Code/MasterV5Base.cs index 72bebfa2..114650a2 100644 --- a/Site5/App_Code/MasterV5Base.cs +++ b/Site5/App_Code/MasterV5Base.cs @@ -24,6 +24,7 @@ public class MasterV5Base : System.Web.UI.MasterPage protected Organization _currentOrganization = null; public EasyUIControl EasyUIControlsUsed { get; set; } // these are set by each page, and called by Master to render in ExternalScripts control + public IncludedControl IncludedControlsUsed { get; set; } // as above with IncludedScripts control // ReSharper restore InconsistentNaming public DateTime PermissionCacheTimestamp diff --git a/Site5/App_Code/PageV5Base.cs b/Site5/App_Code/PageV5Base.cs index 0742849a..a5893112 100644 --- a/Site5/App_Code/PageV5Base.cs +++ b/Site5/App_Code/PageV5Base.cs @@ -51,6 +51,12 @@ public class PageV5Base : System.Web.UI.Page set { this.Master.EasyUIControlsUsed = value; } } + protected IncludedControl IncludedControlsUsed + { + get { return this.Master.IncludedControlsUsed; } + set { this.Master.IncludedControlsUsed = value; } + } + protected Person CurrentUser { get { return this.Master.CurrentUser; } diff --git a/Site5/Controls/v5/Base/FileUpload.ascx b/Site5/Controls/v5/Base/FileUpload.ascx index 8100eda1..20c09030 100644 --- a/Site5/Controls/v5/Base/FileUpload.ascx +++ b/Site5/Controls/v5/Base/FileUpload.ascx @@ -64,5 +64,5 @@ -
/>
​
+
/>
​
diff --git a/Site5/Controls/v5/UI/IncludedScripts.ascx b/Site5/Controls/v5/UI/IncludedScripts.ascx new file mode 100644 index 00000000..05ad84ff --- /dev/null +++ b/Site5/Controls/v5/UI/IncludedScripts.ascx @@ -0,0 +1,5 @@ +<%@ Control Language="C#" AutoEventWireup="true" CodeFile="IncludedScripts.ascx.cs" Inherits="Swarmops.Frontend.Controls.v5.UI.IncludedScripts" %> + + + + diff --git a/Site5/Controls/v5/UI/IncludedScripts.ascx.cs b/Site5/Controls/v5/UI/IncludedScripts.ascx.cs new file mode 100644 index 00000000..89bf30a1 --- /dev/null +++ b/Site5/Controls/v5/UI/IncludedScripts.ascx.cs @@ -0,0 +1,41 @@ +using System; +using System.IO; +using System.Text; +using NBitcoin; +using Swarmops.Logic.Support; + +namespace Swarmops.Frontend.Controls.v5.UI +{ + public partial class IncludedScripts : ControlV5Base + { + protected void Page_Load(object sender, EventArgs e) + { + StringBuilder scriptRef = new StringBuilder(); + + string[] controlNames = Controls.Split(','); + foreach (string controlName in controlNames) + { + switch (controlName.Trim().ToLowerInvariant()) + { + case "fileupload": + scriptRef.Append( + "\r\n" + + "\r\n"); + break; + + case "switchbutton": + scriptRef.Append( + "\r\n" + + "\r\n"); + break; + default: + break; + } + } + + this.LiteralReference.Text = scriptRef.ToString(); + } + + public new string Controls { get; set; } + } +} \ No newline at end of file diff --git a/Site5/Master-v5.master b/Site5/Master-v5.master index 3e4d5698..1062c2c4 100644 --- a/Site5/Master-v5.master +++ b/Site5/Master-v5.master @@ -1,5 +1,6 @@ <%@ Master Language="C#" AutoEventWireup="true" CodeFile="Master-v5.master.cs" Inherits="Swarmops.MasterV5" %> <%@ Register TagPrefix="Swarmops5" TagName="ExternalScripts" Src="~/Controls/v5/UI/ExternalScripts.ascx" %> +<%@ Register TagPrefix="Swarmops5" TagName="IncludedScripts" Src="~/Controls/v5/UI/IncludedScripts.ascx" %> <%@ Register TagPrefix="Swarmops5" TagName="MainMenu" Src="~/Controls/v5/Base/MainMenu.ascx" %> @@ -39,6 +40,8 @@ + + diff --git a/Site5/Master-v5.master.cs b/Site5/Master-v5.master.cs index 58b4a1da..d9b53c8d 100644 --- a/Site5/Master-v5.master.cs +++ b/Site5/Master-v5.master.cs @@ -48,6 +48,7 @@ namespace Swarmops this.Page.Title = "Swarmops - " + this.CurrentPageTitle; this.ExternalScriptEasyUI.Controls = EasyUIControlsUsed.ToString(); + this.IncludedScripts.Controls = IncludedControlsUsed.ToString(); this.LiteralSidebarInfo.Text = this.CurrentPageInfoBoxLiteral; diff --git a/Site5/Pages/v5/Admin/EditOrganization.aspx b/Site5/Pages/v5/Admin/EditOrganization.aspx index e4de0059..350402da 100644 --- a/Site5/Pages/v5/Admin/EditOrganization.aspx +++ b/Site5/Pages/v5/Admin/EditOrganization.aspx @@ -1,8 +1,8 @@ <%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="EditOrganization.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Admin.EditOrganization" %> +<%@ Register tagPrefix="Swarmops5" tagName="FileUpload" src="~/Controls/v5/Base/FileUpload.ascx" %> - - +