v1.2.8
This commit is contained in:
@@ -65,7 +65,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
|
||||
// Captions.
|
||||
responseData.Stats.User.Caption = Localiser["user.caption.users"];
|
||||
responseData.Stats.Organisation.Caption = Localiser["organisation.caption.organisations"];
|
||||
responseData.Stats.Organisation.Caption = Localiser["caption.organisations"];
|
||||
|
||||
// Core Database connection.
|
||||
ISacsDatabase db = SaxGlobals.App.GetCoreDatabase(SessionContext);
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
// NB Only allowed if there isn't a current user session.
|
||||
if (!ValidUserSession && AppConfig.Security.SignIn.KeepLoggedIn.Allowed)
|
||||
{
|
||||
String encryptedParams = GetRequestCookie(CookieName_KeepLoggedIn);
|
||||
String encryptedParams = GetRequestCookie(KeepLoggedIn.CookieName);
|
||||
KeepLoggedInParams keepLoggedInParams = ExtractKeepLoggedInParams(encryptedParams);
|
||||
String logSuffix = keepLoggedInParams.GetValidParams().Concat("", " ", ".");
|
||||
if (SysId.IsValid(keepLoggedInParams.UserAccountId))
|
||||
|
||||
+4
-4
@@ -16,7 +16,7 @@ using System.Threading.Tasks;
|
||||
namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
{
|
||||
//=======================================================================
|
||||
// Controller: Organisation - Activation - Ajax
|
||||
// Controller: Organisation - Ajax - Activation
|
||||
//=======================================================================
|
||||
partial class OrganisationController
|
||||
{
|
||||
@@ -30,7 +30,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
// Organisation details.
|
||||
public OrganisationItemData organisation { get; } = new OrganisationItemData();
|
||||
// Member awaiting activation.
|
||||
public List<MemberData_List> Members { get; } = new List<MemberData_List>();
|
||||
public List<MemberListData> Members { get; } = new List<MemberListData>();
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
[HttpPost]
|
||||
@@ -38,7 +38,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
public IActionResult Ajax_GetActivationInfo(Model_Organisation model)
|
||||
{
|
||||
String fn = GetType().Name + ".Ajax_GetActivationInfo";
|
||||
String messageTitle = Localiser["organisation.caption.organisation"];
|
||||
String messageTitle = Localiser["caption.organisation"];
|
||||
AjaxResponse_OrganisationActivationInfo responseData = new AjaxResponse_OrganisationActivationInfo(model);
|
||||
|
||||
// Validate session.
|
||||
@@ -108,7 +108,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
public IActionResult Ajax_Activate(Model_OrganisationActivation model)
|
||||
{
|
||||
String fn = GetType().Name + ".Ajax_Activate";
|
||||
String messageTitle = Localiser["organisation.caption.organisation"];
|
||||
String messageTitle = Localiser["caption.organisation"];
|
||||
AjaxResponse_Organisation responseData = new AjaxResponse_Organisation(model);
|
||||
|
||||
// Validate session.
|
||||
@@ -0,0 +1,619 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Core.Web.Admin.Models;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using Saxonite.Net.Standard.Base.Bus;
|
||||
using System;
|
||||
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
|
||||
{
|
||||
//=======================================================================
|
||||
// Controller: Organisation - Ajax - Associations
|
||||
//=======================================================================
|
||||
partial class OrganisationController
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Association type combinations.
|
||||
//-------------------------------------------------------------------
|
||||
private static readonly String optionLabel_AffiliatedTo = "Affiliated to";
|
||||
private static readonly String optionLabel_Affiliate = "Affiliate";
|
||||
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
|
||||
// the 'From' item (normal) or the 'To' item (reversed).
|
||||
private class AssociationTypeData
|
||||
{
|
||||
public AssociationTypeData()
|
||||
{
|
||||
// No parameter construction - populating association details for individual item (see Populate()).
|
||||
}
|
||||
public AssociationTypeData(AssociationTypeOption associationTypeOption)
|
||||
{
|
||||
// Population on construction - generic association type definitions, eg. for drop down menu options.
|
||||
Populate(associationTypeOption);
|
||||
}
|
||||
public void Populate(AssociationTypeOption associationTypeOption)
|
||||
{
|
||||
// Default labels - option to select association etc.
|
||||
Type = ((int)associationTypeOption).ToString();
|
||||
Label = GetOptionLabel(associationTypeOption);
|
||||
}
|
||||
public void Populate(Sax.AssociationType associationType, bool reversed)
|
||||
{
|
||||
// Default labels - option to select association etc.
|
||||
Populate(GetAssociationTypeOption(associationType, reversed));
|
||||
}
|
||||
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);
|
||||
Type = ((int)associationTypeOption).ToString();
|
||||
Label = label;
|
||||
}
|
||||
// Properties.
|
||||
public String Type { get; set; }
|
||||
public String Label { get; set; }
|
||||
// Utilities.
|
||||
public static 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;
|
||||
}
|
||||
return AssociationTypeOption.Unknown;
|
||||
}
|
||||
public static String GetOptionLabel(AssociationTypeOption associationTypeOption)
|
||||
{
|
||||
switch (associationTypeOption)
|
||||
{
|
||||
case AssociationTypeOption.AffiliateParent: return optionLabel_AffiliatedTo;
|
||||
case AssociationTypeOption.AffiliatedTo: return optionLabel_Affiliate;
|
||||
case AssociationTypeOption.Partner: return optionLabel_Partner;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Association data.
|
||||
//-------------------------------------------------------------------
|
||||
private class AssociationListData : AjaxResponse_Data.ItemData_Base
|
||||
{
|
||||
public class OrganisationData
|
||||
{
|
||||
public String Id { get; set; }
|
||||
public String Name { get; set; }
|
||||
}
|
||||
public OrganisationData Organisation { get; } = new OrganisationData();
|
||||
public OrganisationData OrganisationAssoc { get; } = new OrganisationData();
|
||||
public AssociationTypeData Assoc { get; } = new AssociationTypeData();
|
||||
}
|
||||
private class AssociationItemData : AssociationListData
|
||||
{
|
||||
}
|
||||
private void PopulateAssociationResponseListData(AssociationListData data, SaxItemAssociation itemAssociation, SaxOrganisation organisation, SaxOrganisation organisationAssoc)
|
||||
{
|
||||
data.Id = SysId.ToString(itemAssociation.Id);
|
||||
// Organisation.
|
||||
data.Organisation.Id = SysId.ToString(organisation.Id);
|
||||
data.Organisation.Name = organisation.Name;
|
||||
// Associated Organisation.
|
||||
data.OrganisationAssoc.Id = SysId.ToString(organisationAssoc.Id);
|
||||
data.OrganisationAssoc.Name = organisationAssoc.Name;
|
||||
// Association type.
|
||||
bool associationReversed = itemAssociation.ItemIdTo.Id.Equals(organisation.Id);
|
||||
String associationLabel = "";
|
||||
if (itemAssociation.AssociationType == Sax.AssociationType.Affiliate)
|
||||
associationLabel = associationReversed ? "Member organisation" : associationLabel = "Parent organisation";
|
||||
else if (itemAssociation.AssociationType == Sax.AssociationType.Partner)
|
||||
associationLabel = "Partner organisation";
|
||||
data.Assoc.Populate(itemAssociation.AssociationType, associationReversed, associationLabel);
|
||||
// Common properties.
|
||||
data.StatusCode = itemAssociation.StatusCode;
|
||||
data.StatusDesc = itemAssociation.StatusDesc;
|
||||
}
|
||||
private void PopulateAssociationResponseItemData(AssociationItemData data, SaxItemAssociation itemAssociation, SaxOrganisation organisation, SaxOrganisation organisationAssoc)
|
||||
{
|
||||
PopulateAssociationResponseListData(data, itemAssociation, organisation, organisationAssoc);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Get Organisation Association List ajax request.
|
||||
//-------------------------------------------------------------------
|
||||
private class AjaxResponse_AssociationList : AjaxResponse_Data
|
||||
{
|
||||
// Construction.
|
||||
public AjaxResponse_AssociationList(SaxModel_Admin model) : base(model) { }
|
||||
// Association list.
|
||||
public List<AssociationListData> Associations { get; } = new List<AssociationListData>();
|
||||
// Reference data.
|
||||
public List<AssociationTypeData> AssociationTypes { get; } = new List<AssociationTypeData>();
|
||||
public List<CodeDesc> Statuses { get; } = new List<CodeDesc>();
|
||||
public String DefaultStatusCode { get; set; }
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
[HttpPost]
|
||||
[Route("Organisation/Ajax/GetAssociationList")]
|
||||
[Route("Organisation/Ajax/GetAssociations")]
|
||||
public IActionResult Ajax_GetAssociationList(Model_OrganisationAssociations model)
|
||||
{
|
||||
String fn = GetType().Name + ".Ajax_GetAssociationList";
|
||||
String messageTitle = Localiser["caption.organisation.associations"];
|
||||
AjaxResponse_AssociationList responseData = new AjaxResponse_AssociationList(model);
|
||||
|
||||
// Validate session.
|
||||
if (!ValidUserSession)
|
||||
return GetAjaxResult_InvalidSession(responseData);
|
||||
|
||||
// Organisation Id is mandatory.
|
||||
SysId organisationId = model.Filter.OrganisationId.ToSysId();
|
||||
if (!SysId.IsValid(organisationId))
|
||||
{
|
||||
SaLogger.Warn(fn + " Request to retrieve associations without valid organisation Id.");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.specified"]));
|
||||
}
|
||||
|
||||
// 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));
|
||||
|
||||
// Reference data - statuses.
|
||||
foreach (SaStatus status in SaxItemAssociation.ValidStatuses.FindAll(item => item != SaStatus.Deleted))
|
||||
responseData.Statuses.Add(SacsSystem.GetStatusCode(status), Localiser.GetStatusCaption(status));
|
||||
responseData.DefaultStatusCode = SacsSystem.GetStatusCode(SaxItemAssociation.DefaultStatus);
|
||||
|
||||
// Get organisation associations.
|
||||
GetOrganisationAssociations(model, organisationId, responseData.Associations);
|
||||
|
||||
if (model.Paging.IsPaged)
|
||||
model.Paging.ItemCount = (ushort)responseData.Associations.Count;
|
||||
|
||||
// Complete response.
|
||||
responseData.SetPaging(model);
|
||||
responseData.Success = true;
|
||||
return Json(responseData);
|
||||
}
|
||||
private void GetOrganisationAssociations(SaxModel_Admin model, SysId organisationId, List<AssociationListData> associations)
|
||||
{
|
||||
String fn = GetType().Name + ".GetOrganisationAssociations";
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposableItems = new DisposableCollection<SacsHierarchyItem>())
|
||||
{
|
||||
|
||||
// Item filter.
|
||||
SaxItemAssociation.Params prmItemAssociation = new SaxItemAssociation.Params();
|
||||
prmItemAssociation.ItemIdsIncluded.Add(new ItemId((short)Sax.DataItemType.Organisation, organisationId));
|
||||
prmItemAssociation.StatusCat = SaxItemAssociation.StatusCat.NotDeleted;
|
||||
model.Paging.ItemTotal = (ulong)ItemDataMgr.GetItemAssociationCount(prmItemAssociation);
|
||||
model.PopulatePagingTo(prmItemAssociation.ResultsPaging);
|
||||
|
||||
// Item columns.
|
||||
ColumnDfn colId = ItemDataMgr.GetItemAssociationColumnDfn(SaxItemAssociation.Column.Id);
|
||||
ColumnDfn colItemTypeFrom = ItemDataMgr.GetItemAssociationColumnDfn(SaxItemAssociation.Column.ItemTypeFrom);
|
||||
ColumnDfn colItemIdFrom = ItemDataMgr.GetItemAssociationColumnDfn(SaxItemAssociation.Column.ItemIdFrom);
|
||||
ColumnDfn colItemTypeTo = ItemDataMgr.GetItemAssociationColumnDfn(SaxItemAssociation.Column.ItemTypeTo);
|
||||
ColumnDfn colItemIdTo = ItemDataMgr.GetItemAssociationColumnDfn(SaxItemAssociation.Column.ItemIdTo);
|
||||
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
|
||||
};
|
||||
|
||||
// Query items.
|
||||
List<SysId> organisationIds = new List<SysId>();
|
||||
using (DbResultSet resultSet = ItemDataMgr.ExecuteItemAssociationQuery(columns, prmItemAssociation))
|
||||
{
|
||||
while (resultSet != null && resultSet.HasRows && resultSet.NextRecord())
|
||||
{
|
||||
NamedValue.Map values = resultSet.GetRecordValues();
|
||||
AssociationListData associationData = new AssociationListData()
|
||||
{
|
||||
Id = values.GetString(colId.DataName),
|
||||
StatusCode = values.GetString(colStatus.DataName),
|
||||
StatusDesc = SacsSystem.GetStatusDescForCode(values.GetString(colStatus.DataName)),
|
||||
};
|
||||
// Items.
|
||||
bool assiationReversed = false;
|
||||
ItemId itemIdFrom = new ItemId((short)values.GetLong(colItemTypeFrom.DataName), new SysId(values.GetLong(colItemIdFrom.DataName)));
|
||||
ItemId itemIdTo = new ItemId((short)values.GetLong(colItemTypeTo.DataName), new SysId(values.GetLong(colItemIdTo.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.OrganisationAssoc.Id = SysId.ToString(itemIdTo.Id);
|
||||
}
|
||||
else if (itemIdTo.Id.Equals(organisationId))
|
||||
{
|
||||
assiationReversed = true;
|
||||
associationData.Organisation.Id = SysId.ToString(itemIdTo.Id);
|
||||
associationData.OrganisationAssoc.Id = SysId.ToString(itemIdFrom.Id);
|
||||
}
|
||||
else if (SacsSystem.DebugMode)
|
||||
// Track invalid associations, ie. where neither item is this organisation.
|
||||
Debugger.Break();
|
||||
}
|
||||
else if (SacsSystem.DebugMode)
|
||||
// Track invalid associations, ie. where either item is not an organisation.
|
||||
Debugger.Break();
|
||||
// Association type.
|
||||
Sax.AssociationType associationType = (Sax.AssociationType)values.GetLong(colAssociationType.DataName);
|
||||
associationData.Assoc.Populate(associationType, assiationReversed);
|
||||
// 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)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Get Organisation Association ajax request.
|
||||
//-------------------------------------------------------------------
|
||||
private class AjaxResponse_Association : AjaxResponse_Data
|
||||
{
|
||||
// Construction.
|
||||
public AjaxResponse_Association(SaxModel_Admin model) : base(model) { }
|
||||
// Association details.
|
||||
public AssociationItemData Association { get; } = new AssociationItemData();
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
[HttpPost]
|
||||
[Route("Organisation/Ajax/GetAssociation")]
|
||||
public IActionResult Ajax_GetAssociation(Model_OrganisationAssociations model)
|
||||
{
|
||||
String fn = GetType().Name + ".Ajax_GetAssociation";
|
||||
String messageTitle = Localiser["caption.organisation.association"];
|
||||
AjaxResponse_Association responseData = new AjaxResponse_Association(model);
|
||||
|
||||
// Validate session.
|
||||
if (!ValidUserSession)
|
||||
return GetAjaxResult_InvalidSession(responseData);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposableItems = new DisposableCollection<SacsHierarchyItem>())
|
||||
{
|
||||
|
||||
// Identify item.
|
||||
SysId itemAssociationId = model.ItemAssociationId.ToSysId();
|
||||
if (!SysId.IsValid(itemAssociationId))
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.specified"]));
|
||||
|
||||
// Retrieve association.
|
||||
SaxItemAssociation itemAssociation = ItemDataMgr.GetItemAssociationById(itemAssociationId);
|
||||
disposableItems.Add(itemAssociation);
|
||||
if (itemAssociation == null)
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to retrieve Item Association for Id: '" + model.ItemAssociationId + "'");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.found"]));
|
||||
}
|
||||
|
||||
// Identify organisations.
|
||||
SysId organisationId = model.OrganisationId.ToSysId();
|
||||
SysId organisationIdAssoc = null;
|
||||
if (!SysId.IsValid(organisationId))
|
||||
{
|
||||
SaLogger.Warn(fn + " Organisation Id must be supplied.");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.data.incomplete"]));
|
||||
}
|
||||
|
||||
// Validate the association.
|
||||
if (itemAssociation.ItemIdFrom.Type != (int)Sax.DataItemType.Organisation)
|
||||
{
|
||||
SaLogger.Warn(fn + " Inconsistent association 'From' item type: " + AssociationTypeCodes.GetCodeForType(itemAssociation.ItemIdFrom.Type) + ". Expected: Organisation.");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.data.inconsistent"]));
|
||||
}
|
||||
if (itemAssociation.ItemIdTo.Type != (int)Sax.DataItemType.Organisation)
|
||||
{
|
||||
SaLogger.Warn(fn + " Inconsistent association 'To' item type: " + AssociationTypeCodes.GetCodeForType(itemAssociation.ItemIdTo.Type) + ". Expected: Organisation.");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.data.inconsistent"]));
|
||||
}
|
||||
|
||||
// Identify organisations from association items.
|
||||
// The specified organisation must be one or other of the association's items.
|
||||
if (itemAssociation.ItemIdFrom.Id.Equals(organisationId))
|
||||
organisationIdAssoc = itemAssociation.ItemIdTo.Id;
|
||||
else if (itemAssociation.ItemIdTo.Id.Equals(organisationId))
|
||||
organisationIdAssoc = itemAssociation.ItemIdFrom.Id;
|
||||
else
|
||||
{
|
||||
SaLogger.Warn(fn + " Inconsistent association - Specified organisation is neither item.");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.data.inconsistent"]));
|
||||
}
|
||||
|
||||
// Retrieve Organisation.
|
||||
SaxOrganisation organisation = AccountMgr.GetOrganisationById(organisationId);
|
||||
disposableItems.Add(organisation);
|
||||
if (organisation == null)
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to retrieve Organisation for Id: '" + organisationId + "'");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
|
||||
// Retrieve associated Organisation.
|
||||
SaxOrganisation organisationAssoc = AccountMgr.GetOrganisationById(organisationIdAssoc);
|
||||
disposableItems.Add(organisationAssoc);
|
||||
if (organisationAssoc == null)
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to retrieve Organisation for Id: '" + organisationIdAssoc + "'");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
|
||||
// Construct response.
|
||||
PopulateAssociationResponseItemData(responseData.Association, itemAssociation, organisation, organisationAssoc);
|
||||
}
|
||||
|
||||
responseData.Success = true;
|
||||
return Json(responseData);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Store Organisation Association ajax request.
|
||||
//-------------------------------------------------------------------
|
||||
[HttpPost]
|
||||
[Route("Organisation/Ajax/StoreAssociation")]
|
||||
public IActionResult Ajax_StoreAssociation(Model_OrganisationAssociations model)
|
||||
{
|
||||
String fn = GetType().Name + ".Ajax_StoreAssociation";
|
||||
String messageTitle = Localiser["caption.organisation.association"];
|
||||
AjaxResponse_Association responseData = new AjaxResponse_Association(model);
|
||||
|
||||
// Validate session.
|
||||
if (!ValidUserSession)
|
||||
return GetAjaxResult_InvalidSession(responseData);
|
||||
|
||||
// Validate item properties.
|
||||
model.ValidateOrganisationAssociationData(responseData);
|
||||
if (responseData.HasControlErrors())
|
||||
return Json(responseData);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposableItems = new DisposableCollection<SacsHierarchyItem>())
|
||||
{
|
||||
|
||||
// Organisation.
|
||||
SysId organisationId = model.OrganisationId.ToSysId();
|
||||
SaxOrganisation organisation = AccountMgr.GetOrganisationById(organisationId);
|
||||
disposableItems.Add(organisation);
|
||||
if (organisation == null)
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to retrieve Organisation for Id: " + model.OrganisationId);
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.data.incomplete"]));
|
||||
}
|
||||
|
||||
// Associated Organisation.
|
||||
SysId organisationIdAssoc = model.OrganisationIdAssoc.ToSysId();
|
||||
SaxOrganisation organisationAssoc = AccountMgr.GetOrganisationById(organisationIdAssoc);
|
||||
disposableItems.Add(organisationAssoc);
|
||||
if (organisationAssoc == null)
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to retrieve associated Organisation for Id: " + model.OrganisationIdAssoc);
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.data.incomplete"]));
|
||||
}
|
||||
if (organisationIdAssoc.Equals(organisationId))
|
||||
{
|
||||
SaLogger.Warn(fn + " Associated organisation must not be the same as the organisation.");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.data.inconsistent"]));
|
||||
}
|
||||
|
||||
// Association type.
|
||||
Sax.AssociationType associationType = model.GetAssociationTypeForOption(model.Association.GetAssociationTypeOption());
|
||||
if ((int)associationType < 1)
|
||||
{
|
||||
SaLogger.Warn(fn + " Association Type must be specified.");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.data.inconsistent"]));
|
||||
}
|
||||
AssociationTypeOption associationTypeOption = model.Association.GetAssociationTypeOption();
|
||||
if ((int)associationTypeOption < 1)
|
||||
{
|
||||
SaLogger.Warn(fn + " Association Type Option must be specified.");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.data.inconsistent"]));
|
||||
}
|
||||
if (!model.IsConsistentWith(associationTypeOption, associationType))
|
||||
{
|
||||
SaLogger.Warn(fn + " Association Type Option (" + associationTypeOption + ") is inconsistent with Association Type (" + associationType + ").");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.data.inconsistent"]));
|
||||
}
|
||||
|
||||
// Identify From/To items.
|
||||
ItemId itemIdFrom = organisation.GetItemId();
|
||||
ItemId itemIdTo = organisationAssoc.GetItemId();
|
||||
if (model.IsAssociationTypeDirectionReversed(associationTypeOption))
|
||||
{
|
||||
itemIdFrom = organisationAssoc.GetItemId();
|
||||
itemIdTo = organisation.GetItemId();
|
||||
}
|
||||
|
||||
// Retrieve existing association.
|
||||
SysId itemAssociationId = model.ItemAssociationId.ToSysId();
|
||||
if (SysId.IsValid(itemAssociationId) == StringUtil.ToBool(model.NewItem))
|
||||
{
|
||||
// Inconsistentcy between the 'Existing' flag and whether the Item Association Id has been specified.
|
||||
SaLogger.Warn(fn + " Item Association Id " + (StringUtil.ToBool(model.NewItem) ? "specified for new item" : "not specified for existing item") + ".");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.data.inconsistent"]));
|
||||
}
|
||||
SaxItemAssociation itemAssociation = ItemDataMgr.GetItemAssociationById(itemAssociationId);
|
||||
disposableItems.Add(itemAssociation);
|
||||
if (itemAssociation == null && SysId.IsValid(itemAssociationId))
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to retrieve item association for Id: '" + itemAssociationId + "'");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.found"]));
|
||||
}
|
||||
|
||||
if (itemAssociation != null)
|
||||
{
|
||||
// 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));
|
||||
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));
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Item Association not identified.
|
||||
|
||||
// Check for deleted association that can be reused.
|
||||
SaxItemAssociation.Params itemAssociationParams = new SaxItemAssociation.Params();
|
||||
|
||||
if (itemAssociation != null)
|
||||
itemAssociation.Status = SaxItemAssociation.DefaultStatus;
|
||||
else
|
||||
{
|
||||
// Association not found - create a new one.
|
||||
itemAssociation = ItemDataMgr.CreateItemAssociation(itemIdFrom, itemIdTo, associationType);
|
||||
}
|
||||
disposableItems.Add(itemAssociation);
|
||||
}
|
||||
|
||||
// Populate item properties.
|
||||
if (model.Association.StatusCode != null)
|
||||
itemAssociation.Status = model.Association.GetStatus();
|
||||
|
||||
// Store item.
|
||||
if (!SysId.IsValid(itemAssociation.Id))
|
||||
{
|
||||
if (!ItemDataMgr.InsertItemAssociation(itemAssociation, DbUpdateInfo))
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to insert user organisation: " + ItemDataMgr.ErrorStateMessage);
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.insert.failed"] + "\n\n" + ItemDataMgr.ErrorStateMessage));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!ItemDataMgr.UpdateItemAssociation(itemAssociation, DbUpdateInfo))
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to update user organisation [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);
|
||||
}
|
||||
|
||||
responseData.Success = true;
|
||||
return Json(responseData);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Remove Organisation Association ajax request.
|
||||
//-------------------------------------------------------------------
|
||||
[HttpPost]
|
||||
[Route("Organisation/Ajax/RemoveAssociation")]
|
||||
public IActionResult Ajax_RemoveAssociation(Model_OrganisationAssociations model)
|
||||
{
|
||||
String fn = GetType().Name + ".Ajax_RemoveAssociation";
|
||||
String messageTitle = Localiser["caption.organisation.association"];
|
||||
AjaxResponse_Association responseData = new AjaxResponse_Association(model);
|
||||
|
||||
// Validate session.
|
||||
if (!ValidUserSession)
|
||||
return GetAjaxResult_InvalidSession(responseData);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposableItems = new DisposableCollection<SacsHierarchyItem>())
|
||||
{
|
||||
|
||||
// Organisation.
|
||||
SysId organisationId = model.OrganisationId.ToSysId();
|
||||
SaxOrganisation organisation = AccountMgr.GetOrganisationById(organisationId);
|
||||
disposableItems.Add(organisation);
|
||||
if (organisation == null)
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to retrieve Organisation for Id: '" + model.OrganisationId + "'");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.data.incomplete"]));
|
||||
}
|
||||
|
||||
// Association Organisation.
|
||||
SysId organisationIdAssoc = model.OrganisationIdAssoc.ToSysId();
|
||||
SaxOrganisation organisationAssoc = AccountMgr.GetOrganisationById(organisationIdAssoc);
|
||||
disposableItems.Add(organisationAssoc);
|
||||
if (organisationAssoc == null)
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to retrieve associated Organisation for Id: '" + model.OrganisationIdAssoc + "'");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.data.incomplete"]));
|
||||
}
|
||||
if (organisationIdAssoc.Equals(organisationId))
|
||||
{
|
||||
SaLogger.Warn(fn + " Associated organisation must not be the same as the organisation.");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.data.inconsistent"]));
|
||||
}
|
||||
|
||||
// Item Association.
|
||||
SysId itemAssociationId = model.ItemAssociationId.ToSysId();
|
||||
SaxItemAssociation itemAssociation = ItemDataMgr.GetItemAssociationById(itemAssociationId);
|
||||
disposableItems.Add(itemAssociation);
|
||||
if (itemAssociation == null)
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to retrieve Item Association for Id: '" + itemAssociationId + "'");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.found"]));
|
||||
}
|
||||
|
||||
// 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");
|
||||
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");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.data.inconsistent"]));
|
||||
}
|
||||
|
||||
// Logically delete item.
|
||||
itemAssociation.Status = SaStatus.Deleted;
|
||||
if (!ItemDataMgr.UpdateItemAssociation(itemAssociation, DbUpdateInfo))
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
responseData.Success = true;
|
||||
return Json(responseData);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
+17
-17
@@ -15,13 +15,13 @@ using System.Threading.Tasks;
|
||||
namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
{
|
||||
//=======================================================================
|
||||
// Controller: Organisation - Members - Ajax
|
||||
// Controller: Organisation - Ajax - Members
|
||||
//=======================================================================
|
||||
partial class OrganisationController
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Member data.
|
||||
private class MemberData_List : AjaxResponse_Data.ItemData_Base
|
||||
private class MemberListData : AjaxResponse_Data.ItemData_Base
|
||||
{
|
||||
// User.
|
||||
public String UserAccountId { get; set; }
|
||||
@@ -38,12 +38,12 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
public int RoleCount { get; set; }
|
||||
public bool? Member { get; set; } = null;
|
||||
}
|
||||
private class MemberData_Full : MemberData_List
|
||||
private class MemberItemData : MemberListData
|
||||
{
|
||||
// Organisation user.
|
||||
public List<String> RoleCodes { get; } = new List<string>();
|
||||
}
|
||||
private void PopulateMemberResponseData(MemberData_List data, SaxUserOrganisation userOrganisation, SaxUserAccount userAccount, SaxOrganisation organisation)
|
||||
private void PopulateMemberResponseListData(MemberListData data, SaxUserOrganisation userOrganisation, SaxUserAccount userAccount, SaxOrganisation organisation)
|
||||
{
|
||||
data.Id = SysId.ToString(userOrganisation.Id);
|
||||
// User.
|
||||
@@ -63,9 +63,9 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
if (userOrganisation.GetOrganisationRoles().ToList().Exists(item => item == Sax.OrganisationRole.Member))
|
||||
data.Member = true;
|
||||
}
|
||||
private void PopulateMemberResponseData(MemberData_Full data, SaxUserOrganisation userOrganisation, SaxUserAccount userAccount, SaxOrganisation organisation)
|
||||
private void PopulateMemberResponseItemData(MemberItemData data, SaxUserOrganisation userOrganisation, SaxUserAccount userAccount, SaxOrganisation organisation)
|
||||
{
|
||||
PopulateMemberResponseData(data as MemberData_List, userOrganisation, userAccount, organisation);
|
||||
PopulateMemberResponseListData(data, userOrganisation, userAccount, organisation);
|
||||
// Organisation user:
|
||||
// Exclude 'Member' role.
|
||||
foreach (Sax.OrganisationRole organisationRole in userOrganisation.GetOrganisationRoles().ToList().FindAll(item => item != Sax.OrganisationRole.Member))
|
||||
@@ -80,7 +80,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
// Construction.
|
||||
public AjaxResponse_MemberList(SaxModel_Admin model) : base(model) { }
|
||||
// Member list.
|
||||
public List<MemberData_List> Members { get; } = new List<MemberData_List>();
|
||||
public List<MemberListData> Members { get; } = new List<MemberListData>();
|
||||
// Reference data.
|
||||
public List<CodeDesc> MemberRoles { get; } = new List<CodeDesc>();
|
||||
public List<CodeDesc> Statuses { get; } = new List<CodeDesc>();
|
||||
@@ -92,7 +92,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
public IActionResult Ajax_GetMemberList(Model_OrganisationMembers model)
|
||||
{
|
||||
String fn = GetType().Name + ".Ajax_GetMemberList";
|
||||
String messageTitle = Localiser["organisation.caption.members"];
|
||||
String messageTitle = Localiser["caption.organisation.members"];
|
||||
AjaxResponse_MemberList responseData = new AjaxResponse_MemberList(model);
|
||||
|
||||
// Validate session.
|
||||
@@ -128,7 +128,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
responseData.Success = true;
|
||||
return Json(responseData);
|
||||
}
|
||||
private void GetOrganisationMembers(SaxModel_Admin model, SysId organisationId, List<MemberData_List> members)
|
||||
private void GetOrganisationMembers(SaxModel_Admin model, SysId organisationId, List<MemberListData> members)
|
||||
{
|
||||
// Item filter.
|
||||
SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params();
|
||||
@@ -165,7 +165,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
while (resultSet != null && resultSet.HasRows && resultSet.NextRecord())
|
||||
{
|
||||
NamedValue.Map values = resultSet.GetRecordValues();
|
||||
MemberData_List memberData = new MemberData_List()
|
||||
MemberListData memberData = new MemberListData()
|
||||
{
|
||||
Id = values.GetString(colId.DataName),
|
||||
// User.
|
||||
@@ -196,7 +196,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
// Construction.
|
||||
public AjaxResponse_Member(SaxModel_Admin model) : base(model) { }
|
||||
// Member details.
|
||||
public MemberData_Full Member { get; } = new MemberData_Full();
|
||||
public MemberItemData Member { get; } = new MemberItemData();
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
[HttpPost]
|
||||
@@ -204,7 +204,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
public IActionResult Ajax_GetMember(Model_OrganisationMembers model)
|
||||
{
|
||||
String fn = GetType().Name + ".Ajax_GetItem";
|
||||
String messageTitle = Localiser["organisation.caption.member"];
|
||||
String messageTitle = Localiser["caption.organisation.member"];
|
||||
AjaxResponse_Member responseData = new AjaxResponse_Member(model);
|
||||
|
||||
// Validate session.
|
||||
@@ -248,7 +248,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
}
|
||||
|
||||
// Construct response.
|
||||
PopulateMemberResponseData(responseData.Member, userOrganisation, userAccount, organisation);
|
||||
PopulateMemberResponseItemData(responseData.Member, userOrganisation, userAccount, organisation);
|
||||
}
|
||||
|
||||
responseData.Success = true;
|
||||
@@ -263,7 +263,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
public IActionResult Ajax_StoreMember(Model_OrganisationMembers model)
|
||||
{
|
||||
String fn = GetType().Name + ".Ajax_StoreMember";
|
||||
String messageTitle = Localiser["organisation.caption.member"];
|
||||
String messageTitle = Localiser["caption.organisation.member"];
|
||||
AjaxResponse_Member responseData = new AjaxResponse_Member(model);
|
||||
|
||||
// Validate session.
|
||||
@@ -375,7 +375,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
}
|
||||
|
||||
// Construct response.
|
||||
PopulateMemberResponseData(responseData.Member, userOrganisation, userAccount, organisation);
|
||||
PopulateMemberResponseItemData(responseData.Member, userOrganisation, userAccount, organisation);
|
||||
}
|
||||
|
||||
responseData.Success = true;
|
||||
@@ -390,7 +390,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
public IActionResult Ajax_RemoveMember(Model_OrganisationMembers model)
|
||||
{
|
||||
String fn = GetType().Name + ".Ajax_RemoveMember";
|
||||
String messageTitle = Localiser["organisation.caption.member"];
|
||||
String messageTitle = Localiser["caption.organisation.member"];
|
||||
AjaxResponse_Member responseData = new AjaxResponse_Member(model);
|
||||
|
||||
// Validate session.
|
||||
@@ -457,7 +457,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
}
|
||||
|
||||
// Construct response.
|
||||
PopulateMemberResponseData(responseData.Member, userOrganisation, userAccount, organisation);
|
||||
PopulateMemberResponseItemData(responseData.Member, userOrganisation, userAccount, organisation);
|
||||
}
|
||||
|
||||
responseData.Success = true;
|
||||
@@ -133,7 +133,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
public IActionResult Ajax_GetList(Model_Organisation model)
|
||||
{
|
||||
String fn = GetType().Name + ".Ajax_GetList";
|
||||
String messageTitle = Localiser["organisation.caption.organisations"];
|
||||
String messageTitle = Localiser["caption.organisations"];
|
||||
AjaxResponse_OrganisationList responseData = new AjaxResponse_OrganisationList(model);
|
||||
|
||||
// Validate session.
|
||||
@@ -253,7 +253,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
public IActionResult Ajax_GetItem(Model_Organisation model)
|
||||
{
|
||||
String fn = GetType().Name + ".Ajax_GetItem";
|
||||
String messageTitle = Localiser["organisation.caption.organisation"];
|
||||
String messageTitle = Localiser["caption.organisation"];
|
||||
AjaxResponse_Organisation responseData = new AjaxResponse_Organisation(model);
|
||||
|
||||
// Validate session.
|
||||
@@ -299,7 +299,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
public IActionResult Ajax_StoreItem(Model_Organisation model)
|
||||
{
|
||||
String fn = GetType().Name + ".Ajax_StoreItem";
|
||||
String messageTitle = Localiser["organisation.caption.organisation"];
|
||||
String messageTitle = Localiser["caption.organisation"];
|
||||
AjaxResponse_Organisation responseData = new AjaxResponse_Organisation(model);
|
||||
|
||||
// Validate session.
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
public IActionResult Ajax_GetImages(Model_Organisation model)
|
||||
{
|
||||
String fn = GetType().Name + ".Ajax_GetImages";
|
||||
String messageTitle = Localiser["organisation.caption.organisation"];
|
||||
String messageTitle = Localiser["caption.organisation"];
|
||||
AjaxResponse_OrganisationImages responseData = new AjaxResponse_OrganisationImages(model);
|
||||
|
||||
// Validate session.
|
||||
@@ -113,7 +113,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
{
|
||||
String fn = GetType().Name + ".UploadOrganisationLogoImage";
|
||||
AjaxResponse_UploadOrganisationLogoImage responseData = new AjaxResponse_UploadOrganisationLogoImage(model);
|
||||
String messageTitle = Localiser["organisation.caption.organisation"];
|
||||
String messageTitle = Localiser["caption.organisation"];
|
||||
|
||||
// Validate session and referrer.
|
||||
if (!ValidReferer) return Forbid();
|
||||
@@ -223,7 +223,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
public IActionResult Ajax_StoreImages(Model_Organisation model)
|
||||
{
|
||||
String fn = GetType().Name + ".Ajax_StoreImages";
|
||||
String messageTitle = Localiser["organisation.caption.organisation"];
|
||||
String messageTitle = Localiser["caption.organisation"];
|
||||
AjaxResponse_OrganisationImages responseData = new AjaxResponse_OrganisationImages(model);
|
||||
|
||||
// Validate session.
|
||||
|
||||
@@ -68,10 +68,37 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
return RedirectToAction("", "");
|
||||
|
||||
// Retrieve organisation.
|
||||
SaxOrganisation organisation = AccountMgr.GetOrganisationById(model.Filter.OrganisationId.ToSysId());
|
||||
SaxOrganisation organisation = AccountMgr.GetOrganisationById(model.OrganisationId.ToSysId());
|
||||
if (organisation == null)
|
||||
RedirectToAction("", "Organisation");
|
||||
model.MemberOrganisationName = organisation?.Name;
|
||||
model.Filter.OrganisationId= SysId.ToString(organisation.Id);
|
||||
model.Filter.OrganisationName = organisation.Name;
|
||||
|
||||
// Paging.
|
||||
model.Paging.PageNo = 1;
|
||||
model.Paging.PageLength = 12;
|
||||
|
||||
return View(model);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Organisation Associations action.
|
||||
/// <para>- POST action to allow Organisation Id to be supplied, eg. from Organsiations page.</para>
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
public IActionResult Associations(Model_OrganisationAssociations model)
|
||||
{
|
||||
// Validate session.
|
||||
if (!ValidUserSession)
|
||||
return RedirectToAction("", "");
|
||||
|
||||
// Retrieve organisation.
|
||||
SaxOrganisation organisation = AccountMgr.GetOrganisationById(model.OrganisationId.ToSysId());
|
||||
if (organisation == null)
|
||||
RedirectToAction("", "Organisation");
|
||||
model.Filter.OrganisationId = SysId.ToString(organisation.Id);
|
||||
model.Filter.OrganisationName = organisation.Name;
|
||||
|
||||
// Paging.
|
||||
model.Paging.PageNo = 1;
|
||||
|
||||
@@ -143,16 +143,16 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
{
|
||||
String keepLoggedInCookieValue = GenerateKeepLoggedInCookieValue();
|
||||
int cookieExpiresDays = Math.Max(Sax.Config.Security.SignIn.KeepLoggedIn.CookieExpiresDays_Min, Math.Min(Sax.Config.Security.SignIn.KeepLoggedIn.CookieExpiresDays_Max, AppConfig.Security.SignIn.KeepLoggedIn.CookieExpiresDays));
|
||||
SetResponseCookie(CookieName_KeepLoggedIn, keepLoggedInCookieValue, DateTime.Now.AddDays(cookieExpiresDays), true);
|
||||
SetResponseCookie(KeepLoggedIn.CookieName, keepLoggedInCookieValue, DateTime.Now.AddDays(cookieExpiresDays), true);
|
||||
SaLogger.Info(this.GetType().Name + ".SetKeepLoggedInCookie 'Keep Logged In' cookie set. Value: " + keepLoggedInCookieValue);
|
||||
}
|
||||
|
||||
/// <summary>Set the 'Keep Logged In' response cookie to expired with no data.</summary>
|
||||
public void ClearKeepLoggedInCookie()
|
||||
{
|
||||
if (StringUtil.IsEmpty(GetRequestCookie(CookieName_KeepLoggedIn))) return;
|
||||
if (StringUtil.IsEmpty(GetRequestCookie(KeepLoggedIn.CookieName))) return;
|
||||
// Clear cookie by setting expiry date in the past.
|
||||
SetResponseCookie(CookieName_KeepLoggedIn, "", DateTime.Today.AddDays(-7), true);
|
||||
SetResponseCookie(KeepLoggedIn.CookieName, "", DateTime.Today.AddDays(-7), true);
|
||||
SaLogger.Info(GetType().Name + ".ClearKeepLoggedInCookie 'Keep Logged In' cookie cleared.");
|
||||
}
|
||||
|
||||
@@ -162,11 +162,13 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
// to ensure that cookie value can be decrypted even if application restarts in the meantime.
|
||||
// - Generating IV from same key results in different value each time.
|
||||
// - IV Must be regenerated if key is changed: uncomment 'Generated' variable and copy resulting value to IV variable.
|
||||
// NB
|
||||
public static String CookieName_KeepLoggedIn = "SXKLI";
|
||||
public static String Base64Key_KeepLoggedIn = SacsEncryptionHelper.EncodePlainKey("<=Saxonite^{kEEp+1Ogg3d-IN}~32*>", SacsEncryptionHelper.KeyLength);
|
||||
public static String Base64IV_KeepLoggedIn_Generated = SacsEncryptionHelper.InitSymmetricEncryptionIV(Base64Key_KeepLoggedIn);
|
||||
public static String Base64IV_KeepLoggedIn = "YOX10FIPp1zM1pg5U6fW7A==";
|
||||
public static class KeepLoggedIn
|
||||
{
|
||||
public static String CookieName = "SXKLI";
|
||||
public static String Base64Key = SacsEncryptionHelper.EncodePlainKey("<=Saxonite^{kEEp+1Ogg3d-IN}~32*>", SacsEncryptionHelper.KeyLength);
|
||||
public static String Base64IV = "YOX10FIPp1zM1pg5U6fW7A==";
|
||||
private static String Base64IV_Generated = SacsEncryptionHelper.InitSymmetricEncryptionIV(KeepLoggedIn.Base64Key);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Keep-logged-in cookie value.
|
||||
@@ -175,7 +177,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
{
|
||||
NameValueCollection keepLoggedInParams = new NameValueCollection();
|
||||
keepLoggedInParams.Add(ParamName_KeepLoggedIn_UserAccountId, SysId.ToString(SessionData_Admin.User.UserAccountId));
|
||||
return EncryptParameters(keepLoggedInParams, Base64IV_KeepLoggedIn, Base64Key_KeepLoggedIn);
|
||||
return EncryptParameters(keepLoggedInParams, KeepLoggedIn.Base64IV, KeepLoggedIn.Base64Key);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -196,7 +198,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
KeepLoggedInParams keepLoggedInParams = new KeepLoggedInParams();
|
||||
if (!StringUtil.IsEmpty(encryptedParams))
|
||||
{
|
||||
NameValueCollection linkParams = DecryptParameters(encryptedParams, Base64IV_KeepLoggedIn, Base64Key_KeepLoggedIn);
|
||||
NameValueCollection linkParams = DecryptParameters(encryptedParams, KeepLoggedIn.Base64IV, KeepLoggedIn.Base64Key);
|
||||
keepLoggedInParams.UserAccountId = new SysId(StringUtil.ToInt(linkParams.Get(ParamName_KeepLoggedIn_UserAccountId)));
|
||||
}
|
||||
if (DebugMode) SaLogger.Info(GetType().Name + ".ExtractKeepLoggedInParams UserAccountId: " + SysId.ToString(keepLoggedInParams.UserAccountId));
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
return Json(responseData);
|
||||
|
||||
// Resend the cookie to extend the expiry date if it is currently populated.
|
||||
if (!StringUtil.IsEmpty(GetRequestCookie(CookieName_KeepLoggedIn)))
|
||||
if (!StringUtil.IsEmpty(GetRequestCookie(KeepLoggedIn.CookieName)))
|
||||
SetKeepLoggedInCookie();
|
||||
|
||||
// Construct response.
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// User data.
|
||||
private class UserData_List : AjaxResponse_Data.ItemData_Base
|
||||
private class UserListData : AjaxResponse_Data.ItemData_Base
|
||||
{
|
||||
public String EmailAddress { get; set; }
|
||||
public String DisplayName { get; set; }
|
||||
@@ -34,7 +34,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
public String LastOnlineLoginAt { get; set; }
|
||||
public String LastAdminLoginAt { get; set; }
|
||||
}
|
||||
private class UserData_Full : UserData_List
|
||||
private class UserItemData : UserListData
|
||||
{
|
||||
public String RegionIdCountry { get; set; }
|
||||
public String RegionIdProvince { get; set; }
|
||||
@@ -48,7 +48,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
// User roles.
|
||||
public List<String> userRoleCodes { get; } = new List<string>();
|
||||
}
|
||||
private void PopulateUserResponseData(SaxModel_Admin model, UserData_List data, SaxUserAccount user, List<SaxUserSport> userSports, List<SaxUserRole> userRoles)
|
||||
private void PopulateUserResponseListData(SaxModel_Admin model, UserListData data, SaxUserAccount user, List<SaxUserSport> userSports, List<SaxUserRole> userRoles)
|
||||
{
|
||||
data.Id = SysId.ToString(user.Id);
|
||||
data.EmailAddress = user.EmailAddress;
|
||||
@@ -71,9 +71,9 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
if (userRole_SystemAdmin != null)
|
||||
data.LastAdminLoginAt = model.FormatDateTimeForDisplay(userRole_SystemAdmin.LastLoginAt);
|
||||
}
|
||||
private void PopulateUserResponseData(SaxModel_Admin model, UserData_Full data, SaxUserAccount user, List<SaxUserSport> userSports, List<SaxUserRole> userRoles)
|
||||
private void PopulateUserResponseItemData(SaxModel_Admin model, UserItemData data, SaxUserAccount user, List<SaxUserSport> userSports, List<SaxUserRole> userRoles)
|
||||
{
|
||||
PopulateUserResponseData(model, data as UserData_List, user, userSports, userRoles);
|
||||
PopulateUserResponseListData(model, data, user, userSports, userRoles);
|
||||
|
||||
data.RegionIdCountry = SysId.ToString(user.RegionIdCountry);
|
||||
data.RegionIdProvince = SysId.ToString(user.RegionIdProvince);
|
||||
@@ -81,12 +81,12 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
// User sports.
|
||||
if (userSports != null && !userSports.IsEmpty())
|
||||
{
|
||||
data.Sports = new List<UserData_Full.UserSportData>();
|
||||
data.Sports = new List<UserItemData.UserSportData>();
|
||||
List<SaxSport> sports = ReferenceMgr.GetSportListByIds(userSports.GetSportIds());
|
||||
foreach (SaxUserSport userSport in userSports)
|
||||
{
|
||||
SaxSport sport = sports.GetSportById(userSport.SportId);
|
||||
UserData_Full.UserSportData userSportData = new UserData_Full.UserSportData()
|
||||
UserItemData.UserSportData userSportData = new UserItemData.UserSportData()
|
||||
{
|
||||
SportId = SysId.ToString(userSport.SportId),
|
||||
SportName = sport?.Name ?? null
|
||||
@@ -130,7 +130,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
// Construction.
|
||||
public AjaxResponse_UserList(SaxModel_Admin model) : base(model) { }
|
||||
// User list.
|
||||
public List<UserData_List> Users { get; } = new List<UserData_List>();
|
||||
public List<UserListData> Users { get; } = new List<UserListData>();
|
||||
// Reference data.
|
||||
public List<CodeDesc> UserRoles { get; } = new List<CodeDesc>();
|
||||
public List<CodeDesc> Statuses { get; } = new List<CodeDesc>();
|
||||
@@ -205,7 +205,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
while (resultSet != null && resultSet.HasRows && resultSet.NextRecord())
|
||||
{
|
||||
NamedValue.Map values = resultSet.GetRecordValues();
|
||||
UserData_List userData = new UserData_List()
|
||||
UserListData userData = new UserListData()
|
||||
{
|
||||
Id = values.GetString(colId.DataName),
|
||||
EmailAddress = values.GetString(colEmail.DataName),
|
||||
@@ -246,7 +246,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
// Construction.
|
||||
public AjaxResponse_User(SaxModel_Admin model) : base(model) { }
|
||||
// User details.
|
||||
public UserData_Full user { get; } = new UserData_Full();
|
||||
public UserItemData user { get; } = new UserItemData();
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
[HttpPost]
|
||||
@@ -290,7 +290,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
disposableItems.AddRange(userRoles);
|
||||
|
||||
// Construct response.
|
||||
PopulateUserResponseData(model, responseData.user, user, userSports, userRoles);
|
||||
PopulateUserResponseItemData(model, responseData.user, user, userSports, userRoles);
|
||||
responseData.Success = true;
|
||||
}
|
||||
return Json(responseData);
|
||||
@@ -342,7 +342,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
disposableItems.AddRange(userRoles);
|
||||
|
||||
// Construct response.
|
||||
PopulateUserResponseData(model, responseData.user, user, userSports, userRoles);
|
||||
PopulateUserResponseItemData(model, responseData.user, user, userSports, userRoles);
|
||||
responseData.Success = true;
|
||||
}
|
||||
return Json(responseData);
|
||||
@@ -478,7 +478,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
disposableItems.AddRange(userSports);
|
||||
|
||||
// Construct response.
|
||||
PopulateUserResponseData(model, responseData.user, user, userSports, userRoles.GetUserRolesByStatus(SaStatus.Active));
|
||||
PopulateUserResponseItemData(model, responseData.user, user, userSports, userRoles.GetUserRolesByStatus(SaStatus.Active));
|
||||
responseData.Success = true;
|
||||
}
|
||||
return Json(responseData);
|
||||
@@ -554,7 +554,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
disposableItems.AddRange(userSports);
|
||||
|
||||
// Construct response.
|
||||
PopulateUserResponseData(model, responseData.user, userAccount, userSports, userRoles.GetUserRolesByStatus(SaStatus.Active));
|
||||
PopulateUserResponseItemData(model, responseData.user, userAccount, userSports, userRoles.GetUserRolesByStatus(SaStatus.Active));
|
||||
responseData.SetNotification(messageTitle, "Emails sent: " + emailsSentCount);
|
||||
responseData.Success = true;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// User data.
|
||||
private class UserData_List : AjaxResponse_Data.ItemData_Base
|
||||
private class UserListData : AjaxResponse_Data.ItemData_Base
|
||||
{
|
||||
public String EmailAddress { get; set; }
|
||||
public String DisplayName { get; set; }
|
||||
@@ -29,10 +29,10 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
public String LastLoginAt { get; set; }
|
||||
public String OnlineAt { get; set; }
|
||||
}
|
||||
private class UserData_Full : UserData_List
|
||||
private class UserItemData : UserListData
|
||||
{
|
||||
}
|
||||
private void PopulateUserResponseData(SaxModel_Admin model, UserData_List data, SaxUserAccount user, SaxUserOnline userOnline)
|
||||
private void PopulateUserResponseListData(SaxModel_Admin model, UserListData data, SaxUserAccount user, SaxUserOnline userOnline)
|
||||
{
|
||||
data.Id = SysId.ToString(user.Id);
|
||||
data.EmailAddress = user.EmailAddress;
|
||||
@@ -44,9 +44,9 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
if (userOnline != null)
|
||||
data.OnlineAt = model.FormatDateTimeForDisplay(userOnline.OnlineAt);
|
||||
}
|
||||
private void PopulateUserResponseData(SaxModel_Admin model, UserData_Full data, SaxUserAccount user, SaxUserOnline userOnline)
|
||||
private void PopulateUserResponseItemData(SaxModel_Admin model, UserItemData data, SaxUserAccount user, SaxUserOnline userOnline)
|
||||
{
|
||||
PopulateUserResponseData(model, data as UserData_List, user, userOnline);
|
||||
PopulateUserResponseListData(model, data, user, userOnline);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -60,7 +60,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
// Construction.
|
||||
public AjaxResponse_UserList(SaxModel_Admin model) : base(model) { }
|
||||
// User list.
|
||||
public List<UserData_List> Users { get; } = new List<UserData_List>();
|
||||
public List<UserListData> Users { get; } = new List<UserListData>();
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
[HttpPost]
|
||||
@@ -107,7 +107,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
while (resultSet != null && resultSet.HasRows && resultSet.NextRecord())
|
||||
{
|
||||
NamedValue.Map values = resultSet.GetRecordValues();
|
||||
UserData_List userData = new UserData_List()
|
||||
UserListData userData = new UserListData()
|
||||
{
|
||||
Id = values.GetString(colUserAccountId.DataName),
|
||||
EmailAddress = values.GetString(colEmail.DataName),
|
||||
@@ -138,7 +138,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
// Construction.
|
||||
public AjaxResponse_User(SaxModel_Admin model) : base(model) { }
|
||||
// User details.
|
||||
public UserData_Full user { get; } = new UserData_Full();
|
||||
public UserItemData user { get; } = new UserItemData();
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
[HttpPost]
|
||||
@@ -178,7 +178,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
disposableItems.Add(userOnline);
|
||||
|
||||
// Construct response.
|
||||
PopulateUserResponseData(model, responseData.user, user, userOnline);
|
||||
PopulateUserResponseItemData(model, responseData.user, user, userOnline);
|
||||
responseData.Success = true;
|
||||
}
|
||||
return Json(responseData);
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Base.App;
|
||||
using Saxonite.Net.Core.Web.Base.App;
|
||||
using Saxonite.Net.Core.Web.Base.Controllers;
|
||||
using Saxonite.Net.Core.Web.Base.Models;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using Saxonite.Net.Standard.Base.Bus;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Saxonite.Net.Core.Web.Admin.Models
|
||||
{
|
||||
//=======================================================================
|
||||
public class Model_OrganisationAssociations : SaxModel_Admin
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Definitions.
|
||||
public enum AssociationTypeOption
|
||||
{
|
||||
Unknown = 0,
|
||||
AffiliateParent,
|
||||
AffiliatedTo,
|
||||
Partner,
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public Model_OrganisationAssociations(SaxLocaliser localiser) :
|
||||
base(localiser)
|
||||
{
|
||||
AdditionalFiles_JS.Add("js/sax-org-ass.js");
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// List configuration.
|
||||
public class FilterData
|
||||
{
|
||||
public String OrganisationId { get; set; }
|
||||
public String OrganisationName { get; set; }
|
||||
}
|
||||
public FilterData Filter { get; } = new FilterData();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Item association.
|
||||
public String ItemAssociationId { get; set; }
|
||||
/// <summary>Flag to indicate that a new association needs to be created - must be consistent with validity of Item Association Id.</summary>
|
||||
public String NewItem { get; set; }
|
||||
// Organisation.
|
||||
public String OrganisationId { get; set; }
|
||||
// Associated organisation.
|
||||
public String OrganisationIdAssoc { get; set; }
|
||||
public class AssociationData
|
||||
{
|
||||
// Association type option.
|
||||
public String TypeOption { get; set; }
|
||||
public AssociationTypeOption GetAssociationTypeOption() { return EnumUtil.ParseEnum(TypeOption, AssociationTypeOption.Unknown); }
|
||||
// Association properties.
|
||||
public String StatusCode { get; set; }
|
||||
public SaStatus GetStatus() { return SacsSystem.GetStatusForCode(StatusCode); }
|
||||
}
|
||||
public AssociationData Association { get; } = new AssociationData();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities.
|
||||
public bool IsAssociationTypeDirectionReversed(AssociationTypeOption associationTypeOption)
|
||||
{
|
||||
switch (associationTypeOption)
|
||||
{
|
||||
case AssociationTypeOption.AffiliatedTo:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public Sax.AssociationType GetAssociationTypeForOption(AssociationTypeOption associationTypeOption)
|
||||
{
|
||||
switch (associationTypeOption)
|
||||
{
|
||||
case AssociationTypeOption.AffiliateParent:
|
||||
case AssociationTypeOption.AffiliatedTo:
|
||||
return Sax.AssociationType.Affiliate;
|
||||
case AssociationTypeOption.Partner:
|
||||
return Sax.AssociationType.Partner;
|
||||
}
|
||||
return Sax.AssociationType.Unknown;
|
||||
}
|
||||
public bool IsConsistentWith(AssociationTypeOption associationTypeOption, Sax.AssociationType associationType)
|
||||
{
|
||||
switch (associationType)
|
||||
{
|
||||
case Sax.AssociationType.Affiliate:
|
||||
return new List<AssociationTypeOption>() { AssociationTypeOption.AffiliatedTo, AssociationTypeOption.AffiliateParent }.Contains(associationTypeOption);
|
||||
case Sax.AssociationType.Partner:
|
||||
return new List<AssociationTypeOption>() { AssociationTypeOption.Partner }.Contains(associationTypeOption);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validation.
|
||||
//-------------------------------------------------------------------
|
||||
// Organisation association validation.
|
||||
public bool ValidateOrganisationAssociationData(SaxController_Base.AjaxResponse_Data responseData)
|
||||
{
|
||||
|
||||
// Associated Organisation.
|
||||
if (OrganisationIdAssoc != null)
|
||||
{
|
||||
// Mandatory.
|
||||
String controlName = "OrganisationIdAssoc";
|
||||
if (!SysId.IsValid(OrganisationIdAssoc.ToSysId()))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.mandatory.value"]);
|
||||
// Must exist.
|
||||
else if (!AccountMgr.OrganisationExistsById(OrganisationIdAssoc.ToSysId()))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.invalid.value"]);
|
||||
// Not same as primary organisation.
|
||||
else if (OrganisationId != null && OrganisationId.ToSysId().Equals(OrganisationIdAssoc.ToSysId()))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.invalid.value"]);
|
||||
}
|
||||
|
||||
// Association type option.
|
||||
if (Association.TypeOption != null)
|
||||
{
|
||||
// Mandatory.
|
||||
String controlName = "AssociationTypeOption";
|
||||
if (StringUtil.IsEmpty(Association.TypeOption))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.mandatory.value"]);
|
||||
// Valid value.
|
||||
else if ((int)Association.GetAssociationTypeOption() < 1)
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.invalid.value"]);
|
||||
}
|
||||
|
||||
// Association status.
|
||||
if (Association.StatusCode != null)
|
||||
{
|
||||
// Mandatory.
|
||||
String controlName = "AssociationStatus";
|
||||
if (StringUtil.IsEmpty(Association.StatusCode))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.mandatory.value"]);
|
||||
// Valid value.
|
||||
else if (!SaxOrganisation.ValidStatuses.Contains(Association.GetStatus()))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.invalid.value"]);
|
||||
}
|
||||
|
||||
return !responseData.HasControlErrors();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -32,18 +32,19 @@ namespace Saxonite.Net.Core.Web.Admin.Models
|
||||
public class FilterData
|
||||
{
|
||||
public String OrganisationId { get; set; }
|
||||
public String OrganisationName { get; set; }
|
||||
}
|
||||
public FilterData Filter { get; } = new FilterData();
|
||||
public String OrganisationId { get { return Filter.OrganisationId; } set { Filter.OrganisationId = value; } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Organisation.
|
||||
public String OrganisationId { get; set; }
|
||||
// User Organisation (member) properties.
|
||||
public String UserOrganisationId { get; set; }
|
||||
[EmailAddress]
|
||||
public String MemberUserEmailAddress{ get; set; }
|
||||
public String MemberUserAccountId { get; set; }
|
||||
public String MemberOrganisationId { get; set; }
|
||||
public String MemberOrganisationName { get; set; }
|
||||
public String MemberRoleCodeDelim = ",";
|
||||
public List<String> MemberRoleCodes { get; set; }
|
||||
public List<String> GetMemberRoleCodes()
|
||||
|
||||
@@ -123,12 +123,39 @@
|
||||
<data name="caption.image.upload" xml:space="preserve">
|
||||
<value>Image Upload</value>
|
||||
</data>
|
||||
<data name="caption.member.create" xml:space="preserve">
|
||||
<value>Add Member</value>
|
||||
</data>
|
||||
<data name="caption.member.remove" xml:space="preserve">
|
||||
<value>Remove Member</value>
|
||||
</data>
|
||||
<data name="caption.member.update" xml:space="preserve">
|
||||
<value>Update Member</value>
|
||||
</data>
|
||||
<data name="caption.organisation" xml:space="preserve">
|
||||
<value>Organisation</value>
|
||||
</data>
|
||||
<data name="caption.organisation.address" xml:space="preserve">
|
||||
<value>Organisation Address</value>
|
||||
</data>
|
||||
<data name="caption.organisation.association" xml:space="preserve">
|
||||
<value>Organisation Association</value>
|
||||
</data>
|
||||
<data name="caption.organisation.associations" xml:space="preserve">
|
||||
<value>Organisation Associations</value>
|
||||
</data>
|
||||
<data name="caption.organisation.images" xml:space="preserve">
|
||||
<value>Organisation Images</value>
|
||||
</data>
|
||||
<data name="caption.organisation.member" xml:space="preserve">
|
||||
<value>Organisation Member</value>
|
||||
</data>
|
||||
<data name="caption.organisation.members" xml:space="preserve">
|
||||
<value>Organisation Members</value>
|
||||
</data>
|
||||
<data name="caption.organisations" xml:space="preserve">
|
||||
<value>Organisations</value>
|
||||
</data>
|
||||
<data name="company.name" xml:space="preserve">
|
||||
<value>Sportierre</value>
|
||||
</data>
|
||||
@@ -192,6 +219,15 @@
|
||||
<data name="label.assigned" xml:space="preserve">
|
||||
<value>Assigned</value>
|
||||
</data>
|
||||
<data name="label.associated.organisation" xml:space="preserve">
|
||||
<value>Associated organisation</value>
|
||||
</data>
|
||||
<data name="label.association" xml:space="preserve">
|
||||
<value>Association</value>
|
||||
</data>
|
||||
<data name="label.associations" xml:space="preserve">
|
||||
<value>Associations</value>
|
||||
</data>
|
||||
<data name="label.available" xml:space="preserve">
|
||||
<value>Available</value>
|
||||
</data>
|
||||
@@ -567,24 +603,6 @@
|
||||
<data name="organisation.activate.organisation.header" xml:space="preserve">
|
||||
<value>Organisation to activate:</value>
|
||||
</data>
|
||||
<data name="organisation.caption.member" xml:space="preserve">
|
||||
<value>Organisation Member</value>
|
||||
</data>
|
||||
<data name="organisation.caption.member.create" xml:space="preserve">
|
||||
<value>Add Member</value>
|
||||
</data>
|
||||
<data name="organisation.caption.member.remove" xml:space="preserve">
|
||||
<value>Remove Member</value>
|
||||
</data>
|
||||
<data name="organisation.caption.member.update" xml:space="preserve">
|
||||
<value>Update Member</value>
|
||||
</data>
|
||||
<data name="organisation.caption.members" xml:space="preserve">
|
||||
<value>Organisation Members</value>
|
||||
</data>
|
||||
<data name="organisation.caption.organisation" xml:space="preserve">
|
||||
<value>Organisation</value>
|
||||
</data>
|
||||
<data name="organisation.caption.organisation.activate" xml:space="preserve">
|
||||
<value>Activate Organisation</value>
|
||||
</data>
|
||||
@@ -594,9 +612,6 @@
|
||||
<data name="organisation.caption.organisation.update" xml:space="preserve">
|
||||
<value>Update Organisation</value>
|
||||
</data>
|
||||
<data name="organisation.caption.organisations" xml:space="preserve">
|
||||
<value>Organisations</value>
|
||||
</data>
|
||||
<data name="organisation.caption.select.member.roles" xml:space="preserve">
|
||||
<value>Select Member Roles</value>
|
||||
</data>
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
@model Model_OrganisationAssociations
|
||||
@inject SaxLocaliser Localiser
|
||||
@{
|
||||
/* Organisation Associations - Index */
|
||||
ViewData["Title"] = "Organisation Associations";
|
||||
}
|
||||
|
||||
<div class="sax-panel OrganisationAssociations">
|
||||
|
||||
<script type="text/javascript">
|
||||
sax.lbl.refresh = '@(Localiser.GetJavascriptText("label.refresh"))';
|
||||
sax.lbl.add = '@(Localiser.GetJavascriptText("label.add"))';
|
||||
sax.lbl.create = '@(Localiser.GetJavascriptText("label.create"))';
|
||||
sax.lbl.edit = '@(Localiser.GetJavascriptText("label.edit"))';
|
||||
sax.lbl.remove = '@(Localiser.GetJavascriptText("label.remove"))';
|
||||
</script>
|
||||
|
||||
@* Filter Panel *@
|
||||
@using (@Html.BeginForm(FormMethod.Post, new { @id = "frmAssociationFilter", @class = "sax-form", @onSubmit = "return false;" }))
|
||||
{
|
||||
<div class="sax-panel-filter">
|
||||
|
||||
@* Header - Page caption, paging controls, actions. *@
|
||||
<div class="sax-header row">
|
||||
<div class="col"><div class="sax-caption">@Localiser["caption.organisation.associations"]</div></div>
|
||||
<div class="fixed row">
|
||||
<div>
|
||||
<partial name="~/Views/Common/ResultsPaging.cshtml" />
|
||||
</div>
|
||||
<div class="fixed">
|
||||
@* Burger menu *@
|
||||
<ul class="nav navbar-nav navbar-dark navbar-right sax-burger">
|
||||
<li class="dropdown-toggle caret-off">
|
||||
<a href="#" class="dropdown" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="navbar-toggler-icon"></span></a>
|
||||
<ul class="dropdown-menu dropdown-menu-right sax-dropdown-menu">@* Menu items will be inserted here. *@</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sax-content">
|
||||
@* Organisation Association filter - Organisation etc. *@
|
||||
<div class="row">
|
||||
<div class="col-sm-3 sax-label text-left text-sm-right">@Localiser["caption.organisation"]</div>
|
||||
<div class="col-sm-9">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
@Html.HiddenFor(model => model.Filter.OrganisationId, new { @id = "ifFilterOrganisationId", @class= "OrganisationId" })
|
||||
<input type="text" id="ifFilterOrganisation" class="sax-input OrganisationName" readonly="readonly" value="@(Model.Filter.OrganisationName)" />
|
||||
</div>
|
||||
<div class="fixed"><button id="pbFilterOrganisationSelect" class="sax-button">@Localiser["label.select"]</button></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@* Filter element templates *@
|
||||
<div class="sax-panel-item-template">
|
||||
@* Burger dropdown item template - ul is ignored *@
|
||||
<ul class="sax-dropdown-menu AssociationFilter">
|
||||
<li class="sax-dropdown-item sax-action"><div class="sax-label">XXX</div></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@* Results Panel *@
|
||||
<div class="sax-panel-results">
|
||||
<div class="sax-panel-messages"></div>
|
||||
<div class="sax-panel-item-list"></div>
|
||||
|
||||
@* element 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>
|
||||
<div class="fixed sax-actions">
|
||||
@* Burger menu *@
|
||||
<ul class="nav navbar-nav navbar-light navbar-right sax-burger">
|
||||
<li class="dropdown-toggle caret-off">
|
||||
<a href="#" class="dropdown" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="navbar-toggler-icon"></span></a>
|
||||
<ul class="dropdown-menu dropdown-menu-right sax-dropdown-menu">@* Menu items will be inserted here. *@</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sax-content">
|
||||
<div class="row">
|
||||
<div class="col-sm-6"></div>
|
||||
<div class="col-sm-6 right"></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-4"></div>
|
||||
<div class="col-sm-4"><div class=""></div></div>
|
||||
@* Association status *@
|
||||
<div class="col-sm-4 sax-note right"><span class="StatusDesc"></span></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@* Burger dropdown item template - ul is ignored *@
|
||||
<ul class="sax-dropdown-menu Association">
|
||||
<li class="sax-dropdown-item sax-action"><div class="sax-label">...</div></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@* Organisation Association components *@
|
||||
<partial name="Panel-Organisation-Association.cshtml" />
|
||||
@* Select Organisation components *@
|
||||
<partial name="~/Views/Common/SelectOrganisation.cshtml" />
|
||||
@@ -12,6 +12,7 @@
|
||||
sax.lbl.create = '@(Localiser.GetJavascriptText("label.create"))';
|
||||
sax.lbl.edit = '@(Localiser.GetJavascriptText("label.edit"))';
|
||||
sax.lbl.location = '@(Localiser.GetJavascriptText("label.location"))';
|
||||
sax.lbl.associations = '@(Localiser.GetJavascriptText("label.associations"))';
|
||||
sax.lbl.images = '@(Localiser.GetJavascriptText("label.images"))';
|
||||
sax.lbl.activate = '@(Localiser.GetJavascriptText("label.activate"))';
|
||||
</script>
|
||||
@@ -29,7 +30,7 @@
|
||||
@* Header - Page caption, paging controls, actions. *@
|
||||
<div class="sax-header">
|
||||
<div class="row">
|
||||
<div class="col"><div class="sax-caption">@Localiser["organisation.caption.organisations"]</div></div>
|
||||
<div class="col"><div class="sax-caption">@Localiser["caption.organisations"]</div></div>
|
||||
<div class="fixed row">
|
||||
<div class="col">
|
||||
<partial name="~/Views/Common/ResultsPaging.cshtml" />
|
||||
@@ -174,14 +175,14 @@
|
||||
{
|
||||
@Html.HiddenFor(model => model.OrganisationId, new { @class = "OrganisationId" })
|
||||
}
|
||||
@* Organisation dialog and form. *@
|
||||
<partial name="Panel-OrganisationDialog.cshtml" />
|
||||
@* Organisation Activation dialog and form. *@
|
||||
<partial name="Panel-ActivationDialog.cshtml" />
|
||||
@* Organisation Address dialog, form and script. *@
|
||||
<partial name="Panel-OrganisationAddressDialog.cshtml" />
|
||||
@* Organisation Images dialog, form and script. *@
|
||||
<partial name="Panel-OrganisationImagesDialog.cshtml" />
|
||||
@* Select Item dialog and script. *@
|
||||
@* Organisation dialog and form *@
|
||||
<partial name="Panel-Organisation-Dialog.cshtml" />
|
||||
@* Organisation Activation dialog and form *@
|
||||
<partial name="Panel-Organisation-Activation.cshtml" />
|
||||
@* Organisation Address dialog, form and script *@
|
||||
<partial name="Panel-Organisation-Address.cshtml" />
|
||||
@* Organisation Images dialog, form and script *@
|
||||
<partial name="Panel-Organisation-Images.cshtml" />
|
||||
@* Select Item dialog and script *@
|
||||
<partial name="~/Views/Common/SelectItem.cshtml" />
|
||||
</div>
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
@* Header - Page caption, paging controls, actions. *@
|
||||
<div class="sax-header row">
|
||||
<div class="col"><div class="sax-caption">@Localiser["organisation.caption.members"]</div></div>
|
||||
<div class="col"><div class="sax-caption">@Localiser["caption.organisation.members"]</div></div>
|
||||
<div class="fixed row">
|
||||
<div>
|
||||
<partial name="~/Views/Common/ResultsPaging.cshtml" />
|
||||
@@ -41,12 +41,12 @@
|
||||
<div class="sax-content">
|
||||
@* Organisation Member filter - Organisation etc. *@
|
||||
<div class="row">
|
||||
<div class="col-sm-3 sax-label text-left text-sm-right">@Localiser["organisation.caption.organisation"]</div>
|
||||
<div class="col-sm-3 sax-label text-left text-sm-right">@Localiser["caption.organisation"]</div>
|
||||
<div class="col-sm-9">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
@Html.HiddenFor(model => model.Filter.OrganisationId, new { @id = "ifFilterOrganisationId" })
|
||||
<input type="text" id="ifFilterOrganisation" class="sax-input" readonly="readonly" value="@(Model.MemberOrganisationName)" />
|
||||
<input type="text" id="ifFilterOrganisation" class="sax-input" readonly="readonly" value="@(Model.Filter.OrganisationName)" />
|
||||
</div>
|
||||
<div class="fixed"><button id="pbFilterOrganisationSelect" class="sax-button">@Localiser["label.select"]</button></div>
|
||||
</div>
|
||||
@@ -112,6 +112,6 @@
|
||||
|
||||
</div>
|
||||
|
||||
<partial name="Panel-MemberDialog.cshtml" />
|
||||
<partial name="Panel-Organisation-Member.cshtml" />
|
||||
|
||||
<partial name="~/Views/Common/SelectOrganisation.cshtml" />
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
@model Model_OrganisationAssociations
|
||||
@inject SaxLocaliser Localiser
|
||||
@* Organisation - Associations components *@
|
||||
|
||||
@* Organisation Association Id form. *@
|
||||
@using (@Html.BeginForm(FormMethod.Post, new { @id = "frmAssociationId" }))
|
||||
{
|
||||
@Html.HiddenFor(model => model.OrganisationId, new { @id = "", @class = "OrganisationId" })
|
||||
@Html.HiddenFor(model => model.ItemAssociationId, new { @id = "", @class = "ItemAssociationId" })
|
||||
}
|
||||
|
||||
@* Organisation Association dialog. *@
|
||||
<div id="dlgOrganisationAssociation" class="sax-dialog" title="@Localiser["caption.organisation.association"]">
|
||||
|
||||
<div class="spacer"></div>
|
||||
@using (@Html.BeginForm(FormMethod.Post, new { @id = "frmOrganisationAssociation", @class = "sax-form", @onSubmit = "return false;" }))
|
||||
{
|
||||
@Html.HiddenFor(model => model.ItemAssociationId, new { @id = "", @class = "ItemAssociationId" })
|
||||
@Html.HiddenFor(model => model.NewItem, new { @id = "", @class = "NewItem" })
|
||||
@Html.HiddenFor(model => model.OrganisationId, new { @id = "", @class = "OrganisationId" })
|
||||
|
||||
@* Organisation name *@
|
||||
<div class="sax-form-control OrganisationName">
|
||||
<div class="row">
|
||||
<div class="col-sm-3">
|
||||
<div class="sax-label">
|
||||
<label for="ifOrganisationName"><span>@Localiser["label.organisation"]</span></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm">
|
||||
<div class="sax-control">
|
||||
<input type="text" id="ifOrganisationName" class="OrganisationName sax-input" maxlength="@Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.Organisation_Name)" disabled="disabled" />
|
||||
</div>
|
||||
<div class="sax-message"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@* Association Type Option *@
|
||||
<div class="sax-form-control AssociationTypeOption">
|
||||
<div class="row">
|
||||
<div class="col-sm-3">
|
||||
<div class="sax-label">
|
||||
<label for="cbAssociationTypeOption"><span>@Localiser["label.association"]</span></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm">
|
||||
<div class="sax-control">
|
||||
<select type="text" id="cbAssociationTypeOption" name="Association.TypeOption" class="AssociationTypeOption sax-select"></select>
|
||||
</div>
|
||||
<div class="sax-message"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@* Associated Organisation *@
|
||||
<div class="sax-form-control OrganisationIdAssoc">
|
||||
<div class="row">
|
||||
<div class="col-sm-3">
|
||||
<div class="sax-label">
|
||||
<label for="ifOrganisationNameAssoc"><span>@Localiser["label.associated.organisation"]</span></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm">
|
||||
<div class="sax-control row">
|
||||
<div class="col">
|
||||
<input type="hidden" name="OrganisationIdAssoc" class="OrganisationIdAssoc" />
|
||||
<input type="text" id="ifOrganisationNameAssoc" class="OrganisationNameAssoc sax-input" disabled="disabled" />
|
||||
</div>
|
||||
<div class="fixed pl4">
|
||||
<button type="button" id="pbAssocOrganisationSelect" class="sax-button">@Localiser["label.select"]</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sax-message"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
}
|
||||
<div class="spacer"></div>
|
||||
</div>
|
||||
+3
-3
@@ -6,9 +6,9 @@
|
||||
|
||||
<script type="text/javascript">
|
||||
sax.dlg.title.selectOrganisation = '@Localiser.GetJavascriptText("organisation.caption.select.organisation")';
|
||||
sax.dlg.title.createMember = '@Localiser.GetJavascriptText("organisation.caption.member.create")';
|
||||
sax.dlg.title.updateMember = '@Localiser.GetJavascriptText("organisation.caption.member.update")';
|
||||
sax.dlg.title.removeMember = '@Localiser.GetJavascriptText("organisation.caption.member.remove")';
|
||||
sax.dlg.title.createMember = '@Localiser.GetJavascriptText("caption.member.create")';
|
||||
sax.dlg.title.updateMember = '@Localiser.GetJavascriptText("caption.member.update")';
|
||||
sax.dlg.title.removeMember = '@Localiser.GetJavascriptText("caption.member.remove")';
|
||||
sax.dlg.title.selectMemberRoles = '@Localiser.GetJavascriptText("organisation.caption.select.member.roles")';
|
||||
sax.data.userRoleCodeDelim = '@Model.MemberRoleCodeDelim';
|
||||
</script>
|
||||
@@ -134,7 +134,7 @@
|
||||
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
|
||||
<div class="dropdown-item text-dark sax-action" onclick="sax.goToPage('UsersOnline');">@Localiser["label.users.online"]</div>
|
||||
<div class="dropdown-item text-dark sax-action" onclick="sax.goToPage('User');">@Localiser["user.caption.users"]</div>
|
||||
<div class="dropdown-item text-dark sax-action" onclick="sax.goToPage('Organisation');">@Localiser["organisation.caption.organisations"]</div>
|
||||
<div class="dropdown-item text-dark sax-action" onclick="sax.goToPage('Organisation');">@Localiser["caption.organisations"]</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="nav-item dropdown">
|
||||
|
||||
@@ -182,6 +182,11 @@
|
||||
background-image: url('../img/action/process24.png');
|
||||
}
|
||||
|
||||
.sax-header ul.nav.sax-burger ul.sax-dropdown-menu li.sax-action.sax-dropdown-item.sax-network
|
||||
{
|
||||
background-image: url('../img/action/network-24.png');
|
||||
}
|
||||
|
||||
.sax-header ul.nav.sax-burger ul.sax-dropdown-menu li.sax-action.sax-dropdown-item.sax-close
|
||||
{
|
||||
background-image: url('../img/action/prev24.png');
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 362 B |
Binary file not shown.
|
After Width: | Height: | Size: 525 B |
Binary file not shown.
|
After Width: | Height: | Size: 743 B |
@@ -97,11 +97,17 @@
|
||||
return index % 2 == 1 ? "other" : "";
|
||||
});
|
||||
}
|
||||
sax.populateSelectCodeDesc = function ($sel, values)
|
||||
sax.populateSelect = function ($sel, values, code, desc)
|
||||
{
|
||||
code = code || 'code';
|
||||
desc = desc || 'desc';
|
||||
$sel = $($sel).empty();
|
||||
for (const value of values)
|
||||
$sel.append($('<option>').prop('value', value.code).text(value.desc));
|
||||
$sel.append($('<option>').prop('value', value[code]).text(value[desc]));
|
||||
}
|
||||
sax.populateSelectCodeDesc = function ($sel, values)
|
||||
{
|
||||
sax.populateSelect($sel, values);
|
||||
}
|
||||
sax.checkTextAreaMaxLength = function (ctrl, len)
|
||||
{
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
let addr = item.address || {};
|
||||
let frm = $frm.orgAddr;
|
||||
$('input.OrganisationId', frm).val(item.id);
|
||||
$('.OrganisationName', frm).val(item.name);
|
||||
$('input.OrganisationName', frm).val(item.name);
|
||||
$('input.AddressId', frm).val(addr.id);
|
||||
$('input.AddressLine1', frm).val(addr.line1);
|
||||
$('input.AddressLine2', frm).val(addr.line2);
|
||||
|
||||
@@ -0,0 +1,217 @@
|
||||
/*
|
||||
* Admin - Organisation Association scripts.
|
||||
*/
|
||||
|
||||
(function (win, doc, undef)
|
||||
{
|
||||
"use strict";
|
||||
let oa = sax.mdl.organisationAssociations = { data: {}, ajax: {} };
|
||||
let $pnl = oa.$pnl = {}, $frm = oa.$frm = {}, $dlg = oa.$dlg = {};
|
||||
let mdlOrg = function () { return sax.mdl.organisations; }
|
||||
|
||||
//--------------------------------------------------------------
|
||||
oa.refreshResults = function (delay)
|
||||
{
|
||||
if (!oa.awaitingRefreshResponse)
|
||||
{
|
||||
var $items = $('.sax-panel-item-list', $pnl.results).fadeOut(200).empty();
|
||||
var $msgs = $('.sax-panel-messages', $pnl.results).hide().empty().append($('<div class="sax-message">' + sax.msg.dataQuerying + '</div>')).fadeIn(200);
|
||||
}
|
||||
oa.ajax.refreshResults = oa.ajax.refreshResults || { url: sax.url.base + 'Organisation/Ajax/GetAssociationList', formId: 'frmAssociationFilter', callbackFn: oa.doRefreshResults };
|
||||
sax.doAjaxRequest(oa.ajax.refreshResults, delay || 50);
|
||||
oa.awaitingRefreshResponse = true;
|
||||
}
|
||||
oa.doRefreshResults = function (response)
|
||||
{
|
||||
sax.debug('doRefreshResults', response);
|
||||
delete oa.awaitingRefreshResponse;
|
||||
sax.refreshControlValues(response.controlValues);
|
||||
var $msgs = $('.sax-panel-messages', $pnl.results).hide().empty();
|
||||
var $items = $('.sax-panel-item-list', $pnl.results).hide().empty();
|
||||
sax.refreshPaging(response, '#frmAssociationFilter', oa.refreshResults);
|
||||
if (!response.success) return;
|
||||
// Reference data - association types.
|
||||
if (response.associationTypes && response.associationTypes.length)
|
||||
oa.data.associationTypes = response.associationTypes;
|
||||
// Reference data - Statuses.
|
||||
if (response.defaultStatusCode) oa.data.defaultStatusCode = response.defaultStatusCode;
|
||||
if (response.statuses)
|
||||
sax.populateSelectCodeDesc('#cbAssociationStatus', response.statuses);
|
||||
// Menu.
|
||||
var $bgr = $('.sax-burger', $pnl.filter).hide();
|
||||
var $mnu = $('ul.sax-dropdown-menu', $bgr).empty();
|
||||
$mnu.append(oa.getFilterMenuOption(sax.lbl.refresh, function () { oa.refreshResults(); }, 'sax-refresh'));
|
||||
$mnu.append(oa.getFilterMenuOption(sax.lbl.add, function () { oa.createItem(); }, 'sax-add'));
|
||||
$bgr.toggle(!!$('.sax-dropdown-item', $mnu).length);
|
||||
// Items.
|
||||
var items = response.associations;
|
||||
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.fadeIn(50);
|
||||
}
|
||||
sax.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());
|
||||
$('.sax-caption .sax-action').toggleClass('sax-action', !item.deleted);
|
||||
let $mnu = $('ul.sax-dropdown-menu', $item).empty();
|
||||
if (!item.deleted)
|
||||
{
|
||||
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'));
|
||||
}
|
||||
$('.sax-burger', $item).toggle(!!$('.sax-dropdown-item', $mnu).length);
|
||||
$('.sax-panel-messages', $pnl.results).hide().empty();
|
||||
return $item;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
oa.getFilterDropdownTemplate = function ()
|
||||
{
|
||||
return $('.sax-panel-item-template .sax-dropdown-menu.AssociationFilter li.sax-dropdown-item', $pnl.filter).clone();
|
||||
}
|
||||
oa.getItemTemplate = function ()
|
||||
{
|
||||
return $('.sax-panel-item-template .sax-panel-item.Association', $pnl.results).clone();
|
||||
}
|
||||
oa.getItemDropdownTemplate = function ()
|
||||
{
|
||||
return $('.sax-panel-item-template .sax-dropdown-menu.Association li.sax-dropdown-item', $pnl.results).clone();
|
||||
}
|
||||
oa.getFilterMenuOption = function (lbl, fn, cls)
|
||||
{
|
||||
return oa.getMenuOption(oa.getFilterDropdownTemplate(), lbl, fn, cls);
|
||||
}
|
||||
oa.getItemMenuOption = function (lbl, fn, cls)
|
||||
{
|
||||
return oa.getMenuOption(oa.getItemDropdownTemplate(), lbl, fn, cls);
|
||||
}
|
||||
oa.getMenuOption = function ($opt, lbl, fn, cls)
|
||||
{
|
||||
return $opt.find('div.sax-label').text(lbl).end().on('click', fn).addClass(cls);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
oa.selectFilterOrganisation = function ()
|
||||
{
|
||||
sax.selectOrganisation.fn.openDialog({ caption: sax.dlg.title.selectOrganisation, fnCallback: oa.onFilterOrganisationSelected });
|
||||
}
|
||||
oa.onFilterOrganisationSelected = function (id, name)
|
||||
{
|
||||
$('#ifFilterOrganisationId', $frm.filter).val(id);
|
||||
$('#ifFilterOrganisation', $frm.filter).val(name);
|
||||
oa.refreshResults(50);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
oa.selectAssocOrganisation = function ()
|
||||
{
|
||||
sax.selectOrganisation.fn.openDialog({ caption: sax.dlg.title.selectOrganisation, fnCallback: oa.onAssocOrganisationSelected });
|
||||
}
|
||||
oa.onAssocOrganisationSelected = function (id, name)
|
||||
{
|
||||
$('.OrganisationIdAssoc', $frm.assoc).val(id);
|
||||
$('.OrganisationNameAssoc', $frm.assoc).val(name);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
oa.createItem = function ()
|
||||
{
|
||||
oa.clearItem();
|
||||
let frm = $frm.assoc;
|
||||
$('.NewItem', frm).val(1);
|
||||
$('.OrganisationId', frm).val($('.OrganisationId', $frm.filter).val());
|
||||
$('.OrganisationName', frm).val($('.OrganisationName', $frm.filter).val());
|
||||
sax.openAssocDialog();
|
||||
}
|
||||
oa.clearItem = function ()
|
||||
{
|
||||
let frm = $frm.assoc;
|
||||
$('.ItemAssociationId,.NewItem,.OrganisationId,.OrganisationIdAssoc,input[type="text"],textarea,select', frm).val('');
|
||||
sax.populateSelect($('.sax-select.AssociationTypeOption', $frm.assoc), oa.data.associationTypes, 'type', 'label');
|
||||
sax.clearControlErrors(frm);
|
||||
}
|
||||
sax.openAssocDialog = function ()
|
||||
{
|
||||
sax.openDialog($dlg.assoc, 640, 480);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
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 };
|
||||
sax.doAjaxRequest(oa.ajax.getItemAssoc, 50);
|
||||
}
|
||||
oa.onUpdateItem = function (response)
|
||||
{
|
||||
sax.debug('onUpdateItemAssociation', response);
|
||||
if (!response.success) return;
|
||||
oa.clearItem();
|
||||
// Association.
|
||||
let item = response.organisation;
|
||||
let assoc = item.association || {};
|
||||
let frm = $frm.assoc;
|
||||
|
||||
$('input.ItemAssociationId', frm).val(item.id);
|
||||
$('input.OrganisationId', frm).val(item.organisationId);
|
||||
$('.OrganisationName', frm).val(item.name);
|
||||
|
||||
sax.openAssocDialog();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
oa.storeItem = function ()
|
||||
{
|
||||
oa.ajax.storeItemAssoc = oa.ajax.storeItemAssoc || { url: sax.url.base + 'Organisation/Ajax/StoreAssociation', formId: 'frmOrganisationAssociation', callbackFn: oa.onStoreItem };
|
||||
sax.doAjaxRequest(oa.ajax.storeItemAssoc, 50);
|
||||
}
|
||||
oa.onStoreItem = function (response)
|
||||
{
|
||||
//sax.debug('onStoreItemAssociation', response);
|
||||
sax.refreshControlValues(response.controlValues, $frm.assoc);
|
||||
if (!response.success) return;
|
||||
$dlg.assoc.dialog('close');
|
||||
mdlOrg().refreshItem(response.organisation);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
$(function ()
|
||||
{
|
||||
$pnl.assocs = $('.sax-panel.OrganisationAssociations');
|
||||
$pnl.filter = $('.sax-panel-filter', $pnl.assocs);
|
||||
$pnl.results = $('.sax-panel-results', $pnl.assocs);
|
||||
|
||||
$frm.filter = $('#frmAssociationFilter', $pnl.assocs);
|
||||
$frm.filter.on('dblclick', '#ifFilterOrganisation', oa.selectFilterOrganisation).on('click', '#pbFilterOrganisationSelect', oa.selectFilterOrganisation);
|
||||
|
||||
$frm.assocId = $('#frmAssociationId');
|
||||
|
||||
var opt = sax.dlgOpts();
|
||||
opt.buttons[sax.dlg.btn.ok] = function () { oa.storeItem(); };
|
||||
opt.buttons[sax.dlg.btn.cancel] = function () { $(this).dialog('close'); };
|
||||
$dlg.assoc = $('#dlgOrganisationAssociation').dialog(opt);
|
||||
|
||||
$frm.assoc = $('#frmOrganisationAssociation', $dlg.assoc);
|
||||
$frm.assoc.on('input', '.sax-input', function () { sax.clearControlError(this); });
|
||||
$frm.assoc.on('change', '.sax-select', function () { sax.clearControlError(this); });
|
||||
$frm.assoc.on('dblclick', '.OrganisationAssoc', oa.selectAssocOrganisation).on('click', '#pbAssocOrganisationSelect', oa.selectAssocOrganisation);
|
||||
|
||||
setTimeout(oa.refreshResults, 250);
|
||||
});
|
||||
|
||||
//--------------------------------------------------------------
|
||||
}(window, window.document));
|
||||
|
||||
/* The End */
|
||||
@@ -256,7 +256,7 @@
|
||||
$pnl.filter = $('.sax-panel-filter', $pnl.mbrs);
|
||||
$pnl.results = $('.sax-panel-results', $pnl.mbrs);
|
||||
|
||||
$frm.filter = $('#frmOrganisationFilter');
|
||||
$frm.filter = $('#frmMemberFilter');
|
||||
$frm.filter.on('dblclick', '#ifFilterOrganisation', sax.selectFilterOrganisation);
|
||||
$frm.filter.on('click', '#pbFilterOrganisationSelect', sax.selectFilterOrganisation);
|
||||
|
||||
@@ -276,6 +276,7 @@
|
||||
setTimeout(om.refreshResults, 250);
|
||||
});
|
||||
|
||||
//--------------------------------------------------------------
|
||||
}(window, window.document));
|
||||
|
||||
/* The End */
|
||||
@@ -74,6 +74,7 @@
|
||||
$mnu.append(op.getItemMenuOption(sax.lbl.activate, function () { op.activateItem(item) }, 'sax-unlock'));
|
||||
$mnu.append(op.getItemMenuOption(sax.lbl.images, function () { op.updateItemImages(item, $item) }, 'sax-image'));
|
||||
$mnu.append(op.getItemMenuOption(sax.lbl.location, function () { op.updateItemAddress(item, $item) }, 'sax-location'));
|
||||
$mnu.append(op.getItemMenuOption(sax.lbl.associations, function () { op.viewItemAssociations(item, $item) }, 'sax-network'));
|
||||
}
|
||||
$('.sax-burger', $item).toggle(!!$('.sax-dropdown-item', $mnu).length);
|
||||
$('.sax-panel-messages', $pnl.results).hide().empty();
|
||||
@@ -106,16 +107,6 @@
|
||||
return $opt.find('div.sax-label').text(lbl).end().on('click', fn).addClass(cls);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
op.onClickMemberCount = function (id)
|
||||
{
|
||||
if (!(id * 1)) return;
|
||||
sax.doPleaseWait();
|
||||
let frm = $('#frmOrganisationId');
|
||||
$('.OrganisationId', frm).val(id);
|
||||
frm.prop('action', sax.url.base + 'Organisation/Members').submit();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
op.getFilterSport = function ()
|
||||
{
|
||||
@@ -443,6 +434,14 @@
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
op.onClickMemberCount = function (id)
|
||||
{
|
||||
if (!(id * 1)) return;
|
||||
sax.doPleaseWait();
|
||||
$('.OrganisationId', $frm.orgId).val(id);
|
||||
$frm.orgId.prop('action', sax.url.base + 'Organisation/Members').submit();
|
||||
}
|
||||
|
||||
op.updateItemImages = function (item, $item)
|
||||
{
|
||||
sax.mdl.organisationImages.updateItemImages(item, $item)
|
||||
@@ -453,6 +452,14 @@
|
||||
sax.mdl.organisationAddress.updateItemAddress(item, $item);
|
||||
}
|
||||
|
||||
op.viewItemAssociations = function (item, $item)
|
||||
{
|
||||
if (!(item.id * 1)) return;
|
||||
sax.doPleaseWait();
|
||||
$('.OrganisationId', $frm.orgId).val(item.id);
|
||||
$frm.orgId.prop('action', sax.url.base + 'Organisation/Associations').submit();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
$(function ()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user