This commit is contained in:
2021-05-13 19:36:30 +01:00
parent ae64e14da4
commit edd6e39c35
63 changed files with 2694 additions and 1680 deletions
@@ -30,6 +30,13 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
public String CategoryCode { get; set; }
public String CategoryDesc { get; set; }
public long MemberCount { get; set; }
// Region.
public long RegionId { get; set; }
public String RegionName { get; set; }
// Sport.
public long SportId { get; set; }
public String SportName { get; set; }
// Common properties.
public String StatusCode { get; set; }
public String StatusDesc { get; set; }
}
@@ -45,6 +52,21 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
data.CategoryCode = OrganisationCategories.GetCodeForType(organisation.OrganisationCategory);
data.CategoryDesc = OrganisationCategories.GetDescForType(organisation.OrganisationCategory);
data.MemberCount = AccountMgr.GetOrganisationMemberCount(organisation.Id);
// Region.
data.RegionId = SysId.ToLong(organisation.RegionIdPrimary);
using (SaxRegion region = ReferenceMgr.GetRegionById(organisation.RegionIdPrimary))
{
if (region != null)
data.RegionName = region.Name;
}
// Sport.
data.SportId = SysId.ToLong(organisation.SportIdPrimary);
using (SaxSport region = ReferenceMgr.GetSportById(organisation.SportIdPrimary))
{
if (region != null)
data.SportName = region.Name;
}
// Common properties.
data.StatusCode = organisation.StatusCode;
data.StatusDesc = organisation.StatusDesc;
}
@@ -59,6 +81,9 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
public class AjaxResponse_OrganisationList : AjaxResponse_Data
{
public List<OrganisationData_List> Organisations { get; } = new List<OrganisationData_List>();
// Reference data.
public List<CodeDesc> Statuses { get; } = new List<CodeDesc>();
public String DefaultStatusCode { get; set; }
}
//-------------------------------------------------------------------
[HttpPost]
@@ -73,6 +98,11 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
if (!ValidUserSession)
return GetAjaxResult_InvalidSession(responseData);
// Reference data - statuses.
foreach (SaStatus status in SaxOrganisation.ValidStatuses.FindAll(item => item != SaStatus.Deleted))
responseData.Statuses.Add(SacsSystem.GetStatusCode(status), Localiser.GetStatusCaption(status));
responseData.DefaultStatusCode = SacsSystem.GetStatusCode(SaxOrganisation.DefaultStatus);
// Item filter.
SaxOrganisation.Params prmOrganisation = new SaxOrganisation.Params();
prmOrganisation.OrganisationFilter = model.Filter.Organisation;
@@ -89,6 +119,10 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
ColumnDfn colPhoneAlt = AccountMgr.GetOrganisationColumnDfn(SaxOrganisation.Column.PhoneAlt);
ColumnDfn colUserCount = AccountMgr.GetOrganisationColumnDfn(SaxOrganisation.Column.User_Count);
ColumnDfn colMemberCount = AccountMgr.GetOrganisationColumnDfn(SaxOrganisation.Column.Member_Count);
ColumnDfn colRegionId = AccountMgr.GetOrganisationColumnDfn(SaxOrganisation.Column.RegionId);
ColumnDfn colRegionName = AccountMgr.GetOrganisationColumnDfn(SaxOrganisation.Column.Region_Name);
ColumnDfn colSportId = AccountMgr.GetOrganisationColumnDfn(SaxOrganisation.Column.SportId);
ColumnDfn colSportName = AccountMgr.GetOrganisationColumnDfn(SaxOrganisation.Column.Sport_Name);
ColumnDfn colStatus = AccountMgr.GetOrganisationColumnDfn(SaxOrganisation.Column.Status);
List<ColumnDfn> columns = new List<ColumnDfn>()
{
@@ -98,8 +132,9 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
colOrganisationCategory,
colPhoneMain,
colPhoneAlt,
colUserCount,
colMemberCount,
colUserCount, colMemberCount,
colRegionId, colRegionName,
colSportId, colSportName,
colStatus
};
@@ -120,6 +155,10 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
CategoryCode = values.GetString(colOrganisationCategory.DataName),
CategoryDesc = OrganisationCategories.GetDescForCode(values.GetString(colOrganisationCategory.DataName)),
MemberCount = StringUtil.ToLong(values.GetString(colMemberCount.DataName)),
RegionId = values.GetLong(colRegionId.DataName),
RegionName = values.GetString(colRegionName.DataName),
SportId = values.GetLong(colSportId.DataName),
SportName = values.GetString(colSportName.DataName),
StatusCode = values.GetString(colStatus.DataName),
StatusDesc = SacsSystem.GetStatusDescForCode(values.GetString(colStatus.DataName))
};
@@ -216,8 +255,15 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
organisation.OrganisationType = model.OrganisationType;
if (model.OrganisationCategoryValue != null)
organisation.OrganisationCategory = model.OrganisationCategory;
if (model.OrganisationRegionId != null)
organisation.RegionIdPrimary = model.OrganisationRegionId.ToSysId();
if (model.OrganisationSportId != null)
organisation.SportIdPrimary = model.OrganisationSportId.ToSysId();
// Common properties.
if (model.OrganisationStatusCode != null)
organisation.Status = model.OrganisationStatus;
if (model.OrganisationNotes != null)
organisation.Notes = model.OrganisationNotes;
// Store item.
if (!SysId.IsValid(organisation.Id))
@@ -49,8 +49,8 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
foreach (Sax.OrganisationRole organisationRole in userOrganisation.OrganisationRoles.FindAll(item => item != Sax.OrganisationRole.Member))
data.RoleCodes.Add(OrganisationRoles.GetCodeForType(organisationRole));
data.RoleCount = userOrganisation.OrganisationRoles.Count - 1;
data.StatusCode = organisation.StatusCode;
data.StatusDesc = organisation.StatusDesc;
data.StatusCode = userOrganisation.StatusCode;
data.StatusDesc = userOrganisation.StatusDesc;
}
private void PopulateMemberResponseData(MemberData_Full data, SaxUserOrganisation userOrganisation, SaxUserAccount userAccount, SaxOrganisation organisation)
{
@@ -63,7 +63,10 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
public class AjaxResponse_MemberList : AjaxResponse_Data
{
public List<MemberData_List> Members { get; } = new List<MemberData_List>();
// Reference data.
public List<CodeDesc> MemberRoles { get; } = new List<CodeDesc>();
public List<CodeDesc> Statuses { get; } = new List<CodeDesc>();
public String DefaultStatusCode { get; set; }
}
//-------------------------------------------------------------------
[HttpPost]
@@ -91,6 +94,11 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
foreach (TypeCodeDesc organisationRole in OrganisationRoles.FindAll(item => item.Type != (int)Sax.OrganisationRole.Member))
responseData.MemberRoles.Add(organisationRole.Code, Localiser.GetOrganisationRoleCaption((Sax.OrganisationRole)organisationRole.Type));
// Reference data - statuses.
foreach (SaStatus status in SaxUserOrganisation.ValidStatuses.FindAll(item => item != SaStatus.Deleted))
responseData.Statuses.Add(SacsSystem.GetStatusCode(status), Localiser.GetStatusCaption(status));
responseData.DefaultStatusCode = SacsSystem.GetStatusCode(SaxUserOrganisation.DefaultStatus);
// Item filter.
SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params();
prmUserOrganisation.OrganisationIdsIncluded.Add(filterOrganisationId);
@@ -277,7 +285,9 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
prmUserOrganisation.OrganisationMembersOnly = false;
prmUserOrganisation.StatusCat = SaxUserOrganisation.StatusCat.Any;
userOrganisation = AccountMgr.GetUserOrganisation(prmUserOrganisation);
if (userOrganisation == null)
if (userOrganisation != null)
userOrganisation.Status = SaStatus.Active;
else
// Organisation not found for user.
userOrganisation = AccountMgr.CreateUserOrganisation(userAccountId, organisationId);
}
@@ -293,8 +303,8 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
userOrganisation.OrganisationRoles = SaxUserOrganisation.GetOrganisationRolesFromCodes(model.GetMemberRoleCodes());
if (!userOrganisation.OrganisationRoles.Contains(Sax.OrganisationRole.Member))
userOrganisation.OrganisationRoles.Add(Sax.OrganisationRole.Member);
userOrganisation.Status = SaStatus.Active;
if (model.MemberStatusCode != null)
userOrganisation.Status = model.MemberStatus;
// Store item.
if (!SysId.IsValid(userOrganisation.Id))
@@ -53,6 +53,9 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
public class AjaxResponse_RegionList : AjaxResponse_Data
{
public List<RegionData_List> Regions { get; } = new List<RegionData_List>();
// Reference data.
public List<CodeDesc> Statuses { get; } = new List<CodeDesc>();
public String DefaultStatusCode { get; set; }
}
//-------------------------------------------------------------------
[HttpPost]
@@ -67,6 +70,11 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
if (!ValidUserSession)
return GetAjaxResult_InvalidSession(responseData);
// Reference data - statuses.
foreach (SaStatus status in SaxRegion.ValidStatuses.FindAll(item => item != SaStatus.Deleted))
responseData.Statuses.Add(SacsSystem.GetStatusCode(status), Localiser.GetStatusCaption(status));
responseData.DefaultStatusCode = SacsSystem.GetStatusCode(SaxRegion.DefaultStatus);
// Item filter.
SaxRegion.Params prmRegion = new SaxRegion.Params();
prmRegion.RegionFilter = model.Filter.Region;
@@ -133,7 +133,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
return userAccount;
}
private void recordInvalidLoginAttempt (Model_Security model, SaxUserAccount userAccount)
private void recordInvalidLoginAttempt(Model_Security model, SaxUserAccount userAccount)
{
String fn = GetType().Name + ".recordInvalidLoginAttempt";
@@ -321,7 +321,13 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
// Retrieve user account.
SaxUserAccount userAccount = AccountMgr.GetUserAccountByEmailAddress(model.EmailAddress);
if (userAccount != null && (userAccount.IsStatusActive || DebugMode))
if (userAccount == null)
SaLogger.Warn(fn + " Unable to send password request email to " + model.EmailAddress + " - account does not exist");
else if (!userAccount.IsStatusActive)
SaLogger.Warn(fn + " Unable to send password request email to " + model.EmailAddress + " - account is not active");
else if (!AccountMgr.UserHasRole(userAccount.Id, Sax.UserRole.SystemAdmin))
SaLogger.Warn(fn + " Unable to send password request email to " + model.EmailAddress + " - account is not 'Admin'");
else
{
// Send password request email.
SaEmailData emailData = new SaEmailData();
@@ -333,11 +339,6 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
SaLogger.Info(fn + " Password request email sent to " + model.EmailAddress, true);
else SaLogger.Warn(fn + " Failed to send password request email to " + model.EmailAddress);
}
else
{
if (userAccount == null) SaLogger.Warn(fn + " Unable to send password request email to " + model.EmailAddress + " - account does not exist");
else if (!userAccount.IsStatusActive) SaLogger.Warn(fn + " Unable to send password request email to " + model.EmailAddress + " - account is not active");
}
// Construct response.
responseData.Success = true;
@@ -77,12 +77,20 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
String logSuffix = requestPasswordParams.GetValidParams().Concat("", " ", ".");
using (SaxUserAccount userAccount = AccountMgr.GetUserAccountById(requestPasswordParams.UserAccountId))
{
if (requestPasswordParams.IsValid(userAccount))
if (userAccount.IsStatusActive)
{
model.rpe = encryptedParams;
validSessionRequired = false;
if (AccountMgr.UserHasRole(userAccount.Id, Sax.UserRole.SystemAdmin))
{
if (requestPasswordParams.IsValid(userAccount))
{
model.rpe = encryptedParams;
validSessionRequired = false;
}
else SaLogger.Warn(fn + " 'Request Password' parameters supplied but invalid. " + logSuffix);
}
else SaLogger.Warn(fn + " 'Request Password' parameters supplied but account is not 'Admin'. " + logSuffix);
}
else SaLogger.Warn(fn + " 'Request Password' parameters supplied but invalid. " + logSuffix);
else SaLogger.Warn(fn + " 'Request Password' parameters supplied but account is not active. " + logSuffix);
}
}
}
@@ -46,6 +46,9 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
public class AjaxResponse_SportList : AjaxResponse_Data
{
public List<SportData_List> Sports { get; } = new List<SportData_List>();
// Reference data.
public List<CodeDesc> Statuses { get; } = new List<CodeDesc>();
public String DefaultStatusCode { get; set; }
}
//-------------------------------------------------------------------
[HttpPost]
@@ -60,6 +63,11 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
if (!ValidUserSession)
return GetAjaxResult_InvalidSession(responseData);
// Reference data - statuses.
foreach (SaStatus status in SaxSport.ValidStatuses.FindAll(item => item != SaStatus.Deleted))
responseData.Statuses.Add(SacsSystem.GetStatusCode(status), Localiser.GetStatusCaption(status));
responseData.DefaultStatusCode = SacsSystem.GetStatusCode(SaxSport.DefaultStatus);
// Item filter.
SaxSport.Params prmSport = new SaxSport.Params();
prmSport.SportFilter = model.Filter.Sport;
@@ -59,20 +59,36 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
}
}
//-------------------------------------------------------------------
// Utilities.
private List<SaxUserRole> GetUserRoles(SysId userAccountId, SaxUserRole.StatusCat statusCat = SaxUserRole.StatusCat.NotDeleted)
{
if (!SysId.IsValid(userAccountId)) return new List<SaxUserRole>();
SaxUserRole.Params prmUserRole = new SaxUserRole.Params();
prmUserRole.UserAccountIdsIncluded.Add(userAccountId);
prmUserRole.StatusCat = statusCat;
return AccountMgr.GetUserRoleList(prmUserRole);
}
//-------------------------------------------------------------------
// Get User List ajax request.
//-------------------------------------------------------------------
public class AjaxResponse_UserList : AjaxResponse_Data
{
public List<UserData_List> Users { get; } = new List<UserData_List>();
// Reference data.
public List<CodeDesc> UserRoles { get; } = new List<CodeDesc>();
public List<CodeDesc> Statuses { get; } = new List<CodeDesc>();
public String DefaultStatusCode { get; set; }
}
//-------------------------------------------------------------------
[HttpPost]
[Route("User/Ajax/GetList")]
public IActionResult Ajax_GetList(Model_User model)
[Route("User/Ajax/GetUsers")]
[Route("User/Ajax/GetUserList")]
public IActionResult Ajax_GetUserList(Model_User model)
{
String fn = GetType().Name + ".Ajax_GetList";
String fn = GetType().Name + ".Ajax_GetUserList";
String messageTitle = Localiser["user.caption.users"];
AjaxResponse_UserList responseData = new AjaxResponse_UserList();
@@ -83,6 +99,11 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
// Reference data - user roles.
foreach (TypeCodeDesc userRole in UserRoles)
responseData.UserRoles.Add(userRole.Code, Localiser.GetUserRoleCaption((Sax.UserRole)userRole.Type));
responseData.DefaultStatusCode = SacsSystem.GetStatusCode(SaxUserAccount.DefaultStatus);
// Reference data - statuses.
foreach (SaStatus status in SaxUserAccount.ValidStatuses.FindAll(item => item != SaStatus.Deleted))
responseData.Statuses.Add(SacsSystem.GetStatusCode(status), Localiser.GetStatusCaption(status));
// Item filter.
SaxUserAccount.Params prmUserAccount = new SaxUserAccount.Params();
@@ -140,7 +161,6 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
// Complete response.
responseData.SetPaging(model);
responseData.Success = true;
return Json(responseData);
}
@@ -154,9 +174,10 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
//-------------------------------------------------------------------
[HttpPost]
[Route("User/Ajax/GetItem")]
public IActionResult Ajax_GetItem(Model_User model)
[Route("User/Ajax/GetUser")]
public IActionResult Ajax_GetUser(Model_User model)
{
String fn = GetType().Name + ".Ajax_GetItem";
String fn = GetType().Name + ".Ajax_GetUser";
String messageTitle = Localiser["user.caption.user"];
AjaxResponse_User responseData = new AjaxResponse_User();
@@ -176,25 +197,47 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.found"]));
}
// User's roles.
// Construct response.
PopulateUserResponseData(responseData.user, user, GetUserRoles(user.Id).GetUserRolesByStatus(SaStatus.Active));
// Complete response.
responseData.Success = true;
return Json(responseData);
}
//-------------------------------------------------------------------
private List<SaxUserRole> GetUserRoles(SysId userAccountId, SaxUserRole.StatusCat statusCat = SaxUserRole.StatusCat.NotDeleted)
// Get User by email ajax request.
//-------------------------------------------------------------------
[HttpPost]
[Route("User/Ajax/GetUserByEmail")]
public IActionResult Ajax_GetUserByEmail(Model_User model)
{
if (!SysId.IsValid(userAccountId)) return new List<SaxUserRole>();
SaxUserRole.Params prmUserRole = new SaxUserRole.Params();
prmUserRole.UserAccountIdsIncluded.Add(userAccountId);
prmUserRole.StatusCat = statusCat;
return AccountMgr.GetUserRoleList(prmUserRole);
String fn = GetType().Name + ".Ajax_GetUserByEmail";
String messageTitle = Localiser["user.caption.user"];
AjaxResponse_User responseData = new AjaxResponse_User();
StoreSessionData = false;
// Validate session.
if (!ValidUserSession)
return GetAjaxResult_InvalidSession(responseData);
// Identify user.
if (StringUtil.IsEmpty(model.UserEmailAddress))
{
SaLogger.Warn(fn + " Attempt to get user details with blank email.");
return Json(responseData);
}
// Retrieve user.
SaxUserAccount user = AccountMgr.GetUserAccountByEmailAddress(model.UserEmailAddress);
if (user == null)
{
SaLogger.Warn(fn + " Failed to retrieve user for Email: " + model.UserEmailAddress);
return Json(responseData);
}
// Construct response.
PopulateUserResponseData(responseData.user, user, GetUserRoles(user.Id).GetUserRolesByStatus(SaStatus.Active));
responseData.Success = true;
return Json(responseData);
}
//-------------------------------------------------------------------
@@ -202,9 +245,10 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
//-------------------------------------------------------------------
[HttpPost]
[Route("User/Ajax/StoreItem")]
public IActionResult Ajax_StoreItem(Model_User model)
[Route("User/Ajax/StoreUser")]
public IActionResult Ajax_StoreUser(Model_User model)
{
String fn = GetType().Name + ".Ajax_StoreItem";
String fn = GetType().Name + ".Ajax_StoreUser";
String messageTitle = Localiser["user.caption.user"];
AjaxResponse_User responseData = new AjaxResponse_User();
@@ -225,27 +269,30 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.found"]));
}
// User roles, including deleted.
List<String> userRoleCodes = model.GetUserRoleCodes();
// User roles, including deleted in case of reassignment.
List<SaxUserRole> userRoles = new List<SaxUserRole>();
if (user != null) userRoles = GetUserRoles(user.Id, SaxUserRole.StatusCat.Any);
foreach (String userRoleCode in userRoleCodes)
if (model.UserRoleCodes != null)
{
// Role to activate.
Sax.UserRole role = (Sax.UserRole)UserRoles.GetTypeForCode(userRoleCode);
SaxUserRole userRole = userRoles.GetUserRoleByRole(role);
if (userRole == null)
List<String> userRoleCodes = model.GetUserRoleCodes();
foreach (String userRoleCode in userRoleCodes)
{
userRole = AccountMgr.CreateUserRole(user?.Id, role);
userRoles.Add(userRole);
// Role to activate.
Sax.UserRole role = (Sax.UserRole)UserRoles.GetTypeForCode(userRoleCode);
SaxUserRole userRole = userRoles.GetUserRoleByRole(role);
if (userRole == null)
{
userRole = AccountMgr.CreateUserRole(user?.Id, role);
userRoles.Add(userRole);
}
userRole.Status = SaStatus.Active;
}
// Roles to deactivate.
foreach (SaxUserRole userRole in userRoles)
{
if (!userRoleCodes.Exists(item => item.EqualsCI(UserRoles.GetCodeForType(userRole.UserRole))))
userRole.Status = SaStatus.Inactive;
}
userRole.Status = SaStatus.Active;
}
// Roles to deactivate.
foreach (SaxUserRole userRole in userRoles)
{
if (!userRoleCodes.Exists(item => item.EqualsCI(UserRoles.GetCodeForType(userRole.UserRole))))
userRole.Status = SaStatus.Inactive;
}
// Create new item if required.
@@ -274,9 +321,6 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
SaLogger.Warn(fn + " Failed to insert user: " + AccountMgr.ErrorStateMessage);
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.insert.failed"] + "\n\n" + AccountMgr.ErrorStateMessage));
}
// Apply User Account Id to dependent items.
foreach (SaxUserRole userRole in (userRoles))
userRole.UserAccountId = user.Id;
}
else
{
@@ -287,28 +331,31 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
}
}
// Associated data - User Roles.
foreach (SaxUserRole userRole in (userRoles))
if (model.UserRoleCodes != null)
{
// Store User Role.
if (!SysId.IsValid(userRole.Id))
// Associated data - User Roles.
foreach (SaxUserRole userRole in (userRoles))
{
if (!AccountMgr.InsertUserRole(userRole, DbUpdateInfo))
SaLogger.Warn(fn + " Failed to insert user role: " + AccountMgr.ErrorStateMessage);
}
else
{
if (!AccountMgr.UpdateUserRole(userRole, DbUpdateInfo))
SaLogger.Warn(fn + " Failed to update user role [Id:" + SysId.ToString(userRole.Id) + "]: " + AccountMgr.ErrorStateMessage);
// Store User Role.
if (!SysId.IsValid(userRole.Id))
{
// Apply User Account Id if not yet done (for new user).
if (!SysId.IsValid(userRole.UserAccountId))
userRole.UserAccountId = user.Id;
if (!AccountMgr.InsertUserRole(userRole, DbUpdateInfo))
SaLogger.Warn(fn + " Failed to insert user role: " + AccountMgr.ErrorStateMessage);
}
else
{
if (!AccountMgr.UpdateUserRole(userRole, DbUpdateInfo))
SaLogger.Warn(fn + " Failed to update user role [Id:" + SysId.ToString(userRole.Id) + "]: " + AccountMgr.ErrorStateMessage);
}
}
}
// Construct response.
PopulateUserResponseData(responseData.user, user, userRoles.GetUserRolesByStatus(SaStatus.Active));
// Complete response.
responseData.Success = true;
return Json(responseData);
}
@@ -52,6 +52,10 @@ namespace Saxonite.Net.Core.Web.Admin.Models
public Sax.OrganisationType OrganisationType { get { return (Sax.OrganisationType)OrganisationTypes.GetTypeForCode(OrganisationTypeValue); } }
public String OrganisationCategoryValue { get; set; }
public Sax.OrganisationCategory OrganisationCategory { get { return (Sax.OrganisationCategory)OrganisationCategories.GetTypeForCode(OrganisationCategoryValue); } }
public String OrganisationRegionId { get; set; }
public String OrganisationSportId { get; set; }
// Common properties.
public String OrganisationNotes { get; set; }
public String OrganisationStatusCode { get; set; }
public SaStatus OrganisationStatus { get { return SacsSystem.GetStatusForCode(OrganisationStatusCode); } }
@@ -89,9 +93,9 @@ namespace Saxonite.Net.Core.Web.Admin.Models
if (OrganisationStatusCode != null)
{
if (StringUtil.IsEmpty(OrganisationStatusCode))
responseData.SetControlError(nameof(OrganisationStatusCode), Localiser["msg.validation.mandatory.value"]);
responseData.SetControlError(nameof(OrganisationStatus), Localiser["msg.validation.mandatory.value"]);
else if (!SaxOrganisation.ValidStatuses.Contains(OrganisationStatus))
responseData.SetControlError(nameof(OrganisationStatusCode), Localiser["msg.validation.invalid.value"]);
responseData.SetControlError(nameof(OrganisationStatus), Localiser["msg.validation.invalid.value"]);
}
return !responseData.HasControlErrors();
@@ -91,6 +91,15 @@ namespace Saxonite.Net.Core.Web.Admin.Models
// Roles can be left empty as the 'Member' role is automatically applied.
}
// User Organisation status.
if (MemberStatusCode != null)
{
if (StringUtil.IsEmpty(MemberStatusCode))
responseData.SetControlError(nameof(MemberStatus), Localiser["msg.validation.mandatory.value"]);
else if (!SaxOrganisation.ValidStatuses.Contains(MemberStatus))
responseData.SetControlError(nameof(MemberStatus), Localiser["msg.validation.invalid.value"]);
}
return !responseData.HasControlErrors();
}
@@ -127,9 +127,9 @@ namespace Saxonite.Net.Core.Web.Admin.Models
if (RegionStatusCode != null)
{
if (StringUtil.IsEmpty(RegionStatusCode))
responseData.SetControlError(nameof(RegionStatusCode), Localiser["msg.validation.mandatory.value"]);
responseData.SetControlError(nameof(RegionStatus), Localiser["msg.validation.mandatory.value"]);
else if (!SaxRegion.ValidStatuses.Contains(RegionStatus))
responseData.SetControlError(nameof(RegionStatusCode), Localiser["msg.validation.invalid.value"]);
responseData.SetControlError(nameof(RegionStatus), Localiser["msg.validation.invalid.value"]);
}
return !responseData.HasControlErrors();
@@ -77,9 +77,9 @@ namespace Saxonite.Net.Core.Web.Admin.Models
if (SportStatusCode != null)
{
if (StringUtil.IsEmpty(SportStatusCode))
responseData.SetControlError(nameof(SportStatusCode), Localiser["msg.validation.mandatory.value"]);
responseData.SetControlError(nameof(SportStatus), Localiser["msg.validation.mandatory.value"]);
else if (!SaxSport.ValidStatuses.Contains(SportStatus))
responseData.SetControlError(nameof(SportStatusCode), Localiser["msg.validation.invalid.value"]);
responseData.SetControlError(nameof(SportStatus), Localiser["msg.validation.invalid.value"]);
}
return !responseData.HasControlErrors();
@@ -54,7 +54,10 @@ namespace Saxonite.Net.Core.Web.Admin.Models
{
List<String> codes = new List<string>();
foreach (String code in UserRoleCodes)
{
if (StringUtil.IsEmpty(code)) continue;
codes.AddRange(code.Split(UserRoleCodeDelim));
}
return codes;
}
public String UserStatusCode { get; set; }
@@ -119,9 +122,9 @@ namespace Saxonite.Net.Core.Web.Admin.Models
if (UserStatusCode != null)
{
if (StringUtil.IsEmpty(UserStatusCode))
responseData.SetControlError(nameof(UserStatusCode), Localiser["msg.validation.mandatory.value"]);
responseData.SetControlError(nameof(UserStatus), Localiser["msg.validation.mandatory.value"]);
else if (!SaxUserAccount.ValidStatuses.Contains(UserStatus))
responseData.SetControlError(nameof(UserStatusCode), Localiser["msg.validation.invalid.value"]);
responseData.SetControlError(nameof(UserStatus), Localiser["msg.validation.invalid.value"]);
}
return !responseData.HasControlErrors();
@@ -177,6 +177,12 @@
<data name="label.iso2.code" xml:space="preserve">
<value>ISO2 code</value>
</data>
<data name="label.item.selected" xml:space="preserve">
<value>Selected item</value>
</data>
<data name="label.items.available" xml:space="preserve">
<value>Available items</value>
</data>
<data name="label.keep.signed.in" xml:space="preserve">
<value>Keep me signed-in</value>
</data>
@@ -210,12 +216,18 @@
<data name="label.refresh" xml:space="preserve">
<value>Refresh</value>
</data>
<data name="label.region" xml:space="preserve">
<value>Region</value>
</data>
<data name="label.remove" xml:space="preserve">
<value>Remove</value>
</data>
<data name="label.roles" xml:space="preserve">
<value>Roles</value>
</data>
<data name="label.search" xml:space="preserve">
<value>Search</value>
</data>
<data name="label.security" xml:space="preserve">
<value>Security</value>
</data>
@@ -228,6 +240,12 @@
<data name="label.selected.none" xml:space="preserve">
<value>none selected</value>
</data>
<data name="label.sport" xml:space="preserve">
<value>Sport</value>
</data>
<data name="label.status" xml:space="preserve">
<value>Status</value>
</data>
<data name="label.strength" xml:space="preserve">
<value>Strength</value>
</data>
@@ -336,6 +354,9 @@
<data name="region.caption.region.create" xml:space="preserve">
<value>Create Region</value>
</data>
<data name="region.caption.region.select" xml:space="preserve">
<value>Select Region</value>
</data>
<data name="region.caption.region.update" xml:space="preserve">
<value>Update Region</value>
</data>
@@ -384,6 +405,9 @@
<data name="sport.caption.sport.create" xml:space="preserve">
<value>Create Sport</value>
</data>
<data name="sport.caption.sport.select" xml:space="preserve">
<value>Select Sport</value>
</data>
<data name="sport.caption.sport.update" xml:space="preserve">
<value>Update Sport</value>
</data>
@@ -18,7 +18,7 @@
{
<div class="row">
<div class="col-sm-5 sax-label text-left text-sm-right">@Localiser["organisation.caption.organisation"]</div>
<div class="col-sm-7"><input type="text" id="" class="sax-input" name="Filter.Organisation" onkeypress="sax.organisationSelection.fn.refreshOrganisations(250)" /></div>
<div class="col-sm-7"><input type="text" id="" class="sax-input FilterOrganisation" name="Filter.Organisation" maxlength="32" /></div>
</div>
}
@@ -1,12 +1,12 @@
@model SaxModel_Admin
@inject SaxLocaliser Localiser
<link rel="stylesheet" href="~/css/sax-codeSelection.css?@Model.HrefVersion" />
<script src="~/js/sax-codeSelection.js?@Model.HrefVersion"></script>
<link rel="stylesheet" href="~/css/sax-selectCode.css?@Model.HrefVersion" />
<script src="~/js/sax-selectCode.js?@Model.HrefVersion"></script>
<script type="text/javascript">
</script>
<div id="dlgCodeSelection" class="sax-dialog sax-form">
<div id="dlgSelectCode" class="sax-dialog sax-form">
@* Filter *@
<div class="">
@@ -18,7 +18,7 @@
@* Available codes *@
<div class="col-sm-5">
<div class="h-100 sax-codeSelection-codes AvailableCodes">
<div class="h-100 sax-selectCode-codes AvailableCodes">
</div>
@@ -30,11 +30,11 @@
<div class="row">
<div class="col-sx-6 col-sm-12 center">
<button class="sax-button" onclick="">@Localiser["label.select"]</button>
<button class="sax-button Select">@Localiser["label.select"]</button>
</div>
<div class="col-sx-6 col-sm-12 center">
<button class="sax-button" onclick="">@Localiser["label.remove"]</button>
<button class="sax-button Remove">@Localiser["label.remove"]</button>
</div>
</div>
@@ -44,7 +44,7 @@
@* Selected codes *@
<div class="col-sm-5">
<div class="h-100 sax-codeSelection-codes SelectedCodes">
<div class="h-100 sax-selectCode-codes SelectedCodes">
</div>
</div>
@@ -0,0 +1,49 @@
@model SaxModel_Admin
@inject SaxLocaliser Localiser
<link rel="stylesheet" href="~/css/sax-selectItem.css?@Model.HrefVersion" />
<div id="dlgSelectItem" class="sax-dialog sax-form">
<div class="container-fluid h-100">
@* Selected Item *@
<div class="SelectedItem">
<div class="row">
<div class="col-sm-12"><div class="sax-label">@Localiser["label.item.selected"]:</div></div>
<div class="col-sm-12"><div class="SelectedItemName"></div></div>
</div>
<div class="spacer2"></div>
</div>
@* Item Filter *@
<div class="ItemFilter sax-form">
<div class="row">
<div class="col right"><div class="sax-label">@Localiser["label.search"]</div></div>
<div class="fixed"><input id="ifItemFilter" class="sax-input" type="text" onkeyup="sax.data.selectItem.fn.displayItems();" /></div>
</div>
<div class="spacer2"></div>
</div>
@* Available items *@
<div class="row">
<div class="col"><div class="sax-label bottom">@Localiser["label.items.available"]:</div></div>
</div>
<div class="row">
<div class="col-sm-12 sax-selectItem-items AvailableItems"></div>
</div>
</div>
<div class="sax-panel-item-template">
<div class="sax-panel-item Item">
<div class="ItemName"></div>
</div>
</div>
<script src="~/js/sax-selectItem.js?@Model.HrefVersion"></script>
</div>
@@ -19,7 +19,7 @@
{
<div class="row">
<div class="col-sm-5 sax-label text-left text-sm-right">@Localiser["organisation.caption.organisation"]</div>
<div class="col-sm-7">@Html.TextBoxFor(model => model.Filter.Organisation, new { @id = "ifFilterOrganisation", @class = "FilterOrganisation", @maxlength = "32", @onkeypress = "sax.refreshResults(250)" })</div>
<div class="col-sm-7">@Html.TextBoxFor(model => model.Filter.Organisation, new { @id = "ifFilterOrganisation", @class = "FilterOrganisation", @maxlength = "32" })</div>
</div>
}
</div>
@@ -39,12 +39,12 @@
<div class="row">
<div class="col-sm-4"><div class="OrganisationCategory"></div></div>
<div class="col-sm-4"><div class="OrganisationType"></div></div>
<div class="col-sm-4 right"><div class=""></div></div>
<div class="col-sm-4 text-left text-sm-right"><div class="OrganisationRegion"></div></div>
</div>
<div class="row">
<div class="col-sm-4"><div class="OrganisationSport"></div></div>
<div class="col-sm-4"><div class="OrganisationMemberCount sax-action-text">@Localiser["label.members"]:&nbsp;<span class="MemberCount"></span></div></div>
<div class="col-sm-4"><div class=""></div></div>
<div class="col-sm-4 right"><div class="StatusDesc"></div></div>
<div class="col-sm-4 text-left text-sm-right"><div class="StatusDesc"></div></div>
</div>
</div>
</div>
@@ -12,10 +12,14 @@
sax.dlg.title.selectMemberRoles = '@Localiser.GetJavascriptText("organisation.caption.select.member.roles")';
sax.data.userRoleCodeDelim = '@Model.MemberRoleCodeDelim';
</script>
@using (@Html.BeginForm(FormMethod.Post, new { @id = "frmMemberId", @class = "sax-form" }))
@using (@Html.BeginForm(FormMethod.Post, new { @id = "frmMemberId" }))
{
@Html.HiddenFor(model => model.UserOrganisationId, new { @id = "", @class = "UserOrganisationId" })
}
@using (@Html.BeginForm(FormMethod.Post, new { @id = "frmUserEmail"}))
{
<input type="hidden" id="" class="UserEmailAddress" name="UserEmailAddress" />
}
<div id="dlgMember" class="sax-dialog" title="">
@using (@Html.BeginForm(FormMethod.Post, new { @id = "frmMember", @class = "sax-form", @onSubmit = "return false;" }))
@@ -58,8 +62,19 @@
<div class="sax-message"></div>
</div>
@* Member status *@
<div class="sax-form-control MemberStatus">
<div class="sax-label">
<label for="cbMemberStatus"><span><span class="required">*</span> @Localiser["label.status"]</span></label>
</div>
<div class="sax-control">
<select id="cbMemberStatus" class="sax-select MemberStatus" name="MemberStatusCode"></select>
</div>
<div class="sax-message"></div>
</div>
}
<partial name="~/Views/Common/CodeSelection.cshtml" />
<partial name="~/Views/Common/SelectCode.cshtml" />
</div>
@@ -7,6 +7,8 @@
<script type="text/javascript">
sax.dlg.title.createOrganisation = '@Localiser.GetJavascriptText("organisation.caption.organisation.create")';
sax.dlg.title.updateOrganisation = '@Localiser.GetJavascriptText("organisation.caption.organisation.update")';
sax.dlg.title.selectRegion = '@Localiser.GetJavascriptText("region.caption.region.select")';
sax.dlg.title.selectSport = '@Localiser.GetJavascriptText("sport.caption.sport.select")';
</script>
@using (@Html.BeginForm(FormMethod.Post, new { @id = "frmOrganisationId", @class = "sax-form" }))
{
@@ -16,7 +18,7 @@
@using (@Html.BeginForm(FormMethod.Post, new { @id = "frmOrganisation", @class = "sax-form", @onSubmit = "return false;" }))
{
@Html.HiddenFor(model => model.OrganisationId, new { @id="", @class = "OrganisationId" })
@Html.HiddenFor(model => model.OrganisationId, new { @id = "", @class = "OrganisationId" })
@* Organisation name *@
<div class="sax-form-control OrganisationName">
@@ -51,8 +53,45 @@
<div class="sax-message"></div>
</div>
@* Organisation country *@
@* Organisation region *@
<div class="sax-form-control OrganisationRegionId">
<div class="sax-label">
<label for="ifOrganisationRegionId"><span><span class="required">*</span> @Localiser["label.region"]</span></label>
</div>
<div class="sax-control row">
@Html.HiddenFor(model => model.OrganisationRegionId, new { @id = "ifOrganisationRegionId", @class = "OrganisationRegionId" })
<div class="col"><input type="text" id="ifOrganisationRegionCaption" class="OrganisationRegionCaption sax-input" readonly="readonly" ondblclick="sax.selectRegion()" /> </div>
<div class="fixed"><button id="pbSelectRegion" class="sax-button" style="min-width:auto;margin-left:4px;padding:4px 6px" onclick="sax.selectRegion()">@Localiser["label.select"]</button></div>
</div>
<div class="sax-message"></div>
</div>
@* Organisation sport *@
<div class="sax-form-control OrganisationSportId">
<div class="sax-label">
<label for="ifOrganisationSportId"><span><span class="required">*</span> @Localiser["label.sport"]</span></label>
</div>
<div class="sax-control row">
@Html.HiddenFor(model => model.OrganisationSportId, new { @id = "ifOrganisationSportId", @class = "OrganisationSportId" })
<div class="col"><input type="text" id="ifOrganisationSportCaption" class="OrganisationSportCaption sax-input" readonly="readonly" ondblclick="sax.selectSport()" /> </div>
<div class="fixed"><button id="pbSelectSport" class="sax-button" style="min-width:auto;margin-left:4px;padding:4px 6px" onclick="sax.selectSport()">@Localiser["label.select"]</button></div>
</div>
<div class="sax-message"></div>
</div>
@* Organisation status *@
<div class="sax-form-control OrganisationStatus">
<div class="sax-label">
<label for="cbOrganisationStatus"><span><span class="required">*</span> @Localiser["label.status"]</span></label>
</div>
<div class="sax-control">
<select id="cbOrganisationStatus" class="sax-select OrganisationStatus" name="OrganisationStatusCode"></select>
</div>
<div class="sax-message"></div>
</div>
}
<partial name="~/Views/Common/SelectItem.cshtml" />
</div>
@@ -19,7 +19,7 @@
{
<div class="row">
<div class="col-sm-5 sax-label text-left text-sm-right">@Localiser["region.caption.region"]</div>
<div class="col-sm-7">@Html.TextBoxFor(model => model.Filter.Region, new { @id = "ifFilterRegion", @class = "FilterRegion", @maxlength = "32", @onkeypress = "sax.refreshResults(250)" })</div>
<div class="col-sm-7">@Html.TextBoxFor(model => model.Filter.Region, new { @id = "ifFilterRegion", @class = "FilterRegion", @maxlength = "32" })</div>
</div>
}
</div>
@@ -51,6 +51,17 @@
<div class="sax-message"></div>
</div>
@* Region status *@
<div class="sax-form-control RegionStatus">
<div class="sax-label">
<label for="cbRegionStatus"><span><span class="required">*</span> @Localiser["label.status"]</span></label>
</div>
<div class="sax-control">
<select id="cbRegionStatus" class="sax-select RegionStatus" name="RegionStatusCode"></select>
</div>
<div class="sax-message"></div>
</div>
}
</div>
@@ -19,7 +19,7 @@
{
<div class="row">
<div class="col-sm-5 sax-label text-left text-sm-right">@Localiser["sport.caption.sport"]</div>
<div class="col-sm-7">@Html.TextBoxFor(model => model.Filter.Sport, new { @id = "ifFilterSport", @class = "FilterSport", @maxlength = "32", @onkeypress = "sax.refreshResults(250)" })</div>
<div class="col-sm-7">@Html.TextBoxFor(model => model.Filter.Sport, new { @id = "ifFilterSport", @class = "FilterSport", @maxlength = "32" })</div>
</div>
}
</div>
@@ -29,6 +29,17 @@
<div class="sax-message"></div>
</div>
@* Sport status *@
<div class="sax-form-control SportStatus">
<div class="sax-label">
<label for="cbSportStatus"><span><span class="required">*</span> @Localiser["label.status"]</span></label>
</div>
<div class="sax-control">
<select id="cbSportStatus" class="sax-select SportStatus" name="SportStatusCode"></select>
</div>
<div class="sax-message"></div>
</div>
}
</div>
+1 -1
View File
@@ -19,7 +19,7 @@
{
<div class="row">
<div class="col-sm-5 sax-label text-left text-sm-right">@Localiser["user.caption.user"]</div>
<div class="col-sm-7">@Html.TextBoxFor(model => model.Filter.User, new { @id = "ifFilterUser", @class = "FilterUser", @maxlength = "32", @onkeypress = "sax.refreshResults(250)" })</div>
<div class="col-sm-7">@Html.TextBoxFor(model => model.Filter.User, new { @id = "ifFilterUser", @class = "FilterUser", @maxlength = "32" })</div>
</div>
}
</div>
@@ -76,8 +76,19 @@
<div class="sax-message"></div>
</div>
@* User status *@
<div class="sax-form-control UserStatus">
<div class="sax-label">
<label for="cbUserStatus"><span><span class="required">*</span> @Localiser["label.status"]</span></label>
</div>
<div class="sax-control">
<select id="cbUserStatus" class="sax-select UserStatus" name="UserStatusCode"></select>
</div>
<div class="sax-message"></div>
</div>
}
<partial name="~/Views/Common/CodeSelection.cshtml" />
<partial name="~/Views/Common/SelectCode.cshtml" />
</div>
@@ -4,7 +4,7 @@
/* Panels */
.sax-codeSelection-codes
.sax-selectCode-codes
{
padding:2px 0;
background-color:#f0f0f0;
@@ -12,7 +12,7 @@
border-radius: 6px;
}
#dlgCodeSelection.sax-form button.sax-button
#dlgSelectCode.sax-form button.sax-button
{
margin: 4px 0;
}
@@ -0,0 +1,61 @@
/*
Item Selection stylesheet.
*/
/* Panels */
#dlgSelectItem .SelectedItemName
{
min-height: 1.5rem;
padding: 2px 4px;
background-color: #f0f0f0;
border: 1px solid #b0b0b0;
border-radius: 4px;
overflow: hidden;
}
#dlgSelectItem .ItemFilter .sax-label
{
margin-right: 6px;
}
#dlgSelectItem .sax-button
{
padding: 2px 8px;
border-radius: 6px;
}
#dlgSelectItem .sax-selectItem-items
{
margin-bottom: 8px;
padding: 2px 0;
background-color: #f0f0f0;
border: 1px solid #b0b0b0;
border-top-left-radius: 6px;
border-bottom-left-radius: 6px;
overflow-x: hidden;
overflow-y: scroll;
}
#dlgSelectItem.sax-form button.sax-button
{
margin: 4px 0;
}
#dlgSelectItem .sax-panel-item.Item
{
margin: 2px 4px;
padding: 2px 4px;
background-color: #fff;
border: 2px solid #d8d8ff;
border-radius: 4px;
cursor: pointer;
}
#dlgSelectItem .sax-panel-item.Item.sel
{
background-color: #ececff;
border-color: #8a8aff;
}
/* The End */
@@ -1,83 +0,0 @@
/*
* Admin - User page scripts.
*/
(function (win, doc, undef)
{
"use strict";
let cs = sax.codeSelection = sax.codeSelection || { fn: {}, $dlg: {}, codeIdPrefix: 'Code_' };
//--------------------------------------------------------------
/*
* Code selection config:
* - caption - dialog title.
* - width: preferred dialog width (default: 400).
* - height: preferred dialog height (default: 400).
* - showFilter: whether to display filter control(s).
* - filterLabel: filter code field caption.
* - maxItems: maximum number of available items to list.
* - codes - list of {code,desc,comment} objects
* - selectedCodes - list of codes.
* - fnCallback - method to call on completion to store codes taking list of selected codes as parameter.
*/
cs.fn.openCodeSelection = function (cfg)
{
sax.debug('openCodeSelection', cfg);
cs.fn.init();
cs.cfg = cfg;
cs.selectedCodes = cfg.selectedCodes || [];
cs.fn.displayCodes(cfg.codes);
sax.openDialog(cs.$dlg.dialog('option', { title: cfg.caption || 'Select Codes' }), cs.cfg.width || 400, cs.cfg.height || 400);
}
cs.fn.displayCodes = function (codes)
{
let $codesAvail = $('.sax-codeSelection-codes.AvailableCodes').empty();
let $codesSelec = $('.sax-codeSelection-codes.SelectedCodes').empty();
let $codeTmpl = $('.sax-panel-item-template .sax-panel-item.Code');
for (let codeIdx = 0; codeIdx < codes.length; codeIdx++)
{
let code = codes[codeIdx];
let selected = cs.selectedCodes.indexOf(code.code) >= 0;
let $code = $codeTmpl.clone();
$($code).prop('id', cs.codeIdPrefix + code.code).attr('aria-code', code.code).on('click', function () { cs.fn.onClickCode(code.code); }).on('dblclick', function () { cs.fn.onDblClickCode(code.code); }).find('.CodeDesc').text(code.desc).end();
if (selected) $codesSelec.append($code);
else $codesAvail.append($code);
}
}
cs.fn.onClickCode = function (code)
{
$('.sax-panel-item.Code').removeClass('sel');
$('.sax-panel-item.Code[aria-code="' + code + '"]').addClass('sel');
}
cs.fn.onDblClickCode = function (code)
{
let codeIdx = cs.selectedCodes.indexOf(code);
//sax.debug('onDblClickCode', code, codeIdx);
if (codeIdx >= 0) cs.selectedCodes.splice(codeIdx, 1); else cs.selectedCodes.push(code)
cs.fn.displayCodes(cs.cfg.codes)
$('.sax-panel-item.Code[aria-code="' + code + '"]').addClass('sel');
}
cs.fn.storeCodeSelection = function ()
{
//sax.debug('storeCodeSelection', cs.cfg, cs.selectedCodes);
if (cs.cfg.fnCallback) cs.cfg.fnCallback(cs.selectedCodes);
cs.$dlg.dialog('close');
delete cs.cfg;
delete cs.selectedCodes;
}
//--------------------------------------------------------------
cs.fn.init = function ()
{
if (!cs.$dlg) return;
var opt = sax.dlgOpts();
opt.buttons[sax.dlg.btn.ok] = function () { cs.fn.storeCodeSelection(); };
opt.buttons[sax.dlg.btn.cancel] = function () { $(this).dialog('close'); };
cs.$dlg = $('#dlgCodeSelection').dialog(opt);
}
}(window, window.document));
/* The End */
@@ -31,6 +31,10 @@
{
return sax.isNumeric(value) ? parseInt(value, 10) : defaultValue || 0;
}
sax.escapeRegExp = function (val)
{
return (val || '').replace(/[[{}()*+?^$|\]\.\\]/g, "\\$&");
}
sax.debug = sax.debugMode ? win.console.log.bind(win.console) : function () { };
//--------------------------------------------------------------
@@ -56,6 +60,12 @@
return index % 2 == 1 ? "other" : "";
});
}
sax.populateSelectCodeDesc = function ($sel, values)
{
$sel = $($sel).empty();
for (const value of values)
$sel.append($('<option>').prop('value', value.code).text(value.desc));
}
sax.checkTextAreaMaxLength = function (ctrl, len)
{
if (ctrl == null || ctrl.value == null) return;
@@ -460,6 +470,7 @@
}(window, window.document));
//--------------------------------------------------------------
(function ()
{
if (typeof Object.defineProperty === 'function')
@@ -1,147 +1,223 @@
/*
* Admin - Organisation page scripts.
*/
"use strict";
sax.itemIdPrefix = 'Itm_';
//--------------------------------------------------------------
sax.refreshResults = function (delay)
(function (win, doc, undef)
{
var $results = $('.sax-panel-results');
if (!sax.awaitingRefreshResponse)
{
var $items = $('.sax-panel-item-list', $results).fadeOut(200).empty();
var $msgs = $('.sax-panel-messages', $results).hide().empty().append($('<div class="sax-message">' + sax.msg.dataQuerying + '</div>')).fadeIn(200);
}
sax.ajaxRefreshResults = sax.ajaxRefreshResults || { url: sax.url.base + 'Organisation/Ajax/GetList', formId: 'frmOrganisationFilter', callbackFn: sax.doRefreshResults };
sax.doAjaxRequest(sax.ajaxRefreshResults, delay || 50);
sax.awaitingRefreshResponse = true;
}
sax.doRefreshResults = function (response)
{
sax.debug('doRefreshResults', response);
delete sax.awaitingRefreshResponse;
sax.refreshControlValues(response.controlValues);
var $results = $('.sax-panel-results');
var $msgs = $('.sax-panel-messages', $results).hide().empty();
var $items = $('.sax-panel-item-list', $results).hide().empty();
var $templ = $('.sax-panel-item-template .sax-panel-item.Organisation', $results);
if (!response.success) return;
// Items.
var items = response.organisations;
if (!items.length)
return $msgs.append($('<div class="sax-message">' + sax.msg.dataNoneFound + '</div>')).fadeIn(500);
for (let itemIdx = 0; itemIdx < items.length; itemIdx++)
{
let item = items[itemIdx];
let $item = $templ.clone();
sax.populateItem($item, item);
$items.append($item);
}
$items.fadeIn(50);
}
sax.populateItem = function ($item, item)
{
if (!item) return;
$item.prop('id', sax.itemIdPrefix + item.id);
$('.OrganisationName', $item).text(item.name);
$('.OrganisationType', $item).text(item.typeDesc);
$('.OrganisationCategory', $item).text(item.categoryDesc);
$('.OrganisationMemberCount', $item).on('click', function () { sax.onClickMemberCount(item.id); }).find('.MemberCount').text(item.memberCount);
$('.StatusDesc', $item).text(item.statusDesc);
$('.sax-action.sax-item-update', $item).off('click').on('click', function () { sax.updateItem(item.id) })
}
"use strict";
sax.itemIdPrefix = 'Itm_';
//--------------------------------------------------------------
sax.createItem = function ()
{
$('.OrganisationId,input[type="text"],textarea,select', sax.$frm.organisation).val('');
sax.clearControlErrors();
sax.$dlg.organisation.dialog('option', 'title', sax.dlg.title.createOrganisation);
sax.openDialog(sax.$dlg.organisation, 600, 600);
}
sax.doCreateItem = function ()
{
sax.storeItem();
}
//--------------------------------------------------------------
sax.updateItem = function (id)
{
$('.OrganisationId', sax.$frm.organisationId).val(id);
sax.ajaxUpdateItem = sax.ajaxUpdateItem || { url: sax.url.base + 'Organisation/Ajax/GetItem', formId: 'frmOrganisationId', callbackFn: sax.onUpdateItem };
sax.doAjaxRequest(sax.ajaxUpdateItem, 50);
}
sax.onUpdateItem = function (response)
{
//sax.debug('onUpdateItem', response);
let $frm = sax.$frm.organisation;
$('.OrganisationId,input[type="text"],textarea,select', $frm).val('');
if (!response.success) return;
let item = response.organisation;
$('.OrganisationId', $frm).val(item.id);
$('.OrganisationName', $frm).val(item.name);
$('.OrganisationType', $frm).val(item.typeCode);
$('.OrganisationCategory', $frm).val(item.categoryCode);
sax.clearControlErrors();
sax.$dlg.organisation.dialog('option', 'title', sax.dlg.title.updateOrganisation);
sax.openDialog(sax.$dlg.organisation, 600, 600);
}
sax.doUpdateItem = function ()
{
sax.storeItem();
}
//--------------------------------------------------------------
sax.storeItem = function ()
{
sax.ajaxStoreItem = sax.ajaxStoreItem || { url: sax.url.base + 'Organisation/Ajax/StoreItem', formId: 'frmOrganisation', callbackFn: sax.onStoreItem };
sax.doAjaxRequest(sax.ajaxStoreItem, 50);
}
sax.onStoreItem = function (response)
{
//sax.debug('onStoreItem', response);
sax.refreshControlValues(response.controlValues);
if (!response.success) return;
sax.$dlg.organisation.dialog('close');
var item = response.organisation;
var $item = $('#' + sax.itemIdPrefix + item.id);
if (!$item.length)
//--------------------------------------------------------------
sax.refreshResults = function (delay)
{
var $results = $('.sax-panel-results');
$item = $('.sax-panel-item-template .sax-panel-item.Organisation', $results).clone();
$('.sax-panel-item-list', $results).prepend($item).show();
if (!sax.awaitingRefreshResponse)
{
var $items = $('.sax-panel-item-list', $results).fadeOut(200).empty();
var $msgs = $('.sax-panel-messages', $results).hide().empty().append($('<div class="sax-message">' + sax.msg.dataQuerying + '</div>')).fadeIn(200);
}
sax.ajaxRefreshResults = sax.ajaxRefreshResults || { url: sax.url.base + 'Organisation/Ajax/GetList', formId: 'frmOrganisationFilter', callbackFn: sax.doRefreshResults };
sax.doAjaxRequest(sax.ajaxRefreshResults, delay || 50);
sax.awaitingRefreshResponse = true;
}
sax.doRefreshResults = function (response)
{
sax.debug('doRefreshResults', response);
delete sax.awaitingRefreshResponse;
sax.refreshControlValues(response.controlValues);
var $results = $('.sax-panel-results');
var $msgs = $('.sax-panel-messages', $results).hide().empty();
var $items = $('.sax-panel-item-list', $results).hide().empty();
var $templ = $('.sax-panel-item-template .sax-panel-item.Organisation', $results);
if (!response.success) return;
// Reference data - Statuses.
if (response.defaultStatusCode) sax.data.defaultStatusCode = response.defaultStatusCode;
if (response.statuses)
sax.populateSelectCodeDesc('#cbOrganisationStatus', response.statuses);
// Items.
var items = response.organisations;
if (!items.length)
return $msgs.append($('<div class="sax-message">' + sax.msg.dataNoneFound + '</div>')).fadeIn(500);
for (let itemIdx = 0; itemIdx < items.length; itemIdx++)
{
let item = items[itemIdx];
let $item = $templ.clone();
sax.populateItem($item, item);
$items.append($item);
}
$items.fadeIn(50);
}
sax.populateItem = function ($item, item)
{
if (!item) return;
$item.prop('id', sax.itemIdPrefix + item.id);
$('.OrganisationName', $item).text(item.name);
$('.OrganisationType', $item).text(item.typeDesc);
$('.OrganisationCategory', $item).text(item.categoryDesc);
$('.OrganisationRegion', $item).text(item.regionName);
$('.OrganisationSport', $item).text(item.sportName);
$('.OrganisationMemberCount', $item).on('click', function () { sax.onClickMemberCount(item.id); }).find('.MemberCount').text(item.memberCount);
$('.StatusDesc', $item).text(item.statusDesc);
$('.sax-action.sax-item-update', $item).off('click').on('click', function () { sax.updateItem(item.id) })
}
sax.populateItem($item, item)
}
//--------------------------------------------------------------
sax.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();
}
//--------------------------------------------------------------
sax.selectRegion = function ()
{
if (!sax.data.regions)
{
let handleRegionsResponse = function (response)
{
if (response && response.success && response.regions)
sax.data.regions = response.regions;
sax.showSelectRegion();
}
sax.ajaxRegions = sax.ajaxRegions || { url: sax.url.base + 'Region/Ajax/GetList', formId: 'frmNavigate', callbackFn: handleRegionsResponse };
sax.doAjaxRequest(sax.ajaxRegions, 50);
}
else sax.showSelectRegion();
}
sax.showSelectRegion = function ()
{
sax.data.selectItem.fn.selectItem({ caption: sax.dlg.title.selectRegion, items: sax.data.regions, fnCallback: sax.onRegionSelected });
}
sax.onRegionSelected = function (rgn)
{
sax.debug('onRegionSelected', rgn);
let $frm = sax.$frm.organisation;
$('.OrganisationRegionId', $frm).val(rgn.id);
$('.OrganisationRegionCaption', $frm).val(rgn.name);
}
//--------------------------------------------------------------
$(function ()
{
$('.sax-panel-filter .sax-action.sax-item-create').on('click', function () { sax.createItem(); });
$('.sax-panel-filter .sax-action.sax-results-refresh').on('click', function () { sax.refreshResults(); });
$('.sax-input').on('keydown', function () { sax.clearControlError(this); });
//--------------------------------------------------------------
sax.selectSport = function ()
{
if (!sax.data.sports)
{
let handleSportsResponse = function (response)
{
if (response && response.success && response.sports)
sax.data.sports = response.sports;
sax.showSelectSport();
}
sax.ajaxSports = sax.ajaxSports || { url: sax.url.base + 'Sport/Ajax/GetList', formId: 'frmNavigate', callbackFn: handleSportsResponse };
sax.doAjaxRequest(sax.ajaxSports, 50);
}
else sax.showSelectSport();
}
sax.showSelectSport = function ()
{
sax.data.selectItem.fn.selectItem({ caption: sax.dlg.title.selectSport, items: sax.data.sports, fnCallback: sax.onSportSelected });
}
sax.onSportSelected = function (rgn)
{
sax.debug('onSportSelected', rgn);
let $frm = sax.$frm.organisation;
$('.OrganisationSportId', $frm).val(rgn.id);
$('.OrganisationSportCaption', $frm).val(rgn.name);
}
sax.$frm.organisationId = $('#frmOrganisationId');
sax.$frm.organisation = $('#frmOrganisation');
//--------------------------------------------------------------
sax.createItem = function ()
{
let $frm = sax.$frm.organisation;
$('.OrganisationId,.OrganisationRegionId,.OrganisationSportId,input[type="text"],textarea,select', $frm).val('');
$('.OrganisationStatus', $frm).val(sax.data.defaultStatusCode);
sax.clearControlErrors();
sax.$dlg.organisation.dialog('option', 'title', sax.dlg.title.createOrganisation);
sax.openDialog(sax.$dlg.organisation, 600, 600);
}
sax.doCreateItem = function ()
{
sax.storeItem();
}
var opt = sax.dlgOpts();
opt.buttons[sax.dlg.btn.ok] = function () { sax.doCreateItem(); };
opt.buttons[sax.dlg.btn.cancel] = function () { $(this).dialog('close'); };
sax.$dlg.organisation = $('#dlgOrganisation').dialog(opt);
//--------------------------------------------------------------
sax.updateItem = function (id)
{
$('.OrganisationId', sax.$frm.organisationId).val(id);
sax.ajaxUpdateItem = sax.ajaxUpdateItem || { url: sax.url.base + 'Organisation/Ajax/GetItem', formId: 'frmOrganisationId', callbackFn: sax.onUpdateItem };
sax.doAjaxRequest(sax.ajaxUpdateItem, 50);
}
sax.onUpdateItem = function (response)
{
//sax.debug('onUpdateItem', response);
let $frm = sax.$frm.organisation;
$('.OrganisationId,input[type="text"],textarea,select', $frm).val('');
if (!response.success) return;
let item = response.organisation;
$('.OrganisationId', $frm).val(item.id);
$('.OrganisationName', $frm).val(item.name);
$('.OrganisationType', $frm).val(item.typeCode);
$('.OrganisationCategory', $frm).val(item.categoryCode);
$('.OrganisationRegionId', $frm).val(item.regionId);
$('.OrganisationRegionCaption', $frm).val(item.regionName);
$('.OrganisationSportId', $frm).val(item.sportId);
$('.OrganisationSportCaption', $frm).val(item.sportName);
$('.OrganisationStatus', $frm).val(item.statusCode);
sax.clearControlErrors();
sax.$dlg.organisation.dialog('option', 'title', sax.dlg.title.updateOrganisation);
sax.openDialog(sax.$dlg.organisation, 600, 600);
}
sax.doUpdateItem = function ()
{
sax.storeItem();
}
setTimeout(sax.refreshResults, 250);
});
//--------------------------------------------------------------
sax.storeItem = function ()
{
sax.ajaxStoreItem = sax.ajaxStoreItem || { url: sax.url.base + 'Organisation/Ajax/StoreItem', formId: 'frmOrganisation', callbackFn: sax.onStoreItem };
sax.doAjaxRequest(sax.ajaxStoreItem, 50);
}
sax.onStoreItem = function (response)
{
//sax.debug('onStoreItem', response);
sax.refreshControlValues(response.controlValues);
if (!response.success) return;
sax.$dlg.organisation.dialog('close');
//--------------------------------------------------------------
var item = response.organisation;
var $item = $('#' + sax.itemIdPrefix + item.id);
if (!$item.length)
{
var $results = $('.sax-panel-results');
$item = $('.sax-panel-item-template .sax-panel-item.Organisation', $results).clone();
$('.sax-panel-item-list', $results).prepend($item).show();
}
sax.populateItem($item, item)
}
//--------------------------------------------------------------
sax.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();
}
//--------------------------------------------------------------
$(function ()
{
$('.sax-panel-filter .sax-action.sax-item-create').on('click', function () { sax.createItem(); });
$('.sax-panel-filter .sax-action.sax-results-refresh').on('click', function () { sax.refreshResults(); });
$('.sax-input').on('input', function () { sax.clearControlError(this); });
sax.$frm.filter = $('#frmOrganisationFilter');
$('.FilterOrganisation', sax.$frm.filter).on('input', function () { sax.refreshResults(250); });
sax.$frm.organisationId = $('#frmOrganisationId');
sax.$frm.organisation = $('#frmOrganisation');
var opt = sax.dlgOpts();
opt.buttons[sax.dlg.btn.ok] = function () { sax.doCreateItem(); };
opt.buttons[sax.dlg.btn.cancel] = function () { $(this).dialog('close'); };
sax.$dlg.organisation = $('#dlgOrganisation').dialog(opt);
setTimeout(sax.refreshResults, 250);
});
}(window, window.document));
/* The End */
@@ -30,9 +30,13 @@
var $items = $('.sax-panel-item-list', $results).hide().empty();
var $templ = $('.sax-panel-item-template .sax-panel-item.Member', $results);
if (!response.success) return;
// Reference data.
// Reference data - roles.
if (response.memberRoles && response.memberRoles.length)
sax.data.memberRoles = response.memberRoles;
// Reference data - Statuses.
if (response.defaultStatusCode) sax.data.defaultStatusCode = response.defaultStatusCode;
if (response.statuses)
sax.populateSelectCodeDesc('#cbMemberStatus', response.statuses);
// Items.
var items = response.members;
if (!items.length)
@@ -60,7 +64,7 @@
//--------------------------------------------------------------
sax.selectOrganisation = function ()
{
sax.debug('sax.selectOrganisation');
//sax.debug('sax.selectOrganisation');
sax.organisationSelection.fn.openDialog({ caption: sax.dlg.title.selectOrganisation, fnCallback: sax.onOrganisationSelected });
}
sax.onOrganisationSelected = function (id, name)
@@ -71,6 +75,22 @@
sax.refreshResults(50);
}
//--------------------------------------------------------------
sax.onChangeEmail = function ()
{
let $frm = sax.$frm.member;
let $mbrName = $('.MemberUserName', $frm);
$('#frmUserEmail .UserEmailAddress').val($('.MemberUserEmailAddress', $frm).val());
$mbrName.val('');
let fn = function (response)
{
if (!response || !response.success || !response.user) return;
$mbrName.val(response.user.displayName);
}
sax.ajaxUserByEmail = sax.ajaxUserByEmail || { url: sax.url.base + 'User/Ajax/GetUserByEmail', formId: 'frmUserEmail', callbackFn: fn };
sax.doAjaxRequest(sax.ajaxUserByEmail, 100);
}
//--------------------------------------------------------------
// Member Roles.
sax.selectMemberRoles = function ()
@@ -79,7 +99,7 @@
sax.selectMemberRoleConfig = sax.selectMemberRoleConfig || { caption: sax.dlg.title.selectMemberRoles, width: 520, fnCallback: sax.updateMemberRoles };
sax.selectMemberRoleConfig.codes = sax.data.memberRoles;
sax.selectMemberRoleConfig.selectedCodes = sax.member.roleCodes || [];
sax.codeSelection.fn.openCodeSelection(sax.selectMemberRoleConfig);
sax.selectCode.fn.openSelectCode(sax.selectMemberRoleConfig);
}
sax.updateMemberRoles = function (memberRoleCodes)
{
@@ -108,6 +128,7 @@
$('.UserOrganisationId,.MemberRoleCodes,input[type="text"],textarea,select', $frm).val('');
$('.MemberOrganisationId', $frm).val($('#frmMemberFilter #ifFilterOrganisationId').val());
$('.MemberUserEmailAddress', $frm).prop('readonly', false);
$('.MemberStatus', $frm).val(sax.data.defaultStatusCode);
sax.clearControlErrors();
sax.member = { roleCodes: [] };
sax.$dlg.member.dialog('option', 'title', sax.dlg.title.createMember);
@@ -138,6 +159,7 @@
$('.MemberUserName', $frm).val(item.displayName).prop('readonly', true);
$('.MemberRoleCodes', $frm).val(item.roleCodes);
$('#ifMemberRoles').val(sax.getSelectedMemberRoleDescs().join('\n'));
$('.MemberStatus', $frm).val(item.statusCode);
sax.clearControlErrors();
sax.$dlg.member.dialog('option', 'title', sax.dlg.title.updateMember);
sax.openDialog(sax.$dlg.member, 600, 600);
@@ -171,21 +193,16 @@
sax.populateItem($item, item)
}
//--------------------------------------------------------------
sax.onClickMemberCount = function (id)
{
sax.debug('onClickMemberCount', id);
}
//--------------------------------------------------------------
$(function ()
{
$('.sax-panel-filter .sax-action.sax-item-create').on('click', function () { sax.createItem(); });
$('.sax-panel-filter .sax-action.sax-results-refresh').on('click', function () { sax.refreshResults(); });
$('.sax-input').on('keydown', function () { sax.clearControlError(this); });
$('.sax-input').on('input', function () { sax.clearControlError(this); });
sax.$frm.memberId = $('#frmMemberId');
sax.$frm.member = $('#frmMember');
$('#ifMemberUserEmailAddress', sax.$frm.member).on('change', function () { sax.onChangeEmail(); });
var opt = sax.dlgOpts();
opt.buttons[sax.dlg.btn.ok] = function () { sax.doCreateItem(); };
@@ -32,8 +32,8 @@
{
//sax.debug('os.doRefreshResults', response);
if (!response.success) return;
let $results = $('.sax-selection-results.Organisations').empty().hide();
let $tmpl = $('.sax-panel-item-template .sax-panel-item.Organisation');
let $results = $('.sax-selection-results.Organisations', os.$dlg).empty().hide();
let $tmpl = $('.sax-panel-item-template .sax-panel-item.Organisation', os.$dlg);
let items = response.organisations;
if (items)
{
@@ -51,10 +51,10 @@
{
//sax.debug('onClickOrganisation', item);
os.data.item = item;
$('.sax-panel-item.Organisation').removeClass('sel');
$('.sax-panel-item.Organisation#' + os.itemIdPrefix + item.id).addClass('sel');
$('.sax-panel-item.Organisation', os.$dlg).removeClass('sel');
$('.sax-panel-item.Organisation#' + os.itemIdPrefix + item.id, os.$dlg).addClass('sel');
}
os.fn.onDblClickOrganisation= function (item)
os.fn.onDblClickOrganisation = function (item)
{
//sax.debug('onDblClickCode', item);
os.data.item = item;
@@ -62,7 +62,7 @@
}
os.fn.confirmSelection = function ()
{
//sax.debug('storeCodeSelection', os.data.item);
//sax.debug('confirmSelection', os.data.item);
if (!os.data.item) return;
if (os.cfg.fnCallback) os.cfg.fnCallback(os.data.item.id, os.data.item.name);
os.$dlg.dialog('close');
@@ -79,6 +79,8 @@
opt.buttons[sax.dlg.btn.ok] = function () { os.fn.confirmSelection(); };
opt.buttons[sax.dlg.btn.cancel] = function () { $(this).dialog('close'); };
os.$dlg = $('#dlgOrganisationSelection').dialog(opt);
$('.sax-input.FilterOrganisation', os.$dlg).on('input', function () { sax.organisationSelection.fn.refreshOrganisations(250); });
}
}(window, window.document));
+137 -123
View File
@@ -1,137 +1,151 @@
/*
* Admin - Region page scripts.
*/
"use strict";
sax.itemIdPrefix = 'Itm_';
//--------------------------------------------------------------
sax.refreshResults = function (delay)
(function (win, doc, undef)
{
var $results = $('.sax-panel-results');
if (!sax.awaitingRefreshResponse)
{
var $items = $('.sax-panel-item-list', $results).fadeOut(200).empty();
var $msgs = $('.sax-panel-messages', $results).hide().empty().append($('<div class="sax-message">' + sax.msg.dataQuerying + '</div>')).fadeIn(200);
}
sax.ajaxRefreshResults = sax.ajaxRefreshResults || { url: sax.url.base + 'Region/Ajax/GetList', formId: 'frmRegionFilter', callbackFn: sax.doRefreshResults };
sax.doAjaxRequest(sax.ajaxRefreshResults, delay || 50);
sax.awaitingRefreshResponse = true;
}
sax.doRefreshResults = function (response)
{
//sax.debug('doRefreshResults', response);
delete sax.awaitingRefreshResponse;
sax.refreshControlValues(response.controlValues);
var $results = $('.sax-panel-results');
var $msgs = $('.sax-panel-messages', $results).hide().empty();
var $items = $('.sax-panel-item-list', $results).hide().empty();
var $templ = $('.sax-panel-item-template .sax-panel-item.Region', $results);
if (!response.success) return;
// Items.
var items = response.regions;
if (!items.length)
return $msgs.append($('<div class="sax-message">' + sax.msg.dataNoneFound + '</div>')).fadeIn(500);
for (let itemIdx = 0; itemIdx < items.length; itemIdx++)
{
let item = items[itemIdx];
let $item = $templ.clone();
sax.populateItem($item, item);
$items.append($item);
}
$items.fadeIn(50);
}
sax.populateItem = function ($item, item)
{
if (!item) return;
$item.prop('id', sax.itemIdPrefix + item.id);
$('.RegionName', $item).text(item.name);
$('.RegionCountryIso2Code', $item).text(item.countryIso2Code);
$('.RegionTypeDesc', $item).text(item.regionTypeDesc);
$('.RegionParentName', $item).text(item.parentName);
$('.RegionStatusDesc', $item).text(item.statusDesc);
$('.sax-action.sax-item-update', $item).off('click').on('click', function () { sax.updateItem(item.id) })
}
"use strict";
sax.itemIdPrefix = 'Itm_';
//--------------------------------------------------------------
sax.createItem = function ()
{
$('.RegionId,input[type="text"],textarea,select', sax.$frm.region).val('');
sax.clearControlErrors();
sax.$dlg.region.dialog('option', 'title', sax.dlg.title.createRegion);
sax.openDialog(sax.$dlg.region, 600, 600);
}
sax.doCreateItem = function ()
{
sax.storeItem();
}
//--------------------------------------------------------------
sax.updateItem = function (id)
{
$('.RegionId', sax.$frm.regionId).val(id);
sax.ajaxUpdateItem = sax.ajaxUpdateItem || { url: sax.url.base + 'Region/Ajax/GetItem', formId: 'frmRegionId', callbackFn: sax.onUpdateItem };
sax.doAjaxRequest(sax.ajaxUpdateItem, 50);
}
sax.onUpdateItem = function (response)
{
//sax.debug('onUpdateItem', response);
let $frm = sax.$frm.region;
$('.RegionId,input[type="text"],textarea,select', $frm).val('');
if (!response.success) return;
let item = response.region;
$('.RegionId', $frm).val(item.id);
$('.RegionType', $frm).val(item.regionTypeCode);
$('.RegionCountryIso2Code', $frm).val(item.countryIso2Code);
$('.RegionName', $frm).val(item.name);
sax.clearControlErrors();
sax.$dlg.region.dialog('option', 'title', sax.dlg.title.updateRegion);
sax.openDialog(sax.$dlg.region, 600, 600);
}
sax.doUpdateItem = function ()
{
sax.storeItem();
}
//--------------------------------------------------------------
sax.storeItem = function ()
{
sax.ajaxStoreItem = sax.ajaxStoreItem || { url: sax.url.base + 'Region/Ajax/StoreItem', formId: 'frmRegion', callbackFn: sax.onStoreItem };
sax.doAjaxRequest(sax.ajaxStoreItem, 50);
}
sax.onStoreItem = function (response)
{
//sax.debug('onStoreItem', response);
sax.refreshControlValues(response.controlValues);
if (!response.success) return;
sax.$dlg.region.dialog('close');
var item = response.region;
var $item = $('#' + sax.itemIdPrefix + item.id);
if (!$item.length)
//--------------------------------------------------------------
sax.refreshResults = function (delay)
{
var $results = $('.sax-panel-results');
$item = $('.sax-panel-item-template .sax-panel-item.Region', $results).clone();
$('.sax-panel-item-list', $results).prepend($item).show();
if (!sax.awaitingRefreshResponse)
{
var $items = $('.sax-panel-item-list', $results).fadeOut(200).empty();
var $msgs = $('.sax-panel-messages', $results).hide().empty().append($('<div class="sax-message">' + sax.msg.dataQuerying + '</div>')).fadeIn(200);
}
sax.ajaxRefreshResults = sax.ajaxRefreshResults || { url: sax.url.base + 'Region/Ajax/GetList', formId: 'frmRegionFilter', callbackFn: sax.doRefreshResults };
sax.doAjaxRequest(sax.ajaxRefreshResults, delay || 50);
sax.awaitingRefreshResponse = true;
}
sax.doRefreshResults = function (response)
{
//sax.debug('doRefreshResults', response);
delete sax.awaitingRefreshResponse;
sax.refreshControlValues(response.controlValues);
var $results = $('.sax-panel-results');
var $msgs = $('.sax-panel-messages', $results).hide().empty();
var $items = $('.sax-panel-item-list', $results).hide().empty();
var $templ = $('.sax-panel-item-template .sax-panel-item.Region', $results);
if (!response.success) return;
// Reference data - Statuses.
if (response.defaultStatusCode) sax.data.defaultStatusCode = response.defaultStatusCode;
if (response.statuses)
sax.populateSelectCodeDesc('#cbRegionStatus', response.statuses);
// Items.
var items = response.regions;
if (!items.length)
return $msgs.append($('<div class="sax-message">' + sax.msg.dataNoneFound + '</div>')).fadeIn(500);
for (let itemIdx = 0; itemIdx < items.length; itemIdx++)
{
let item = items[itemIdx];
let $item = $templ.clone();
sax.populateItem($item, item);
$items.append($item);
}
$items.fadeIn(50);
}
sax.populateItem = function ($item, item)
{
if (!item) return;
$item.prop('id', sax.itemIdPrefix + item.id);
$('.RegionName', $item).text(item.name);
$('.RegionCountryIso2Code', $item).text(item.countryIso2Code);
$('.RegionTypeDesc', $item).text(item.regionTypeDesc);
$('.RegionParentName', $item).text(item.parentName);
$('.RegionStatusDesc', $item).text(item.statusDesc);
$('.sax-action.sax-item-update', $item).off('click').on('click', function () { sax.updateItem(item.id) })
}
sax.populateItem($item, item)
}
//--------------------------------------------------------------
$(function ()
{
$('.sax-action.sax-item-create').on('click', function () { sax.createItem(); });
$('.sax-action.sax-results-refresh').on('click', function () { sax.refreshResults(); });
$('.sax-input').on('keydown', function () { sax.clearControlError(this); });
//--------------------------------------------------------------
sax.createItem = function ()
{
let $frm = sax.$frm.region;
$('.RegionId,input[type="text"],textarea,select', $frm).val('');
$('.RegionStatus', $frm).val(sax.data.defaultStatusCode);
sax.clearControlErrors();
sax.$dlg.region.dialog('option', 'title', sax.dlg.title.createRegion);
sax.openDialog(sax.$dlg.region, 600, 600);
}
sax.doCreateItem = function ()
{
sax.storeItem();
}
sax.$frm.regionId = $('#frmRegionId');
sax.$frm.region = $('#frmRegion');
//--------------------------------------------------------------
sax.updateItem = function (id)
{
$('.RegionId', sax.$frm.regionId).val(id);
sax.ajaxUpdateItem = sax.ajaxUpdateItem || { url: sax.url.base + 'Region/Ajax/GetItem', formId: 'frmRegionId', callbackFn: sax.onUpdateItem };
sax.doAjaxRequest(sax.ajaxUpdateItem, 50);
}
sax.onUpdateItem = function (response)
{
//sax.debug('onUpdateItem', response);
let $frm = sax.$frm.region;
$('.RegionId,input[type="text"],textarea,select', $frm).val('');
if (!response.success) return;
let item = response.region;
$('.RegionId', $frm).val(item.id);
$('.RegionType', $frm).val(item.regionTypeCode);
$('.RegionCountryIso2Code', $frm).val(item.countryIso2Code);
$('.RegionName', $frm).val(item.name);
$('.RegionStatus', $frm).val(item.statusCode);
sax.clearControlErrors();
sax.$dlg.region.dialog('option', 'title', sax.dlg.title.updateRegion);
sax.openDialog(sax.$dlg.region, 600, 600);
}
sax.doUpdateItem = function ()
{
sax.storeItem();
}
var opt = sax.dlgOpts();
opt.buttons[sax.dlg.btn.ok] = function () { sax.doCreateItem(); };
opt.buttons[sax.dlg.btn.cancel] = function () { $(this).dialog('close'); };
sax.$dlg.region = $('#dlgRegion').dialog(opt);
//--------------------------------------------------------------
sax.storeItem = function ()
{
sax.ajaxStoreItem = sax.ajaxStoreItem || { url: sax.url.base + 'Region/Ajax/StoreItem', formId: 'frmRegion', callbackFn: sax.onStoreItem };
sax.doAjaxRequest(sax.ajaxStoreItem, 50);
}
sax.onStoreItem = function (response)
{
//sax.debug('onStoreItem', response);
sax.refreshControlValues(response.controlValues);
if (!response.success) return;
sax.$dlg.region.dialog('close');
setTimeout(sax.refreshResults, 250);
});
var item = response.region;
var $item = $('#' + sax.itemIdPrefix + item.id);
if (!$item.length)
{
var $results = $('.sax-panel-results');
$item = $('.sax-panel-item-template .sax-panel-item.Region', $results).clone();
$('.sax-panel-item-list', $results).prepend($item).show();
}
sax.populateItem($item, item)
}
//--------------------------------------------------------------
//--------------------------------------------------------------
$(function ()
{
$('.sax-action.sax-item-create').on('click', function () { sax.createItem(); });
$('.sax-action.sax-results-refresh').on('click', function () { sax.refreshResults(); });
$('.sax-input').on('input', function () { sax.clearControlError(this); });
sax.$frm.filter = $('#frmRegionFilter');
$('.FilterRegion', sax.$frm.filter).on('input', function () { sax.refreshResults(250); });
sax.$frm.regionId = $('#frmRegionId');
sax.$frm.region = $('#frmRegion');
var opt = sax.dlgOpts();
opt.buttons[sax.dlg.btn.ok] = function () { sax.doCreateItem(); };
opt.buttons[sax.dlg.btn.cancel] = function () { $(this).dialog('close'); };
sax.$dlg.region = $('#dlgRegion').dialog(opt);
setTimeout(sax.refreshResults, 250);
});
}(window, window.document));
/* The End */
+79 -74
View File
@@ -1,84 +1,89 @@
/*
* Admin - Security page scripts.
*/
"use strict";
//--------------------------------------------------------------
sax.doSignin = function ()
(function (win, doc, undef)
{
sax.clearControlErrors();
sax.ajaxSignin = sax.ajaxSignin || { url: sax.url.base + 'Security/Ajax/Signin', formId: 'frmSignIn', callbackFn: sax.onSignin };
sax.doAjaxRequest(sax.ajaxSignin, 50);
}
sax.onSignin = function (response)
{
sax.debug(response);
sax.refreshControlValues(response.controlValues);
if (!response.success) return;
sax.goToPage('');
}
"use strict";
//--------------------------------------------------------------
sax.doScorePassword = function ()
{
sax.ajaxScorePassword = sax.ajaxScorePassword || { url: sax.url.base + 'Security/Ajax/ScorePassword', formId: 'frmChangePassword', callbackFn: sax.onScorePassword, noWaitIcon: true };
sax.doAjaxRequest(sax.ajaxScorePassword, 250);
}
sax.onScorePassword = function (response)
{
var score = (response || {}).score || 0;
sax.$prgPasswordStrength.progressbar("option", "value", score).removeClass('amber green').addClass(score > 3 ? 'green' : score > 2 ? 'amber' : '');
}
//--------------------------------------------------------------
sax.doChangePassword = function ()
{
sax.clearControlErrors();
sax.ajaxChangePassword = sax.ajaxChangePassword || { url: sax.url.base + 'Security/Ajax/StorePassword', formId: 'frmChangePassword', callbackFn: sax.onChangePassword };
sax.doAjaxRequest(sax.ajaxChangePassword, 50);
}
sax.onChangePassword = function (response)
{
sax.refreshControlValues(response.controlValues);
if (!response.success) return;
if ($('#ifRpe').length)
sax.goToPage('Security/Signin');
else sax.goToPage('');
}
//--------------------------------------------------------------
sax.doRequestPassword = function ()
{
sax.clearControlErrors();
sax.ajaxRequestPassword = sax.ajaxRequestPassword || { url: sax.url.base + 'Security/Ajax/RequestNewPassword', formId: 'frmRequestPassword', callbackFn: sax.onRequestPassword };
sax.doAjaxRequest(sax.ajaxRequestPassword, 50);
}
sax.onRequestPassword = function (response)
{
sax.refreshControlValues(response.controlValues);
if (!response.success) return;
var gotoSigninPage = function ()
//--------------------------------------------------------------
sax.doSignin = function ()
{
sax.goToPage('Security/Signin');
sax.clearControlErrors();
sax.ajaxSignin = sax.ajaxSignin || { url: sax.url.base + 'Security/Ajax/Signin', formId: 'frmSignIn', callbackFn: sax.onSignin };
sax.doAjaxRequest(sax.ajaxSignin, 50);
}
sax.onSignin = function (response)
{
sax.debug(response);
sax.refreshControlValues(response.controlValues);
if (!response.success) return;
sax.goToPage('');
}
if (response.successMsg)
sax.doAlert($('.sax-page-caption').text(), response.successMsg, gotoSigninPage);
else gotoSigninPage();
}
//--------------------------------------------------------------
$(function ()
{
$(':input:enabled:visible:first').focus();
$('#ifEmailAddress,#ifPasswordCurrent,#ifPassword,#ifPasswordConfirm').on('keydown', function () { sax.clearControlError(this); });
$('#frmChangePassword #ifPassword').on('keyup', sax.doScorePassword);
sax.$prgPasswordStrength = $('#frmChangePassword #prgPasswordStrength').progressbar({ 'max': 5 });
$('#ifEmailAddress,#ifPassword', $('#frmSignIn')).on('keypress', function (e) { if (e.which == 13) sax.doSignin(); });
$('#frmSignIn #pbSignIn').on('click', function () { sax.doSignin(); });
$('#ifPasswordCurrent,#ifPassword,#ifPasswordConfirm', $('#frmChangePassword')).on('keypress', function (e) { if (e.which == 13) sax.doChangePassword(); });
$('#frmChangePassword #pbChangePassword').on('click', function () { sax.doChangePassword(); });
$('#ifEmailAddress', $('#frmRequestPassword')).on('keypress', function (e) { if (e.which == 13) sax.doRequestPassword(); });
$('#frmRequestPassword #pbRequestPassword').on('click', function () { sax.doRequestPassword(); });
});
//--------------------------------------------------------------
sax.doScorePassword = function ()
{
sax.ajaxScorePassword = sax.ajaxScorePassword || { url: sax.url.base + 'Security/Ajax/ScorePassword', formId: 'frmChangePassword', callbackFn: sax.onScorePassword, noWaitIcon: true };
sax.doAjaxRequest(sax.ajaxScorePassword, 250);
}
sax.onScorePassword = function (response)
{
var score = (response || {}).score || 0;
sax.$prgPasswordStrength.progressbar("option", "value", score).removeClass('amber green').addClass(score > 3 ? 'green' : score > 2 ? 'amber' : '');
}
//--------------------------------------------------------------
//--------------------------------------------------------------
sax.doChangePassword = function ()
{
sax.clearControlErrors();
sax.ajaxChangePassword = sax.ajaxChangePassword || { url: sax.url.base + 'Security/Ajax/StorePassword', formId: 'frmChangePassword', callbackFn: sax.onChangePassword };
sax.doAjaxRequest(sax.ajaxChangePassword, 50);
}
sax.onChangePassword = function (response)
{
sax.refreshControlValues(response.controlValues);
if (!response.success) return;
if ($('#ifRpe').length)
sax.goToPage('Security/Signin');
else sax.goToPage('');
}
//--------------------------------------------------------------
sax.doRequestPassword = function ()
{
sax.clearControlErrors();
sax.ajaxRequestPassword = sax.ajaxRequestPassword || { url: sax.url.base + 'Security/Ajax/RequestNewPassword', formId: 'frmRequestPassword', callbackFn: sax.onRequestPassword };
sax.doAjaxRequest(sax.ajaxRequestPassword, 50);
}
sax.onRequestPassword = function (response)
{
sax.refreshControlValues(response.controlValues);
if (!response.success) return;
var gotoSigninPage = function ()
{
sax.goToPage('Security/Signin');
}
if (response.successMsg)
sax.doAlert($('.sax-page-caption').text(), response.successMsg, gotoSigninPage);
else gotoSigninPage();
}
//--------------------------------------------------------------
$(function ()
{
$(':input:enabled:visible:first').focus();
$('#ifEmailAddress,#ifPasswordCurrent,#ifPassword,#ifPasswordConfirm').on('input', function () { sax.clearControlError(this); });
$('#frmChangePassword #ifPassword').on('keyup', sax.doScorePassword);
sax.$prgPasswordStrength = $('#frmChangePassword #prgPasswordStrength').progressbar({ 'max': 5 });
$('#ifEmailAddress,#ifPassword', $('#frmSignIn')).on('keypress', function (e) { if (e.which == 13) sax.doSignin(); });
$('#frmSignIn #pbSignIn').on('click', function () { sax.doSignin(); });
$('#ifPasswordCurrent,#ifPassword,#ifPasswordConfirm', $('#frmChangePassword')).on('keypress', function (e) { if (e.which == 13) sax.doChangePassword(); });
$('#frmChangePassword #pbChangePassword').on('click', function () { sax.doChangePassword(); });
$('#ifEmailAddress', $('#frmRequestPassword')).on('keypress', function (e) { if (e.which == 13) sax.doRequestPassword(); });
$('#frmRequestPassword #pbRequestPassword').on('click', function () { sax.doRequestPassword(); });
});
}(window, window.document));
/* The End */
@@ -0,0 +1,119 @@
/*
* Admin - Code selection.
*/
(function (win, doc, undef)
{
"use strict";
let sc = sax.selectCode = sax.selectCode || { fn: {}, $dlg: {}, codeIdPrefix: 'Code_' };
//--------------------------------------------------------------
/*
* Code selection config:
* - caption - dialog title.
* - width: preferred dialog width (default: 400).
* - height: preferred dialog height (default: 400).
* - showFilter: whether to display filter control(s).
* - filterLabel: filter code field caption.
* - maxItems: maximum number of available items to list.
* - codes - list of {code,desc,comment} objects
* - selectedCodes - list of codes.
* - fnCallback - method to call on completion to store codes taking list of selected codes as parameter.
*/
sc.fn.openSelectCode = function (cfg)
{
//sax.debug('openSelectCode', cfg);
sc.fn.init();
sc.cfg = cfg;
sc.selectedCodes = cfg.selectedCodes || [];
sc.fn.displayCodes(cfg.codes);
sax.openDialog(sc.$dlg.dialog('option', { title: cfg.caption || 'Select Codes' }), sc.cfg.width || 400, sc.cfg.height || 400);
}
sc.fn.displayCodes = function (codes)
{
let $codesAvail = $('.sax-selectCode-codes.AvailableCodes').empty();
let $codesSelec = $('.sax-selectCode-codes.SelectedCodes').empty();
let $codeTmpl = $('.sax-panel-item-template .sax-panel-item.Code');
for (let codeIdx = 0; codeIdx < codes.length; codeIdx++)
{
let code = codes[codeIdx];
let selected = sc.selectedCodes.indexOf(code.code) >= 0;
let $code = $codeTmpl.clone();
$($code).prop('id', sc.codeIdPrefix + code.code).attr('aria-code', code.code).on('click', function () { sc.fn.onClickCode(code.code); }).on('dblclick', function () { sc.fn.onDblClickCode(code.code); }).find('.CodeDesc').text(code.desc).end();
if (selected) $codesSelec.append($code);
else $codesAvail.append($code);
}
}
sc.fn.onClickCode = function (code)
{
$('.sax-panel-item.Code').removeClass('sel');
$('.sax-panel-item.Code[aria-code="' + code + '"]').addClass('sel');
}
sc.fn.onDblClickCode = function (code)
{
let codeIdx = sc.selectedCodes.indexOf(code);
//sax.debug('onDblClickCode', code, codeIdx);
if (codeIdx >= 0) sc.selectedCodes.splice(codeIdx, 1); else sc.selectedCodes.push(code)
sc.fn.displayCodes(sc.cfg.codes)
$('.sax-panel-item.Code[aria-code="' + code + '"]').addClass('sel');
}
sc.fn.onClickSelect = function ()
{
let codes = [];
$('.sax-selectCode-codes.AvailableCodes .sax-panel-item.Code.sel').each(function (idx, el)
{
let code = $(el).attr('aria-code');
if (code)
{
codes.push(code);
sc.selectedCodes.push(code);
};
});
sc.fn.displayCodes(sc.cfg.codes)
for (const code of codes)
$('.sax-panel-item.Code[aria-code="' + code + '"]').addClass('sel');
}
sc.fn.onClickRemove = function ()
{
let codes = [];
$('.sax-selectCode-codes.SelectedCodes .sax-panel-item.Code.sel').each(function (idx, el)
{
let code = $(el).attr('aria-code');
if (code)
{
let codeIdx = sc.selectedCodes.indexOf(code);
if (codeIdx >= 0)
{
codes.push(code);
sc.selectedCodes.splice(codeIdx, 1);
}
};
});
sc.fn.displayCodes(sc.cfg.codes)
for (const code of codes)
$('.sax-panel-item.Code[aria-code="' + code + '"]').addClass('sel');
}
sc.fn.storeSelectCode = function ()
{
//sax.debug('storeSelectCode', sc.cfg, sc.selectedCodes);
if (sc.cfg.fnCallback) sc.cfg.fnCallback(sc.selectedCodes);
sc.$dlg.dialog('close');
delete sc.cfg;
delete sc.selectedCodes;
}
//--------------------------------------------------------------
sc.fn.init = function ()
{
if (!sc.$dlg) return;
var opt = sax.dlgOpts();
opt.buttons[sax.dlg.btn.ok] = function () { sc.fn.storeSelectCode(); };
opt.buttons[sax.dlg.btn.cancel] = function () { $(this).dialog('close'); };
sc.$dlg = $('#dlgSelectCode').dialog(opt);
$('.sax-button.Select', sc.$dlg).on('click', function () { sc.fn.onClickSelect(); });
$('.sax-button.Remove', sc.$dlg).on('click', function () { sc.fn.onClickRemove(); });
}
}(window, window.document));
/* The End */
@@ -0,0 +1,124 @@
/*
* Admin - Item selection.
*/
(function (win, doc, undef)
{
"use strict";
let si = sax.data.selectItem = sax.data.selectItem || { items: {}, fn: {}, $dlg: {}, itemIdPrefix: 'Itm_' };
//--------------------------------------------------------------
/*
* Item selection config:
* - caption - dialog title.
* - items - list of objects: { id, name }
* - itemId - currently selected item.
* - fnCallback - method to call on completion to store selected item.
*/
si.fn.selectItem = function (cfg)
{
si.fn.init();
si.cfg = cfg;
si.itemId = cfg.itemId;
si.fn.showSelectItem();
}
si.fn.showSelectItem = function ()
{
$('.SelectedItemName', si.$dlg).text(si.fn.getItemName(si.itemId));
$('#ifItemFilter', si.$dlg).val('');
si.fn.displayItems();
sax.openDialog(si.$dlg.dialog('option', { title: si.cfg.caption || 'Select Item' }), 400, 600);
}
//--------------------------------------------------------------
si.fn.compareItems = function (a, b)
{
var comparison = a.name.toLowerCase().localeCompare(b.name.toLowerCase());
if (comparison === 0)
return a.name.localeCompare(b.name);
return comparison;
}
//--------------------------------------------------------------
si.fn.displayItems = function ()
{
let filter = $('#ifItemFilter', si.$dlg).val();
let reFilter = new RegExp(sax.escapeRegExp((filter || '').trim()), 'i');
let $itemsAvail = $('.sax-selectItem-items.AvailableItems').empty();
let $itemTmpl = $('.sax-panel-item-template .sax-panel-item.Item');
let items = [...si.cfg.items];
items.sort(si.fn.compareItems);
for (let rgnIdx = 0; rgnIdx < items.length; rgnIdx++)
{
let item = items[rgnIdx];
let id = item.id;
if (filter && !item.name.match(reFilter)) continue;
let $item = $itemTmpl.clone();
$item.prop('id', si.itemIdPrefix + id).on('click', function () { si.fn.onClickItem(id); }).on('dblclick', function () { si.fn.onDblClickItem(id); }).find('.ItemName').text(item.name).end();
if (id == si.itemId) $item.addClass('sel');
$itemsAvail.append($item);
}
}
si.fn.getItem = function (id)
{
for (let rgnIdx = 0; rgnIdx < si.cfg.items.length; rgnIdx++)
{
let item = si.cfg.items[rgnIdx];
if (item.id == id) return item;
}
}
si.fn.getItemName = function (id)
{
let item = si.fn.getItem(id);
return item ? item.name : '';
}
//--------------------------------------------------------------
si.fn.onClickItem = function (id)
{
$('.SelectedItemName', si.$dlg).text(si.fn.getItemName(si.itemId = id));
$('.sax-panel-item.Item').removeClass('sel');
$('.sax-panel-item.Item#' + si.itemIdPrefix + id).addClass('sel');
}
si.fn.onDblClickItem = function (id)
{
si.itemId = id;
si.fn.storeSelectItem();
}
si.fn.storeSelectItem = function ()
{
if (!si.itemId) return;
let item = si.fn.getItem(si.itemId);
if (!item) return;
if (si.cfg.fnCallback) si.cfg.fnCallback(item);
si.$dlg.dialog('close');
si.fn.cleanUp();
}
si.fn.cleanUp = function ()
{
delete si.cfg;
delete si.itemId;
}
//--------------------------------------------------------------
si.fn.onDlgSize = function ()
{
let $pnl = $('.sax-selectItem-items.AvailableItems');
$pnl.outerHeight(Math.floor(si.$dlg.innerHeight() - $pnl.position().top - ($pnl.outerHeight(true) - $pnl.innerHeight())));
}
//--------------------------------------------------------------
si.fn.init = function ()
{
if (!si.$dlg) return;
var opt = sax.dlgOpts();
opt.open = function (evt, ui) { si.fn.onDlgSize(); };
opt.resize = function (evt, ui) { si.fn.onDlgSize(); };
opt.buttons[sax.dlg.btn.ok] = function () { si.fn.storeSelectItem(); };
opt.buttons[sax.dlg.btn.cancel] = function () { si.fn.cleanUp(); $(this).dialog('close'); };
si.$dlg = $('#dlgSelectItem').dialog(opt);
}
}(window, window.document));
/* The End */
+132 -122
View File
@@ -1,136 +1,146 @@
/*
* Admin - Sport page scripts.
*/
"use strict";
sax.itemIdPrefix = 'Itm_';
//--------------------------------------------------------------
sax.refreshResults = function (delay)
(function (win, doc, undef)
{
var $results = $('.sax-panel-results');
if (!sax.awaitingRefreshResponse)
{
var $items = $('.sax-panel-item-list', $results).fadeOut(200).empty();
var $msgs = $('.sax-panel-messages', $results).hide().empty().append($('<div class="sax-message">' + sax.msg.dataQuerying + '</div>')).fadeIn(200);
}
sax.ajaxRefreshResults = sax.ajaxRefreshResults || { url: sax.url.base + 'Sport/Ajax/GetList', formId: 'frmSportFilter', callbackFn: sax.doRefreshResults };
sax.doAjaxRequest(sax.ajaxRefreshResults, delay || 50);
sax.awaitingRefreshResponse = true;
}
sax.doRefreshResults = function (response)
{
//sax.debug('doRefreshResults', response);
delete sax.awaitingRefreshResponse;
sax.refreshControlValues(response.controlValues);
var $results = $('.sax-panel-results');
var $msgs = $('.sax-panel-messages', $results).hide().empty();
var $items = $('.sax-panel-item-list', $results).hide().empty();
var $templ = $('.sax-panel-item-template .sax-panel-item.Sport', $results);
if (!response.success) return;
// Items.
var items = response.sports;
if (!items.length)
return $msgs.append($('<div class="sax-message">' + sax.msg.dataNoneFound + '</div>')).fadeIn(500);
for (let itemIdx = 0; itemIdx < items.length; itemIdx++)
{
let item = items[itemIdx];
let $item = $templ.clone();
sax.populateItem($item, item);
$items.append($item);
}
$items.fadeIn(50);
}
sax.populateItem = function ($item, item)
{
if (!item) return;
$item.prop('id', sax.itemIdPrefix + item.id);
$('.SportName', $item).text(item.name);
$('.SportType', $item).text(item.typeDesc);
$('.SportCategory', $item).text(item.categoryDesc);
$('.StatusDesc', $item).text(item.statusDesc);
$('.sax-action.sax-item-update', $item).off('click').on('click', function () { sax.updateItem(item.id) })
}
"use strict";
sax.itemIdPrefix = 'Itm_';
//--------------------------------------------------------------
sax.createItem = function ()
{
$('.SportId,input[type="text"],textarea,select', sax.$frm.sport).val('');
sax.clearControlErrors();
sax.$dlg.sport.dialog('option', 'title', sax.dlg.title.createSport);
sax.openDialog(sax.$dlg.sport, 600, 600);
}
sax.doCreateItem = function ()
{
sax.storeItem();
}
//--------------------------------------------------------------
sax.updateItem = function (id)
{
$('.SportId', sax.$frm.sportId).val(id);
sax.ajaxUpdateItem = sax.ajaxUpdateItem || { url: sax.url.base + 'Sport/Ajax/GetItem', formId: 'frmSportId', callbackFn: sax.onUpdateItem };
sax.doAjaxRequest(sax.ajaxUpdateItem, 50);
}
sax.onUpdateItem = function (response)
{
//sax.debug('onUpdateItem', response);
let $frm = sax.$frm.sport;
$('.SportId,input[type="text"],textarea,select', $frm).val('');
if (!response.success) return;
let item = response.sport;
$('.SportId', $frm).val(item.id);
$('.SportName', $frm).val(item.name);
$('.SportType', $frm).val(item.typeCode);
$('.SportCategory', $frm).val(item.categoryCode);
sax.clearControlErrors();
sax.$dlg.sport.dialog('option', 'title', sax.dlg.title.updateSport);
sax.openDialog(sax.$dlg.sport, 600, 600);
}
sax.doUpdateItem = function ()
{
sax.storeItem();
}
//--------------------------------------------------------------
sax.storeItem = function ()
{
sax.ajaxStoreItem = sax.ajaxStoreItem || { url: sax.url.base + 'Sport/Ajax/StoreItem', formId: 'frmSport', callbackFn: sax.onStoreItem };
sax.doAjaxRequest(sax.ajaxStoreItem, 50);
}
sax.onStoreItem = function (response)
{
//sax.debug('onStoreItem', response);
sax.refreshControlValues(response.controlValues);
if (!response.success) return;
sax.$dlg.sport.dialog('close');
var item = response.sport;
var $item = $('#' + sax.itemIdPrefix + item.id);
if (!$item.length)
//--------------------------------------------------------------
sax.refreshResults = function (delay)
{
var $results = $('.sax-panel-results');
$item = $('.sax-panel-item-template .sax-panel-item.Sport', $results).clone();
$('.sax-panel-item-list', $results).prepend($item).show();
if (!sax.awaitingRefreshResponse)
{
var $items = $('.sax-panel-item-list', $results).fadeOut(200).empty();
var $msgs = $('.sax-panel-messages', $results).hide().empty().append($('<div class="sax-message">' + sax.msg.dataQuerying + '</div>')).fadeIn(200);
}
sax.ajaxRefreshResults = sax.ajaxRefreshResults || { url: sax.url.base + 'Sport/Ajax/GetList', formId: 'frmSportFilter', callbackFn: sax.doRefreshResults };
sax.doAjaxRequest(sax.ajaxRefreshResults, delay || 50);
sax.awaitingRefreshResponse = true;
}
sax.doRefreshResults = function (response)
{
//sax.debug('doRefreshResults', response);
delete sax.awaitingRefreshResponse;
sax.refreshControlValues(response.controlValues);
var $results = $('.sax-panel-results');
var $msgs = $('.sax-panel-messages', $results).hide().empty();
var $items = $('.sax-panel-item-list', $results).hide().empty();
var $templ = $('.sax-panel-item-template .sax-panel-item.Sport', $results);
if (!response.success) return;
// Reference data - Statuses.
if (response.defaultStatusCode) sax.data.defaultStatusCode = response.defaultStatusCode;
if (response.statuses)
sax.populateSelectCodeDesc('#cbSportStatus', response.statuses);
// Items.
var items = response.sports;
if (!items.length)
return $msgs.append($('<div class="sax-message">' + sax.msg.dataNoneFound + '</div>')).fadeIn(500);
for (let itemIdx = 0; itemIdx < items.length; itemIdx++)
{
let item = items[itemIdx];
let $item = $templ.clone();
sax.populateItem($item, item);
$items.append($item);
}
$items.fadeIn(50);
}
sax.populateItem = function ($item, item)
{
if (!item) return;
$item.prop('id', sax.itemIdPrefix + item.id);
$('.SportName', $item).text(item.name);
$('.StatusDesc', $item).text(item.statusDesc);
$('.sax-action.sax-item-update', $item).off('click').on('click', function () { sax.updateItem(item.id) })
}
sax.populateItem($item, item)
}
//--------------------------------------------------------------
$(function ()
{
$('.sax-action.sax-item-create').on('click', function () { sax.createItem(); });
$('.sax-action.sax-results-refresh').on('click', function () { sax.refreshResults(); });
$('.sax-input').on('keydown', function () { sax.clearControlError(this); });
//--------------------------------------------------------------
sax.createItem = function ()
{
let $frm = sax.$frm.sport;
$('.SportId,input[type="text"],textarea,select', $frm).val('');
$('.SportStatus', $frm).val(sax.data.defaultStatusCode);
sax.clearControlErrors();
sax.$dlg.sport.dialog('option', 'title', sax.dlg.title.createSport);
sax.openDialog(sax.$dlg.sport, 600, 600);
}
sax.doCreateItem = function ()
{
sax.storeItem();
}
sax.$frm.sportId = $('#frmSportId');
sax.$frm.sport = $('#frmSport');
//--------------------------------------------------------------
sax.updateItem = function (id)
{
$('.SportId', sax.$frm.sportId).val(id);
sax.ajaxUpdateItem = sax.ajaxUpdateItem || { url: sax.url.base + 'Sport/Ajax/GetItem', formId: 'frmSportId', callbackFn: sax.onUpdateItem };
sax.doAjaxRequest(sax.ajaxUpdateItem, 50);
}
sax.onUpdateItem = function (response)
{
//sax.debug('onUpdateItem', response);
let $frm = sax.$frm.sport;
$('.SportId,input[type="text"],textarea,select', $frm).val('');
if (!response.success) return;
let item = response.sport;
$('.SportId', $frm).val(item.id);
$('.SportName', $frm).val(item.name);
$('.SportStatus', $frm).val(item.statusCode);
sax.clearControlErrors();
sax.$dlg.sport.dialog('option', 'title', sax.dlg.title.updateSport);
sax.openDialog(sax.$dlg.sport, 600, 600);
}
sax.doUpdateItem = function ()
{
sax.storeItem();
}
var opt = sax.dlgOpts();
opt.buttons[sax.dlg.btn.ok] = function () { sax.doCreateItem(); };
opt.buttons[sax.dlg.btn.cancel] = function () { $(this).dialog('close'); };
sax.$dlg.sport = $('#dlgSport').dialog(opt);
//--------------------------------------------------------------
sax.storeItem = function ()
{
sax.ajaxStoreItem = sax.ajaxStoreItem || { url: sax.url.base + 'Sport/Ajax/StoreItem', formId: 'frmSport', callbackFn: sax.onStoreItem };
sax.doAjaxRequest(sax.ajaxStoreItem, 50);
}
sax.onStoreItem = function (response)
{
//sax.debug('onStoreItem', response);
sax.refreshControlValues(response.controlValues);
if (!response.success) return;
sax.$dlg.sport.dialog('close');
setTimeout(sax.refreshResults, 250);
});
var item = response.sport;
var $item = $('#' + sax.itemIdPrefix + item.id);
if (!$item.length)
{
var $results = $('.sax-panel-results');
$item = $('.sax-panel-item-template .sax-panel-item.Sport', $results).clone();
$('.sax-panel-item-list', $results).prepend($item).show();
}
sax.populateItem($item, item)
}
//--------------------------------------------------------------
//--------------------------------------------------------------
$(function ()
{
$('.sax-action.sax-item-create').on('click', function () { sax.createItem(); });
$('.sax-action.sax-results-refresh').on('click', function () { sax.refreshResults(); });
$('.sax-input').on('input', function () { sax.clearControlError(this); });
sax.$frm.filter = $('#frmSportFilter');
$('.FilterSport', sax.$frm.filter).on('input', function () { sax.refreshResults(250); });
sax.$frm.sportId = $('#frmSportId');
sax.$frm.sport = $('#frmSport');
var opt = sax.dlgOpts();
opt.buttons[sax.dlg.btn.ok] = function () { sax.doCreateItem(); };
opt.buttons[sax.dlg.btn.cancel] = function () { $(this).dialog('close'); };
sax.$dlg.sport = $('#dlgSport').dialog(opt);
setTimeout(sax.refreshResults, 250);
});
}(window, window.document));
/* The End */
+14 -4
View File
@@ -31,9 +31,13 @@
var $items = $('.sax-panel-item-list', $results).hide().empty();
var $templ = $('.sax-panel-item-template .sax-panel-item.User', $results);
if (!response.success) return;
// Reference data.
// Reference data - Roles.
if (response.userRoles && response.userRoles.length)
sax.data.userRoles = response.userRoles;
// Reference data - Statuses.
if (response.defaultStatusCode) sax.data.defaultStatusCode = response.defaultStatusCode;
if (response.statuses)
sax.populateSelectCodeDesc('#cbUserStatus', response.statuses);
// Items.
var items = response.users;
if (!items.length)
@@ -72,7 +76,7 @@
sax.selectUserRoleConfig = sax.selectUserRoleConfig || { caption: sax.dlg.title.selectUserRoles, width: 520, fnCallback: sax.updateUserRoles };
sax.selectUserRoleConfig.codes = sax.data.userRoles;
sax.selectUserRoleConfig.selectedCodes = sax.userAccount.userRoleCodes || [];
sax.codeSelection.fn.openCodeSelection(sax.selectUserRoleConfig);
sax.selectCode.fn.openSelectCode(sax.selectUserRoleConfig);
}
sax.updateUserRoles = function (userRoleCodes)
{
@@ -97,7 +101,9 @@
//--------------------------------------------------------------
sax.createItem = function ()
{
$('.UserAccountId,.UserRoleCodes,input[type="text"],textarea,select', sax.$frm.user).val('');
let $frm = sax.$frm.user;
$('.UserAccountId,.UserRoleCodes,input[type="text"],textarea,select', $frm).val('');
$('.UserStatus', $frm).val(sax.data.defaultStatusCode);
sax.clearControlErrors();
sax.userAccount = { userRoleCodes: [] };
sax.$dlg.user.dialog('option', 'title', sax.dlg.title.createUser);
@@ -130,6 +136,7 @@
$('.UserLastName', $frm).val(item.lastName);
$('.UserRoles', $frm).val(sax.getSelectedUserRoleDescs().join('\n'));
$('#ifUserRoleCodes').val(item.userRoleCodes.join(sax.data.userRoleCodeDelim));
$('.UserStatus', $frm).val(item.statusCode);
sax.$dlg.user.dialog('option', 'title', sax.dlg.title.updateUser);
sax.openDialog(sax.$dlg.user, 600, 600);
}
@@ -167,8 +174,11 @@
{
$('.sax-action.sax-item-create').on('click', function () { sax.createItem(); });
$('.sax-action.sax-results-refresh').on('click', function () { sax.refreshResults(); });
$('.sax-input,.sax-select').on('keydown click', function () { sax.clearControlError(this); });
$('.sax-input').on('input', function () { sax.clearControlError(this); });
$('.sax-select').on('click', function () { sax.clearControlError(this); });
sax.$frm.filter = $('#frmUserFilter');
$('.FilterUser', sax.$frm.filter).on('input', function () { sax.refreshResults(250); });
sax.$frm.userId = $('#frmUserId');
sax.$frm.user = $('#frmUser');
@@ -50,7 +50,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
{
String fn = GetType().Name + ".GetProfileContact";
AjaxResponse_AccountContactData responseData = new AjaxResponse_AccountContactData();
String messageTitle = Localiser["account.caption.contact"];
String messageTitle = Localiser["account.caption.profile.contact"];
// Validate session and referrer.
if (!ValidReferer)
@@ -58,11 +58,6 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
if (!ValidUserSession)
return GetAjaxResult_InvalidSession(responseData);
// Validate data.
model.ValidateContactDetails(responseData);
if (responseData.HasControlErrors())
return Json(responseData);
// Retrieve user details.
SaxUserAccount userAccount = AccountMgr.GetUserAccountById(SessionData.User.UserAccountId);
if (userAccount == null)
@@ -92,7 +87,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
{
String fn = GetType().Name + ".StoreProfileContact";
AjaxResponse_StoreAccountContactDetails responseData = new AjaxResponse_StoreAccountContactDetails();
String messageTitle = Localiser["account.caption.contact"];
String messageTitle = Localiser["account.caption.profile.contact"];
// Validate session and referrer.
if (!ValidReferer)
@@ -0,0 +1,89 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Saxonite.Net.Core.Web.Online.Models;
using Saxonite.Net.Core.Web.Base.App;
using Saxonite.Net.Core.Web.Base.Controllers;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Saxonite.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Utils;
namespace Saxonite.Net.Core.Web.Online.Controllers
{
//=======================================================================
// Online Account Controller - Ajax actions.
//=======================================================================
partial class AccountController
{
//-------------------------------------------------------------------
// Account - Get Organisations.
//-------------------------------------------------------------------
public class ProfileOrganisationResponseData
{
public ProfileOrganisationResponseData(SaxOrganisation organisation)
{
Name = organisation.Name;
}
public String Name { get; }
}
public class AjaxResponse_ProfileOrganisationsData : AjaxResponse_Data
{
public List<ProfileOrganisationResponseData> Organisations { get; } = new List<ProfileOrganisationResponseData>();
}
// Ajax request.
[HttpPost]
[Route("Account/Ajax/GetProfileOrganisations")]
public IActionResult GetProfileOrganisations(Model_Account model)
{
String fn = GetType().Name + ".GetProfileOrganisations";
AjaxResponse_ProfileOrganisationsData responseData = new AjaxResponse_ProfileOrganisationsData();
String messageTitle = Localiser["account.caption.profile.organisations"];
// Validate session and referrer.
if (!ValidReferer)
return Forbid();
if (!ValidUserSession)
return GetAjaxResult_InvalidSession(responseData);
// Retrieve users organisations.
SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params();
prmUserOrganisation.UserAccountIdsIncluded.Add(SessionData.User.UserAccountId);
prmUserOrganisation.OrganisationMembersOnly = true;
prmUserOrganisation.StatusCat = SaxUserOrganisation.StatusCat.ActiveOnly;
List<SaxUserOrganisation> userOrganisations = AccountMgr.GetUserOrganisationList(prmUserOrganisation);
List<SysId> organisationIds = userOrganisations.GetOrganisationIds();
// Retrieve the organisation details.
List<SaxOrganisation> organisations = new List<SaxOrganisation>();
if (!organisationIds.IsEmpty())
{
SaxOrganisation.Params prmOrganisation = new SaxOrganisation.Params();
prmOrganisation.IdsIncluded.AddRange(organisationIds);
prmOrganisation.StatusCat = SaxOrganisation.StatusCat.ActiveOnly;
prmOrganisation.SortColumns.Add(AccountMgr.GetOrganisationColumnDfn(SaxOrganisation.Column.Name));
organisations.AddRange(AccountMgr.GetOrganisationList(prmOrganisation));
}
// Add the organisations to the response.
foreach (SaxUserOrganisation userOrganisation in userOrganisations)
{
SaxOrganisation organisation = organisations.GetOrganisationById(userOrganisation.OrganisationId);
if (organisation == null) continue;
ProfileOrganisationResponseData organisationData = new ProfileOrganisationResponseData(organisation);
responseData.Organisations.Add(organisationData);
}
// Complete response.
responseData.Success = true;
return Json(responseData);
}
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -328,7 +328,11 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
// Retrieve user account.
SaxUserAccount userAccount = AccountMgr.GetUserAccountByEmailAddress(model.EmailAddress);
if (userAccount != null && (userAccount.IsStatusActive || DebugMode))
if (userAccount == null)
SaLogger.Warn(fn + " Unable to send password request email to " + model.EmailAddress + " - account does not exist");
else if (!userAccount.IsStatusActive)
SaLogger.Warn(fn + " Unable to send password request email to " + model.EmailAddress + " - account is not active");
else
{
// Send password request email.
SaEmailData emailData = new SaEmailData();
@@ -340,11 +344,6 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
SaLogger.Info(fn + " Password request email sent to " + model.EmailAddress, true);
else SaLogger.Warn(fn + " Failed to send password request email to " + model.EmailAddress);
}
else
{
if (userAccount == null) SaLogger.Warn(fn + " Unable to send password request email to " + model.EmailAddress + " - account does not exist");
else if (!userAccount.IsStatusActive) SaLogger.Warn(fn + " Unable to send password request email to " + model.EmailAddress + " - account is not active");
}
// Construct response.
responseData.Success = true;
@@ -79,12 +79,16 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
String logSuffix = requestPasswordParams.GetValidParams().Concat("", " ", ".");
using (SaxUserAccount userAccount = AccountMgr.GetUserAccountById(requestPasswordParams.UserAccountId))
{
if (requestPasswordParams.IsValid(userAccount))
if (userAccount.IsStatusActive)
{
model.rpe = encryptedParams;
validSessionRequired = false;
if (requestPasswordParams.IsValid(userAccount))
{
model.rpe = encryptedParams;
validSessionRequired = false;
}
else SaLogger.Warn(fn + " 'Request Password' parameters supplied but invalid. " + logSuffix);
}
else SaLogger.Warn(fn + " 'Request Password' parameters supplied but invalid. " + logSuffix);
else SaLogger.Warn(fn + " 'Request Password' parameters supplied but account is not active. " + logSuffix);
}
}
}
@@ -9,15 +9,33 @@
<div class="row">
<div class="col"><div class="sax-caption">@Localiser["account.caption.profile.organisations"]</div></div>
<div class="fixed">
<div class="sax-action sax-edit"><img src="~/img/action/edit24.png" alt="@(Localiser["label.update"])" title="@(Localiser["label.update"])" /></div>
<!-- <div class="sax-action sax-edit"><img src="~/img/action/edit24.png" alt="@(Localiser["label.update"])" title="@(Localiser["label.update"])" /></div> -->
</div>
</div>
</div>
<div class="sax-content">
<div class="sax-panel-results Organisations">
</div>
</div>
<div class="sax-panel-item-template">
<div class="sax-panel-item Organisation">
<div class="sax-header">
<div class="OrganisationName"></div>
</div>
<div class="sax-content">
<div class="row">
<div class="col-sm-6"><div class=""></div></div>
<div class="col-sm-6"><div class=""></div></div>
</div>
</div>
</div>
</div>
</div>
<div class="sax-panel-form">
@@ -34,8 +52,6 @@
@using (@Html.BeginForm(FormMethod.Post, new { @id = "frmProfileOrganisations", @class = "sax-form", @onSubmit = "return false;" }))
{
}
</div>
@@ -1,9 +1,9 @@
@model SaxModel_Online
@inject SaxLocaliser Localiser
<link rel="stylesheet" href="~/css/sax-regionSelection.css?@Model.HrefVersion" />
<link rel="stylesheet" href="~/css/sax-selectRegion.css?@Model.HrefVersion" />
<div id="dlgRegionSelection" class="sax-dialog sax-form">
<div id="dlgSelectRegion" class="sax-dialog sax-form">
<div class="container-fluid h-100">
@@ -20,7 +20,7 @@
<div class="RegionFilter sax-form">
<div class="row">
<div class="col right"><div class="sax-label">@Localiser["label.search"]</div></div>
<div class="fixed"><input id="ifRegionFilter" class="sax-input" type="text" onkeyup="sax.data.regionSel.fn.displayRegions();" /></div>
<div class="fixed"><input id="ifRegionFilter" class="sax-input" type="text" onkeyup="sax.data.selectRegion.fn.displayRegions();" /></div>
</div>
<div class="spacer2"></div>
</div>
@@ -32,7 +32,7 @@
<div class="row">
<div class="col-sm-12 sax-regionSelection-regions AvailableRegions"></div>
<div class="col-sm-12 sax-selectRegion-regions AvailableRegions"></div>
</div>
@@ -44,6 +44,6 @@
</div>
</div>
<script src="~/js/sax-regionSelection.js?@Model.HrefVersion"></script>
<script src="~/js/sax-selectRegion.js?@Model.HrefVersion"></script>
</div>
@@ -1,9 +1,9 @@
@model SaxModel_Online
@inject SaxLocaliser Localiser
<link rel="stylesheet" href="~/css/sax-sportSelection.css?@Model.HrefVersion" />
<link rel="stylesheet" href="~/css/sax-selectSport.css?@Model.HrefVersion" />
<div id="dlgSportSelection" class="sax-dialog sax-form">
<div id="dlgSelectSport" class="sax-dialog sax-form">
<div class="container-fluid h-100">
@@ -20,7 +20,7 @@
<div class="SportFilter sax-form">
<div class="row">
<div class="col right"><div class="sax-label">@Localiser["label.search"]</div></div>
<div class="fixed"><input id="ifSportFilter" class="sax-input" type="text" onkeyup="sax.data.sportSel.fn.displaySports();" /></div>
<div class="fixed"><input id="ifSportFilter" class="sax-input" type="text" onkeyup="sax.data.selectSport.fn.displaySports();" /></div>
</div>
<div class="spacer2"></div>
</div>
@@ -32,7 +32,7 @@
<div class="row">
<div class="col-sm-12 sax-sportSelection-sports AvailableSports"></div>
<div class="col-sm-12 sax-selectSport-sports AvailableSports"></div>
</div>
@@ -44,6 +44,6 @@
</div>
</div>
<script src="~/js/sax-sportSelection.js?@Model.HrefVersion"></script>
<script src="~/js/sax-selectSport.js?@Model.HrefVersion"></script>
</div>
@@ -71,7 +71,7 @@
}
<partial name="~/Views/Common/RegionSelection.cshtml" />
<partial name="~/Views/Common/SportSelection.cshtml" />
<partial name="~/Views/Common/SelectRegion.cshtml" />
<partial name="~/Views/Common/SelectSport.cshtml" />
</div>
@@ -18,7 +18,7 @@
overflow: hidden;
}
.sax-profile .sax-header
.sax-profile > .sax-header
{
padding: 4px 8px;
background-color: #e8e8e8;
@@ -44,11 +44,18 @@
border-color: var(--color-profile);
}
.sax-profile .sax-panel-info .sax-header,
.sax-profile .sax-panel-form .sax-header
.sax-profile .sax-panel-info > .sax-header,
.sax-profile .sax-panel-form > .sax-header
{
padding: 4px 8px;
background-color: #e8e8e8;
border-bottom: solid 1px #b0b0b0;
border-color: var(--color-profile);
}
.sax-profile .sax-panel-results .sax-panel-info > .sax-header
{
text-align:left;
}
/* The End */
+18 -10
View File
@@ -21,7 +21,7 @@
}
}
.sax-panel-filter .sax-header
.sax-panel-filter > .sax-header
{
padding: 2px 8px;
min-height: 24px;
@@ -30,39 +30,39 @@
border-bottom: solid 2px #979797;
}
.sax-panel-filter .sax-header .sax-caption
.sax-panel-filter > .sax-header .sax-caption
{
margin-top: 4px;
font-size: 1.2rem;
font-weight: bold;
}
.sax-panel-filter .sax-header .sax-action
.sax-panel-filter > .sax-header .sax-action
{
margin: 2px 0 0 8px;
border-radius: 4px;
}
.sax-panel-filter .sax-header .sax-action:hover
.sax-panel-filter > .sax-header .sax-action:hover
{
background-color: #b0b0b0;
box-shadow: 0 0 4px 2px #80808080;
}
.sax-panel-filter .sax-content
.sax-panel-filter > .sax-content
{
margin: 4px 8px;
padding: 4px 8px;
}
.sax-panel-filter .sax-content .sax-label
.sax-panel-filter > .sax-content .sax-label
{
padding-top: 2px;
padding-right: 12px;
text-align: right;
}
.sax-panel-filter .sax-content .sax-button
.sax-panel-filter > .sax-content .sax-button
{
min-width: auto;
margin-left: 4px;
@@ -110,7 +110,7 @@
overflow:hidden;
}
.sax-panel-item .sax-header
.sax-panel-item > .sax-header
{
padding: 2px 8px;
min-height: 24px;
@@ -125,16 +125,24 @@
font-weight: bold;
}
.sax-panel-item .sax-content
.sax-panel-item > .sax-content
{
margin: 6px 8px;
padding: 4px 4px;
}
/* Organisations */
.sax-panel-item.Organisation,
.sax-panel-item.Organisation > .sax-header
{
border-color: var(--color-alt3);
}
/* Articles */
.sax-panel-item.Article,
.sax-panel-item.Article .sax-header
.sax-panel-item.Article > .sax-header
{
border-color: #23397a;
}
@@ -30,8 +30,8 @@
}
}
.sax-panel-info .sax-header,
.sax-panel-form .sax-header
.sax-panel-info > .sax-header,
.sax-panel-form > .sax-header
{
padding: 12px 12px;
text-align: center;
@@ -40,24 +40,24 @@
border-color: var(--color-primary);
}
.sax-panel-info .sax-header .sax-caption,
.sax-panel-form .sax-header .sax-caption
.sax-panel-info > .sax-header .sax-caption,
.sax-panel-form > .sax-header .sax-caption
{
font-size: 1.5rem;
font-weight: bold;
color: var(--color-primary-dark);
}
.sax-panel-info .sax-header .sax-action img:hover,
.sax-panel-form .sax-header .sax-action img:hover
.sax-panel-info > .sax-header .sax-action img:hover,
.sax-panel-form > .sax-header .sax-action img:hover
{
background-color: #f0f0f0;
border-radius:4px;
box-shadow: 2px 2px 4px 0 #80808080;
}
.sax-panel-info .sax-content,
.sax-panel-form .sax-content
.sax-panel-info > .sax-content,
.sax-panel-form > .sax-content
{
padding: 24px 24px;
}
@@ -4,7 +4,7 @@
/* Panels */
#dlgRegionSelection .SelectedRegionName
#dlgSelectRegion .SelectedRegionName
{
min-height: 1rem;
padding: 2px 4px;
@@ -14,18 +14,18 @@
overflow: hidden;
}
#dlgRegionSelection .RegionFilter .sax-label
#dlgSelectRegion .RegionFilter .sax-label
{
margin-right: 6px;
}
#dlgRegionSelection .sax-button
#dlgSelectRegion .sax-button
{
padding: 2px 8px;
border-radius: 6px;
}
#dlgRegionSelection .sax-regionSelection-regions
#dlgSelectRegion .sax-selectRegion-regions
{
margin-bottom: 8px;
padding: 2px 0;
@@ -37,12 +37,12 @@
overflow-y: scroll;
}
#dlgRegionSelection.sax-form button.sax-button
#dlgSelectRegion.sax-form button.sax-button
{
margin: 4px 0;
}
#dlgRegionSelection .sax-panel-item.Region
#dlgSelectRegion .sax-panel-item.Region
{
margin: 2px 4px;
padding: 2px 4px;
@@ -52,7 +52,7 @@
cursor: pointer;
}
#dlgRegionSelection .sax-panel-item.Region.sel
#dlgSelectRegion .sax-panel-item.Region.sel
{
background-color: #ececff;
border-color: #8a8aff;
@@ -4,7 +4,7 @@
/* Panels */
#dlgSportSelection .SelectedSportName
#dlgSelectSport .SelectedSportName
{
min-height: 1rem;
padding: 2px 4px;
@@ -14,18 +14,18 @@
overflow: hidden;
}
#dlgSportSelection .SportFilter .sax-label
#dlgSelectSport .SportFilter .sax-label
{
margin-right: 6px;
}
#dlgSportSelection .sax-button
#dlgSelectSport .sax-button
{
padding: 2px 8px;
border-radius: 6px;
}
#dlgSportSelection .sax-sportSelection-sports
#dlgSelectSport .sax-selectSport-sports
{
margin-bottom: 8px;
padding: 2px 0;
@@ -37,12 +37,12 @@
overflow-y: scroll;
}
#dlgSportSelection.sax-form button.sax-button
#dlgSelectSport.sax-form button.sax-button
{
margin: 4px 0;
}
#dlgSportSelection .sax-panel-item.Sport
#dlgSelectSport .sax-panel-item.Sport
{
margin: 2px 4px;
padding: 2px 4px;
@@ -52,7 +52,7 @@
cursor: pointer;
}
#dlgSportSelection .sax-panel-item.Sport.sel
#dlgSelectSport .sax-panel-item.Sport.sel
{
background-color: #ececff;
border-color: #8a8aff;
+161 -120
View File
@@ -1,134 +1,175 @@
/*
* Account page scripts.
*/
"use strict";
//--------------------------------------------------------------
sax.refreshProfile = function ()
(function (win, doc, undef)
{
setTimeout(sax.refreshProfileContactInfo, 50);
setTimeout(sax.refreshSportsInfo, 50);
setTimeout(sax.refreshOrganisations, 50);
}
"use strict";
//--------------------------------------------------------------
sax.refreshProfileContactInfo = function ()
{
var $section = $('.sax-panel-section.ProfileContact');
$section.removeClass('sax-edit').addClass('sax-populating');
$('.sax-property', $section).hide();
sax.showDataRefreshingMsg($section);
sax.refreshProfileContact(sax.onRefreshProfileContactInfo);
}
sax.refreshProfileContactForm = function ()
{
if (!sax.closeEditPanels()) return;
sax.refreshProfileContact(sax.onRefreshProfileContactForm);
}
sax.refreshProfileContact = function (callbackFn)
{
delete sax.page.profileContactChanged;
sax.ajaxProfileContact = sax.ajaxProfileContact || { url: sax.url.base + 'Account/Ajax/GetProfileContact', formId: 'frmNavigate', noWaitIcon: true };
sax.ajaxProfileContact.callbackFn = callbackFn;
sax.doAjaxRequest(sax.ajaxProfileContact, 50);
}
sax.onRefreshProfileContactInfo = function (response)
{
//sax.debug('onRefreshProfileContactInfo', response);
if (!response || !response.success || !response.contact) return;
var $section = $('.sax-panel-section.ProfileContact');
$('.sax-message', $section).stop(true, false).fadeOut(200).empty();
$('.sax-value', $section).empty();
sax.refreshInfo($section, 'AccountEmailAddress', response.contact.emailAddress);
sax.refreshInfo($section, 'AccountName', response.contact.displayName);
sax.showNoInfoMsg($section);
$section.removeClass('sax-populating');
}
sax.onRefreshProfileContactForm = function (response)
{
if (!response || !response.success) return;
var $section = $('.sax-panel-section.ProfileContact');
$('.sax-message', $section).stop(true, false).fadeOut(200).empty();
sax.refreshInput($section, 'AccountEmailAddress', response.contact.emailAddress);
sax.refreshSelect($section, 'AccountTitle', response.contact.title);
sax.refreshInput($section, 'AccountFirstName', response.contact.firstName);
sax.refreshInput($section, 'AccountLastName', response.contact.lastName);
$section.addClass('sax-edit');
}
sax.doStoreProfileContact = function ()
{
sax.clearControlErrors();
sax.ajaxStoreProfileContact = sax.ajaxStoreProfileContact || { url: sax.url.base + 'Account/Ajax/StoreProfileContact', formId: 'frmProfileContact', callbackFn: sax.onStoreProfileContact };
sax.doAjaxRequest(sax.ajaxStoreProfileContact, 50);
}
sax.onStoreProfileContact = function (response)
{
sax.refreshControlValues(response.controlValues);
if (!response.success)
//--------------------------------------------------------------
sax.refreshProfile = function ()
{
return;
setTimeout(sax.refreshProfileContactInfo, 50);
setTimeout(sax.refreshSportsInfo, 50);
setTimeout(sax.refreshOrganisationsInfo, 50);
}
sax.refreshProfileContactInfo();
}
//--------------------------------------------------------------
sax.refreshSportsInfo = function ()
{
}
//--------------------------------------------------------------
sax.refreshOrganisationsInfo = function ()
{
}
//--------------------------------------------------------------
sax.showDataRefreshingMsg = function ($section)
{
//$('.sax-message', $section).html(sax.msg.dataRefreshing).fadeIn(200);
}
sax.showNoInfoMsg = function ($section)
{
if (!$('.sax-value', $section).text().length)
$('.sax-message', $section).html(sax.msg.noInformation).fadeIn(200);
}
sax.closeEditPanels = function ()
{
if (sax.page.profileContactChanged || sax.page.profileSportsChanged || sax.page.profileOrganisationsChanged)
//--------------------------------------------------------------
sax.refreshProfileContactInfo = function ()
{
sax.doAlert(sax.msg.changesMade);
return false;
var $section = $('.sax-panel-section.ProfileContact');
$section.removeClass('sax-edit').addClass('sax-populating');
$('.sax-property', $section).hide();
sax.showDataRefreshingMsg($section);
sax.refreshProfileContact(sax.onRefreshProfileContactInfo);
}
sax.refreshProfileContactForm = function ()
{
if (!sax.closeEditPanels()) return;
sax.refreshProfileContact(sax.onRefreshProfileContactForm);
}
sax.refreshProfileContact = function (callbackFn)
{
delete sax.page.profileContactChanged;
sax.ajaxProfileContact = sax.ajaxProfileContact || { url: sax.url.base + 'Account/Ajax/GetProfileContact', formId: 'frmNavigate', noWaitIcon: true };
sax.ajaxProfileContact.callbackFn = callbackFn;
sax.doAjaxRequest(sax.ajaxProfileContact, 50);
}
sax.onRefreshProfileContactInfo = function (response)
{
//sax.debug('onRefreshProfileContactInfo', response);
if (!response || !response.success || !response.contact) return;
var $section = $('.sax-panel-section.ProfileContact');
$('.sax-message', $section).stop(true, false).fadeOut(200).empty();
$('.sax-value', $section).empty();
sax.refreshInfo($section, 'AccountEmailAddress', response.contact.emailAddress);
sax.refreshInfo($section, 'AccountName', response.contact.displayName);
sax.showNoInfoMsg($section);
$section.removeClass('sax-populating');
}
sax.onRefreshProfileContactForm = function (response)
{
if (!response || !response.success) return;
var $section = $('.sax-panel-section.ProfileContact');
$('.sax-message', $section).stop(true, false).fadeOut(200).empty();
sax.refreshInput($section, 'AccountEmailAddress', response.contact.emailAddress);
sax.refreshSelect($section, 'AccountTitle', response.contact.title);
sax.refreshInput($section, 'AccountFirstName', response.contact.firstName);
sax.refreshInput($section, 'AccountLastName', response.contact.lastName);
$section.addClass('sax-edit');
}
sax.doStoreProfileContact = function ()
{
sax.clearControlErrors();
sax.ajaxStoreProfileContact = sax.ajaxStoreProfileContact || { url: sax.url.base + 'Account/Ajax/StoreProfileContact', formId: 'frmProfileContact', callbackFn: sax.onStoreProfileContact };
sax.doAjaxRequest(sax.ajaxStoreProfileContact, 50);
}
sax.onStoreProfileContact = function (response)
{
sax.refreshControlValues(response.controlValues);
if (!response.success)
{
return;
}
sax.refreshProfileContactInfo();
}
$('.sax-panel-section').removeClass('sax-edit');
return true;
}
sax.refreshInfo = function ($section, name, value)
{
$('.' + name + ' .sax-value', $section).html(value).closest('.sax-property').toggle(!!value);
}
sax.refreshInput = function ($section, name, value)
{
$('.' + name + ' input.sax-input', $section).val(value);
}
sax.refreshTextArea = function ($section, name, value)
{
var $textarea = $('.' + name + ' textarea.sax-textarea', $section);
$textarea.val(value);
}
sax.refreshSelect = function ($section, name, value)
{
var $select = $('.' + name + ' select.sax-select', $section);
$select.val(value);
$select.scrollTop(0);
sax.setItemsSelectedLabel($select);
}
//--------------------------------------------------------------
$(function ()
{
$('.sax-panel-section.ProfileContact .sax-action.sax-edit').on('click', function (evt) { sax.refreshProfileContactForm(); });
$('input,textarea,select', '.sax-panel-section.ProfileContact').on('change', function () { sax.clearControlErrors(); sax.page.profileContactChanged = true; });
//--------------------------------------------------------------
sax.refreshSportsInfo = function ()
{
}
setTimeout(sax.refreshProfile, 200);
});
//--------------------------------------------------------------
sax.refreshOrganisationsInfo = function (delay)
{
var $section = $('.sax-panel-section.ProfileOrganisations');
$section.removeClass('sax-edit').addClass('sax-populating');
$('.sax-property', $section).hide();
sax.showDataRefreshingMsg($section);
sax.refreshProfileOrganisations(sax.onRefreshProfileOrganisationsInfo);
}
sax.refreshProfileOrganisations = function (callbackFn)
{
//sax.debug('refreshProfileOrganisations');
delete sax.page.profileOrganisationsChanged;
sax.ajaxProfileOrganisations = sax.ajaxProfileOrganisations || { url: sax.url.base + 'Account/Ajax/GetProfileOrganisations', formId: 'frmNavigate', noWaitIcon: true };
sax.ajaxProfileOrganisations.callbackFn = callbackFn;
sax.doAjaxRequest(sax.ajaxProfileOrganisations, 50);
}
sax.onRefreshProfileOrganisationsInfo = function (response)
{
sax.debug('onRefreshProfileOrganisationsInfo', response);
if (!response || !response.success) return;
var $section = $('.sax-panel-section.ProfileOrganisations');
$('.sax-message', $section).stop(true, false).fadeOut(200).empty();
//--------------------------------------------------------------
let items = response.organisations;
if (!items) return;
let $items = $('.sax-panel-results.Organisations', $section).empty();
let $tmpl = $('.sax-panel-item-template .sax-panel-item.Organisation', $section);
for (let itemIdx = 0; itemIdx < items.length; itemIdx++)
{
let item = items[itemIdx];
let $item = $tmpl.clone();
sax.debug(item, $item);
$('.OrganisationName', $item).text(item.name);
$items.append($item);
}
$items.show();
sax.showNoInfoMsg($section);
$section.removeClass('sax-populating');
}
//--------------------------------------------------------------
sax.showDataRefreshingMsg = function ($section)
{
//$('.sax-message', $section).html(sax.msg.dataRefreshing).fadeIn(200);
}
sax.showNoInfoMsg = function ($section)
{
if (!$('.sax-value', $section).text().length)
$('.sax-message', $section).html(sax.msg.noInformation).fadeIn(200);
}
sax.closeEditPanels = function ()
{
if (sax.page.profileContactChanged || sax.page.profileSportsChanged || sax.page.profileOrganisationsChanged)
{
sax.doAlert(sax.msg.changesMade);
return false;
}
$('.sax-panel-section').removeClass('sax-edit');
return true;
}
sax.refreshInfo = function ($section, name, value)
{
$('.' + name + ' .sax-value', $section).html(value).closest('.sax-property').toggle(!!value);
}
sax.refreshInput = function ($section, name, value)
{
$('.' + name + ' input.sax-input', $section).val(value);
}
sax.refreshTextArea = function ($section, name, value)
{
var $textarea = $('.' + name + ' textarea.sax-textarea', $section);
$textarea.val(value);
}
sax.refreshSelect = function ($section, name, value)
{
var $select = $('.' + name + ' select.sax-select', $section);
$select.val(value);
$select.scrollTop(0);
sax.setItemsSelectedLabel($select);
}
//--------------------------------------------------------------
$(function ()
{
$('.sax-panel-section.ProfileContact .sax-action.sax-edit').on('click', function (evt) { sax.refreshProfileContactForm(); });
$('input,textarea,select', '.sax-panel-section.ProfileContact').on('change', function () { sax.clearControlErrors(); sax.page.profileContactChanged = true; });
setTimeout(sax.refreshProfile, 200);
});
}(window, window.document));
/* The End */
+165 -160
View File
@@ -1,173 +1,178 @@
/*
* Journalist - Articles page scripts.
*/
"use strict";
sax.itemIdPrefix = 'Itm_';
//--------------------------------------------------------------
sax.refreshResults = function (delay)
(function (win, doc, undef)
{
var $results = $('.sax-panel-results');
if (!sax.awaitingRefreshResponse)
{
var $items = $('.sax-panel-item-list', $results).fadeOut(200).empty();
var $msgs = $('.sax-panel-messages', $results).hide().empty().append($('<div class="sax-message">' + sax.msg.dataQuerying + '</div>')).fadeIn(200);
}
sax.ajaxRefreshResults = sax.ajaxRefreshResults || { url: sax.url.base + 'Journalist/Ajax/GetArticleList', formId: 'frmArticleFilter', callbackFn: sax.doRefreshResults };
sax.doAjaxRequest(sax.ajaxRefreshResults, delay||50);
sax.awaitingRefreshResponse = true;
}
sax.doRefreshResults = function (response)
{
sax.debug('doRefreshResults', response);
delete sax.awaitingRefreshResponse;
sax.refreshControlValues(response.controlValues);
var $results = $('.sax-panel-results');
var $msgs = $('.sax-panel-messages', $results).hide().empty();
var $items = $('.sax-panel-item-list', $results).hide().empty();
var $templ = $('.sax-panel-item-template .sax-panel-item', $results);
if (!response.success) return;
var items = response.articles;
if (!items.length)
return $msgs.append($('<div class="sax-message">' + sax.msg.dataNoneFound + '</div>')).fadeIn(500);
for (let itemIdx = 0; itemIdx < items.length; itemIdx++)
{
let item = items[itemIdx];
let $item = $templ.clone();
sax.populateItem($item, item);
$items.append($item);
}
$items.fadeIn(50);
}
sax.populateItem = function ($item, item)
{
if (!item) return;
$item.prop('id', sax.itemIdPrefix + item.id);
$('.ArticleHeadline', $item).text(item.headline);
$('.ArticleSummary', $item).text(item.summary);
$('.ArticleRegionCaption', $item).text(item.regionCaptionPrimary);
$('.ArticleSportCaption', $item).text(item.sportCaptionPrimary);
$('.ArticleCreatedOn', $item).text(item.createdOnFmt);
$('.ArticlePublishedOn', $item).text(item.publishedOnFmt);
$('.ArticlePublished', $item).toggle(item.publishedOnFmt);
$('.ArticleStatusDesc', $item).text(item.statusDesc);
$('.sax-action.sax-item-update', $item).off('click').on('click', function () { sax.updateItem(item.id) })
}
"use strict";
sax.itemIdPrefix = 'Itm_';
//--------------------------------------------------------------
sax.selectRegion = function ()
{
sax.data.regionSel.fn.selectRegion({ caption: sax.dlg.title.selectRegion, regionId: $('#ifArticleRegionId').val(), fnCallback: sax.onSelectRegion })
}
sax.onSelectRegion = function (region)
{
sax.clearControlError($('#ifArticleRegionId').val(region.id));
$('#ifArticleRegionCaption').val(region ? region.name : '');
}
//--------------------------------------------------------------
sax.selectSport = function ()
{
sax.data.sportSel.fn.selectSport({ caption: sax.dlg.title.selectSport, sportId: $('#ifArticleSportId').val(), fnCallback: sax.onSelectSport })
}
sax.onSelectSport = function (sport)
{
sax.clearControlError($('#ifArticleSportId').val(sport.id));
$('#ifArticleSportCaption').val(sport ? sport.name : '');
}
//--------------------------------------------------------------
sax.createItem = function ()
{
sax.clearItem();
sax.$dlg.article.dialog('option', 'title', sax.dlg.title.createArticle);
sax.openDialog(sax.$dlg.article, 600, 600);
}
sax.clearItem = function ()
{
$('#ifArticleId,#ifArticleExists,#ifArticleRegionId,#ifArticleSportId,input[type="text"],textarea,select', sax.$frm.article).val('');
sax.clearControlErrors();
}
sax.doCreateItem = function ()
{
sax.storeItem();
}
//--------------------------------------------------------------
sax.updateItem = function (id)
{
$('.ArticleId', sax.$frm.articleId).val(id);
sax.ajaxUpdateItem = sax.ajaxUpdateItem || { url: sax.url.base + 'Journalist/Ajax/GetArticle', formId: 'frmArticleId', callbackFn: sax.onUpdateItem };
sax.doAjaxRequest(sax.ajaxUpdateItem, 50);
}
sax.onUpdateItem = function (response)
{
//sax.debug('onUpdateItem', response);
sax.clearItem();
if (!response.success) return;
let $frm = sax.$frm.article;
let item = response.article;
$('#ifArticleId', $frm).val(item.id);
$('#ifArticleExists', $frm).val(1);
$('#ifArticleHeadline', $frm).val(item.headline);
$('#ifArticleSummary', $frm).val(item.summary);
$('#ifArticleRegionId', $frm).val(item.regionIdPrimary);
$('#ifArticleRegionCaption', $frm).val(item.regionCaptionPrimary);
$('#ifArticleSportId', $frm).val(item.sportIdPrimary);
$('#ifArticleSportCaption', $frm).val(item.sportCaptionPrimary);
$('#cbArticleStatusCode', $frm).val(item.statusCode);
sax.clearControlErrors();
sax.$dlg.article.dialog('option', 'title', sax.dlg.title.updateArticle);
sax.openDialog(sax.$dlg.article, 600, 600);
}
sax.doUpdateItem = function ()
{
sax.storeItem();
}
//--------------------------------------------------------------
sax.storeItem = function ()
{
sax.ajaxStoreItem = sax.ajaxStoreItem || { url: sax.url.base + 'Journalist/Ajax/StoreArticle', formId: 'frmArticle', callbackFn: sax.onStoreItem };
sax.doAjaxRequest(sax.ajaxStoreItem, 50);
}
sax.onStoreItem = function (response)
{
//sax.debug('onStoreItem', response);
sax.refreshControlValues(response.controlValues);
if (!response.success) return;
sax.$dlg.article.dialog('close');
var item = response.article;
var $item = $('#' + sax.itemIdPrefix + item.id);
if (!$item.length)
//--------------------------------------------------------------
sax.refreshResults = function (delay)
{
var $results = $('.sax-panel-results');
$item = $('.sax-panel-item-template .sax-panel-item', $results).clone();
$('.sax-panel-item-list', $results).prepend($item).show();
if (!sax.awaitingRefreshResponse)
{
var $items = $('.sax-panel-item-list', $results).fadeOut(200).empty();
var $msgs = $('.sax-panel-messages', $results).hide().empty().append($('<div class="sax-message">' + sax.msg.dataQuerying + '</div>')).fadeIn(200);
}
sax.ajaxRefreshResults = sax.ajaxRefreshResults || { url: sax.url.base + 'Journalist/Ajax/GetArticleList', formId: 'frmArticleFilter', callbackFn: sax.doRefreshResults };
sax.doAjaxRequest(sax.ajaxRefreshResults, delay || 50);
sax.awaitingRefreshResponse = true;
}
sax.populateItem($item, item)
}
//--------------------------------------------------------------
$(function ()
{
$('.sax-action.sax-item-create').on('click', function () { sax.createItem(); });
$('.sax-action.sax-results-refresh').on('click', function () { sax.refreshResults(); });
$('.ArticleFilter', '#frmArticleFilter').keypress(function (event)
sax.doRefreshResults = function (response)
{
if (event.keyCode == 13) setTimeout(sax.refreshResults, 50);
sax.debug('doRefreshResults', response);
delete sax.awaitingRefreshResponse;
sax.refreshControlValues(response.controlValues);
var $results = $('.sax-panel-results');
var $msgs = $('.sax-panel-messages', $results).hide().empty();
var $items = $('.sax-panel-item-list', $results).hide().empty();
var $templ = $('.sax-panel-item-template .sax-panel-item', $results);
if (!response.success) return;
var items = response.articles;
if (!items.length)
return $msgs.append($('<div class="sax-message">' + sax.msg.dataNoneFound + '</div>')).fadeIn(500);
for (let itemIdx = 0; itemIdx < items.length; itemIdx++)
{
let item = items[itemIdx];
let $item = $templ.clone();
sax.populateItem($item, item);
$items.append($item);
}
$items.fadeIn(50);
}
sax.populateItem = function ($item, item)
{
if (!item) return;
$item.prop('id', sax.itemIdPrefix + item.id);
$('.ArticleHeadline', $item).text(item.headline);
$('.ArticleSummary', $item).text(item.summary);
$('.ArticleRegionCaption', $item).text(item.regionCaptionPrimary);
$('.ArticleSportCaption', $item).text(item.sportCaptionPrimary);
$('.ArticleCreatedOn', $item).text(item.createdOnFmt);
$('.ArticlePublishedOn', $item).text(item.publishedOnFmt);
$('.ArticlePublished', $item).toggle(item.publishedOnFmt);
$('.ArticleStatusDesc', $item).text(item.statusDesc);
$('.sax-action.sax-item-update', $item).off('click').on('click', function () { sax.updateItem(item.id) })
}
//--------------------------------------------------------------
sax.selectRegion = function ()
{
sax.data.selectRegion.fn.selectRegion({ caption: sax.dlg.title.selectRegion, regionId: $('#ifArticleRegionId').val(), fnCallback: sax.onSelectRegion })
}
sax.onSelectRegion = function (region)
{
sax.clearControlError($('#ifArticleRegionId').val(region.id));
$('#ifArticleRegionCaption').val(region ? region.name : '');
}
//--------------------------------------------------------------
sax.selectSport = function ()
{
sax.data.selectSport.fn.selectSport({ caption: sax.dlg.title.selectSport, sportId: $('#ifArticleSportId').val(), fnCallback: sax.onSelectSport })
}
sax.onSelectSport = function (sport)
{
sax.clearControlError($('#ifArticleSportId').val(sport.id));
$('#ifArticleSportCaption').val(sport ? sport.name : '');
}
//--------------------------------------------------------------
sax.createItem = function ()
{
sax.clearItem();
sax.$dlg.article.dialog('option', 'title', sax.dlg.title.createArticle);
sax.openDialog(sax.$dlg.article, 600, 600);
}
sax.clearItem = function ()
{
$('#ifArticleId,#ifArticleExists,#ifArticleRegionId,#ifArticleSportId,input[type="text"],textarea,select', sax.$frm.article).val('');
sax.clearControlErrors();
}
sax.doCreateItem = function ()
{
sax.storeItem();
}
//--------------------------------------------------------------
sax.updateItem = function (id)
{
$('.ArticleId', sax.$frm.articleId).val(id);
sax.ajaxUpdateItem = sax.ajaxUpdateItem || { url: sax.url.base + 'Journalist/Ajax/GetArticle', formId: 'frmArticleId', callbackFn: sax.onUpdateItem };
sax.doAjaxRequest(sax.ajaxUpdateItem, 50);
}
sax.onUpdateItem = function (response)
{
//sax.debug('onUpdateItem', response);
sax.clearItem();
if (!response.success) return;
let $frm = sax.$frm.article;
let item = response.article;
$('#ifArticleId', $frm).val(item.id);
$('#ifArticleExists', $frm).val(1);
$('#ifArticleHeadline', $frm).val(item.headline);
$('#ifArticleSummary', $frm).val(item.summary);
$('#ifArticleRegionId', $frm).val(item.regionIdPrimary);
$('#ifArticleRegionCaption', $frm).val(item.regionCaptionPrimary);
$('#ifArticleSportId', $frm).val(item.sportIdPrimary);
$('#ifArticleSportCaption', $frm).val(item.sportCaptionPrimary);
$('#cbArticleStatusCode', $frm).val(item.statusCode);
sax.clearControlErrors();
sax.$dlg.article.dialog('option', 'title', sax.dlg.title.updateArticle);
sax.openDialog(sax.$dlg.article, 600, 600);
}
sax.doUpdateItem = function ()
{
sax.storeItem();
}
//--------------------------------------------------------------
sax.storeItem = function ()
{
sax.ajaxStoreItem = sax.ajaxStoreItem || { url: sax.url.base + 'Journalist/Ajax/StoreArticle', formId: 'frmArticle', callbackFn: sax.onStoreItem };
sax.doAjaxRequest(sax.ajaxStoreItem, 50);
}
sax.onStoreItem = function (response)
{
//sax.debug('onStoreItem', response);
sax.refreshControlValues(response.controlValues);
if (!response.success) return;
sax.$dlg.article.dialog('close');
var item = response.article;
var $item = $('#' + sax.itemIdPrefix + item.id);
if (!$item.length)
{
var $results = $('.sax-panel-results');
$item = $('.sax-panel-item-template .sax-panel-item', $results).clone();
$('.sax-panel-item-list', $results).prepend($item).show();
}
sax.populateItem($item, item)
}
//--------------------------------------------------------------
$(function ()
{
$('.sax-action.sax-item-create').on('click', function () { sax.createItem(); });
$('.sax-action.sax-results-refresh').on('click', function () { sax.refreshResults(); });
$('.ArticleFilter', '#frmArticleFilter').keypress(function (event)
{
if (event.keyCode == 13) setTimeout(sax.refreshResults, 50);
});
sax.$frm.articleId = $('#frmArticleId');
sax.$frm.article = $('#frmArticle');
$('.sax-input', sax.$frm.article).on('input', function () { sax.clearControlError(this); });
var opt = sax.dlgOpts();
opt.buttons[sax.dlg.btn.ok] = function () { sax.doCreateItem(); };
opt.buttons[sax.dlg.btn.cancel] = function () { $(this).dialog('close'); };
sax.$dlg.article = $('#dlgArticle').dialog(opt);
setTimeout(sax.refreshResults, 250);
});
sax.$frm.articleId = $('#frmArticleId');
sax.$frm.article = $('#frmArticle');
$('.sax-input', sax.$frm.article).on('keydown', function () { sax.clearControlError(this); });
var opt = sax.dlgOpts();
opt.buttons[sax.dlg.btn.ok] = function () { sax.doCreateItem(); };
opt.buttons[sax.dlg.btn.cancel] = function () { $(this).dialog('close'); };
sax.$dlg.article = $('#dlgArticle').dialog(opt);
}(window, window.document));
setTimeout(sax.refreshResults, 250);
});
//--------------------------------------------------------------
/* The End */
+437 -433
View File
@@ -1,449 +1,453 @@
/*
* Main scripts.
*/
"use strict";
var sax = sax || {};
//--------------------------------------------------------------
// Utilities.
sax.isDef = function (obj)
(function (win, doc, undef)
{
return obj === null || typeof obj == "undefined" ? false : true;
}
sax.isFn = function (fn)
{
return fn != null && typeof fn == typeof Function;
}
sax.isNumeric = function (n)
{
return !isNaN(parseFloat(n)) && isFinite(n);
}
sax.zeroPad = function (num, count)
{
var val = num + '';
while (val.length < count) val = "0" + val;
return val;
}
sax.toInt = function (value, defaultValue)
{
return sax.isNumeric(value) ? parseInt(value, 10) : defaultValue || 0;
}
sax.escapeRegExp=function(val)
{
return (val||'').replace(/[[{}()*+?^$|\]\.\\]/g, "\\$&");
}
sax.debug = sax.debugMode ? window.console.log.bind(window.console) : function () { };
"use strict";
win.sax = win.sax || {};
//--------------------------------------------------------------
sax.checkTextAreaMaxLength = function (ctrl, len)
{
if (ctrl == null || ctrl.value == null) return;
if (ctrl.value.length > len) ctrl.value = ctrl.value.substring(0, len);
}
sax.setAvailableCharsLabel = function ($if, max, $lbl)
{
var avail = Math.max(0, max - $if.val().length);
$lbl.text(avail == 1 ? sax.lbl.availableCharacter : sax.lbl.availableCharacters.replace(/\{0\}/g, avail));
}
sax.setCharsAvailableLabel = function ($if, max)
{
var avail = Math.max(0, max - $if.val().length);
$('.sax-select-chars-available', $if.closest('.sax-form-control')).text(avail == 1 ? sax.lbl.availableCharacter : sax.lbl.availableCharacters.replace(/\{0\}/g, avail));
}
sax.setItemsSelectedLabel = function ($sel)
{
var sel = $(':selected', $sel).length;
$('.sax-select-items-selected', $sel.closest('.sax-form-control')).text(sel == 0 ? sax.lbl.noneSelected : sax.lbl.numberSelected.replace(/\{0\}/g, sel));
}
sax.setOddDataRowClass = function (rowSel,cName)
{
$(rowSel).addClass(function (index, currentClasses)
//--------------------------------------------------------------
// Utilities.
sax.isDef = function (obj)
{
return index % 2 == 1 ? (cName||"other") : "";
});
}
return obj === null || typeof obj == "undefined" ? false : true;
}
sax.isFn = function (fn)
{
return fn != null && typeof fn == typeof Function;
}
sax.isNumeric = function (n)
{
return !isNaN(parseFloat(n)) && isFinite(n);
}
sax.zeroPad = function (num, count)
{
var val = num + '';
while (val.length < count) val = "0" + val;
return val;
}
sax.toInt = function (value, defaultValue)
{
return sax.isNumeric(value) ? parseInt(value, 10) : defaultValue || 0;
}
sax.escapeRegExp = function (val)
{
return (val || '').replace(/[[{}()*+?^$|\]\.\\]/g, "\\$&");
}
sax.debug = sax.debugMode ? window.console.log.bind(window.console) : function () { };
//--------------------------------------------------------------
// Page navigation.
sax.navigateTo = function (action)
{
sax.doPleaseWait();
$('#frmNavigate').prop('action', sax.url.base + action).submit();
}
sax.goToPage = function (action)
{
sax.doPleaseWait();
location = sax.url.base + action;
}
// Account action.
sax.onAccountAction = function (select)
{
var action = $(select).val();
$(select).val("");
if (action == "Profile")
sax.navigateTo("Profile");
else if (action == "Organisations")
sax.navigateTo("Organisations");
}
// Security.
sax.redirectHome = function ()
{
sax.goToPage('');
}
sax.redirectHomeExp = function ()
{
sax.doPleaseWait();
document.location = sax.url.sesionExpired;
}
sax.onSignOut = function ()
{
sax.doConfirm(sax.dlg.title.signOut, sax.msg.signOutConfirm, sax.doSignOut);
}
sax.doSignOut = function ()
{
sax.doAjaxRequest({ url: sax.url.base + 'Security/Ajax/SignOut', formId: 'frmNavigate' }, 50);
}
//--------------------------------------------------------------
// Dialogs.
sax.openDialog = function ($dlg, width, height)
{
$dlg.dialog(
//--------------------------------------------------------------
sax.checkTextAreaMaxLength = function (ctrl, len)
{
if (ctrl == null || ctrl.value == null) return;
if (ctrl.value.length > len) ctrl.value = ctrl.value.substring(0, len);
}
sax.setAvailableCharsLabel = function ($if, max, $lbl)
{
var avail = Math.max(0, max - $if.val().length);
$lbl.text(avail == 1 ? sax.lbl.availableCharacter : sax.lbl.availableCharacters.replace(/\{0\}/g, avail));
}
sax.setCharsAvailableLabel = function ($if, max)
{
var avail = Math.max(0, max - $if.val().length);
$('.sax-select-chars-available', $if.closest('.sax-form-control')).text(avail == 1 ? sax.lbl.availableCharacter : sax.lbl.availableCharacters.replace(/\{0\}/g, avail));
}
sax.setItemsSelectedLabel = function ($sel)
{
var sel = $(':selected', $sel).length;
$('.sax-select-items-selected', $sel.closest('.sax-form-control')).text(sel == 0 ? sax.lbl.noneSelected : sax.lbl.numberSelected.replace(/\{0\}/g, sel));
}
sax.setOddDataRowClass = function (rowSel, cName)
{
$(rowSel).addClass(function (index, currentClasses)
{
minWidth: null, maxWidth: null, width: Math.min(width || 400, $(window).width() * .90),
minHeight: null, maxHeight: null, height: Math.min(height || 320, $(window).innerHeight() * .90)
}).dialog('open');
return $dlg;
}
sax.dlgOpts = function ()
{
return { autoOpen: false, modal: true, show: 'clip', hide: 'clip', minWidth: 320, maxWidth: 480, width: 'auto', resizable: false, draggable: false, closeOnEscape: false, dialogClass: "no-close center-buttons", buttons: {} };
}
sax.dlgOptsClose = function ()
{
var opts = sax.dlgOpts();
opts.buttons[sax.dlg.btn.close] = function () { $(this).dialog('close'); };
return opts;
}
sax.doAlert = function (title, msg, onOk)
{
if (!msg)
{
msg = title;
title = null;
}
if (!sax.isDef(sax.$dlg.alert))
{
var opt = sax.dlgOpts();
opt.buttons[sax.dlg.btn.ok] = function () { $(this).dialog('close'); if (onOk) onOk(); };
sax.$dlg.alert = $('<div id="dlgAlert"><div id="dlgAlertMsg"></div></div>').dialog(opt);
}
$('#dlgAlertMsg', sax.$dlg.alert).html(msg);
sax.$dlg.alert.dialog('option', { title: title || sax.dlg.title.alert });
sax.openDialog(sax.$dlg.alert);
}
sax.doConfirm = function (title, msg, onOk, onCancel)
{
if (!msg)
{
msg = title;
title = null;
}
if (!sax.isDef(sax.$dlg.confirm))
{
var opt = sax.dlgOpts();
sax.$dlg.confirm = $('<div id="dlgConfirm"><div class="spacer2"></div><div id="dlgConfirmMsg"></div></div>').dialog(opt);
}
var buttons = sax.$dlg.confirm.dialog('option', 'buttons');
buttons[sax.dlg.btn.yes] = function () { $(this).dialog('close'); if (onOk) onOk(); };
buttons[sax.dlg.btn.no] = function () { $(this).dialog('close'); if (onCancel) onCancel(); };
sax.$dlg.confirm.dialog('option', { title: title || sax.dlg.title.confirm, 'buttons': buttons });
$('#dlgConfirmMsg').html(msg);
sax.openDialog(sax.$dlg.confirm);
}
sax.doProgress = function (title, msg, delay)
{
if (!msg)
{
msg = title;
title = null;
}
clearTimeout(sax.toShowProgress);
if (!sax.isDef(sax.$dlg.progress))
{
var opt = sax.dlgOpts();
opt.show = { effect: 'fade', duration: 200 };
opt.hide = { effect: 'fade', duration: 200 };
sax.$dlg.progress = $('<div id="dlgProgress"><div id="dlgProgressMsg"></div></div>').dialog(opt);
}
$('#dlgProgressMsg').html(msg);
sax.$dlg.progress.dialog('option', { title: title || sax.dlg.title.progress });
if (delay > 0) sax.toShowProgress = setTimeout(function () { sax.$dlg.progress.dialog('open'); }, delay);
else sax.$dlg.progress.dialog('open');
}
sax.hideProgress = function ()
{
clearTimeout(sax.toShowProgress);
sax.$dlg.progress.dialog('close');
}
//--------------------------------------------------------------
// Notifications.
sax.showNotification = function (title, msg)
{
window.clearTimeout(sax.toNotification);
var $win = $(window);
var $not = $('#sax-notification').hide();
if (!$not.length)
{
$not = $('<div id="sax-notification"><div class="content"><div class="heading"><div class="close" onclick="sax.hideNotification()">&#10006;</div><div class="title"></div></div><div class="message"></div></div></div>');
$('body').append($not);
}
var $hdr = $('.heading', $not).css({ 'background-color': 'rgba(247,217,0,0.7)' });
$('.title', $not).html(title);
$('.message', $not).html(msg);
var $bdy = $('.sax-page-body');
sax.debug(sax.topMargin($bdy));
var fbr = $bdy[0].getBoundingClientRect();
var fn = function () { $hdr.delay(2000).animate({ backgroundColor: '#f0f0f0' }, 1000); };
$not.css({ 'top': Math.max(0, fbr.top - sax.topMargin($bdy)), 'right': $win.width() - fbr.right }).slideDown(500, fn);
sax.toNotification = setTimeout(sax.hideNotification, 6000);
}
sax.hideNotification = function ()
{
window.clearTimeout(sax.toNotification);
$('#sax-notification').slideUp(500);
}
sax.doPleaseWait = function ()
{
sax.$pleaseWait = sax.$pleaseWait || $('#sax-please-wait');
sax.$pleaseWait.stop(true, false).animate({ "null": 1 }, 200).fadeTo(200, 1);
}
sax.hidePleaseWait = function ()
{
if (sax.$pleaseWait) sax.$pleaseWait.stop(true, false).fadeOut(200);
}
//--------------------------------------------------------------
// Ajax.
sax.doAjaxRequest = function (ajax, delay)
{
window.clearTimeout(ajax.timeout);
if (!ajax.noWaitIcon) sax.doPleaseWait();
ajax.timeout = setTimeout(function () { sax.execAjaxRequest(ajax); }, Math.max(50, parseInt(delay || 0, 10)));
}
sax.execAjaxRequest = function (ajax)
{
window.clearTimeout(ajax.timeout);
if (ajax.request) ajax.request.abort();
var cfgAjax =
{
url: ajax.url,
type: 'POST',
cache: false,
//enctype: 'multipart/form-data',
data: ajax.formData || $("#" + ajax.formId).serialize(),
dataType: 'json',
success: function (response, status, jqXHR)
{
if (!ajax.noWaitIcon) sax.hidePleaseWait();
ajax.status = status;
if (response.notification)
sax.showNotification(response.notification.title, response.notification.message);
if (response.message)
{
var fnCloseAlert = function ()
{
if (response.sessionExpired) return sax.redirectHomeExp();
if (response.goHome) return sax.redirectHome();
if (ajax.callbackFn) ajax.callbackFn(response);
}
sax.doAlert(response.message.title, response.message.text, function () { fnCloseAlert(); });
}
else if (response.sessionExpired)
return sax.redirectHomeExp();
else if (response.goHome)
return sax.redirectHome();
else if (response.error && ajax.errFn) ajax.errFn(response);
else if (ajax.callbackFn) ajax.callbackFn(response);
},
error: function (jqXHR, status, errorThrown)
{
if (!ajax.noWaitIcon) sax.hidePleaseWait();
ajax.status = status;
if (status == "abort") return;
sax.doAlert(sax.dlg.title.alert, sax.msg.somethingGoneWrong, sax.redirectHome);
},
complete: function (jqXHR, textStatus)
{
if (!ajax.noWaitIcon) sax.hidePleaseWait();
ajax.formData = null;
ajax.complete = true;
}
}
if (ajax.formData)
{
//for (var pair of ajax.formData.entries()) sax.debug(pair[0] + ': ' + pair[1]);
cfgAjax.processData = false;
cfgAjax.contentType = false;
}
ajax.request = $.ajax(cfgAjax);
}
//--------------------------------------------------------------
// Session.
sax.configureKeepLoggedIn = function ()
{
sax.debug('KeepLoggedIn Configuring');
setTimeout(sax.doKeepLoggedIn, Math.max(30000, sax.keepLoggedInDelay || 300000));
}
sax.doKeepLoggedIn = function ()
{
sax.debug('KeepLoggedIn Calling');
var onKeepLoggedIn = function (response)
{
sax.debug('KeepLoggedIn Responded', response);
sax.configureKeepLoggedIn();
}
sax.doAjaxRequest({ url: sax.url.base + 'Security/Ajax/KeepLoggedIn', formId: 'frmNavigate', noWaitIcon: true, callbackFn: onKeepLoggedIn }, 1000)
}
sax.configureSessionRefresh = function ()
{
sax.debug('SessionRefresh Configuring');
$(document).on('mousedown mousemove touchstart scroll keydown', sax.triggeRefreshSession );
}
sax.triggeRefreshSession = function ()
{
sax.session = sax.session || { refresh: {} };
let ssr = sax.session.refresh;
window.clearTimeout(ssr.timeout);
ssr.timeout = setTimeout(function () { sax.refreshSession(); }, 150000);
}
sax.refreshSession = function ()
{
sax.debug('sax.refreshSession');
sax.doKeepLoggedIn();
}
//--------------------------------------------------------------
// Data entry.
sax.clearControlErrors = function ()
{
var $ctrls = $('.sax-form-control').removeClass('sax-error');
$('.sax-message', $ctrls).empty();
}
sax.clearControlError = function (sel)
{
var $ctrl = $(sel).closest('.sax-form-control').removeClass('sax-error');
$('.sax-message', $ctrl).empty();
}
sax.setControlError = function (sel, error)
{
sax.debug(sel, error);
var $ctrl = $(sel).closest('.sax-form-control').addClass('sax-error');
$('.sax-message', $ctrl).text(error);
}
sax.refreshControlValues = function (controlValues)
{
var $frmCtrls = $('.sax-form-control').removeClass('sax-error');
sax.clearControlErrors();
var values = (controlValues || []);
var valuesLen = values.length;
for (var valIdx = 0; valIdx < (controlValues || []).length; valIdx++)
{
let ctrlValue = controlValues[valIdx];
$frmCtrls.each(function (idx, frmCtrl)
{
var $frmCtrl = $(frmCtrl);
var $ctrl = $('input,textarea,select', $frmCtrl);
if ($ctrl.prop('name') != ctrlValue.controlName) return;
if (ctrlValue.value)
$ctrl.val(ctrlValue.value);
if (ctrlValue.error)
$frmCtrl.addClass('sax-error').find('.sax-message').text(ctrlValue.error);
return index % 2 == 1 ? (cName || "other") : "";
});
}
}
//--------------------------------------------------------------
// Elements.
sax.objBtm = function (sel)
{
var $obj = $(sel);
return Math.floor($obj.offset().top + $obj.outerHeight(true));
}
sax.innerBtm = function (sel)
{
var $obj = $(sel);
return Math.floor($obj.offset().top + $obj.outerHeight() - sax.bottomSurround($obj));
}
sax.innerTop = function (sel)
{
var $obj = $(sel);
return Math.floor($obj.offset().top + sax.topSurround($obj));
}
sax.topMargin = function (sel)
{
var $obj = $(sel);
return parseInt($obj.css('margin-top'), 10);
}
sax.topSurround = function (sel)
{
var $obj = $(sel);
return parseInt($obj.css('margin-top'), 10) + parseInt($obj.css('border-top-width'), 10) + parseInt($obj.css('padding-top'), 10);
}
sax.bottomSurround = function (sel)
{
var $obj = $(sel);
return parseInt($obj.css('margin-bottom'), 10) + parseInt($obj.css('border-bottom-width'), 10) + parseInt($obj.css('padding-bottom'), 10);
}
sax.marginHeight = function (sel)
{
var $obj = $(sel);
return parseInt($obj.css('margin-top'), 10) + parseInt($obj.css('margin-bottom'), 10);
}
sax.borderHeight = function (sel)
{
var $obj = $(sel);
return parseInt($obj.css('border-top-width'), 10) + parseInt($obj.css('border-bottom-width'), 10);
}
//--------------------------------------------------------------
// Page navigation.
sax.navigateTo = function (action)
{
sax.doPleaseWait();
$('#frmNavigate').prop('action', sax.url.base + action).submit();
}
sax.goToPage = function (action)
{
sax.doPleaseWait();
location = sax.url.base + action;
}
//--------------------------------------------------------------
// Viewport - Desktop or Mobile.
sax.isMob = function () { return $('body.mob').length > 0; };
sax.onChangeViewport = function (viewport)
{
var $body = $('body');
$body.removeClass('mob dsk');
if (viewport.is('xs')) $body.addClass('mob');
else if (viewport.current() != 'unrecognized') $body.addClass('dsk');
}
sax.isAutoHeight = function () { return ($(window).width() < 360 || $(window).height() < 560 || sax.isMob()); }
sax.onWinResizePage = function () { };
sax.onWinResize = function ()
{
var winH = $(window).height();
var $pageBody = $('#sax-body');
var $hdr = $('#sax-header');
var $ftr = $('#sax-footer');
if (sax.isAutoHeight())
$pageBody.height('auto');
else
$pageBody.innerHeight(Math.min(1200, winH - $hdr.outerHeight() - $ftr.outerHeight(true)));
$ftr.css('visibility', 'visible');
sax.onWinResizePage();
}
// Account action.
sax.onAccountAction = function (select)
{
var action = $(select).val();
$(select).val("");
if (action == "Profile")
sax.navigateTo("Profile");
else if (action == "Organisations")
sax.navigateTo("Organisations");
}
//--------------------------------------------------------------
$(function ()
{
$('.sax-button-cta,.sax-button-action,.sax-action-link,.sax-social-icon.sax-action').prop('tabindex', 0);
if (sax.keepLoggedIn)
sax.configureKeepLoggedIn();
else if (!sax.awaitingLogin)
sax.configureSessionRefresh();
});
// Security.
sax.redirectHome = function ()
{
sax.goToPage('');
}
sax.redirectHomeExp = function ()
{
sax.doPleaseWait();
document.location = sax.url.sesionExpired;
}
sax.onSignOut = function ()
{
sax.doConfirm(sax.dlg.title.signOut, sax.msg.signOutConfirm, sax.doSignOut);
}
sax.doSignOut = function ()
{
sax.doAjaxRequest({ url: sax.url.base + 'Security/Ajax/SignOut', formId: 'frmNavigate' }, 50);
}
//--------------------------------------------------------------
// Dialogs.
sax.openDialog = function ($dlg, width, height)
{
$dlg.dialog(
{
minWidth: null, maxWidth: null, width: Math.min(width || 400, $(window).width() * .90),
minHeight: null, maxHeight: null, height: Math.min(height || 320, $(window).innerHeight() * .90)
}).dialog('open');
return $dlg;
}
sax.dlgOpts = function ()
{
return { autoOpen: false, modal: true, show: 'clip', hide: 'clip', minWidth: 320, maxWidth: 480, width: 'auto', resizable: false, draggable: false, closeOnEscape: false, dialogClass: "no-close center-buttons", buttons: {} };
}
sax.dlgOptsClose = function ()
{
var opts = sax.dlgOpts();
opts.buttons[sax.dlg.btn.close] = function () { $(this).dialog('close'); };
return opts;
}
sax.doAlert = function (title, msg, onOk)
{
if (!msg)
{
msg = title;
title = null;
}
if (!sax.isDef(sax.$dlg.alert))
{
var opt = sax.dlgOpts();
opt.buttons[sax.dlg.btn.ok] = function () { $(this).dialog('close'); if (onOk) onOk(); };
sax.$dlg.alert = $('<div id="dlgAlert"><div id="dlgAlertMsg"></div></div>').dialog(opt);
}
$('#dlgAlertMsg', sax.$dlg.alert).html(msg);
sax.$dlg.alert.dialog('option', { title: title || sax.dlg.title.alert });
sax.openDialog(sax.$dlg.alert);
}
sax.doConfirm = function (title, msg, onOk, onCancel)
{
if (!msg)
{
msg = title;
title = null;
}
if (!sax.isDef(sax.$dlg.confirm))
{
var opt = sax.dlgOpts();
sax.$dlg.confirm = $('<div id="dlgConfirm"><div class="spacer2"></div><div id="dlgConfirmMsg"></div></div>').dialog(opt);
}
var buttons = sax.$dlg.confirm.dialog('option', 'buttons');
buttons[sax.dlg.btn.yes] = function () { $(this).dialog('close'); if (onOk) onOk(); };
buttons[sax.dlg.btn.no] = function () { $(this).dialog('close'); if (onCancel) onCancel(); };
sax.$dlg.confirm.dialog('option', { title: title || sax.dlg.title.confirm, 'buttons': buttons });
$('#dlgConfirmMsg').html(msg);
sax.openDialog(sax.$dlg.confirm);
}
sax.doProgress = function (title, msg, delay)
{
if (!msg)
{
msg = title;
title = null;
}
clearTimeout(sax.toShowProgress);
if (!sax.isDef(sax.$dlg.progress))
{
var opt = sax.dlgOpts();
opt.show = { effect: 'fade', duration: 200 };
opt.hide = { effect: 'fade', duration: 200 };
sax.$dlg.progress = $('<div id="dlgProgress"><div id="dlgProgressMsg"></div></div>').dialog(opt);
}
$('#dlgProgressMsg').html(msg);
sax.$dlg.progress.dialog('option', { title: title || sax.dlg.title.progress });
if (delay > 0) sax.toShowProgress = setTimeout(function () { sax.$dlg.progress.dialog('open'); }, delay);
else sax.$dlg.progress.dialog('open');
}
sax.hideProgress = function ()
{
clearTimeout(sax.toShowProgress);
sax.$dlg.progress.dialog('close');
}
//--------------------------------------------------------------
// Notifications.
sax.showNotification = function (title, msg)
{
window.clearTimeout(sax.toNotification);
var $win = $(window);
var $not = $('#sax-notification').hide();
if (!$not.length)
{
$not = $('<div id="sax-notification"><div class="content"><div class="heading"><div class="close" onclick="sax.hideNotification()">&#10006;</div><div class="title"></div></div><div class="message"></div></div></div>');
$('body').append($not);
}
var $hdr = $('.heading', $not).css({ 'background-color': 'rgba(247,217,0,0.7)' });
$('.title', $not).html(title);
$('.message', $not).html(msg);
var $bdy = $('.sax-page-body');
//sax.debug(sax.topMargin($bdy));
var fbr = $bdy[0].getBoundingClientRect();
var fn = function () { $hdr.delay(2000).animate({ backgroundColor: '#f0f0f0' }, 1000); };
$not.css({ 'top': Math.max(0, fbr.top - sax.topMargin($bdy)), 'right': $win.width() - fbr.right }).slideDown(500, fn);
sax.toNotification = setTimeout(sax.hideNotification, 6000);
}
sax.hideNotification = function ()
{
window.clearTimeout(sax.toNotification);
$('#sax-notification').slideUp(500);
}
sax.doPleaseWait = function ()
{
sax.$pleaseWait = sax.$pleaseWait || $('#sax-please-wait');
sax.$pleaseWait.stop(true, false).animate({ "null": 1 }, 200).fadeTo(200, 1);
}
sax.hidePleaseWait = function ()
{
if (sax.$pleaseWait) sax.$pleaseWait.stop(true, false).fadeOut(200);
}
//--------------------------------------------------------------
// Ajax.
sax.doAjaxRequest = function (ajax, delay)
{
window.clearTimeout(ajax.timeout);
if (!ajax.noWaitIcon) sax.doPleaseWait();
ajax.timeout = setTimeout(function () { sax.execAjaxRequest(ajax); }, Math.max(50, parseInt(delay || 0, 10)));
}
sax.execAjaxRequest = function (ajax)
{
window.clearTimeout(ajax.timeout);
if (ajax.request) ajax.request.abort();
var cfgAjax =
{
url: ajax.url,
type: 'POST',
cache: false,
//enctype: 'multipart/form-data',
data: ajax.formData || $("#" + ajax.formId).serialize(),
dataType: 'json',
success: function (response, status, jqXHR)
{
if (!ajax.noWaitIcon) sax.hidePleaseWait();
ajax.status = status;
if (response.notification)
sax.showNotification(response.notification.title, response.notification.message);
if (response.message)
{
var fnCloseAlert = function ()
{
if (response.sessionExpired) return sax.redirectHomeExp();
if (response.goHome) return sax.redirectHome();
if (ajax.callbackFn) ajax.callbackFn(response);
}
sax.doAlert(response.message.title, response.message.text, function () { fnCloseAlert(); });
}
else if (response.sessionExpired)
return sax.redirectHomeExp();
else if (response.goHome)
return sax.redirectHome();
else if (response.error && ajax.errFn) ajax.errFn(response);
else if (ajax.callbackFn) ajax.callbackFn(response);
},
error: function (jqXHR, status, errorThrown)
{
if (!ajax.noWaitIcon) sax.hidePleaseWait();
ajax.status = status;
if (status == "abort") return;
sax.doAlert(sax.dlg.title.alert, sax.msg.somethingGoneWrong, sax.redirectHome);
},
complete: function (jqXHR, textStatus)
{
if (!ajax.noWaitIcon) sax.hidePleaseWait();
ajax.formData = null;
ajax.complete = true;
}
}
if (ajax.formData)
{
//for (var pair of ajax.formData.entries()) sax.debug(pair[0] + ': ' + pair[1]);
cfgAjax.processData = false;
cfgAjax.contentType = false;
}
ajax.request = $.ajax(cfgAjax);
}
//--------------------------------------------------------------
// Session.
sax.configureKeepLoggedIn = function ()
{
//sax.debug('KeepLoggedIn Configuring');
setTimeout(sax.doKeepLoggedIn, Math.max(30000, sax.keepLoggedInDelay || 300000));
}
sax.doKeepLoggedIn = function ()
{
//sax.debug('KeepLoggedIn Calling');
var onKeepLoggedIn = function (response)
{
//sax.debug('KeepLoggedIn Responded', response);
sax.configureKeepLoggedIn();
}
sax.doAjaxRequest({ url: sax.url.base + 'Security/Ajax/KeepLoggedIn', formId: 'frmNavigate', noWaitIcon: true, callbackFn: onKeepLoggedIn }, 1000)
}
sax.configureSessionRefresh = function ()
{
//sax.debug('SessionRefresh Configuring');
$(document).on('mousedown mousemove touchstart scroll keydown', sax.triggeRefreshSession);
}
sax.triggeRefreshSession = function ()
{
sax.session = sax.session || { refresh: {} };
let ssr = sax.session.refresh;
window.clearTimeout(ssr.timeout);
ssr.timeout = setTimeout(function () { sax.refreshSession(); }, 150000);
}
sax.refreshSession = function ()
{
//sax.debug('sax.refreshSession');
sax.doKeepLoggedIn();
}
//--------------------------------------------------------------
// Data entry.
sax.clearControlErrors = function ()
{
var $ctrls = $('.sax-form-control').removeClass('sax-error');
$('.sax-message', $ctrls).empty();
}
sax.clearControlError = function (sel)
{
var $ctrl = $(sel).closest('.sax-form-control').removeClass('sax-error');
$('.sax-message', $ctrl).empty();
}
sax.setControlError = function (sel, error)
{
var $ctrl = $(sel).closest('.sax-form-control').addClass('sax-error');
$('.sax-message', $ctrl).text(error);
}
sax.refreshControlValues = function (controlValues)
{
var $frmCtrls = $('.sax-form-control').removeClass('sax-error');
sax.clearControlErrors();
var values = (controlValues || []);
var valuesLen = values.length;
for (var valIdx = 0; valIdx < (controlValues || []).length; valIdx++)
{
let ctrlValue = controlValues[valIdx];
$frmCtrls.each(function (idx, frmCtrl)
{
var $frmCtrl = $(frmCtrl);
var $ctrl = $('input,textarea,select', $frmCtrl);
if ($ctrl.prop('name') != ctrlValue.controlName) return;
if (ctrlValue.value)
$ctrl.val(ctrlValue.value);
if (ctrlValue.error)
$frmCtrl.addClass('sax-error').find('.sax-message').text(ctrlValue.error);
});
}
}
//--------------------------------------------------------------
// Elements.
sax.objBtm = function (sel)
{
var $obj = $(sel);
return Math.floor($obj.offset().top + $obj.outerHeight(true));
}
sax.innerBtm = function (sel)
{
var $obj = $(sel);
return Math.floor($obj.offset().top + $obj.outerHeight() - sax.bottomSurround($obj));
}
sax.innerTop = function (sel)
{
var $obj = $(sel);
return Math.floor($obj.offset().top + sax.topSurround($obj));
}
sax.topMargin = function (sel)
{
var $obj = $(sel);
return parseInt($obj.css('margin-top'), 10);
}
sax.topSurround = function (sel)
{
var $obj = $(sel);
return parseInt($obj.css('margin-top'), 10) + parseInt($obj.css('border-top-width'), 10) + parseInt($obj.css('padding-top'), 10);
}
sax.bottomSurround = function (sel)
{
var $obj = $(sel);
return parseInt($obj.css('margin-bottom'), 10) + parseInt($obj.css('border-bottom-width'), 10) + parseInt($obj.css('padding-bottom'), 10);
}
sax.marginHeight = function (sel)
{
var $obj = $(sel);
return parseInt($obj.css('margin-top'), 10) + parseInt($obj.css('margin-bottom'), 10);
}
sax.borderHeight = function (sel)
{
var $obj = $(sel);
return parseInt($obj.css('border-top-width'), 10) + parseInt($obj.css('border-bottom-width'), 10);
}
//--------------------------------------------------------------
// Viewport - Desktop or Mobile.
sax.isMob = function () { return $('body.mob').length > 0; };
sax.onChangeViewport = function (viewport)
{
var $body = $('body');
$body.removeClass('mob dsk');
if (viewport.is('xs')) $body.addClass('mob');
else if (viewport.current() != 'unrecognized') $body.addClass('dsk');
}
sax.isAutoHeight = function () { return ($(window).width() < 360 || $(window).height() < 560 || sax.isMob()); }
sax.onWinResizePage = function () { };
sax.onWinResize = function ()
{
var winH = $(window).height();
var $pageBody = $('#sax-body');
var $hdr = $('#sax-header');
var $ftr = $('#sax-footer');
if (sax.isAutoHeight())
$pageBody.height('auto');
else
$pageBody.innerHeight(Math.min(1200, winH - $hdr.outerHeight() - $ftr.outerHeight(true)));
$ftr.css('visibility', 'visible');
sax.onWinResizePage();
}
//--------------------------------------------------------------
$(function ()
{
$('.sax-button-cta,.sax-button-action,.sax-action-link,.sax-social-icon.sax-action').prop('tabindex', 0);
if (sax.keepLoggedIn)
sax.configureKeepLoggedIn();
else if (!sax.awaitingLogin)
sax.configureSessionRefresh();
});
}(window, window.document));
/* The End */
@@ -1,132 +0,0 @@
/*
* Region selection.
*/
(function (win, doc, undef)
{
"use strict";
let rs = sax.data.regionSel = sax.data.regionSel || { regions: {}, fn: {}, $dlg: {}, itemIdPrefix: 'Rgn_' };
//--------------------------------------------------------------
/*
* Region selection config:
* - caption - dialog title.
* - regionId - currently selected region.
* - fnCallback - method to call on completion to store selected region.
*/
rs.fn.selectRegion = function (cfg)
{
rs.fn.init();
rs.cfg = cfg;
rs.regionId = cfg.regionId;
if (rs.regions.length) rs.fn.showRegionSelection();
else
{
sax.ajaxRegions = sax.ajaxRegions || { url: sax.url.base + 'Reference/Ajax/GetRegions', formId: 'frmNavigate', callbackFn: rs.fn.refreshRegionsAndSelect };
sax.doAjaxRequest(sax.ajaxRegions, 20);
}
}
rs.fn.refreshRegionsAndSelect = function (response)
{
if (!response || !response.success) return;
rs.regions = response.regions;
rs.fn.showRegionSelection();
}
rs.fn.showRegionSelection = function ()
{
$('.SelectedRegionName', rs.$dlg).text(rs.fn.getRegionName(rs.regionId));
$('#ifRegionFilter', rs.$dlg).val('');
rs.fn.displayRegions();
sax.openDialog(rs.$dlg.dialog('option', { title: rs.cfg.caption || 'Select Region' }), 400, 600);
}
//--------------------------------------------------------------
rs.fn.compareRegions=function(a, b)
{
var comparison = a.name.toLowerCase().localeCompare(b.name.toLowerCase());
if (comparison === 0)
return a.name.localeCompare(b.name);
return comparison;
}
//--------------------------------------------------------------
rs.fn.displayRegions = function ()
{
let filter = $('#ifRegionFilter', rs.$dlg).val();
let reFilter = new RegExp(sax.escapeRegExp((filter || '').trim()), 'i');
let $regionsAvail = $('.sax-regionSelection-regions.AvailableRegions').empty();
let $regionTmpl = $('.sax-panel-item-template .sax-panel-item.Region');
let regions = [...rs.regions];
regions.sort(rs.fn.compareRegions);
for (let rgnIdx = 0; rgnIdx < regions.length; rgnIdx++)
{
let region = regions[rgnIdx];
let id = region.id;
if (filter && !region.name.match(reFilter)) continue;
let $region = $regionTmpl.clone();
$region.prop('id', rs.itemIdPrefix + id).on('click', function () { rs.fn.onClickRegion(id); }).on('dblclick', function () { rs.fn.onDblClickRegion(id); }).find('.RegionName').text(region.name).end();
if (id == rs.regionId) $region.addClass('sel');
$regionsAvail.append($region);
}
}
rs.fn.getRegion = function (id)
{
for (let rgnIdx = 0; rgnIdx < rs.regions.length; rgnIdx++)
{
let region = rs.regions[rgnIdx];
if (region.id == id) return region;
}
}
rs.fn.getRegionName = function (id)
{
let region = rs.fn.getRegion(id);
return region ? region.name : '';
}
//--------------------------------------------------------------
rs.fn.onClickRegion = function (id)
{
$('.SelectedRegionName', rs.$dlg).text(rs.fn.getRegionName(rs.regionId = id));
$('.sax-panel-item.Region').removeClass('sel');
$('.sax-panel-item.Region#' + rs.itemIdPrefix + id).addClass('sel');
}
rs.fn.onDblClickRegion = function (id)
{
rs.regionId = id;
rs.fn.storeRegionSelection();
}
rs.fn.storeRegionSelection = function ()
{
if (!rs.regionId) return;
let region = rs.fn.getRegion(rs.regionId);
if (!region) return;
if (rs.cfg.fnCallback) rs.cfg.fnCallback(region);
rs.$dlg.dialog('close');
delete rs.cfg;
delete rs.regionId;
}
//--------------------------------------------------------------
rs.fn.onDlgSize = function ()
{
let $pnl = $('.sax-regionSelection-regions.AvailableRegions');
$pnl.outerHeight(Math.floor(rs.$dlg.innerHeight() - $pnl.position().top - ($pnl.outerHeight(true) - $pnl.innerHeight())));
}
//--------------------------------------------------------------
rs.fn.init = function ()
{
if (!rs.$dlg) return;
var opt = sax.dlgOpts();
opt.open = function (evt, ui) { rs.fn.onDlgSize(); };
opt.resize = function (evt, ui) { rs.fn.onDlgSize(); };
opt.buttons[sax.dlg.btn.ok] = function () { rs.fn.storeRegionSelection(); };
opt.buttons[sax.dlg.btn.cancel] = function () { $(this).dialog('close'); };
rs.$dlg = $('#dlgRegionSelection').dialog(opt);
}
}(window, window.document));
/* The End */
@@ -1,84 +1,89 @@
/*
* Security page scripts.
*/
"use strict";
//--------------------------------------------------------------
sax.doSignin = function ()
(function (win, doc, undef)
{
sax.clearControlErrors();
sax.ajaxSignin = sax.ajaxSignin || { url: sax.url.base + 'Security/Ajax/Signin', formId: 'frmSignIn', callbackFn: sax.onSignin };
sax.doAjaxRequest(sax.ajaxSignin, 50);
}
sax.onSignin = function (response)
{
sax.debug(response);
sax.refreshControlValues(response.controlValues);
if (!response.success) return;
sax.goToPage('');
}
"use strict";
//--------------------------------------------------------------
sax.doScorePassword = function ()
{
sax.ajaxScorePassword = sax.ajaxScorePassword || { url: sax.url.base + 'Security/Ajax/ScorePassword', formId: 'frmChangePassword', callbackFn: sax.onScorePassword, noWaitIcon: true };
sax.doAjaxRequest(sax.ajaxScorePassword, 250);
}
sax.onScorePassword = function (response)
{
var score = (response || {}).score || 0;
sax.$prgPasswordStrength.progressbar("option", "value", score).removeClass('amber green').addClass(score > 3 ? 'green' : score > 2 ? 'amber' : '');
}
//--------------------------------------------------------------
sax.doChangePassword = function ()
{
sax.clearControlErrors();
sax.ajaxChangePassword = sax.ajaxChangePassword || { url: sax.url.base + 'Security/Ajax/StorePassword', formId: 'frmChangePassword', callbackFn: sax.onChangePassword };
sax.doAjaxRequest(sax.ajaxChangePassword, 50);
}
sax.onChangePassword = function (response)
{
sax.refreshControlValues(response.controlValues);
if (!response.success) return;
if ($('#ifRpe').length)
sax.goToPage('Security/Signin');
else sax.goToPage('');
}
//--------------------------------------------------------------
sax.doRequestPassword = function ()
{
sax.clearControlErrors();
sax.ajaxRequestPassword = sax.ajaxRequestPassword || { url: sax.url.base + 'Security/Ajax/RequestNewPassword', formId: 'frmRequestPassword', callbackFn: sax.onRequestPassword };
sax.doAjaxRequest(sax.ajaxRequestPassword, 50);
}
sax.onRequestPassword = function (response)
{
sax.refreshControlValues(response.controlValues);
if (!response.success) return;
var gotoSigninPage = function ()
//--------------------------------------------------------------
sax.doSignin = function ()
{
sax.goToPage('Security/Signin');
sax.clearControlErrors();
sax.ajaxSignin = sax.ajaxSignin || { url: sax.url.base + 'Security/Ajax/Signin', formId: 'frmSignIn', callbackFn: sax.onSignin };
sax.doAjaxRequest(sax.ajaxSignin, 50);
}
sax.onSignin = function (response)
{
sax.debug(response);
sax.refreshControlValues(response.controlValues);
if (!response.success) return;
sax.goToPage('');
}
if (response.successMsg)
sax.doAlert($('.sax-page-caption').text(), response.successMsg, gotoSigninPage);
else gotoSigninPage();
}
//--------------------------------------------------------------
$(function ()
{
$(':input:enabled:visible:first').focus();
$('#ifEmailAddress,#ifPasswordCurrent,#ifPassword,#ifPasswordConfirm').on('keydown', function () { sax.clearControlError(this); });
$('#frmChangePassword #ifPassword').on('keyup', sax.doScorePassword);
sax.$prgPasswordStrength = $('#frmChangePassword #prgPasswordStrength').progressbar({ 'max': 5 });
$('#ifEmailAddress,#ifPassword', $('#frmSignIn')).on('keypress', function (e) { if (e.which == 13) sax.doSignin(); });
$('#frmSignIn #pbSignIn').on('click', function () { sax.doSignin(); });
$('#ifPasswordCurrent,#ifPassword,#ifPasswordConfirm', $('#frmChangePassword')).on('keypress', function (e) { if (e.which == 13) sax.doChangePassword(); });
$('#frmChangePassword #pbChangePassword').on('click', function () { sax.doChangePassword(); });
$('#ifEmailAddress', $('#frmRequestPassword')).on('keypress', function (e) { if (e.which == 13) sax.doRequestPassword(); });
$('#frmRequestPassword #pbRequestPassword').on('click', function () { sax.doRequestPassword(); });
});
//--------------------------------------------------------------
sax.doScorePassword = function ()
{
sax.ajaxScorePassword = sax.ajaxScorePassword || { url: sax.url.base + 'Security/Ajax/ScorePassword', formId: 'frmChangePassword', callbackFn: sax.onScorePassword, noWaitIcon: true };
sax.doAjaxRequest(sax.ajaxScorePassword, 250);
}
sax.onScorePassword = function (response)
{
var score = (response || {}).score || 0;
sax.$prgPasswordStrength.progressbar("option", "value", score).removeClass('amber green').addClass(score > 3 ? 'green' : score > 2 ? 'amber' : '');
}
//--------------------------------------------------------------
//--------------------------------------------------------------
sax.doChangePassword = function ()
{
sax.clearControlErrors();
sax.ajaxChangePassword = sax.ajaxChangePassword || { url: sax.url.base + 'Security/Ajax/StorePassword', formId: 'frmChangePassword', callbackFn: sax.onChangePassword };
sax.doAjaxRequest(sax.ajaxChangePassword, 50);
}
sax.onChangePassword = function (response)
{
sax.refreshControlValues(response.controlValues);
if (!response.success) return;
if ($('#ifRpe').length)
sax.goToPage('Security/Signin');
else sax.goToPage('');
}
//--------------------------------------------------------------
sax.doRequestPassword = function ()
{
sax.clearControlErrors();
sax.ajaxRequestPassword = sax.ajaxRequestPassword || { url: sax.url.base + 'Security/Ajax/RequestNewPassword', formId: 'frmRequestPassword', callbackFn: sax.onRequestPassword };
sax.doAjaxRequest(sax.ajaxRequestPassword, 50);
}
sax.onRequestPassword = function (response)
{
sax.refreshControlValues(response.controlValues);
if (!response.success) return;
var gotoSigninPage = function ()
{
sax.goToPage('Security/Signin');
}
if (response.successMsg)
sax.doAlert($('.sax-page-caption').text(), response.successMsg, gotoSigninPage);
else gotoSigninPage();
}
//--------------------------------------------------------------
$(function ()
{
$(':input:enabled:visible:first').focus();
$('#ifEmailAddress,#ifPasswordCurrent,#ifPassword,#ifPasswordConfirm').on('input', function () { sax.clearControlError(this); });
$('#frmChangePassword #ifPassword').on('keyup', sax.doScorePassword);
sax.$prgPasswordStrength = $('#frmChangePassword #prgPasswordStrength').progressbar({ 'max': 5 });
$('#ifEmailAddress,#ifPassword', $('#frmSignIn')).on('keypress', function (e) { if (e.which == 13) sax.doSignin(); });
$('#frmSignIn #pbSignIn').on('click', function () { sax.doSignin(); });
$('#ifPasswordCurrent,#ifPassword,#ifPasswordConfirm', $('#frmChangePassword')).on('keypress', function (e) { if (e.which == 13) sax.doChangePassword(); });
$('#frmChangePassword #pbChangePassword').on('click', function () { sax.doChangePassword(); });
$('#ifEmailAddress', $('#frmRequestPassword')).on('keypress', function (e) { if (e.which == 13) sax.doRequestPassword(); });
$('#frmRequestPassword #pbRequestPassword').on('click', function () { sax.doRequestPassword(); });
});
}(window, window.document));
/* The End */
@@ -0,0 +1,132 @@
/*
* Region selection.
*/
(function (win, doc, undef)
{
"use strict";
let sr = sax.data.selectRegion = sax.data.selectRegion || { regions: {}, fn: {}, $dlg: {}, itemIdPrefix: 'Rgn_' };
//--------------------------------------------------------------
/*
* Region selection config:
* - caption - dialog title.
* - regionId - currently selected region.
* - fnCallback - method to call on completion to store selected region.
*/
sr.fn.selectRegion = function (cfg)
{
sr.fn.init();
sr.cfg = cfg;
sr.regionId = cfg.regionId;
if (sr.regions.length) sr.fn.showSelectRegion();
else
{
sax.ajaxRegions = sax.ajaxRegions || { url: sax.url.base + 'Reference/Ajax/GetRegions', formId: 'frmNavigate', callbackFn: sr.fn.refreshRegionsAndSelect };
sax.doAjaxRequest(sax.ajaxRegions, 20);
}
}
sr.fn.refreshRegionsAndSelect = function (response)
{
if (!response || !response.success) return;
sr.regions = response.regions;
sr.fn.showSelectRegion();
}
sr.fn.showSelectRegion = function ()
{
$('.SelectedRegionName', sr.$dlg).text(sr.fn.getRegionName(sr.regionId));
$('#ifRegionFilter', sr.$dlg).val('');
sr.fn.displayRegions();
sax.openDialog(sr.$dlg.dialog('option', { title: sr.cfg.caption || 'Select Region' }), 400, 600);
}
//--------------------------------------------------------------
sr.fn.compareRegions=function(a, b)
{
var comparison = a.name.toLowerCase().localeCompare(b.name.toLowerCase());
if (comparison === 0)
return a.name.localeCompare(b.name);
return comparison;
}
//--------------------------------------------------------------
sr.fn.displayRegions = function ()
{
let filter = $('#ifRegionFilter', sr.$dlg).val();
let reFilter = new RegExp(sax.escapeRegExp((filter || '').trim()), 'i');
let $regionsAvail = $('.sax-selectRegion-regions.AvailableRegions').empty();
let $regionTmpl = $('.sax-panel-item-template .sax-panel-item.Region');
let regions = [...sr.regions];
regions.sort(sr.fn.compareRegions);
for (let rgnIdx = 0; rgnIdx < regions.length; rgnIdx++)
{
let region = regions[rgnIdx];
let id = region.id;
if (filter && !region.name.match(reFilter)) continue;
let $region = $regionTmpl.clone();
$region.prop('id', sr.itemIdPrefix + id).on('click', function () { sr.fn.onClickRegion(id); }).on('dblclick', function () { sr.fn.onDblClickRegion(id); }).find('.RegionName').text(region.name).end();
if (id == sr.regionId) $region.addClass('sel');
$regionsAvail.append($region);
}
}
sr.fn.getRegion = function (id)
{
for (let rgnIdx = 0; rgnIdx < sr.regions.length; rgnIdx++)
{
let region = sr.regions[rgnIdx];
if (region.id == id) return region;
}
}
sr.fn.getRegionName = function (id)
{
let region = sr.fn.getRegion(id);
return region ? region.name : '';
}
//--------------------------------------------------------------
sr.fn.onClickRegion = function (id)
{
$('.SelectedRegionName', sr.$dlg).text(sr.fn.getRegionName(sr.regionId = id));
$('.sax-panel-item.Region').removeClass('sel');
$('.sax-panel-item.Region#' + sr.itemIdPrefix + id).addClass('sel');
}
sr.fn.onDblClickRegion = function (id)
{
sr.regionId = id;
sr.fn.storeSelectRegion();
}
sr.fn.storeSelectRegion = function ()
{
if (!sr.regionId) return;
let region = sr.fn.getRegion(sr.regionId);
if (!region) return;
if (sr.cfg.fnCallback) sr.cfg.fnCallback(region);
sr.$dlg.dialog('close');
delete sr.cfg;
delete sr.regionId;
}
//--------------------------------------------------------------
sr.fn.onDlgSize = function ()
{
let $pnl = $('.sax-selectRegion-regions.AvailableRegions');
$pnl.outerHeight(Math.floor(sr.$dlg.innerHeight() - $pnl.position().top - ($pnl.outerHeight(true) - $pnl.innerHeight())));
}
//--------------------------------------------------------------
sr.fn.init = function ()
{
if (!sr.$dlg) return;
var opt = sax.dlgOpts();
opt.open = function (evt, ui) { sr.fn.onDlgSize(); };
opt.resize = function (evt, ui) { sr.fn.onDlgSize(); };
opt.buttons[sax.dlg.btn.ok] = function () { sr.fn.storeSelectRegion(); };
opt.buttons[sax.dlg.btn.cancel] = function () { $(this).dialog('close'); };
sr.$dlg = $('#dlgSelectRegion').dialog(opt);
}
}(window, window.document));
/* The End */
@@ -5,7 +5,7 @@
(function (win, doc, undef)
{
"use strict";
let ss = sax.data.sportSel = sax.data.sportSel || { sports: {}, fn: {}, $dlg: {}, itemIdPrefix: 'Spt_' };
let ss = sax.data.selectSport = sax.data.selectSport || { sports: {}, fn: {}, $dlg: {}, itemIdPrefix: 'Spt_' };
//--------------------------------------------------------------
/*
@@ -19,7 +19,7 @@
ss.fn.init();
ss.cfg = cfg;
ss.sportId = cfg.sportId;
if (ss.sports.length) ss.fn.showSportSelection();
if (ss.sports.length) ss.fn.showSelectSport();
else
{
sax.ajaxSports = sax.ajaxSports || { url: sax.url.base + 'Reference/Ajax/GetSports', formId: 'frmNavigate', callbackFn: ss.fn.refreshSportsAndSelect };
@@ -30,9 +30,9 @@
{
if (!response || !response.success) return;
ss.sports = response.sports;
ss.fn.showSportSelection();
ss.fn.showSelectSport();
}
ss.fn.showSportSelection = function ()
ss.fn.showSelectSport = function ()
{
$('.SelectedSportName', ss.$dlg).text(ss.fn.getSportName(ss.sportId));
$('#ifSportFilter', ss.$dlg).val('');
@@ -54,7 +54,7 @@
{
let filter = $('#ifSportFilter', ss.$dlg).val();
let reFilter = new RegExp(sax.escapeRegExp((filter || '').trim()), 'i');
let $sportsAvail = $('.sax-sportSelection-sports.AvailableSports').empty();
let $sportsAvail = $('.sax-selectSport-sports.AvailableSports').empty();
let $sportTmpl = $('.sax-panel-item-template .sax-panel-item.Sport');
let sports = [...ss.sports];
sports.sort(ss.fn.compareSports);
@@ -93,9 +93,9 @@
ss.fn.onDblClickSport = function (id)
{
ss.sportId = id;
ss.fn.storeSportSelection();
ss.fn.storeSelectSport();
}
ss.fn.storeSportSelection = function ()
ss.fn.storeSelectSport = function ()
{
if (!ss.sportId) return;
let sport = ss.fn.getSport(ss.sportId);
@@ -111,7 +111,7 @@
//--------------------------------------------------------------
ss.fn.onDlgSize = function ()
{
let $pnl = $('.sax-sportSelection-sports.AvailableSports');
let $pnl = $('.sax-selectSport-sports.AvailableSports');
$pnl.outerHeight(Math.floor(ss.$dlg.innerHeight() - $pnl.position().top - ($pnl.outerHeight(true) - $pnl.innerHeight())));
}
@@ -122,9 +122,9 @@
var opt = sax.dlgOpts();
opt.open = function (evt, ui) { ss.fn.onDlgSize(); };
opt.resize = function (evt, ui) { ss.fn.onDlgSize(); };
opt.buttons[sax.dlg.btn.ok] = function () { ss.fn.storeSportSelection(); };
opt.buttons[sax.dlg.btn.ok] = function () { ss.fn.storeSelectSport(); };
opt.buttons[sax.dlg.btn.cancel] = function () { $(this).dialog('close'); };
ss.$dlg = $('#dlgSportSelection').dialog(opt);
ss.$dlg = $('#dlgSelectSport').dialog(opt);
}
}(window, window.document));
+5 -2
View File
@@ -18,7 +18,7 @@ namespace Saxonite.Net.Standard.Base.App
//-------------------------------------------------------------------
public static class Version
{
private static String version { get; } = "1.0.3.1";
private static String version { get; } = "1.0.4.0";
// Retrieve version.
public static String GetFullVersion () { return version; }
public static String GetAppVersion ()
@@ -31,7 +31,7 @@ namespace Saxonite.Net.Standard.Base.App
String[] versionElements = version.Split('.');
return String.Join(".", versionElements.Take(3));
}
catch (Exception exc) { SaLogger.Warn("Sax.VersionData.ToString " + ExceptionUtil.GetErrorStateMessage(exc)); }
catch (Exception exc) { SaLogger.Warn("Sax.Version.ToString " + ExceptionUtil.GetErrorStateMessage(exc)); }
}
return version;
}
@@ -39,8 +39,11 @@ namespace Saxonite.Net.Standard.Base.App
//-------------------------------------------------------------------
// Version history.
// 1.0.4 ?-May-2021 Online Profile Organisation
// - Admin Organisation Region & Sport.
// 1.0.3 11-May-2021 Admin Organisation Members
// - Admin data filters & styling, organisation members.
// - Online Profile Organisations - simple list with name.
// - Online region and sport popups sorted and OK working.
// 1.0.2 6-May-2021 Online bug fix.
// - Resolve Online region & sport popup issue.
@@ -25,6 +25,12 @@ namespace Saxonite.Net.Standard.Base.Bus
OrganisationCategory_Desc,
PhoneMain,
PhoneAlt,
// Region.
RegionId,
Region_Name,
// Sport.
SportId,
Sport_Name,
// Associated data.
/// <summary>Number of users with an active interest in the organisation.</summary>
User_Count,
@@ -49,6 +55,8 @@ namespace Saxonite.Net.Standard.Base.Bus
public Sax.OrganisationCategory OrganisationCategory { get; set; }
public String PhoneMain { get; set; } = String.Empty;
public String PhoneAlt { get; set; } = String.Empty;
public SysId RegionIdPrimary { get; set; }
public SysId SportIdPrimary { get; set; }
}
//-------------------------------------------------------------------
@@ -88,6 +96,16 @@ namespace Saxonite.Net.Standard.Base.Bus
get { return data.PhoneAlt; }
set { CheckChanged(data.PhoneAlt, value); data.PhoneAlt = value; }
}
public SysId RegionIdPrimary
{
get { return data.RegionIdPrimary; }
set { CheckChanged(data.RegionIdPrimary, value); data.RegionIdPrimary = value; }
}
public SysId SportIdPrimary
{
get { return data.SportIdPrimary; }
set { CheckChanged(data.SportIdPrimary, value); data.SportIdPrimary = value; }
}
// Population.
internal void PopulateFrom (Data data)
{
@@ -96,6 +114,8 @@ namespace Saxonite.Net.Standard.Base.Bus
OrganisationCategory = data.OrganisationCategory;
PhoneMain = data.PhoneMain;
PhoneAlt = data.PhoneAlt;
RegionIdPrimary = data.RegionIdPrimary;
SportIdPrimary = data.SportIdPrimary;
base.PopulateFrom(data);
}
public Data Clone ()
@@ -116,6 +136,8 @@ namespace Saxonite.Net.Standard.Base.Bus
public ValidValue OrganisationCategory { get; set; } = ValidValue.Valid;
public ValidValue PhoneMain { get; set; } = ValidValue.Valid;
public ValidValue PhoneAlt { get; set; } = ValidValue.Valid;
public ValidValue RegionIdPrimary { get; set; } = ValidValue.Valid;
public ValidValue SportIdPrimary { get; set; } = ValidValue.Valid;
}
//-------------------------------------------------------------------
@@ -193,6 +215,16 @@ namespace Saxonite.Net.Standard.Base.Bus
get { return data.PhoneAlt; }
set { data.PhoneAlt = value; }
}
public SysId RegionIdPrimary
{
get { return data.RegionIdPrimary; }
set { data.RegionIdPrimary = value; }
}
public SysId SportIdPrimary
{
get { return data.SportIdPrimary; }
set { data.SportIdPrimary = value; }
}
//-------------------------------------------------------------------
// Flags - positions 1-16 available.
@@ -224,6 +256,9 @@ namespace Saxonite.Net.Standard.Base.Bus
public String NamePartial { get; set; }
/// <summary>Partial match on a number of fields, including name, sport, address, etc.</summary>
public String OrganisationFilter { get; set; }
public List<SysId> RegionIdsIncluded { get; } = new List<SysId>();
public List<SysId> SportIdsIncluded { get; } = new List<SysId>();
// Common properties.
public String NotesPartial { get; set; }
public StatusCat StatusCat { get; set; } = StatusCat.ActiveOnly;
}
@@ -234,6 +269,16 @@ namespace Saxonite.Net.Standard.Base.Bus
// Company list methods.
public static class SaxOrganisationList
{
//-------------------------------------------------------------------
/// <summary>
/// Extract the first Organisation in list with the specified Id.
/// </summary>
public static SaxOrganisation GetOrganisationById(this List<SaxOrganisation> values, SysId organisationId)
{
return values.Find(item => item.Id.Equals(organisationId));
}
//-------------------------------------------------------------------
}
//=======================================================================
@@ -4,6 +4,7 @@ using Sarand.Net.Standard.Base.Utils;
using Saxonite.Net.Standard.Base.App;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Saxonite.Net.Standard.Base.Bus
@@ -262,6 +263,21 @@ namespace Saxonite.Net.Standard.Base.Bus
public static class SaxUserOrganisationList
{
//-------------------------------------------------------------------
/// <summary>
/// Extract list of unique Organisation Ids from the list.
/// </summary>
public static List<SysId> GetOrganisationIds(this List<SaxUserOrganisation> values)
{
return new HashSet<SysId>(values.Select(item => item.OrganisationId)).ToList();
}
/// <summary>
/// Extract list of unique User Account Ids from the list.
/// </summary>
public static List<SysId> GetUserAccountIds(this List<SaxUserOrganisation> values)
{
return new HashSet<SysId>(values.Select(item => item.UserAccountId)).ToList();
}
//-------------------------------------------------------------------
}
@@ -18,7 +18,7 @@ namespace Saxonite.Net.Standard.Base.Mgr
// Account Mgr - Organisation
//*******************************************************************
// Utilities.
public long GetOrganisationMemberCount (SysId organisationId)
public long GetOrganisationMemberCount(SysId organisationId)
{
if (!SysId.IsValid(organisationId)) return 0;
SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params();
@@ -30,11 +30,11 @@ namespace Saxonite.Net.Standard.Base.Mgr
//-------------------------------------------------------------------
// Create item.
public abstract SaxOrganisation CreateOrganisation ();
public abstract SaxOrganisation CreateOrganisation();
//-------------------------------------------------------------------
// Item exists.
public bool OrganisationExistsById (SysId id)
public bool OrganisationExistsById(SysId id)
{
ClearErrorState();
if (!SysId.IsValid(id)) return false;
@@ -43,7 +43,7 @@ namespace Saxonite.Net.Standard.Base.Mgr
prmOrganisation.StatusCat = SaxOrganisation.StatusCat.Any;
return GetOrganisationCount(prmOrganisation) == 1;
}
public bool OrganisationExistsByName (String name)
public bool OrganisationExistsByName(String name)
{
ClearErrorState();
if (StringUtil.IsEmpty(name)) return false;
@@ -55,8 +55,8 @@ namespace Saxonite.Net.Standard.Base.Mgr
//-------------------------------------------------------------------
// Retrieve individual items.
public abstract SaxOrganisation GetOrganisation (SaxOrganisation.Params prmOrganisation);
public SaxOrganisation GetOrganisationById (SysId id)
public abstract SaxOrganisation GetOrganisation(SaxOrganisation.Params prmOrganisation);
public SaxOrganisation GetOrganisationById(SysId id)
{
ClearErrorState();
if (!SysId.IsValid(id)) return null;
@@ -65,7 +65,7 @@ namespace Saxonite.Net.Standard.Base.Mgr
prmOrganisation.StatusCat = SaxOrganisation.StatusCat.Any;
return GetOrganisation(prmOrganisation);
}
public SaxOrganisation GetOrganisationByName (String name)
public SaxOrganisation GetOrganisationByName(String name)
{
ClearErrorState();
if (StringUtil.IsEmpty(name)) return null;
@@ -77,13 +77,13 @@ namespace Saxonite.Net.Standard.Base.Mgr
//-------------------------------------------------------------------
// Validate item data.
public bool IsValidOrganisation (SaxOrganisation organisation)
public bool IsValidOrganisation(SaxOrganisation organisation)
{
ClearErrorState();
if (organisation == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
return IsValidOrganisationData(organisation.GetData(), new SaxOrganisation.ErrField());
}
public virtual bool IsValidOrganisationData (SaxOrganisation.Data data, SaxOrganisation.ErrField errField)
public virtual bool IsValidOrganisationData(SaxOrganisation.Data data, SaxOrganisation.ErrField errField)
{
ClearErrorState();
// Name.
@@ -116,6 +116,15 @@ namespace Saxonite.Net.Standard.Base.Mgr
errField.PhoneAlt = SacsHierarchyItem.ValidValue.Invalid;
return false;
}
// Region.
if (errField.RegionIdPrimary != SacsHierarchyItem.ValidValue.Ignore)
{
}
// Sport.
if (errField.SportIdPrimary != SacsHierarchyItem.ValidValue.Ignore)
{
}
// Common properties.
if (errField.Notes != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Notes, "notes", (long)SaxDbDfn.GetColTextLen(SaxDbDfn.ColumnIdx.Organisation_Notes)))
{
@@ -136,34 +145,54 @@ namespace Saxonite.Net.Standard.Base.Mgr
}
}
// Region.
if (errField.RegionIdPrimary != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.RegionIdPrimary))
{
if (!ReferenceMgr.RegionExistsById(data.RegionIdPrimary))
{
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
return SetErrorState("Invalid region specified");
}
}
// Sport.
if (errField.SportIdPrimary != SacsHierarchyItem.ValidValue.Ignore && SysId.IsValid(data.SportIdPrimary))
{
if (!ReferenceMgr.SportExistsById(data.SportIdPrimary))
{
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
return SetErrorState("Invalid sport specified");
}
}
return true;
}
//-------------------------------------------------------------------
// Organisation database interface.
public abstract bool InsertOrganisation (SaxOrganisation organisation, DbUpdateInfo dbUpdateInfo);
public abstract bool UpdateOrganisation (SaxOrganisation organisation, DbUpdateInfo dbUpdateInfo);
public virtual bool OrganisationCanBeDeleted (SaxOrganisation organisation)
public abstract bool InsertOrganisation(SaxOrganisation organisation, DbUpdateInfo dbUpdateInfo);
public abstract bool UpdateOrganisation(SaxOrganisation organisation, DbUpdateInfo dbUpdateInfo);
public virtual bool OrganisationCanBeDeleted(SaxOrganisation organisation)
{
ClearErrorState();
return true;
}
public abstract bool DeleteOrganisation (SaxOrganisation organisation, DbUpdateInfo dbUpdateInfo);
public abstract bool DeleteOrganisation(SaxOrganisation organisation, DbUpdateInfo dbUpdateInfo);
//-------------------------------------------------------------------
// Organisation list:
public abstract ColumnDfn GetOrganisationColumnDfn (SaxOrganisation.Column columnId, String caption = "", int width = 0);
public abstract List<String> GetOrganisationQueryFilter (SaxOrganisation.Params prmOrganisation);
public abstract long GetOrganisationCount (SaxOrganisation.Params prmOrganisation);
public abstract List<SaxOrganisation> GetOrganisationList (SaxOrganisation.Params prmOrganisation);
public abstract DbResultSet ExecuteOrganisationQuery (List<ColumnDfn> columns, SaxOrganisation.Params prmOrganisation);
public abstract ColumnDfn GetOrganisationColumnDfn(SaxOrganisation.Column columnId, String caption = "", int width = 0);
public abstract List<String> GetOrganisationQueryFilter(SaxOrganisation.Params prmOrganisation);
public abstract long GetOrganisationCount(SaxOrganisation.Params prmOrganisation);
public abstract List<SaxOrganisation> GetOrganisationList(SaxOrganisation.Params prmOrganisation);
public abstract DbResultSet ExecuteOrganisationQuery(List<ColumnDfn> columns, SaxOrganisation.Params prmOrganisation);
//-------------------------------------------------------------------
/// <summary>
/// Extract and format result set data value where specific handling is required.
/// <para>Where response is an invalid data value, format value using column.FormatValue(values).</para>
/// </summary>
public virtual DataValue GetOrganisationDataValue (ColumnDfn column, NamedValue.Map values)
public virtual DataValue GetOrganisationDataValue(ColumnDfn column, NamedValue.Map values)
{
DataValue value = new DataValue();
switch ((SaxOrganisation.Column)column.Id)
@@ -194,17 +223,17 @@ namespace Saxonite.Net.Standard.Base.Mgr
// Status.
case SaxOrganisation.Column.Status_Desc:
case SaxOrganisation.Column.Status_Ind:
{
String statusCode = values.GetValue(column.DataName).ToString();
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
if (column.Id == (int)SaxOrganisation.Column.Status_Desc)
value = new DataValue(SacsSystem.GetStatusDesc(status));
else if (column.Id == (int)SaxOrganisation.Column.Status_Ind)
value = new DataValue(SaxOrganisation.GetStatusTriState(status));
}
break;
{
String statusCode = values.GetValue(column.DataName).ToString();
SaStatus status = SacsSystem.GetStatusForCode(statusCode);
if (column.Id == (int)SaxOrganisation.Column.Status_Desc)
value = new DataValue(SacsSystem.GetStatusDesc(status));
else if (column.Id == (int)SaxOrganisation.Column.Status_Ind)
value = new DataValue(SaxOrganisation.GetStatusTriState(status));
}
break;
//-----------------------------------------------------------
//-----------------------------------------------------------
}
return value;
}
@@ -208,6 +208,10 @@ namespace Saxonite.Net.Standard.Dbas.Mgr
dbOrganisation._PhoneAlt = organisation.PhoneAlt;
dbOrganisation._OrganisationType = OrganisationTypes.GetCodeForType(organisation.OrganisationType);
dbOrganisation._OrganisationCategory = OrganisationCategories.GetCodeForType(organisation.OrganisationCategory);
dbOrganisation._PhoneMain = organisation.PhoneMain;
dbOrganisation._PhoneAlt = organisation.PhoneAlt;
dbOrganisation._RegionIdPrimary = SysId.ToInt(organisation.RegionIdPrimary);
dbOrganisation._SportIdPrimary = SysId.ToInt(organisation.SportIdPrimary);
dbOrganisation._Notes = organisation.Notes;
dbOrganisation._Status = SacsSystem.GetStatusCode(organisation.Status);
dbOrganisation._Flags = (short)organisation.Flags;
@@ -230,6 +234,10 @@ namespace Saxonite.Net.Standard.Dbas.Mgr
organisation.PhoneAlt = dbOrganisation._PhoneAlt;
organisation.OrganisationType = (Sax.OrganisationType)OrganisationTypes.GetTypeForCode(dbOrganisation._OrganisationType);
organisation.OrganisationCategory = (Sax.OrganisationCategory)OrganisationCategories.GetTypeForCode(dbOrganisation._OrganisationCategory);
organisation.PhoneMain = dbOrganisation._PhoneMain;
organisation.PhoneAlt = dbOrganisation._PhoneAlt;
organisation.RegionIdPrimary = new SysId(dbOrganisation._RegionIdPrimary);
organisation.SportIdPrimary = new SysId(dbOrganisation._SportIdPrimary);
organisation.Notes = dbOrganisation._Notes;
organisation.Status = SacsSystem.GetStatusForCode(dbOrganisation._Status);
organisation.SetCreateStamp(dbOrganisation._CreateOn, new SysId(dbOrganisation._CreateBy), dbOrganisation._CreateHost);
@@ -240,6 +248,10 @@ namespace Saxonite.Net.Standard.Dbas.Mgr
//-------------------------------------------------------------------
// Item column definitions.
private static readonly String aliasOrganisation = "Org";
private static readonly String aliasOrganisation_Region = "Org_Rgn";
private static readonly String prefixOrganisation_Region = "Org_Rgn_";
private static readonly String aliasOrganisation_Sport = "Org_Spt";
private static readonly String prefixOrganisation_Sport = "Org_Spt_";
private static readonly String colOrganisation_User_Count = "Org_Usr_Count";
private static readonly String colOrganisation_Member_Count = "Org_Mbr_Count";
private void SetOrganisationColDfn
@@ -291,6 +303,26 @@ namespace Saxonite.Net.Standard.Dbas.Mgr
SetOrganisationColDfn(columnDfn, "Alt. phone", 100, SaxDbDfn.ColumnIdx.Organisation_PhoneAlt);
break;
//-----------------------------------------------------------
// Region.
case SaxOrganisation.Column.RegionId:
SetOrganisationColDfn(columnDfn, "Region Id", 80, SaxDbDfn.ColumnIdx.Region_Id, ColumnAlignment.Right, DataValue.DataType.Long, aliasOrganisation_Region, prefixOrganisation_Region);
columnDfn.ReadOnly = true;
break;
case SaxOrganisation.Column.Region_Name:
SetOrganisationColDfn(columnDfn, "Region", 120, SaxDbDfn.ColumnIdx.Organisation_Name, ColumnAlignment.Left, DataValue.DataType.String, aliasOrganisation_Region, prefixOrganisation_Region);
break;
//-----------------------------------------------------------
// Sport.
case SaxOrganisation.Column.SportId:
SetOrganisationColDfn(columnDfn, "Sport Id", 80, SaxDbDfn.ColumnIdx.Sport_Id, ColumnAlignment.Right, DataValue.DataType.Long, aliasOrganisation_Sport, prefixOrganisation_Sport);
columnDfn.ReadOnly = true;
break;
case SaxOrganisation.Column.Sport_Name:
SetOrganisationColDfn(columnDfn, "Sport", 120, SaxDbDfn.ColumnIdx.Organisation_Name, ColumnAlignment.Left, DataValue.DataType.String, aliasOrganisation_Sport, prefixOrganisation_Sport);
break;
//-----------------------------------------------------------
// Derived properties.
case SaxOrganisation.Column.User_Count:
@@ -373,6 +405,16 @@ namespace Saxonite.Net.Standard.Dbas.Mgr
}
}
// Region Ids.
String regionIdsIncluded = prm.RegionIdsIncluded.Concat(",");
if (!regionIdsIncluded.IsEmpty())
filter.Add(SaxDbDfn.GetColumnNameQual(SaxDbDfn.ColumnIdx.Organisation_RegionIdPrimary, aliasOrganisation) + " IN (" + regionIdsIncluded + ")");
// Sport Ids.
String sportIdsIncluded = prm.SportIdsIncluded.Concat(",");
if (!sportIdsIncluded.IsEmpty())
filter.Add(SaxDbDfn.GetColumnNameQual(SaxDbDfn.ColumnIdx.Organisation_SportIdPrimary, aliasOrganisation) + " IN (" + sportIdsIncluded + ")");
// Notes.
if (!StringUtil.IsEmpty(prm.NotesPartial))
filter.Add(SaxDbDfn.GetColumnNameQual(SaxDbDfn.ColumnIdx.Organisation_Notes, aliasOrganisation) + " LIKE '%" + DbQuery.FormatForLike(prm.NotesPartial) + "%'");
@@ -494,6 +536,14 @@ namespace Saxonite.Net.Standard.Dbas.Mgr
query.Columns.Add(SaxDbDfn.GetColumnNameQual(SaxDbDfn.ColumnIdx.Organisation_OrganisationType, aliasOrganisation));
if (columns.HasId(SaxOrganisation.Column.OrganisationCategory) || columns.HasId(SaxOrganisation.Column.OrganisationCategory_Desc))
query.Columns.Add(SaxDbDfn.GetColumnNameQual(SaxDbDfn.ColumnIdx.Organisation_OrganisationCategory, aliasOrganisation));
// Region.
bool hasRegionCols = columns.HasId(SaxOrganisation.Column.Region_Name);
if (columns.HasId(SaxOrganisation.Column.RegionId) || hasRegionCols)
query.Columns.Add(SaxDbDfn.GetColumnNameQual(SaxDbDfn.ColumnIdx.Organisation_RegionIdPrimary, aliasOrganisation));
// Sport.
bool hasSportCols = columns.HasId(SaxOrganisation.Column.Sport_Name);
if (columns.HasId(SaxOrganisation.Column.SportId) || hasSportCols)
query.Columns.Add(SaxDbDfn.GetColumnNameQual(SaxDbDfn.ColumnIdx.Organisation_SportIdPrimary, aliasOrganisation));
// Common properties.
if (columns.HasId(SaxOrganisation.Column.Notes))
query.Columns.Add(SaxDbDfn.GetColumnNameQual(SaxDbDfn.ColumnIdx.Organisation_Notes, aliasOrganisation));
@@ -506,6 +556,34 @@ namespace Saxonite.Net.Standard.Dbas.Mgr
if (columns.HasId(SaxOrganisation.Column.UpdateOn_Date))
query.Columns.Add(SaxDbDfn.GetColumnNameQual(SaxDbDfn.ColumnIdx.Organisation_UpdateOn, aliasOrganisation));
//---------------------------------------------------------------------
// Region.
if (hasRegionCols)
{
DbQueryJoin joinRegion = new DbQueryJoin(DbJoinType.LeftOuter);
joinRegion.Table = new StringPair(SaxDbDfn.GetTableName(SaxDbDfn.TableIdx.Region), aliasOrganisation_Region);
joinRegion.Filters.Add(SaxDbDfn.GetColumnNameQual(SaxDbDfn.ColumnIdx.Region_Id, aliasOrganisation_Region) + "=" + SaxDbDfn.GetColumnNameQual(SaxDbDfn.ColumnIdx.Organisation_RegionIdPrimary, aliasOrganisation));
query.Joins.Add(joinRegion);
List<SaxDbDfn.ColumnIdx> cols = new List<SaxDbDfn.ColumnIdx>();
cols.Add(SaxDbDfn.ColumnIdx.Region_Name);
foreach (var col in cols)
query.Columns.Add(SaxDbDfn.GetColumnNameQual(col, aliasOrganisation_Region), prefixOrganisation_Region + SaxDbDfn.GetColumnName(col, false));
}
//---------------------------------------------------------------------
// Sport.
if (hasSportCols)
{
DbQueryJoin joinSport = new DbQueryJoin(DbJoinType.LeftOuter);
joinSport.Table = new StringPair(SaxDbDfn.GetTableName(SaxDbDfn.TableIdx.Sport), aliasOrganisation_Sport);
joinSport.Filters.Add(SaxDbDfn.GetColumnNameQual(SaxDbDfn.ColumnIdx.Sport_Id, aliasOrganisation_Sport) + "=" + SaxDbDfn.GetColumnNameQual(SaxDbDfn.ColumnIdx.Organisation_SportIdPrimary, aliasOrganisation));
query.Joins.Add(joinSport);
List<SaxDbDfn.ColumnIdx> cols = new List<SaxDbDfn.ColumnIdx>();
cols.Add(SaxDbDfn.ColumnIdx.Sport_Name);
foreach (var col in cols)
query.Columns.Add(SaxDbDfn.GetColumnNameQual(col, aliasOrganisation_Sport), prefixOrganisation_Sport + SaxDbDfn.GetColumnName(col, false));
}
//---------------------------------------------------------------------
// User count.
if (columns.HasId(SaxOrganisation.Column.User_Count))