From 6b96e835b84ecd28b3efeba3b0e64478cc72140c Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Fri, 1 May 2015 16:33:00 +0200 Subject: [PATCH] Work on Positions; Added Local Org --- Basic/Types/Swarm/BasicPosition.cs | 2 +- Common/Generics/Tree.cs | 9 +++ Logic/Security/Accesses.cs | 2 +- Logic/Swarm/Position.cs | 9 +++ Logic/Swarm/Positions.cs | 49 +++++++++++++ Site5/App_GlobalResources/Menu5.resx | 3 + Site5/App_GlobalResources/Pages.Admin.resx | 6 ++ Site5/App_GlobalResources/Pages.Swarm.resx | 7 ++ Site5/Automation/Json-PositionsTree.aspx.cs | 20 +++++ .../iconshock-three-buildings-40px.png | Bin 0 -> 3792 bytes Site5/MainMenu-v5.xml | 10 ++- Site5/Pages/v5/Admin/OrgStaffing.aspx.cs | 7 +- Site5/Pages/v5/Swarm/LocalOrganization.aspx | 27 +++++++ .../Pages/v5/Swarm/LocalOrganization.aspx.cs | 69 ++++++++++++++++++ 14 files changed, 210 insertions(+), 10 deletions(-) create mode 100644 Site5/Images/PageIcons/iconshock-three-buildings-40px.png create mode 100644 Site5/Pages/v5/Swarm/LocalOrganization.aspx create mode 100644 Site5/Pages/v5/Swarm/LocalOrganization.aspx.cs diff --git a/Basic/Types/Swarm/BasicPosition.cs b/Basic/Types/Swarm/BasicPosition.cs index 40f07401..5f7be792 100644 --- a/Basic/Types/Swarm/BasicPosition.cs +++ b/Basic/Types/Swarm/BasicPosition.cs @@ -55,7 +55,7 @@ namespace Swarmops.Basic.Types.Swarm public int PositionId { get; private set; } public PositionLevel PositionLevel { get; private set; } public int OrganizationId { get; private set; } - public int GeographyId { get; private set; } + public int GeographyId { get; protected set; } public int OverridesHigherPositionId { get; protected set; } public int CreatedByPersonId { get; private set; } diff --git a/Common/Generics/Tree.cs b/Common/Generics/Tree.cs index 81b58aa1..a43ed845 100644 --- a/Common/Generics/Tree.cs +++ b/Common/Generics/Tree.cs @@ -84,6 +84,15 @@ namespace Swarmops.Common.Generics Data = data; } + public void AddChild (TNode newChild) + { + TreeNode newNode = new TreeNode(newChild); + newNode.Parent = this; + newNode.Children = new List>(); // should not be necessary + + Children.Add (newNode); + } + public TNode Data; public List> Children; public TreeNode Parent; diff --git a/Logic/Security/Accesses.cs b/Logic/Security/Accesses.cs index 7d48fa97..6a780563 100644 --- a/Logic/Security/Accesses.cs +++ b/Logic/Security/Accesses.cs @@ -87,7 +87,7 @@ namespace Swarmops.Logic.Security Null, /// - /// Uniquely identified person (logged on) in a specific org. Write access means they can submit expense reports on their own behalf &c. + /// Uniquely identified person (logged on) in a specific org. Write access means they can submit expense reports on their own behalf etc. /// Participant, diff --git a/Logic/Swarm/Position.cs b/Logic/Swarm/Position.cs index 2dbc6b3d..5a691862 100644 --- a/Logic/Swarm/Position.cs +++ b/Logic/Swarm/Position.cs @@ -149,6 +149,15 @@ namespace Swarmops.Logic.Swarm } + public void AssignGeography (Geography geography) + { + // This fakes a geography base. Used for locking a position to a specific geo. Not good architecture as it + // creates a different meaning than the database one. + + base.GeographyId = geography.Identity; + } + + public PositionAssignments Assignments { get { return PositionAssignments.ForPosition (this); } diff --git a/Logic/Swarm/Positions.cs b/Logic/Swarm/Positions.cs index 57b3bbd8..7a099014 100644 --- a/Logic/Swarm/Positions.cs +++ b/Logic/Swarm/Positions.cs @@ -25,6 +25,55 @@ namespace Swarmops.Logic.Swarm return FromArray (SwarmDb.GetDatabaseForReading().GetPositions (organization)); } + public static Tree ForOrganizationGeography (Organization organization, Geography geography) + { + Positions result = new Positions(); + string localizedLeaderTitle = null; + Position geographyLeaderTemplate = null; + + if (geography.Identity == Geography.RootIdentity) + { + result = ForOrganization (organization).AtLevel (PositionLevel.OrganizationExecutive); + } + else + { + result = ForOrganization (organization).AtLevel (PositionLevel.GeographyDefault); + localizedLeaderTitle = result.Tree.RootNodes[0].Data.Localized(); // indexer will throw if no root nodes exist + geographyLeaderTemplate = result.Tree.RootNodes[0].Data; + + // TODO: Apply custom geographic positions from executive level downward + } + foreach (Position geoPosition in result) + { + geoPosition.AssignGeography (geography); // used for template geographies + } + + if (localizedLeaderTitle == null) + { + geographyLeaderTemplate = + ForOrganization (organization).AtLevel (PositionLevel.GeographyDefault).Tree.RootNodes[0].Data; + localizedLeaderTitle = geographyLeaderTemplate.Localized(); + } + + // Add leader positions of the geographies immediately below (in X generations?). + + Tree treeResult = result.Tree; + + Geographies children = geography.Children; + + foreach (Geography childGeo in children) + { + // Create copies of the leader position and use as templates for the children + + Position childPosition = Position.FromBasic (geographyLeaderTemplate); + childPosition.AssignGeography (childGeo); + + treeResult.RootNodes[0].AddChild (childPosition); + } + + return treeResult; + } + public Positions AtLevel (PositionLevel level) { return FromArray (this.Where (position => position.PositionLevel == level).ToArray()); diff --git a/Site5/App_GlobalResources/Menu5.resx b/Site5/App_GlobalResources/Menu5.resx index 2426bc43..c8f5cfb8 100644 --- a/Site5/App_GlobalResources/Menu5.resx +++ b/Site5/App_GlobalResources/Menu5.resx @@ -411,4 +411,7 @@ Organization Staffing + + My Local Organization + \ No newline at end of file diff --git a/Site5/App_GlobalResources/Pages.Admin.resx b/Site5/App_GlobalResources/Pages.Admin.resx index d8c83c13..cb81f429 100644 --- a/Site5/App_GlobalResources/Pages.Admin.resx +++ b/Site5/App_GlobalResources/Pages.Admin.resx @@ -217,6 +217,12 @@ Volunteers Awating Response + + Set the staffing structure for this organization, as well as its staffing at the strategic (board) and executive (C-level or equivalent) levels. You can also manage waiting volunteers and the payroll from here. + + + Organization Staffing + Admin Notifications From Address diff --git a/Site5/App_GlobalResources/Pages.Swarm.resx b/Site5/App_GlobalResources/Pages.Swarm.resx index c893a041..a7dc41de 100644 --- a/Site5/App_GlobalResources/Pages.Swarm.resx +++ b/Site5/App_GlobalResources/Pages.Swarm.resx @@ -176,6 +176,13 @@ The result set contains over a thousand people (display limited to a thousand). Please refine your search? + + These are your local contacts. (If you have administrative privileges, you may also assign people to these positions.) + + + My Local Organization ({0}) + The {0} is the geography name. + Assign person... diff --git a/Site5/Automation/Json-PositionsTree.aspx.cs b/Site5/Automation/Json-PositionsTree.aspx.cs index 59462b69..c424be43 100644 --- a/Site5/Automation/Json-PositionsTree.aspx.cs +++ b/Site5/Automation/Json-PositionsTree.aspx.cs @@ -91,6 +91,20 @@ namespace Swarmops.Frontend.Automation } + else if (level == PositionLevel.Geography) + { + _geographyId = Convert.ToInt32 (Request["GeographyId"]); + Geography geography = Geography.FromIdentity (_geographyId); + + if (CurrentAuthority.HasAccess (new Access (CurrentOrganization, AccessAspect.Administration))) + { + _assignable = true; + } + + Tree positions = Positions.ForOrganizationGeography (CurrentOrganization, geography); + Response.Output.WriteLine (RecursePositionTree (positions.RootNodes)); + + } } private string RecursePositionTree (List> positionNodes) @@ -108,6 +122,11 @@ namespace Swarmops.Frontend.Automation string localizedPositionName = position.Localized (positionNode.Data.MaxCount != 1); PositionAssignments assignments = position.Assignments; + if (position.GeographyId != _geographyId) + { + localizedPositionName += " (" + position.Geography.Name + ")"; + } + string expires = string.Empty; string action = string.Empty; string assignedName = Resources.Controls.Swarm.Positions_Vacant; @@ -231,6 +250,7 @@ namespace Swarmops.Frontend.Automation private string _customCookieClass; private bool _assignable = false; // TODO: Maybe make this more dynamic later + private int _geographyId; private class JsonPosition diff --git a/Site5/Images/PageIcons/iconshock-three-buildings-40px.png b/Site5/Images/PageIcons/iconshock-three-buildings-40px.png new file mode 100644 index 0000000000000000000000000000000000000000..4e06d2a7cd5108d48448e8eff5ad0362f58f4f02 GIT binary patch literal 3792 zcmV;>4lnVEP)Fgn7AqheRVuBNv!N7e|O*Boj-!ihzYp={<*i# zJ@q@E`#a}%&hLB${!Dh@uKnC{>uvzXE%@GL3w~r(C10wNFO`{^D>5;YXC`03F?G_>kbKiMmmgZzmfXGd zimOh&*{APM3Hb4keuO*kec+qvRO_D8HG^y_Njw}vlFr0I6a)lOKoSM~l0+;T<;E*F z$J*kdO{a$kJ_vm7&k6`|!HT7q_AOq*Z~Uzc=7R-#W;SzrE?)9lS;(91I}fA(|H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F59>7E&x9E4x5^$*Cz?vKiKGxN!aV9(%H|=QE$* z^nsmM3V)EYaM%9*+`9W#4&HP3J2$`kuO3UL(#b<7#z-U+3=fauI4+@ZkW4B?I+LI- zD@;x2h{s~2Qz;Z(M^QBz4UbB>Oifm}_2!*icF_jLX6E?BzW;2#w6FcyL(d&)21ZoZV+*;#)2;!6ahAyh>rH#3W>stBTlVVXoEA#Qx{Hat<} z-p78zqfb9ecSvGEa~io?tp$_O-P?D5sQCJ>^7{dHtl8v$=4b!oI1P{HmU*1t+sa><7ENIsE5smx1<`WYM zi%<0E$fouQqVUx_zWjyLCtm(JD>l6I_ZKiXY<;hA_*aAJ&TM-1HJdkHcmB#1Tbh#D zMK#@$<_bkljf^mpFJM>}m#$rfY}qX7>0;^pZaU{>dFmIh^7xCd(ASctGa02&t{{2N zsYuZG@!P-n&rkeO3hS>!4$yl3B{W=D>g{Nar;^EqtCsfd^v6;=i>jF%8yV%2wdXN5 zahgiCjuh}w)GVf}D(~OAi6!l=RO&U9TGgA$P`O#Z1_QLV2Tti!JJMIOAaxEH*MY&+*a?;5pUESTx%*--6I`ZGgjvxEn zw+{TrE9dn0r_`w5Jb=Gvb)Yq!XutBE>#mN3LpS?_q2=>?dz*UN=hYv6^oJk6Z{K&m z4JC`ew5{2)?YA3)9f1%0-E9kZf9%umxqjCzy>Hw9P4>UZ1wX#-IE3f`0000 - 3 + 2 Separator - People_RolesResponsibilities - 3 + People_MyLocalOrganization + 1 - Disabled + Link + iconshock-three-buildings + /Pages/v5/Swarm/LocalOrganization.aspx diff --git a/Site5/Pages/v5/Admin/OrgStaffing.aspx.cs b/Site5/Pages/v5/Admin/OrgStaffing.aspx.cs index f185919f..1afdad5b 100644 --- a/Site5/Pages/v5/Admin/OrgStaffing.aspx.cs +++ b/Site5/Pages/v5/Admin/OrgStaffing.aspx.cs @@ -24,10 +24,9 @@ namespace Swarmops.Frontend.Pages.v5.Admin { protected void Page_Load(object sender, EventArgs e) { - // HACK: The organization part must be removed once proper access control is in place - this.PageAccessRequired = new Access(this.CurrentOrganization, AccessAspect.System, AccessType.Write); - this.PageTitle = Resources.Pages.Admin.SystemSettings_PageTitle; - this.InfoBoxLiteral = Resources.Pages.Admin.SystemSettings_Info; + this.PageAccessRequired = new Access(this.CurrentOrganization, AccessAspect.Administration, AccessType.Read); + this.PageTitle = Resources.Pages.Admin.OrgStaffing_PageTitle; + this.InfoBoxLiteral = Resources.Pages.Admin.OrgStaffing_Info; if (!Page.IsPostBack) { diff --git a/Site5/Pages/v5/Swarm/LocalOrganization.aspx b/Site5/Pages/v5/Swarm/LocalOrganization.aspx new file mode 100644 index 00000000..577688f9 --- /dev/null +++ b/Site5/Pages/v5/Swarm/LocalOrganization.aspx @@ -0,0 +1,27 @@ +<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="LocalOrganization.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Swarm.LocalOrganization" %> +<%@ Register tagPrefix="Swarmops5" tagName="AjaxTextBox" src="~/Controls/v5/Base/AjaxTextBox.ascx" %> +<%@ Register tagPrefix="Swarmops5" tagName="TreePositions" src="~/Controls/v5/Swarm/TreePositions.ascx" %> + + + + + + + + + + + +

+ +
+ + + + + diff --git a/Site5/Pages/v5/Swarm/LocalOrganization.aspx.cs b/Site5/Pages/v5/Swarm/LocalOrganization.aspx.cs new file mode 100644 index 00000000..c21fd511 --- /dev/null +++ b/Site5/Pages/v5/Swarm/LocalOrganization.aspx.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Versioning; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using Swarmops.Common.Enums; +using Swarmops.Common.Interfaces; +using Swarmops.Logic; +using Swarmops.Logic.Support; +using Swarmops.Logic.Security; +using System.Globalization; +using System.Web.Services; +using System.Text.RegularExpressions; +using Swarmops.Frontend.Controls.v5.Base; +using Swarmops.Logic.Communications; +using Swarmops.Logic.Structure; +using Swarmops.Logic.Swarm; + +namespace Swarmops.Frontend.Pages.v5.Swarm +{ + public partial class LocalOrganization : PageV5Base + { + protected void Page_Load(object sender, EventArgs e) + { + this.PageAccessRequired = new Access (this.CurrentOrganization, AccessAspect.Participant); + this.PageTitle = Resources.Pages.Swarm.LocalOrganization_PageTitle; + this.InfoBoxLiteral = Resources.Pages.Swarm.LocalOrganization_Info; + + if (!Page.IsPostBack) + { + Localize(); + } + + RegisterControl (EasyUIControl.Tabs); + RegisterControl (IncludedControl.JsonParameters | IncludedControl.SwitchButton); + + Geography displayGeography = CurrentUser.Geography; + + if (CurrentAuthority.Position.Geography != CurrentUser.Geography) + { + if (CurrentAuthority.Position.Geography == null) + { + displayGeography = Geography.Root; + } + else + { + displayGeography = CurrentAuthority.Position.Geography; + } + } + + this.TreePositions.GeographyId = displayGeography.Identity; + + } + + + + + private void Localize() + { + this.LabelHeaderLocal.Text = Resources.Pages.Swarm.LocalOrganization_PageTitle; + } + + + + } + +} \ No newline at end of file