LocalOrg works for display, perhaps - assignment is next

This commit is contained in:
Rick Falkvinge
2015-05-01 21:17:17 +02:00
parent 2e9c073930
commit bdc99b8736
6 changed files with 56 additions and 23 deletions
+2 -1
View File
@@ -84,13 +84,14 @@ namespace Swarmops.Common.Generics
Data = data;
}
public void AddChild (TNode newChild)
public TreeNode<TNode> 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);
return newNode;
}
public TNode Data;
+9
View File
@@ -1,6 +1,7 @@
using System;
using Swarmops.Basic.Types.Financial;
using Swarmops.Common.Enums;
using Swarmops.Common.Generics;
using Swarmops.Database;
using Swarmops.Logic.Structure;
using Swarmops.Logic.Support;
@@ -89,6 +90,14 @@ namespace Swarmops.Logic.Financial
}
}
public Tree<FinancialAccount> Tree
{
get
{
FinancialAccounts accounts = this.ThisAndBelow();
return Tree<FinancialAccount>.FromCollection (accounts);
}
}
+18 -11
View File
@@ -55,25 +55,32 @@ namespace Swarmops.Logic.Swarm
localizedLeaderTitle = geographyLeaderTemplate.Localized();
}
// Add leader positions of the geographies immediately below (in X generations?).
// Add leader positions of the geographies immediately below (in two generations).
Tree<Position> treeResult = result.Tree;
Geographies children = geography.Children;
Tree<Geography> geoTree = geography.Tree;
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);
}
ForOrganizationGeographyRecurse (geoTree.RootNodes[0], treeResult.RootNodes[0], geographyLeaderTemplate, 2);
return treeResult;
}
private static void ForOrganizationGeographyRecurse (TreeNode<Geography> geoNode, TreeNode<Position> positionNode, Position positionTemplate, int generation)
{
if (generation <= 0)
{
return;
}
foreach (TreeNode<Geography> geographyChildNode in geoNode.Children)
{
positionTemplate.AssignGeography (geographyChildNode.Data);
TreeNode<Position> newPositionNode = positionNode.AddChild (Position.FromBasic(positionTemplate)); // "FromBasic" creates a deep copy
ForOrganizationGeographyRecurse (geographyChildNode, newPositionNode, positionTemplate, generation - 1);
}
}
public Positions AtLevel (PositionLevel level)
{
return FromArray (this.Where (position => position.PositionLevel == level).ToArray());
+7 -1
View File
@@ -176,11 +176,17 @@
<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_Header" xml:space="preserve">
<value>Local Organization ({0})</value>
</data>
<data name="LocalOrganization_HeaderGlobal" xml:space="preserve">
<value>The Global Organization</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>
<value>My Local Organization</value>
<comment>The {0} is the geography name.</comment>
</data>
<data name="Positions_AssignPerson" xml:space="preserve">
+11 -9
View File
@@ -121,10 +121,12 @@ namespace Swarmops.Frontend.Automation
Position position = positionNode.Data;
string localizedPositionName = position.Localized (positionNode.Data.MaxCount != 1);
PositionAssignments assignments = position.Assignments;
string nodeState = "open";
if (position.GeographyId != _geographyId)
{
localizedPositionName += " (" + position.Geography.Name + ")";
localizedPositionName += " " + position.Geography.Name;
nodeState = "closed";
}
string expires = string.Empty;
@@ -135,10 +137,10 @@ namespace Swarmops.Frontend.Automation
{
assignedName =
string.Format (
"<a positionId='{3}' positionName='{4}' class='{1} LocalAssignPerson'>{2}</a> {0}",
"<a positionId='{3}' geographyId='{5}' positionName='{4}' class='{1} LocalAssignPerson'>{2}</a> {0}",
Resources.Controls.Swarm.Positions_Vacant, _customCookieClass,
Resources.Controls.Swarm.Positions_AssignFirstPerson, position.Identity,
JavascriptEscape (position.Localized()));
JavascriptEscape(position.Localized()), position.GeographyId);
}
if (localizedPositionName == null)
@@ -164,11 +166,11 @@ namespace Swarmops.Frontend.Automation
}
}
string element = string.Format("\"id\":\"{0}-1\",\"positionTitle\":\"{1}\",\"assignedName\":\"{2}\",\"expires\":\"{3}\",\"minMax\":\"{4} / {5}\",\"iconType\":\"{6}\",\"actions\":\"{7}\"",
string element = string.Format("\"id\":\"{0}-1-{8}\",\"positionTitle\":\"{1}\",\"assignedName\":\"{2}\",\"expires\":\"{3}\",\"minMax\":\"{4} / {5}\",\"iconType\":\"{6}\",\"actions\":\"{7}\"",
position.Identity, JsonSanitize (localizedPositionName), JsonSanitize (assignedName), JsonSanitize (expires), position.MinCount,
position.MaxCount == 0? @"&infin;" : position.MaxCount.ToString(CultureInfo.InvariantCulture),
position.MaxCount == 1? "Person" : "Group",
action);
action, position.GeographyId);
// TODO: Add all assignments after the first one right here
@@ -226,9 +228,9 @@ namespace Swarmops.Frontend.Automation
elements.Add ("{" + element + "}");
string addPerson =
string.Format (
"<a positionId='{1}' positionName='{2}' class='{3} LocalAssignPerson'>{0}</a>",
"<a positionId='{1}' geographyId='{4}' positionName='{2}' class='{3} LocalAssignPerson'>{0}</a>",
overEngineeredAssignmentPrompts[count], position.Identity,
JavascriptEscape (position.Localized()), _customCookieClass);
JavascriptEscape (position.Localized()), _customCookieClass, position.GeographyId);
element =
String.Format(
@@ -237,9 +239,9 @@ namespace Swarmops.Frontend.Automation
}
if (position.Children.Count > 0) // This should only trigger when position.MaxCount is also 1, or a very weird UI will result
if (positionNode.Children.Count > 0) // This should only trigger when position.MaxCount is also 1, or a very weird UI will result
{
element += ",\"state\":\"open\",\"children\":" + RecursePositionTree(positionNode.Children);
element += ",\"state\":\"" + nodeState + "\",\"children\":" + RecursePositionTree(positionNode.Children);
}
elements.Add("{" + element + "}");
@@ -50,6 +50,15 @@ namespace Swarmops.Frontend.Pages.v5.Swarm
}
}
if (displayGeography.Identity == Geography.RootIdentity)
{
this.LabelHeaderLocal.Text = Resources.Pages.Swarm.LocalOrganization_HeaderGlobal;
}
else
{
this.LabelHeaderLocal.Text = String.Format(Resources.Pages.Swarm.LocalOrganization_Header, displayGeography.Name);
}
this.TreePositions.GeographyId = displayGeography.Identity;
}
@@ -59,7 +68,6 @@ namespace Swarmops.Frontend.Pages.v5.Swarm
private void Localize()
{
this.LabelHeaderLocal.Text = Resources.Pages.Swarm.LocalOrganization_PageTitle;
}