Work on Positions; Added Local Org
This commit is contained in:
@@ -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; }
|
||||
|
||||
@@ -84,6 +84,15 @@ namespace Swarmops.Common.Generics
|
||||
Data = data;
|
||||
}
|
||||
|
||||
public void AddChild (TNode newChild)
|
||||
{
|
||||
TreeNode<TNode> newNode = new TreeNode<TNode>(newChild);
|
||||
newNode.Parent = this;
|
||||
newNode.Children = new List<TreeNode<TNode>>(); // should not be necessary
|
||||
|
||||
Children.Add (newNode);
|
||||
}
|
||||
|
||||
public TNode Data;
|
||||
public List<TreeNode<TNode>> Children;
|
||||
public TreeNode<TNode> Parent;
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace Swarmops.Logic.Security
|
||||
Null,
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
Participant,
|
||||
|
||||
|
||||
@@ -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); }
|
||||
|
||||
@@ -25,6 +25,55 @@ namespace Swarmops.Logic.Swarm
|
||||
return FromArray (SwarmDb.GetDatabaseForReading().GetPositions (organization));
|
||||
}
|
||||
|
||||
public static Tree<Position> 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<Position> 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());
|
||||
|
||||
@@ -411,4 +411,7 @@
|
||||
<data name="Menu5_Administration_OrganizationStaffing" xml:space="preserve">
|
||||
<value>Organization Staffing</value>
|
||||
</data>
|
||||
<data name="Menu5_People_MyLocalOrganization" xml:space="preserve">
|
||||
<value>My Local Organization</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -217,6 +217,12 @@
|
||||
<data name="OrgStaffing_Header_WaitingVolunteers" xml:space="preserve">
|
||||
<value>Volunteers Awating Response</value>
|
||||
</data>
|
||||
<data name="OrgStaffing_Info" xml:space="preserve">
|
||||
<value>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.</value>
|
||||
</data>
|
||||
<data name="OrgStaffing_PageTitle" xml:space="preserve">
|
||||
<value>Organization Staffing</value>
|
||||
</data>
|
||||
<data name="SystemSettings_AdminAddress" xml:space="preserve">
|
||||
<value>Admin Notifications From Address</value>
|
||||
</data>
|
||||
|
||||
@@ -176,6 +176,13 @@
|
||||
<data name="ListFindPeople_TooManyHits" xml:space="preserve">
|
||||
<value>The result set contains over a thousand people (display limited to a thousand). Please refine your search?</value>
|
||||
</data>
|
||||
<data name="LocalOrganization_Info" xml:space="preserve">
|
||||
<value>These are your local contacts. (If you have administrative privileges, you may also assign people to these positions.)</value>
|
||||
</data>
|
||||
<data name="LocalOrganization_PageTitle" xml:space="preserve">
|
||||
<value>My Local Organization ({0})</value>
|
||||
<comment>The {0} is the geography name.</comment>
|
||||
</data>
|
||||
<data name="Positions_AssignPerson" xml:space="preserve">
|
||||
<value>Assign person...</value>
|
||||
</data>
|
||||
|
||||
@@ -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<Position> positions = Positions.ForOrganizationGeography (CurrentOrganization, geography);
|
||||
Response.Output.WriteLine (RecursePositionTree (positions.RootNodes));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private string RecursePositionTree (List<TreeNode<Position>> 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
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.7 KiB |
@@ -47,16 +47,18 @@
|
||||
</MainMenuItem>
|
||||
|
||||
<MainMenuItem>
|
||||
<UserLevel>3</UserLevel>
|
||||
<UserLevel>2</UserLevel>
|
||||
<Type>Separator</Type>
|
||||
<Children />
|
||||
</MainMenuItem>
|
||||
|
||||
<MainMenuItem>
|
||||
<ResourceKey>People_RolesResponsibilities</ResourceKey>
|
||||
<UserLevel>3</UserLevel>
|
||||
<ResourceKey>People_MyLocalOrganization</ResourceKey>
|
||||
<UserLevel>1</UserLevel>
|
||||
<Permissions />
|
||||
<Type>Disabled</Type>
|
||||
<Type>Link</Type>
|
||||
<ImageUrl>iconshock-three-buildings</ImageUrl>
|
||||
<NavigateUrl>/Pages/v5/Swarm/LocalOrganization.aspx</NavigateUrl>
|
||||
<Children />
|
||||
</MainMenuItem>
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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" %>
|
||||
|
||||
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderHead" Runat="Server">
|
||||
|
||||
<script language="javascript" type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
// docready goes here
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
</asp:Content>
|
||||
|
||||
|
||||
<asp:Content ID="Content2" ContentPlaceHolderID="PlaceHolderMain" Runat="Server">
|
||||
<h2><asp:Label ID="LabelHeaderLocal" runat="server" /></h2>
|
||||
<Swarmops5:TreePositions ID="TreePositions" Level="Geography" runat="server" />
|
||||
</asp:Content>
|
||||
|
||||
|
||||
<asp:Content ID="Content3" ContentPlaceHolderID="PlaceHolderSide" Runat="Server">
|
||||
</asp:Content>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user