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 00000000..4e06d2a7 Binary files /dev/null and b/Site5/Images/PageIcons/iconshock-three-buildings-40px.png differ diff --git a/Site5/MainMenu-v5.xml b/Site5/MainMenu-v5.xml index 1ac88477..e10d48ce 100644 --- a/Site5/MainMenu-v5.xml +++ b/Site5/MainMenu-v5.xml @@ -47,16 +47,18 @@ - 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