v1.2.11.0
This commit is contained in:
+97
-54
@@ -12,7 +12,6 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using AssociationTypeOption = Saxonite.Net.Core.Web.Admin.Models.Model_OrganisationAssociations.AssociationTypeOption;
|
||||
|
||||
namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
{
|
||||
@@ -25,7 +24,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
// Association type combinations.
|
||||
//-------------------------------------------------------------------
|
||||
private static readonly String optionLabel_AffiliatedTo = "Affiliated to";
|
||||
private static readonly String optionLabel_Affiliate = "Affiliate";
|
||||
private static readonly String optionLabel_Affiliate = "Affiliation for";
|
||||
private static readonly String optionLabel_Partner = "Partner";
|
||||
// Associations are between two items (From & To) but in the context of
|
||||
// displaying associations for an organisation, the organisation may be
|
||||
@@ -36,12 +35,12 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
{
|
||||
// No parameter construction - populating association details for individual item (see Populate()).
|
||||
}
|
||||
public AssociationTypeData(AssociationTypeOption associationTypeOption)
|
||||
public AssociationTypeData(Sax.AssociationTypeOption associationTypeOption)
|
||||
{
|
||||
// Population on construction - generic association type definitions, eg. for drop down menu options.
|
||||
Populate(associationTypeOption);
|
||||
}
|
||||
public void Populate(AssociationTypeOption associationTypeOption)
|
||||
public void Populate(Sax.AssociationTypeOption associationTypeOption)
|
||||
{
|
||||
// Default labels - option to select association etc.
|
||||
Type = ((int)associationTypeOption).ToString();
|
||||
@@ -55,7 +54,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
public void Populate(Sax.AssociationType associationType, bool reversed, String label)
|
||||
{
|
||||
// Populate for specific labels, eg. to identify nature of associated organisation.
|
||||
AssociationTypeOption associationTypeOption = GetAssociationTypeOption(associationType, reversed);
|
||||
Sax.AssociationTypeOption associationTypeOption = GetAssociationTypeOption(associationType, reversed);
|
||||
Type = ((int)associationTypeOption).ToString();
|
||||
Label = label;
|
||||
}
|
||||
@@ -63,22 +62,22 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
public String Type { get; set; }
|
||||
public String Label { get; set; }
|
||||
// Utilities.
|
||||
public static AssociationTypeOption GetAssociationTypeOption(Sax.AssociationType associationType, bool reversed)
|
||||
public static Sax.AssociationTypeOption GetAssociationTypeOption(Sax.AssociationType associationType, bool reversed)
|
||||
{
|
||||
switch (associationType)
|
||||
{
|
||||
case Sax.AssociationType.Affiliate: return reversed ? AssociationTypeOption.AffiliatedTo : AssociationTypeOption.AffiliateParent;
|
||||
case Sax.AssociationType.Partner: return AssociationTypeOption.Partner;
|
||||
case Sax.AssociationType.Affiliate: return reversed ? Sax.AssociationTypeOption.AffiliateChild : Sax.AssociationTypeOption.AffiliateParent;
|
||||
case Sax.AssociationType.Partner: return Sax.AssociationTypeOption.Partner;
|
||||
}
|
||||
return AssociationTypeOption.Unknown;
|
||||
return Sax.AssociationTypeOption.Unknown;
|
||||
}
|
||||
public static String GetOptionLabel(AssociationTypeOption associationTypeOption)
|
||||
public static String GetOptionLabel(Sax.AssociationTypeOption associationTypeOption)
|
||||
{
|
||||
switch (associationTypeOption)
|
||||
{
|
||||
case AssociationTypeOption.AffiliateParent: return optionLabel_AffiliatedTo;
|
||||
case AssociationTypeOption.AffiliatedTo: return optionLabel_Affiliate;
|
||||
case AssociationTypeOption.Partner: return optionLabel_Partner;
|
||||
case Sax.AssociationTypeOption.AffiliateParent: return optionLabel_AffiliatedTo;
|
||||
case Sax.AssociationTypeOption.AffiliateChild: return optionLabel_Affiliate;
|
||||
case Sax.AssociationTypeOption.Partner: return optionLabel_Partner;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@@ -93,6 +92,8 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
{
|
||||
public String Id { get; set; }
|
||||
public String Name { get; set; }
|
||||
public String Sport { get; set; }
|
||||
public String Region { get; set; }
|
||||
}
|
||||
public OrganisationData Organisation { get; } = new OrganisationData();
|
||||
public OrganisationData OrganisationAssoc { get; } = new OrganisationData();
|
||||
@@ -101,7 +102,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
private class AssociationItemData : AssociationListData
|
||||
{
|
||||
}
|
||||
private void PopulateAssociationResponseListData(AssociationListData data, SaxItemAssociation itemAssociation, SaxOrganisation organisation, SaxOrganisation organisationAssoc)
|
||||
private void PopulateAssociationResponseListData(SaxModel_Admin model, AssociationListData data, SaxItemAssociation itemAssociation, SaxOrganisation organisation, SaxOrganisation organisationAssoc)
|
||||
{
|
||||
data.Id = SysId.ToString(itemAssociation.Id);
|
||||
// Organisation.
|
||||
@@ -110,6 +111,10 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
// Associated Organisation.
|
||||
data.OrganisationAssoc.Id = SysId.ToString(organisationAssoc.Id);
|
||||
data.OrganisationAssoc.Name = organisationAssoc.Name;
|
||||
if (!organisation.SportIdPrimary.Equals(organisationAssoc.SportIdPrimary))
|
||||
data.OrganisationAssoc.Sport = model.GetSportName(organisationAssoc.SportIdPrimary);
|
||||
if (!organisation.RegionIdPrimary.Equals(organisationAssoc.RegionIdPrimary))
|
||||
data.OrganisationAssoc.Region = model.GetRegionName(organisationAssoc.RegionIdPrimary);
|
||||
// Association type.
|
||||
bool associationReversed = itemAssociation.ItemIdTo.Id.Equals(organisation.Id);
|
||||
String associationLabel = "";
|
||||
@@ -122,9 +127,9 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
data.StatusCode = itemAssociation.StatusCode;
|
||||
data.StatusDesc = itemAssociation.StatusDesc;
|
||||
}
|
||||
private void PopulateAssociationResponseItemData(AssociationItemData data, SaxItemAssociation itemAssociation, SaxOrganisation organisation, SaxOrganisation organisationAssoc)
|
||||
private void PopulateAssociationResponseItemData(SaxModel_Admin model, AssociationItemData data, SaxItemAssociation itemAssociation, SaxOrganisation organisation, SaxOrganisation organisationAssoc)
|
||||
{
|
||||
PopulateAssociationResponseListData(data, itemAssociation, organisation, organisationAssoc);
|
||||
PopulateAssociationResponseListData(model, data, itemAssociation, organisation, organisationAssoc);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -165,9 +170,9 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
|
||||
// Reference data - association types.
|
||||
// 'Label' is option caption to add new association of the specified type.
|
||||
responseData.AssociationTypes.Add(new AssociationTypeData(AssociationTypeOption.AffiliateParent));
|
||||
responseData.AssociationTypes.Add(new AssociationTypeData(AssociationTypeOption.AffiliatedTo));
|
||||
responseData.AssociationTypes.Add(new AssociationTypeData(AssociationTypeOption.Partner));
|
||||
responseData.AssociationTypes.Add(new AssociationTypeData(Sax.AssociationTypeOption.AffiliateParent));
|
||||
responseData.AssociationTypes.Add(new AssociationTypeData(Sax.AssociationTypeOption.AffiliateChild));
|
||||
responseData.AssociationTypes.Add(new AssociationTypeData(Sax.AssociationTypeOption.Partner));
|
||||
|
||||
// Reference data - statuses.
|
||||
foreach (SaStatus status in SaxItemAssociation.ValidStatuses.FindAll(item => item != SaStatus.Deleted))
|
||||
@@ -204,21 +209,26 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
ColumnDfn colId = ItemDataMgr.GetItemAssociationColumnDfn(SaxItemAssociation.Column.Id);
|
||||
ColumnDfn colItemTypeFrom = ItemDataMgr.GetItemAssociationColumnDfn(SaxItemAssociation.Column.ItemTypeFrom);
|
||||
ColumnDfn colItemIdFrom = ItemDataMgr.GetItemAssociationColumnDfn(SaxItemAssociation.Column.ItemIdFrom);
|
||||
ColumnDfn colOrganisationFrom_Name = ItemDataMgr.GetItemAssociationColumnDfn(SaxItemAssociation.Column.OrganisationFrom_Name);
|
||||
ColumnDfn colOrganisationFrom_SportIdPrimary = ItemDataMgr.GetItemAssociationColumnDfn(SaxItemAssociation.Column.OrganisationFrom_SportIdPrimary);
|
||||
ColumnDfn colOrganisationFrom_RegionIdPrimary = ItemDataMgr.GetItemAssociationColumnDfn(SaxItemAssociation.Column.OrganisationFrom_RegionIdPrimary);
|
||||
ColumnDfn colItemTypeTo = ItemDataMgr.GetItemAssociationColumnDfn(SaxItemAssociation.Column.ItemTypeTo);
|
||||
ColumnDfn colItemIdTo = ItemDataMgr.GetItemAssociationColumnDfn(SaxItemAssociation.Column.ItemIdTo);
|
||||
ColumnDfn colOrganisationTo_Name = ItemDataMgr.GetItemAssociationColumnDfn(SaxItemAssociation.Column.OrganisationTo_Name);
|
||||
ColumnDfn colOrganisationTo_SportIdPrimary = ItemDataMgr.GetItemAssociationColumnDfn(SaxItemAssociation.Column.OrganisationTo_SportIdPrimary);
|
||||
ColumnDfn colOrganisationTo_RegionIdPrimary = ItemDataMgr.GetItemAssociationColumnDfn(SaxItemAssociation.Column.OrganisationTo_RegionIdPrimary);
|
||||
ColumnDfn colAssociationType = ItemDataMgr.GetItemAssociationColumnDfn(SaxItemAssociation.Column.AssociationType);
|
||||
ColumnDfn colStatus = ItemDataMgr.GetItemAssociationColumnDfn(SaxItemAssociation.Column.Status);
|
||||
List<ColumnDfn> columns = new List<ColumnDfn>()
|
||||
{
|
||||
colId,
|
||||
colItemTypeFrom, colItemIdFrom,
|
||||
colItemTypeTo, colItemIdTo,
|
||||
colAssociationType,
|
||||
colStatus
|
||||
};
|
||||
{
|
||||
colId,
|
||||
colItemTypeFrom, colItemIdFrom, colOrganisationFrom_Name, colOrganisationFrom_SportIdPrimary, colOrganisationFrom_RegionIdPrimary,
|
||||
colItemTypeTo, colItemIdTo, colOrganisationTo_Name, colOrganisationTo_SportIdPrimary, colOrganisationTo_RegionIdPrimary,
|
||||
colAssociationType,
|
||||
colStatus
|
||||
};
|
||||
|
||||
// Query items.
|
||||
List<SysId> organisationIds = new List<SysId>();
|
||||
using (DbResultSet resultSet = ItemDataMgr.ExecuteItemAssociationQuery(columns, prmItemAssociation))
|
||||
{
|
||||
while (resultSet != null && resultSet.HasRows && resultSet.NextRecord())
|
||||
@@ -231,23 +241,39 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
StatusDesc = SacsSystem.GetStatusDescForCode(values.GetString(colStatus.DataName)),
|
||||
};
|
||||
// Items.
|
||||
bool assiationReversed = false;
|
||||
bool associationReversed = false;
|
||||
ItemId itemIdFrom = new ItemId((short)values.GetLong(colItemTypeFrom.DataName), new SysId(values.GetLong(colItemIdFrom.DataName)));
|
||||
String organisationNameFrom = values.GetString(colOrganisationFrom_Name.DataName);
|
||||
SysId sportIdFrom = new SysId(values.GetLong(colOrganisationFrom_SportIdPrimary.DataName));
|
||||
SysId regionIdFrom = new SysId(values.GetLong(colOrganisationFrom_RegionIdPrimary.DataName));
|
||||
ItemId itemIdTo = new ItemId((short)values.GetLong(colItemTypeTo.DataName), new SysId(values.GetLong(colItemIdTo.DataName)));
|
||||
String organisationNameTo = values.GetString(colOrganisationTo_Name.DataName);
|
||||
SysId sportIdTo = new SysId(values.GetLong(colOrganisationTo_SportIdPrimary.DataName));
|
||||
SysId regionIdTo = new SysId(values.GetLong(colOrganisationTo_RegionIdPrimary.DataName));
|
||||
if (ItemId.IsValid(itemIdFrom) && ItemId.IsValid(itemIdTo) && itemIdFrom.Type == (int)Sax.DataItemType.Organisation && itemIdTo.Type == (int)Sax.DataItemType.Organisation)
|
||||
{
|
||||
organisationIds.AddId(itemIdFrom.Id);
|
||||
organisationIds.AddId(itemIdTo.Id);
|
||||
if (itemIdFrom.Id.Equals(organisationId))
|
||||
{
|
||||
associationData.Organisation.Id = SysId.ToString(itemIdFrom.Id);
|
||||
associationData.Organisation.Name = organisationNameFrom;
|
||||
associationData.OrganisationAssoc.Id = SysId.ToString(itemIdTo.Id);
|
||||
associationData.OrganisationAssoc.Name = organisationNameTo;
|
||||
if (!sportIdFrom.Equals(sportIdTo))
|
||||
associationData.OrganisationAssoc.Sport = model.GetSportName(sportIdTo);
|
||||
if (!regionIdFrom.Equals(regionIdTo))
|
||||
associationData.OrganisationAssoc.Sport = model.GetRegionName(regionIdTo);
|
||||
}
|
||||
else if (itemIdTo.Id.Equals(organisationId))
|
||||
{
|
||||
assiationReversed = true;
|
||||
associationReversed = true;
|
||||
associationData.Organisation.Id = SysId.ToString(itemIdTo.Id);
|
||||
associationData.Organisation.Name = organisationNameTo;
|
||||
associationData.OrganisationAssoc.Id = SysId.ToString(itemIdFrom.Id);
|
||||
associationData.OrganisationAssoc.Name = organisationNameFrom;
|
||||
if (!sportIdFrom.Equals(sportIdTo))
|
||||
associationData.OrganisationAssoc.Sport = model.GetSportName(sportIdFrom);
|
||||
if (!regionIdFrom.Equals(regionIdTo))
|
||||
associationData.OrganisationAssoc.Sport = model.GetRegionName(regionIdFrom);
|
||||
}
|
||||
else if (SacsSystem.DebugMode)
|
||||
// Track invalid associations, ie. where neither item is this organisation.
|
||||
@@ -258,22 +284,11 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
Debugger.Break();
|
||||
// Association type.
|
||||
Sax.AssociationType associationType = (Sax.AssociationType)values.GetLong(colAssociationType.DataName);
|
||||
associationData.Assoc.Populate(associationType, assiationReversed);
|
||||
associationData.Assoc.Populate(associationType, associationReversed);
|
||||
// Add association to the list.
|
||||
associations.Add(associationData);
|
||||
}
|
||||
}
|
||||
// Populate organisation details.
|
||||
SaxOrganisation.Params prmOrganisation = new SaxOrganisation.Params();
|
||||
prmOrganisation.IdsIncluded.AddRange(organisationIds);
|
||||
prmOrganisation.StatusCat = SaxOrganisation.StatusCat.Any;
|
||||
List<SaxOrganisation> organisations = AccountMgr.GetOrganisationList(prmOrganisation);
|
||||
disposableItems.AddRange(organisations);
|
||||
foreach (AssociationListData associationData in associations)
|
||||
{
|
||||
associationData.Organisation.Name = organisations.GetOrganisationName(new SysId(StringUtil.ToLong(associationData.Organisation.Id)));
|
||||
associationData.OrganisationAssoc.Name = organisations.GetOrganisationName(new SysId(StringUtil.ToLong(associationData.OrganisationAssoc.Id)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -365,12 +380,12 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
disposableItems.Add(organisationAssoc);
|
||||
if (organisationAssoc == null)
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to retrieve Organisation for Id: '" + organisationIdAssoc + "'");
|
||||
SaLogger.Warn(fn + " Failed to retrieve associated Organisation for Id: '" + organisationIdAssoc + "'");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
|
||||
// Construct response.
|
||||
PopulateAssociationResponseItemData(responseData.Association, itemAssociation, organisation, organisationAssoc);
|
||||
PopulateAssociationResponseItemData(model, responseData.Association, itemAssociation, organisation, organisationAssoc);
|
||||
}
|
||||
|
||||
responseData.Success = true;
|
||||
@@ -433,7 +448,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
SaLogger.Warn(fn + " Association Type must be specified.");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.data.inconsistent"]));
|
||||
}
|
||||
AssociationTypeOption associationTypeOption = model.Association.GetAssociationTypeOption();
|
||||
Sax.AssociationTypeOption associationTypeOption = model.Association.GetAssociationTypeOption();
|
||||
if ((int)associationTypeOption < 1)
|
||||
{
|
||||
SaLogger.Warn(fn + " Association Type Option must be specified.");
|
||||
@@ -463,6 +478,24 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.data.inconsistent"]));
|
||||
}
|
||||
SaxItemAssociation itemAssociation = ItemDataMgr.GetItemAssociationById(itemAssociationId);
|
||||
if (itemAssociation == null && StringUtil.ToBool(model.NewItem))
|
||||
{
|
||||
// Check whether there's a matching association for the 'new' association with 'deleted' status.
|
||||
SaxItemAssociation.Params prmItemAsociation = new SaxItemAssociation.Params();
|
||||
prmItemAsociation.ItemIdsIncluded.Add(organisation.GetItemId());
|
||||
prmItemAsociation.AssociationTypesIncluded.Add(associationType);
|
||||
prmItemAsociation.StatusCat = SaxItemAssociation.StatusCat.DeletedOnly;
|
||||
foreach (SaxItemAssociation itemAssociationCandidate in ItemDataMgr.GetItemAssociationList(prmItemAsociation))
|
||||
{
|
||||
if (itemAssociationCandidate.ItemIdFrom.Equals(organisationAssoc.GetItemId()) || itemAssociationCandidate.ItemIdTo.Equals(organisationAssoc.GetItemId()))
|
||||
{
|
||||
itemAssociation = itemAssociationCandidate;
|
||||
itemAssociation.Status = SaxItemAssociation.DefaultStatus;
|
||||
break;
|
||||
}
|
||||
disposableItems.Add(itemAssociationCandidate);
|
||||
}
|
||||
}
|
||||
disposableItems.Add(itemAssociation);
|
||||
if (itemAssociation == null && SysId.IsValid(itemAssociationId))
|
||||
{
|
||||
@@ -472,15 +505,25 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
|
||||
if (itemAssociation != null)
|
||||
{
|
||||
// Check if item relationship has been reversed, eg. from parent to child.
|
||||
bool associationReversed = itemAssociation.ItemIdTo.Id.Equals(organisation.Id);
|
||||
if (model.IsAssociationTypeDirectionReversed(associationTypeOption) != model.IsAssociationTypeDirectionReversed(AssociationTypeData.GetAssociationTypeOption(itemAssociation.AssociationType, associationReversed)))
|
||||
{
|
||||
// Logical direction has been reversed from that stored.
|
||||
// Items must be switched.
|
||||
ItemId itemAssociationItemIdFrom = itemAssociation.ItemIdFrom;
|
||||
itemAssociation.ItemIdFrom = itemAssociation.ItemIdTo;
|
||||
itemAssociation.ItemIdTo = itemAssociationItemIdFrom;
|
||||
}
|
||||
// Validate From/To items.
|
||||
if (!itemAssociation.ItemIdFrom.Equals(itemIdFrom))
|
||||
{
|
||||
SaLogger.Warn(fn + " Inconsistent association - expected 'From' Item Id: " + SysId.ToString(organisation.Id) + ". Found: " + SysId.ToString(itemAssociation.ItemIdFrom.Id));
|
||||
SaLogger.Warn(fn + " Inconsistent association - expected 'From' Item Id: " + SysId.ToString(itemIdFrom.Id) + ". Found: " + SysId.ToString(itemAssociation.ItemIdFrom.Id));
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
if (!itemAssociation.ItemIdTo.Equals(itemIdTo))
|
||||
{
|
||||
SaLogger.Warn(fn + " Inconsistent association - expected 'To' Item Id: " + SysId.ToString(organisation.Id) + ". Found: " + SysId.ToString(itemAssociation.ItemIdTo.Id));
|
||||
SaLogger.Warn(fn + " Inconsistent association - expected 'To' Item Id: " + SysId.ToString(itemIdTo.Id) + ". Found: " + SysId.ToString(itemAssociation.ItemIdTo.Id));
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
}
|
||||
@@ -510,7 +553,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
{
|
||||
if (!ItemDataMgr.InsertItemAssociation(itemAssociation, DbUpdateInfo))
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to insert user organisation: " + ItemDataMgr.ErrorStateMessage);
|
||||
SaLogger.Warn(fn + " Failed to insert item association: " + ItemDataMgr.ErrorStateMessage);
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.insert.failed"] + "\n\n" + ItemDataMgr.ErrorStateMessage));
|
||||
}
|
||||
}
|
||||
@@ -518,13 +561,13 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
{
|
||||
if (!ItemDataMgr.UpdateItemAssociation(itemAssociation, DbUpdateInfo))
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to update user organisation [Id:" + SysId.ToString(itemAssociation.Id) + "]: " + ItemDataMgr.ErrorStateMessage);
|
||||
SaLogger.Warn(fn + " Failed to update item association [Id:" + SysId.ToString(itemAssociation.Id) + "]: " + ItemDataMgr.ErrorStateMessage);
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.update.failed"] + "\n\n" + ItemDataMgr.ErrorStateMessage));
|
||||
}
|
||||
}
|
||||
|
||||
// Construct response.
|
||||
PopulateAssociationResponseItemData(responseData.Association, itemAssociation, organisation, organisationAssoc);
|
||||
PopulateAssociationResponseItemData(model, responseData.Association, itemAssociation, organisation, organisationAssoc);
|
||||
}
|
||||
|
||||
responseData.Success = true;
|
||||
@@ -588,12 +631,12 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
// Validate association Item Ids.
|
||||
if (!itemAssociation.ItemIdFrom.Id.Equals(organisation.Id) && !itemAssociation.ItemIdTo.Id.Equals(organisation.Id))
|
||||
{
|
||||
SaLogger.Warn(fn + " Inconsistent user organisation properties. Organisation must be 'From' or 'To' item");
|
||||
SaLogger.Warn(fn + " Inconsistent item association properties. Organisation must be 'From' or 'To' item");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.data.inconsistent"]));
|
||||
}
|
||||
if (!itemAssociation.ItemIdFrom.Id.Equals(organisationAssoc.Id) && !itemAssociation.ItemIdTo.Id.Equals(organisationAssoc.Id))
|
||||
{
|
||||
SaLogger.Warn(fn + " Inconsistent user organisation properties. Associated Organisation must be 'From' or 'To' item");
|
||||
SaLogger.Warn(fn + " Inconsistent item association properties. Associated Organisation must be 'From' or 'To' item");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.data.inconsistent"]));
|
||||
}
|
||||
|
||||
@@ -606,7 +649,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
}
|
||||
|
||||
// Construct response.
|
||||
PopulateAssociationResponseItemData(responseData.Association, itemAssociation, organisation, organisationAssoc);
|
||||
PopulateAssociationResponseItemData(model, responseData.Association, itemAssociation, organisation, organisationAssoc);
|
||||
}
|
||||
|
||||
responseData.Success = true;
|
||||
|
||||
@@ -142,7 +142,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
|
||||
// Reference data - contact methods.
|
||||
List<Sax.ContactMethod> validContactMethods = SaxOrganisation.ValidContactMethods;
|
||||
foreach (TypeCodeDesc contactMethod in ContactMethodCodes)
|
||||
foreach (TypeCodeDesc contactMethod in ContactMethodCodes.OrderBy(item => item.Desc))
|
||||
{
|
||||
// Skip methods that aren't associated with Organisations.
|
||||
if (!validContactMethods.Contains((Sax.ContactMethod)contactMethod.Type)) continue;
|
||||
|
||||
@@ -21,13 +21,6 @@ namespace Saxonite.Net.Core.Web.Admin.Models
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Definitions.
|
||||
public enum AssociationTypeOption
|
||||
{
|
||||
Unknown = 0,
|
||||
AffiliateParent,
|
||||
AffiliatedTo,
|
||||
Partner,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
@@ -59,7 +52,7 @@ namespace Saxonite.Net.Core.Web.Admin.Models
|
||||
{
|
||||
// Association type option.
|
||||
public String TypeOption { get; set; }
|
||||
public AssociationTypeOption GetAssociationTypeOption() { return EnumUtil.ParseEnum(TypeOption, AssociationTypeOption.Unknown); }
|
||||
public Sax.AssociationTypeOption GetAssociationTypeOption() { return EnumUtil.ParseEnum(TypeOption, Sax.AssociationTypeOption.Unknown); }
|
||||
// Association properties.
|
||||
public String StatusCode { get; set; }
|
||||
public SaStatus GetStatus() { return SacsSystem.GetStatusForCode(StatusCode); }
|
||||
@@ -68,35 +61,35 @@ namespace Saxonite.Net.Core.Web.Admin.Models
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public bool IsAssociationTypeDirectionReversed(AssociationTypeOption associationTypeOption)
|
||||
public bool IsAssociationTypeDirectionReversed(Sax.AssociationTypeOption associationTypeOption)
|
||||
{
|
||||
switch (associationTypeOption)
|
||||
{
|
||||
case AssociationTypeOption.AffiliatedTo:
|
||||
case Sax.AssociationTypeOption.AffiliateChild:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public Sax.AssociationType GetAssociationTypeForOption(AssociationTypeOption associationTypeOption)
|
||||
public Sax.AssociationType GetAssociationTypeForOption(Sax.AssociationTypeOption associationTypeOption)
|
||||
{
|
||||
switch (associationTypeOption)
|
||||
{
|
||||
case AssociationTypeOption.AffiliateParent:
|
||||
case AssociationTypeOption.AffiliatedTo:
|
||||
case Sax.AssociationTypeOption.AffiliateParent:
|
||||
case Sax.AssociationTypeOption.AffiliateChild:
|
||||
return Sax.AssociationType.Affiliate;
|
||||
case AssociationTypeOption.Partner:
|
||||
case Sax.AssociationTypeOption.Partner:
|
||||
return Sax.AssociationType.Partner;
|
||||
}
|
||||
return Sax.AssociationType.Unknown;
|
||||
}
|
||||
public bool IsConsistentWith(AssociationTypeOption associationTypeOption, Sax.AssociationType associationType)
|
||||
public bool IsConsistentWith(Sax.AssociationTypeOption associationTypeOption, Sax.AssociationType associationType)
|
||||
{
|
||||
switch (associationType)
|
||||
{
|
||||
case Sax.AssociationType.Affiliate:
|
||||
return new List<AssociationTypeOption>() { AssociationTypeOption.AffiliatedTo, AssociationTypeOption.AffiliateParent }.Contains(associationTypeOption);
|
||||
return new List<Sax.AssociationTypeOption>() { Sax.AssociationTypeOption.AffiliateChild, Sax.AssociationTypeOption.AffiliateParent }.Contains(associationTypeOption);
|
||||
case Sax.AssociationType.Partner:
|
||||
return new List<AssociationTypeOption>() { AssociationTypeOption.Partner }.Contains(associationTypeOption);
|
||||
return new List<Sax.AssociationTypeOption>() { Sax.AssociationTypeOption.Partner }.Contains(associationTypeOption);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
# Saxonite Admin application
|
||||
|
||||
System management functions to maintain data.
|
||||
|
||||
## Technology
|
||||
|
||||
- VS2022, .Net Core 3.1
|
||||
|
||||
## Lifecycle
|
||||
|
||||
### Build
|
||||
|
||||
- 'Package' project to local folder:
|
||||
- Delete all files prior to publish.
|
||||
|
||||
### Deployment
|
||||
|
||||
- Replace application files under IIS folder.
|
||||
- Verify database schema on startup.
|
||||
@@ -22,8 +22,16 @@
|
||||
|
||||
.ItemContactMethods .ContactMethods table.sax-data .sax-label
|
||||
{
|
||||
margin:0;
|
||||
padding:0 8px 0 0;
|
||||
margin: 0;
|
||||
padding: 0 8px 0 0;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.ItemContactMethods .ContactMethods table.sax-data .sax-value
|
||||
{
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -53,8 +61,8 @@
|
||||
</div>
|
||||
<table class="sax-panel-item-template">
|
||||
<tr class="ContactMethod">
|
||||
<td style="width:20px;"><div class="sax-label nowrap"></div></td>
|
||||
<td class="sax-value " style="width:70%;word-break: break-all;"></td>
|
||||
<td style="width:20px;"><div class="sax-label"></div></td>
|
||||
<td style="width:70%;"><div class="sax-value"></div></td>
|
||||
<td class="sax-actions right nowrap" style="width:10px;">
|
||||
<input type="hidden" name="ContactMethod" />
|
||||
<input type="hidden" name="ContactValue" />
|
||||
|
||||
@@ -69,14 +69,14 @@
|
||||
<div class="sax-panel-messages"></div>
|
||||
<div class="sax-panel-item-list"></div>
|
||||
|
||||
@* element templates *@
|
||||
@* Item templates *@
|
||||
<div class="sax-panel-item-template">
|
||||
@* Organisation Association item template *@
|
||||
<div class="sax-panel-item Association">
|
||||
<div class="sax-header row">
|
||||
<div class="col">
|
||||
@* User name *@
|
||||
<div class="sax-caption sax-action"><div class="UserDisplayName"></div></div>
|
||||
<div class="sax-caption sax-action"><div class="OrganisationName"></div></div>
|
||||
</div>
|
||||
<div class="fixed sax-actions">
|
||||
@* Burger menu *@
|
||||
@@ -90,8 +90,9 @@
|
||||
</div>
|
||||
<div class="sax-content">
|
||||
<div class="row">
|
||||
<div class="col-sm-6"></div>
|
||||
<div class="col-sm-6 right"></div>
|
||||
<div class="col-sm-4 AssociationLabel"></div>
|
||||
<div class="col-sm-4 Sport center"></div>
|
||||
<div class="col-sm-4 Region right"></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-4"></div>
|
||||
|
||||
@@ -5,9 +5,8 @@
|
||||
(function (win, doc, undef)
|
||||
{
|
||||
"use strict";
|
||||
let oa = sax.mdl.organisationAssociations = { data: {}, ajax: {} };
|
||||
let oa = sax.mdl.organisationAssociations = { data: {}, ajax: {}, itemIdPrefix: 'oa_' };
|
||||
let $pnl = oa.$pnl = {}, $frm = oa.$frm = {}, $dlg = oa.$dlg = {};
|
||||
let mdlOrg = function () { return sax.mdl.organisations; }
|
||||
|
||||
//--------------------------------------------------------------
|
||||
oa.refreshResults = function (delay)
|
||||
@@ -48,19 +47,19 @@
|
||||
if (!items.length)
|
||||
return $msgs.append($('<div class="sax-message">' + sax.msg.dataNoneFound + '</div>')).fadeIn(500);
|
||||
for (let itemIdx = 0; itemIdx < items.length; itemIdx++)
|
||||
$items.append(sax.populateItem(oa.getItemTemplate(), items[itemIdx]));
|
||||
$items.append(oa.populateItem(oa.getItemTemplate(), items[itemIdx]));
|
||||
$items.fadeIn(50);
|
||||
}
|
||||
sax.populateItem = function ($item, item)
|
||||
oa.populateItem = function ($item, item)
|
||||
{
|
||||
if (!item) return;
|
||||
$item.prop('id', oa.itemIdPrefix + item.id);
|
||||
$('.UserEmailAddress', $item).text(item.emailAddress);
|
||||
$('.UserStatusDesc', $item).text(item.userStatusDesc).addClass('sax-status-' + (item.userStatusCode || '').toLowerCase());
|
||||
$('.UserStatus', $item).toggle(!item.userActive);
|
||||
$('.UserDisplayName', $item).text(item.displayName);
|
||||
$('.AssociationRoleCount .RoleCount', $item).text(item.roleCount);
|
||||
$('.StatusDesc', $item).text(item.statusDesc).addClass('sax-status-' + (item.statusCode || '').toLowerCase());
|
||||
$item.prop('id', oa.getItemIdProp(item.id));
|
||||
let assoc = item.assoc || {};
|
||||
let org = item.organisationAssoc || {};
|
||||
$('.OrganisationName', $item).text(org.name);
|
||||
$('.AssociationLabel', $item).text(assoc.label);
|
||||
$('.Sport', $item).text(org.sport);
|
||||
$('.Region', $item).text(org.region);
|
||||
$('.sax-caption .sax-action').toggleClass('sax-action', !item.deleted);
|
||||
let $mnu = $('ul.sax-dropdown-menu', $item).empty();
|
||||
if (!item.deleted)
|
||||
@@ -68,8 +67,7 @@
|
||||
let fnUpdItm = function () { oa.updateItem(item, $item) };
|
||||
$mnu.append(oa.getItemMenuOption(sax.lbl.edit, fnUpdItm, 'sax-edit'));
|
||||
$item.on('click', '.sax-header .sax-caption', fnUpdItm).on('dblclick', fnUpdItm);
|
||||
if (item.association)
|
||||
$mnu.append(oa.getItemMenuOption(sax.lbl.remove, function () { oa.removeItem(item, $item) }, 'sax-remove'));
|
||||
$mnu.append(oa.getItemMenuOption(sax.lbl.remove, function () { oa.removeItem(item, $item) }, 'sax-remove'));
|
||||
}
|
||||
$('.sax-burger', $item).toggle(!!$('.sax-dropdown-item', $mnu).length);
|
||||
$('.sax-panel-messages', $pnl.results).hide().empty();
|
||||
@@ -77,6 +75,10 @@
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
oa.getItemIdProp = function (id)
|
||||
{
|
||||
return oa.itemIdPrefix + id;
|
||||
}
|
||||
oa.getFilterDropdownTemplate = function ()
|
||||
{
|
||||
return $('.sax-panel-item-template .sax-dropdown-menu.AssociationFilter li.sax-dropdown-item', $pnl.filter).clone();
|
||||
@@ -150,8 +152,9 @@
|
||||
//--------------------------------------------------------------
|
||||
oa.updateItem = function (item, $item)
|
||||
{
|
||||
$('.OrganisationId', $frm.orgId).val(item.id);
|
||||
oa.ajax.getItemAssoc = oa.ajax.getItemAssoc || { url: sax.url.base + 'Organisation/Ajax/GetAssociation', formId: 'frmOrganisationId', callbackFn: oa.onUpdateItem };
|
||||
$('.ItemAssociationId', $frm.assocId).val(item.id);
|
||||
$('.OrganisationId', $frm.assocId).val($('.OrganisationId', $frm.filter).val());
|
||||
oa.ajax.getItemAssoc = oa.ajax.getItemAssoc || { url: sax.url.base + 'Organisation/Ajax/GetAssociation', formId: 'frmAssociationId', callbackFn: oa.onUpdateItem };
|
||||
sax.doAjaxRequest(oa.ajax.getItemAssoc, 50);
|
||||
}
|
||||
oa.onUpdateItem = function (response)
|
||||
@@ -160,13 +163,19 @@
|
||||
if (!response.success) return;
|
||||
oa.clearItem();
|
||||
// Association.
|
||||
let item = response.organisation;
|
||||
let assoc = item.association || {};
|
||||
let item = response.association || {};
|
||||
let assoc = item.assoc || {};
|
||||
let org = item.organisation || {};
|
||||
let orgAssoc = item.organisationAssoc || {};
|
||||
let frm = $frm.assoc;
|
||||
|
||||
$('input.ItemAssociationId', frm).val(item.id);
|
||||
$('input.OrganisationId', frm).val(item.organisationId);
|
||||
$('.OrganisationName', frm).val(item.name);
|
||||
$('input.NewItem', frm).val(0);
|
||||
$('input.OrganisationId', frm).val(org.id);
|
||||
$('.OrganisationName input.OrganisationName', frm).val(org.name);
|
||||
$('.AssociationTypeOption select.AssociationTypeOption', frm).val(assoc.type);
|
||||
$('.OrganisationIdAssoc input.OrganisationIdAssoc', frm).val(orgAssoc.id);
|
||||
$('.OrganisationIdAssoc .OrganisationNameAssoc', frm).val(orgAssoc.name);
|
||||
|
||||
sax.openAssocDialog();
|
||||
}
|
||||
@@ -183,7 +192,36 @@
|
||||
sax.refreshControlValues(response.controlValues, $frm.assoc);
|
||||
if (!response.success) return;
|
||||
$dlg.assoc.dialog('close');
|
||||
mdlOrg().refreshItem(response.organisation);
|
||||
oa.refreshItem(response.association);
|
||||
}
|
||||
oa.refreshItem = function (item)
|
||||
{
|
||||
var $item = $('#' + oa.getItemIdProp(item.id));
|
||||
if (!$item.length)
|
||||
{
|
||||
$item = oa.getItemTemplate();
|
||||
$('.sax-panel-item-list', $pnl.results).prepend($item).show();
|
||||
}
|
||||
oa.populateItem($item, item);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
oa.removeItem = function (item, $item)
|
||||
{
|
||||
sax.debug('removeItem')
|
||||
oa.clearItem();
|
||||
let frm = $frm.assoc;
|
||||
$('.ItemAssociationId', frm).val(item.id);
|
||||
$('.OrganisationId', frm).val(item.organisation.id);
|
||||
$('.OrganisationIdAssoc', frm).val(item.organisationAssoc.id);
|
||||
oa.ajax.getRemoveItem = oa.ajax.getRemoveItem || { url: sax.url.base + 'Organisation/Ajax/RemoveAssociation', formId: frm.prop('id'), callbackFn: oa.onRemoveItem };
|
||||
sax.doAjaxRequest(oa.ajax.getRemoveItem, 50);
|
||||
}
|
||||
oa.onRemoveItem = function (response)
|
||||
{
|
||||
sax.debug('', response)
|
||||
if (!response.success) return;
|
||||
oa.refreshResults();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
|
||||
@@ -247,7 +247,7 @@
|
||||
op.clearItem = function ()
|
||||
{
|
||||
let frm = $frm.org;
|
||||
$('.OrganisationId,.OrganisationSportId,.OrganisationRegionIdPrimary,input[type="text"],textarea,select', frm).val('');
|
||||
$('.OrganisationId,.OrganisationSportId,.OrganisationRegionIdPrimary,input[name="ContactMethods"],input[type="text"],textarea,select', frm).val('');
|
||||
$pnl.tblconMths.empty();
|
||||
$('.OrganisationStatus', frm).val(op.data.defaultStatusCode);
|
||||
sax.clearControlErrors();
|
||||
|
||||
Reference in New Issue
Block a user