This commit is contained in:
2021-11-01 18:14:21 +00:00
parent ea61d37840
commit 806ebb4024
34 changed files with 766 additions and 411 deletions
@@ -14,6 +14,7 @@ using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Utils;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Dbas;
using Saxonite.Net.Standard.Base.App;
namespace Saxonite.Net.Core.Web.Online.Controllers
{
@@ -35,6 +36,11 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
public String RegionName { get; set; }
public long MemberCount { get; set; }
public long OpportunityCount { get; set; }
public bool? Admin { get; set; } = null;
public bool? MemberAdmin { get; set; } = null;
public bool? OpportunitiyAdmin { get; set; } = null;
public bool? ScheduleAdmin { get; set; } = null;
public bool? ArticleAdmin { get; set; } = null;
}
private class AjaxResponse_ProfileOrganisationsData : AjaxResponse_Data
{
@@ -78,13 +84,15 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
ColumnDfn colOpportunityCount = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Organisation_Opportunity_Count);
ColumnDfn colStatus = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Status);
ColumnDfn colCreatedOn = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.CreateOn_Date);
ColumnDfn colRoleCodes = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.OrganisationRoleCodes);
List<ColumnDfn> columns = new List<ColumnDfn>()
{
colId, colOrganisationId , colOrganisationName,
colOrganisationSportId, colOrganisationSportName,
colOrganisationRegionId, colOrganisationRegionName,
colMemberCount, colOpportunityCount,
colStatus, colStatus, colCreatedOn
colStatus, colStatus, colCreatedOn,
colRoleCodes
};
// Sort columns.
@@ -97,6 +105,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
while (resultSet != null && resultSet.HasRows && resultSet.NextRecord())
{
NamedValue.Map values = resultSet.GetRecordValues();
List<String> roleCodes = StringListUtil.Split(values.GetString(colRoleCodes.DataName), ",");
ProfileOrganisationData organisationData = new ProfileOrganisationData()
{
Id = values.GetLong(colId.DataName),
@@ -108,6 +117,16 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
MemberCount = values.GetLong(colMemberCount.DataName),
OpportunityCount = values.GetLong(colOpportunityCount.DataName)
};
if (roleCodes.ContainsCI(OrganisationRoleCodes.GetCodeForType(Sax.OrganisationRole.Admin)))
organisationData.Admin = true;
if (roleCodes.ContainsCI(OrganisationRoleCodes.GetCodeForType(Sax.OrganisationRole.MemberAdmin)))
organisationData.MemberAdmin = true;
if (roleCodes.ContainsCI(OrganisationRoleCodes.GetCodeForType(Sax.OrganisationRole.OpportunityAdmin)))
organisationData.OpportunitiyAdmin = true;
if (roleCodes.ContainsCI(OrganisationRoleCodes.GetCodeForType(Sax.OrganisationRole.ScheduleAdmin)))
organisationData.ScheduleAdmin = true;
if (roleCodes.ContainsCI(OrganisationRoleCodes.GetCodeForType(Sax.OrganisationRole.ArticleAdmin)))
organisationData.ArticleAdmin = true;
responseData.Organisations.Add(organisationData);
}
}
@@ -145,7 +145,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
RefreshModel(model);
// Organisations that the user has rights to author articles for.
foreach (SaxAccountMgr.OrganisationIdName organisation in AccountMgr.GetOrganisationsForUserRole(userAccountId, Sax.OrganisationRole.ArticleAdmin))
foreach (SaxAccountMgr.OrganisationIdName organisation in AccountMgr.GetOrganisationsForAnyUserRole(userAccountId, new [] { Sax.OrganisationRole.Admin, Sax.OrganisationRole.ArticleAdmin }))
{
if (responseData.Organisations == null) responseData.Organisations = new List<OrganisationData>();
OrganisationData organisationData = new OrganisationData()
@@ -450,7 +450,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
if (SysId.IsValid(organisationId))
{
// Organisation specified - User must have Article Admin role.
if (!AccountMgr.UserHasOrganisationRole(userAccountId, organisationId, Sax.OrganisationRole.ArticleAdmin))
if (!AccountMgr.UserHasAnyOrganisationRole(userAccountId, organisationId, new [] { Sax.OrganisationRole.Admin, Sax.OrganisationRole.ArticleAdmin }))
{
SaLogger.Warn(fn + " User does not have Article Admin role for organisation." + GetLogSuffix());
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
@@ -34,7 +34,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
return RedirectToAction("", "");
// User must either be a Journalist or have Article Admin rights with at least one organisation.
List<SaxAccountMgr.OrganisationIdName> organisations = AccountMgr.GetOrganisationsForUserRole(SessionData.User.UserAccountId, Sax.OrganisationRole.ArticleAdmin);
List<SaxAccountMgr.OrganisationIdName> organisations = AccountMgr.GetOrganisationsForAnyUserRole(SessionData.User.UserAccountId, new [] { Sax.OrganisationRole.Admin, Sax.OrganisationRole.ArticleAdmin });
if (organisations.Count < 1 && !UserIsJournalist)
return RedirectToAction("", "");
@@ -104,17 +104,20 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
if (!ValidUserSession) return GetAjaxResult_InvalidSession(responseData);
RefreshModel(model);
// Organisation.
SysId organisationId = model.ExtractSysId(model.Filter.OrganisationId);
SaxOrganisation organisation = AccountMgr.GetOrganisationById(organisationId);
if (organisation == null || !organisation.IsStatusActive)
// Record disposable items as they are created so all can be disposed when needed.
using (DisposableCollection<SacsHierarchyItem> disposableItems = new DisposableCollection<SacsHierarchyItem>())
{
SaLogger.Warn(fn + " " + (organisation == null ? "Invalid" : "Inactive") + " organisation for Member list. OrganisationId: '" + model.Filter.OrganisationId + "'");
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"]));
}
if (organisation != null)
{
// Organisation.
SysId organisationId = model.ExtractSysId(model.Filter.OrganisationId);
SaxOrganisation organisation = AccountMgr.GetOrganisationById(organisationId);
disposableItems.Add(organisation);
if (organisation == null || !organisation.IsStatusActive)
{
SaLogger.Warn(fn + " " + (organisation == null ? "Invalid" : "Inactive") + " organisation for Member list. OrganisationId: '" + model.Filter.OrganisationId + "'");
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"]));
}
// Store filter data.
SessionData_Online.Filter.SetMemberOrganisation(organisation);
@@ -124,11 +127,11 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
responseData.Titles.Add(title.Code, title.Desc);
// Reference data - member roles.
foreach (TypeCodeDesc memberRole in OrganisationRoleCodes.FindAll( item => item.Type != (int)Sax.OrganisationRole.Member))
foreach (TypeCodeDesc memberRole in OrganisationRoleCodes.FindAll(item => item.Type != (int)Sax.OrganisationRole.Member))
responseData.MemberRoles.Add(memberRole.Code, Localiser.GetOrganisationRoleCaption((Sax.OrganisationRole)memberRole.Type));
// Session User roles.
responseData.User.CanManage = AccountMgr.UserHasOrganisationRole(SessionData.User.UserAccountId, organisationId, Sax.OrganisationRole.MemberAdmin);
responseData.User.CanManage = AccountMgr.UserHasAnyOrganisationRole(SessionData.User.UserAccountId, organisation.Id, new List<Sax.OrganisationRole> { Sax.OrganisationRole.Admin, Sax.OrganisationRole.MemberAdmin });
// Item filter.
SaxUserOrganisation.Params prmMember = new SaxUserOrganisation.Params();
@@ -150,11 +153,11 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
ColumnDfn colAdminComment = responseData.User.CanManage ? AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.AdminComment) : new ColumnDfn(-1, "");
ColumnDfn colCreatedOn = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.CreateOn_Date);
List<ColumnDfn> columns = new List<ColumnDfn>()
{
colId, colUserAccountId , colEmailAddress, colDisplayName,
colOrganisationRoleCodes, colUserStatus,
colAdminComment, colCreatedOn
};
{
colId, colUserAccountId , colEmailAddress, colDisplayName,
colOrganisationRoleCodes, colUserStatus,
colAdminComment, colCreatedOn
};
// Sort columns.
colCreatedOn.SortAscending = false;
@@ -230,9 +233,13 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
if (!SysId.IsValid(memberId))
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.specified"]));
// Retrieve item.
using (SaxUserOrganisation userOrganisation = AccountMgr.GetUserOrganisationById(memberId))
// Record disposable items as they are created so all can be disposed when needed.
using (DisposableCollection<SacsHierarchyItem> disposableItems = new DisposableCollection<SacsHierarchyItem>())
{
// Retrieve item.
SaxUserOrganisation userOrganisation = AccountMgr.GetUserOrganisationById(memberId);
disposableItems.Add(userOrganisation);
if (userOrganisation == null)
{
SaLogger.Warn(fn + " Failed to retrieve Organisation Member for Id: '" + model.MemberId + "'");
@@ -240,33 +247,31 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
}
// Validate organisation.
using (SaxOrganisation organisation = AccountMgr.GetOrganisationById(userOrganisation.OrganisationId))
SaxOrganisation organisation = AccountMgr.GetOrganisationById(userOrganisation.OrganisationId);
disposableItems.Add(organisation);
if (organisation == null || !organisation.IsStatusActive)
{
if (organisation == null || !organisation.IsStatusActive)
{
SaLogger.Warn(fn + " " + (organisation == null ? "Invalid" : "Inactive") + " Organisation for Member. Id: '" + userOrganisation.OrganisationId + "'");
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"]));
}
// Session User roles.
bool userCanManageMembers = AccountMgr.UserHasOrganisationRole(SessionData.User.UserAccountId, organisation.Id, Sax.OrganisationRole.MemberAdmin);
// Validate user account.
using (SaxUserAccount userAccount = AccountMgr.GetUserAccountById(userOrganisation.UserAccountId))
{
bool userActive = userAccount.IsStatusActive || (userAccount.IsStatusAwaiting && userCanManageMembers);
if (userAccount == null || !userActive)
{
SaLogger.Warn(fn + " " + (organisation == null ? "Invalid" : "Inactive") + " User Account for Member. Id: '" + userOrganisation.UserAccountId + "'");
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"]));
}
// Make a note of the selected Organisation.
SessionData_Online.Filter.SetMemberOrganisation(organisation);
PopulateMemberResponseData(model, userOrganisation, userAccount, organisation, responseData.Member);
}
SaLogger.Warn(fn + " " + (organisation == null ? "Invalid" : "Inactive") + " Organisation for Member. Id: '" + userOrganisation.OrganisationId + "'");
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"]));
}
// Session User roles.
bool userCanManageMembers = AccountMgr.UserHasAnyOrganisationRole(SessionData.User.UserAccountId, organisation.Id, new List<Sax.OrganisationRole> { Sax.OrganisationRole.Admin, Sax.OrganisationRole.MemberAdmin });
// Validate user account.
SaxUserAccount userAccount = AccountMgr.GetUserAccountById(userOrganisation.UserAccountId);
disposableItems.Add(userAccount);
bool userActive = userAccount.IsStatusActive || (userAccount.IsStatusAwaiting && userCanManageMembers);
if (userAccount == null || !userActive)
{
SaLogger.Warn(fn + " " + (organisation == null ? "Invalid" : "Inactive") + " User Account for Member. Id: '" + userOrganisation.UserAccountId + "'");
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"]));
}
// Make a note of the selected Organisation.
SessionData_Online.Filter.SetMemberOrganisation(organisation);
PopulateMemberResponseData(model, userOrganisation, userAccount, organisation, responseData.Member);
}
// Construct response.
@@ -361,7 +366,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
}
// Ensure that the user has the correct role to update Members for this organisation.
bool userCanManageMembers = AccountMgr.UserHasOrganisationRole(SessionData.User.UserAccountId, organisationId, Sax.OrganisationRole.MemberAdmin);
bool userCanManageMembers = AccountMgr.UserHasAnyOrganisationRole(SessionData.User.UserAccountId, organisationId, new List<Sax.OrganisationRole> { Sax.OrganisationRole.Admin, Sax.OrganisationRole.MemberAdmin });
if (!userCanManageMembers)
{
SaLogger.Warn(fn + " User doesn't have 'Member Admin' role for Organisation Id: " + organisationId);
@@ -385,6 +390,23 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
SaLogger.Warn(fn + " Inconsistent User Account Id specified for User Organisation. Expected: " + userOrganisation.UserAccountId + ". Found: " + userAccount.Id);
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
}
// Validate roles for current user.
if (userOrganisation.UserAccountId.Equals(SessionData.User.UserAccountId))
{
// User is modifying their own organisation member.
if (userOrganisation.CanManageOrganisation && !model.OrganisationRoleCodes.Any(item => item.Type == (int)Sax.OrganisationRole.Admin))
{
// User has removed their own 'Admin' role.
SaLogger.Warn(fn + " Unable to store member - user is attempting to remove their own 'Admin' role.");
return Json(responseData.SetMessage(messageTitle, Localiser["organisation.members.msg.remove.own.admin.role"]));
}
if (!userOrganisation.CanManageMembers)
{
SaLogger.Warn(fn + " Unable to store member - user is attempting to remove their own 'Admin' and/or 'Member Admin' role.");
return Json(responseData.SetMessage(messageTitle, Localiser["organisation.members.msg.remove.own.admin.role"]));
}
}
}
// New member - Lookup user by email and create new account if needed.
@@ -458,17 +480,6 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
// Ensure user has member role.
userOrganisation.AddOrganisationRole(Sax.OrganisationRole.Member);
// Validate roles.
if (userOrganisation.UserAccountId.Equals(SessionData.User.UserAccountId))
{
// User is modifying their own member.
if (!userOrganisation.HasOrganisationRole(Sax.OrganisationRole.MemberAdmin))
{
SaLogger.Warn(fn + " Unable to store member - user is attempting to remove their own 'Member Admin' role.");
return Json(responseData.SetMessage(messageTitle, Localiser["organisation.members.msg.remove.own.admin.role"]));
}
}
// User organisation properties.
if (model.MemberAdminComment != null)
userOrganisation.AdminComment = model.MemberAdminComment;
@@ -548,7 +559,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
}
// Ensure that the user has the correct role to update Members for this organisation.
bool userCanManageMembers = AccountMgr.UserHasOrganisationRole(SessionData.User.UserAccountId, organisation.Id, Sax.OrganisationRole.MemberAdmin);
bool userCanManageMembers = AccountMgr.UserHasAnyOrganisationRole(SessionData.User.UserAccountId, organisation.Id, new List<Sax.OrganisationRole> { Sax.OrganisationRole.Admin, Sax.OrganisationRole.MemberAdmin });
if (!userCanManageMembers)
{
SaLogger.Warn(fn + " User doesn't have 'Member Admin' role for Organisation Id: " + organisation.Id);
@@ -664,7 +675,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
}
// Ensure that the user has the correct role to update Members for this organisation.
bool userCanManageMembers = AccountMgr.UserHasOrganisationRole(SessionData.User.UserAccountId, organisation.Id, Sax.OrganisationRole.MemberAdmin);
bool userCanManageMembers = AccountMgr.UserHasAnyOrganisationRole(SessionData.User.UserAccountId, organisation.Id, new List<Sax.OrganisationRole> { Sax.OrganisationRole.Admin, Sax.OrganisationRole.MemberAdmin });
if (!userCanManageMembers)
{
SaLogger.Warn(fn + " User doesn't have 'Member Admin' role for Organisation Id: " + organisation.Id);
@@ -154,7 +154,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
responseData.Organisation.RegionName = model.GetRegionCaption(organisation.RegionIdPrimary);
// User details.
responseData.User.CanManage = userOrganisation?.HasOrganisationRole(Sax.OrganisationRole.OpportunityAdmin) ?? false;
responseData.User.CanManage = userOrganisation.CanManageOpportunities;
// Item filter.
SaxOrganisationOpportunity.Params prmOpportunity = new SaxOrganisationOpportunity.Params();
@@ -354,7 +354,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
}
// Ensure that the user has the correct role to update Opportunities for this organisation.
if (!AccountMgr.UserHasOrganisationRole(SessionData.User.UserAccountId, organisationId, Sax.OrganisationRole.OpportunityAdmin))
if (!AccountMgr.UserHasAnyOrganisationRole(SessionData.User.UserAccountId, organisationId, new [] { Sax.OrganisationRole.Admin, Sax.OrganisationRole.OpportunityAdmin }))
{
SaLogger.Warn(fn + " User doesn't have 'Opportunity Admin' role for Organisation Id: " + organisationId);
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
@@ -152,7 +152,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
// Add user as member of organisation.
SaxUserOrganisation userOrganisation = AccountMgr.CreateUserOrganisation(userAccount.Id, organisation.Id);
userOrganisation.OrganisationRoles = new List<Sax.OrganisationRole>() { Sax.OrganisationRole.Member, Sax.OrganisationRole.MemberAdmin };
userOrganisation.OrganisationRoles = new [] { Sax.OrganisationRole.Member, Sax.OrganisationRole.Admin };
if (!AccountMgr.InsertUserOrganisation(userOrganisation, DbUpdateInfo))
{
SaLogger.Warn(fn + " Failed to insert user organisation - " + AccountMgr.ErrorStateMessage);
@@ -181,7 +181,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
}
// Complete response.
responseData.SetMessage(messageTitle, Localiser["msg.organisation.request.success"].ToString().ReplaceAll("\n", "<br>"));
responseData.SetMessage(messageTitle, Localiser["msg.organisation.request.success"].ToString().ReplaceAll("\n", "<br/><br/>"));
responseData.Success = true;
return Json(responseData);
}
@@ -22,8 +22,9 @@ namespace Saxonite.Net.Core.Web.Online.Models
//-------------------------------------------------------------------
// Data members.
private bool? userCanManageOrganisationMembers = null;
private bool? userCanManageOrganisationArticles = null;
private bool? userCanManageOrganisationOpportunities = null;
private bool? userCanManageOrganisationSchedule = null;
private bool? userCanManageOrganisationArticles = null;
//-------------------------------------------------------------------
// Protected construction.
@@ -51,29 +52,14 @@ namespace Saxonite.Net.Core.Web.Online.Models
SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params();
prmUserOrganisation.UserAccountIdsIncluded.Add(SessionData.User.UserAccountId);
prmUserOrganisation.OrganisationMembersOnly = true;
prmUserOrganisation.OrganisationRoles.Add(Sax.OrganisationRole.OpportunityAdmin);
prmUserOrganisation.OrganisationRolesAny.Add(Sax.OrganisationRole.Admin);
prmUserOrganisation.OrganisationRolesAny.Add(Sax.OrganisationRole.MemberAdmin);
prmUserOrganisation.StatusCat = SaxUserOrganisation.StatusCat.ActiveOnly;
userCanManageOrganisationMembers = (AccountMgr.GetUserOrganisationCount(prmUserOrganisation) > 0);
}
return userCanManageOrganisationMembers == true ? true : false;
}
}
public bool UserCanManageOrganisationArticles
{
get
{
if (userCanManageOrganisationArticles == null && ValidUserSession)
{
SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params();
prmUserOrganisation.UserAccountIdsIncluded.Add(SessionData.User.UserAccountId);
prmUserOrganisation.OrganisationMembersOnly = true;
prmUserOrganisation.OrganisationRoles.Add(Sax.OrganisationRole.ArticleAdmin);
prmUserOrganisation.StatusCat = SaxUserOrganisation.StatusCat.ActiveOnly;
userCanManageOrganisationArticles = (AccountMgr.GetUserOrganisationCount(prmUserOrganisation) > 0);
}
return userCanManageOrganisationArticles == true ? true : false;
}
}
public bool UserCanManageOrganisationOpportunities
{
get
@@ -83,13 +69,48 @@ namespace Saxonite.Net.Core.Web.Online.Models
SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params();
prmUserOrganisation.UserAccountIdsIncluded.Add(SessionData.User.UserAccountId);
prmUserOrganisation.OrganisationMembersOnly = true;
prmUserOrganisation.OrganisationRoles.Add(Sax.OrganisationRole.OpportunityAdmin);
prmUserOrganisation.OrganisationRolesAny.Add(Sax.OrganisationRole.Admin);
prmUserOrganisation.OrganisationRolesAny.Add(Sax.OrganisationRole.OpportunityAdmin);
prmUserOrganisation.StatusCat = SaxUserOrganisation.StatusCat.ActiveOnly;
userCanManageOrganisationOpportunities = (AccountMgr.GetUserOrganisationCount(prmUserOrganisation) > 0);
}
return userCanManageOrganisationOpportunities == true ? true : false;
}
}
public bool UserCanManageOrganisationSchedule
{
get
{
if (userCanManageOrganisationSchedule == null && ValidUserSession)
{
SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params();
prmUserOrganisation.UserAccountIdsIncluded.Add(SessionData.User.UserAccountId);
prmUserOrganisation.OrganisationMembersOnly = true;
prmUserOrganisation.OrganisationRolesAny.Add(Sax.OrganisationRole.Admin);
prmUserOrganisation.OrganisationRolesAny.Add(Sax.OrganisationRole.ScheduleAdmin);
prmUserOrganisation.StatusCat = SaxUserOrganisation.StatusCat.ActiveOnly;
userCanManageOrganisationSchedule = (AccountMgr.GetUserOrganisationCount(prmUserOrganisation) > 0);
}
return userCanManageOrganisationSchedule == true ? true : false;
}
}
public bool UserCanManageOrganisationArticles
{
get
{
if (userCanManageOrganisationArticles == null && ValidUserSession)
{
SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params();
prmUserOrganisation.UserAccountIdsIncluded.Add(SessionData.User.UserAccountId);
prmUserOrganisation.OrganisationMembersOnly = true;
prmUserOrganisation.OrganisationRolesAny.Add(Sax.OrganisationRole.Admin);
prmUserOrganisation.OrganisationRolesAny.Add(Sax.OrganisationRole.ArticleAdmin);
prmUserOrganisation.StatusCat = SaxUserOrganisation.StatusCat.ActiveOnly;
userCanManageOrganisationArticles = (AccountMgr.GetUserOrganisationCount(prmUserOrganisation) > 0);
}
return userCanManageOrganisationArticles == true ? true : false;
}
}
//-------------------------------------------------------------------
// Item Id Obfuscation.
@@ -1,13 +1,13 @@
@model SaxModel_Online
@inject SaxLocaliser Localiser
@{
int regionIdCountry = Model.ValidUserSession ? Model.SessionData.User.RegionIdCountry.ToInt() : 0;
String regionIdCountry = Model.ValidUserSession ? Model.SessionData.User.RegionIdCountry.ToString() : "";
String regionNameCountry = Model.ValidUserSession ? Localiser.EscapeJavascriptText(Model.GetRegionCaption(Model.SessionData.User.RegionIdCountry)) : "";
}
<script type="text/javascript">
let or = sax.orgReq = {};
or.dlgTitleRequestOrganisation = '@Localiser.GetJavascriptText("organisation.caption.organisation.request")';
sax.data.regionIdCountryDefault = @regionIdCountry;
sax.data.regionIdCountryDefault = '@regionIdCountry';
sax.data.regionNameCountryDefault = '@regionNameCountry';
</script>
@@ -28,47 +28,52 @@
@* Contact Email Address *@
<div class="sax-form-control ContactEmailAddress">
<div class="sax-label">
<label for="ifContactEmailAddress"><span>@Localiser["label.email"]</span><span class="required">&nbsp;*</span></label>
<div class="row">
<div class="col-sm-4">
<div class="sax-label">
<label for="ifContactEmailAddress"><span>@Localiser["label.email"]</span><span class="required">&nbsp;*</span></label>
</div>
</div>
<div class="col-sm">
<div class="sax-control">
<input type="text" id="ifContactEmailAddress" name="ContactEmailAddress" class="ContactEmailAddress sax-input" autocomplete="off" maxlength="@Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.UserAccount_EmailAddress)" />
</div>
<div class="sax-message"></div>
</div>
</div>
<div class="sax-control">
<input type="text" id="ifContactEmailAddress" name="ContactEmailAddress" class="ContactEmailAddress sax-input" autocomplete="off" maxlength="@Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.UserAccount_EmailAddress)" />
</div>
<div class="sax-message"></div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="col-sm-4">@* No label. *@</div>
<div class="col-sm row">
@* Contact First Name *@
<div class="sax-form-control ContactFirstName pr4">
<div class="sax-label">
<label for="cbContactFirstName"><span>@Localiser["label.first.name"]</span><span class="required">&nbsp;*</span></label>
<div class="col-sm-6">
<div class="sax-form-control ContactFirstName pr4">
<div class="sax-label">
<label for="cbContactFirstName"><span>@Localiser["label.first.name"]</span><span class="required">&nbsp;*</span></label>
</div>
<div class="sax-control">
<input type="text" id="ifContactFirstName" name="ContactFirstName" class="ContactFirstName sax-input" autocomplete="off" maxlength="@Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.UserAccount_FirstName)" />
</div>
<div class="sax-message"></div>
</div>
<div class="sax-control">
<input type="text" id="ifContactFirstName" name="ContactFirstName" class="ContactFirstName sax-input" autocomplete="off" maxlength="@Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.UserAccount_FirstName)" />
</div>
<div class="sax-message"></div>
</div>
</div>
<div class="col-sm-6">
@* Contact Last Name *@
<div class="sax-form-control ContactLastName pr4">
<div class="sax-label">
<label for="cbContactLastName"><span>@Localiser["label.last.name"]</span><span class="required">&nbsp;*</span></label>
<div class="col-sm-6">
<div class="sax-form-control ContactLastName">
<div class="sax-label">
<label for="cbContactLastName"><span>@Localiser["label.last.name"]</span><span class="required">&nbsp;*</span></label>
</div>
<div class="sax-control">
<input type="text" id="ifContactLastName" name="ContactLastName" class="ContactLastName sax-input" autocomplete="off" maxlength="@Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.UserAccount_LastName)" />
</div>
<div class="sax-message"></div>
</div>
<div class="sax-control">
<input type="text" id="ifContactLastName" name="ContactLastName" class="ContactLastName sax-input" autocomplete="off" maxlength="@Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.UserAccount_LastName)" />
</div>
<div class="sax-message"></div>
</div>
</div>
</div>
}
@@ -81,147 +86,202 @@
@* Organisation name *@
<div class="sax-form-control OrganisationName">
<div class="sax-label">
<label for="ifOrganisationName"><span>@Localiser["label.name"]</span><span class="required">&nbsp;*</span></label>
<div class="row">
<div class="col-sm-4">
<div class="sax-label">
<label for="ifOrganisationName"><span>@Localiser["label.name"]</span><span class="required">&nbsp;*</span></label>
</div>
</div>
<div class="col-sm">
<div class="sax-control">
<input type="text" id="ifOrganisationName" name="OrganisationName" class="OrganisationName sax-input" autocomplete="off" maxlength="@Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.Organisation_Name)" />
</div>
<div class="sax-message"></div>
</div>
</div>
<div class="sax-control">
<input type="text" id="ifOrganisationName" name="OrganisationName" class="OrganisationName sax-input" autocomplete="off" maxlength="@Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.Organisation_Name)" />
</div>
<div class="sax-message"></div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="col-sm-4"></div>
<div class="col-sm row">
@* Organisation category *@
<div class="sax-form-control OrganisationCategory pr4">
<div class="sax-label">
<label for="cbOrganisationCategory"><span>@Localiser["label.category"]</span><span class="required">&nbsp;*</span></label>
<div class="col-sm-6">
<div class="sax-form-control OrganisationCategory pr4">
<div class="sax-label">
<label for="cbOrganisationCategory"><span>@Localiser["label.category"]</span><span class="required">&nbsp;*</span></label>
</div>
<div class="sax-control">
@Html.DropDownList("", Model.OrganisationCategoriesForSelect, Localiser["label.select"], new { @id = "cbOrganisationCategory", @name = "OrganisationCategory", @class = "OrganisationCategory sax-select" })
</div>
<div class="sax-message"></div>
</div>
<div class="sax-control">
@Html.DropDownList("", Model.OrganisationCategoriesForSelect, Localiser["label.select"], new { @id = "cbOrganisationCategory", @name = "OrganisationCategory", @class = "OrganisationCategory sax-select" })
</div>
<div class="sax-message"></div>
</div>
</div>
<div class="col-sm-6">
@* Organisation type *@
<div class="sax-form-control OrganisationType">
<div class="sax-label">
<label for="cbOrganisationType"><span>@Localiser["label.type"]</span><span class="required">&nbsp;*</span></label>
<div class="col-sm-6">
<div class="sax-form-control OrganisationType">
<div class="sax-label">
<label for="cbOrganisationType"><span>@Localiser["label.type"]</span><span class="required">&nbsp;*</span></label>
</div>
<div class="sax-control">
@Html.DropDownList("", Model.OrganisationTypesForSelect, Localiser["label.select"], new { @id = "cbOrganisationType", @name = "OrganisationType", @class = "OrganisationType sax-select" })
</div>
<div class="sax-message"></div>
</div>
<div class="sax-control">
@Html.DropDownList("", Model.OrganisationTypesForSelect, Localiser["label.select"], new { @id = "cbOrganisationType", @name = "OrganisationType", @class = "OrganisationType sax-select" })
</div>
<div class="sax-message"></div>
</div>
</div>
</div>
@* Organisation sport *@
<div class="sax-form-control OrganisationSportId">
<div class="sax-label">
<label for="ifOrganisationSportCaption"><span>@Localiser["label.sport"]</span><span class="required">&nbsp;*</span></label>
<div class="row">
<div class="col-sm-4">
<div class="sax-label">
<label for="ifOrganisationSportCaption"><span>@Localiser["label.sport"]</span><span class="required">&nbsp;(*)</span></label>
</div>
</div>
<div class="col-sm">
<div class="sax-control row">
<input type="hidden" id="ifOrganisationSportId" name="OrganisationSportId" OrganisationSportId"" class="OrganisationSportId" />
<div class="col"><input type="text" id="ifOrganisationSportCaption" class="OrganisationSportCaption sax-input" readonly="readonly" ondblclick="sax.selectSport()" /> </div>
<div class="fixed"><button class="SelectSport sax-button" style="min-width:auto;margin-left:4px;padding:4px 6px" onclick="sax.selectOrgSport()">@Localiser["label.select"]</button></div>
</div>
<div class="sax-message"></div>
</div>
</div>
<div class="sax-control row">
<input type="hidden" id="ifOrganisationSportId" name="OrganisationSportId" OrganisationSportId"" class="OrganisationSportId" />
<div class="col"><input type="text" id="ifOrganisationSportCaption" class="OrganisationSportCaption sax-input" readonly="readonly" ondblclick="sax.selectSport()" /> </div>
<div class="fixed"><button class="SelectSport sax-button" style="min-width:auto;margin-left:4px;padding:4px 6px" onclick="sax.selectOrgSport()">@Localiser["label.select"]</button></div>
</div>
<div class="sax-message"></div>
</div>
@* Organisation country *@
<div class="sax-form-control OrganisationRegionIdCountry">
<div class="sax-label">
<label for="ifOrganisationRegionCaption"><span>@Localiser["label.country"]</span><span class="required">&nbsp;*</span></label>
<div class="row">
<div class="col-sm-4">
<div class="sax-label">
<label for="ifOrganisationRegionCaption"><span>@Localiser["label.country"]</span><span class="required">&nbsp;*</span></label>
</div>
</div>
<div class="col-sm">
<div class="sax-control row">
<input type="hidden" id="ifOrganisationRegionIdCountry" name="OrganisationRegionIdCountry" OrganisationRegionIdCountry"" class="OrganisationRegionIdCountry" />
<div class="col"><input type="text" id="ifOrganisationRegionCaptionCountry" class="OrganisationRegionCaptionCountry sax-input" readonly="readonly" ondblclick="sax.selectRegion()" /> </div>
<div class="fixed"><button class="SelectRegion sax-button" style="min-width:auto;margin-left:4px;padding:4px 6px" onclick="sax.selectOrgRegion()">@Localiser["label.select"]</button></div>
</div>
<div class="sax-message"></div>
</div>
</div>
<div class="sax-control row">
<input type="hidden" id="ifOrganisationRegionIdCountry" name="OrganisationRegionIdCountry" OrganisationRegionIdCountry"" class="OrganisationRegionIdCountry" />
<div class="col"><input type="text" id="ifOrganisationRegionCaptionCountry" class="OrganisationRegionCaptionCountry sax-input" readonly="readonly" ondblclick="sax.selectRegion()" /> </div>
<div class="fixed"><button class="SelectRegion sax-button" style="min-width:auto;margin-left:4px;padding:4px 6px" onclick="sax.selectOrgRegion()">@Localiser["label.select"]</button></div>
</div>
<div class="sax-message"></div>
</div>
@* Organisation address - Line 1 *@
<div class="sax-form-control OrganisationAddressLine1">
<div class="sax-caption">
<label for="ifOrganisationAddressLine1"><span>@Localiser["label.organisation.address"]</span><span class="required">&nbsp;*</span></label>
<div class="row">
<div class="col-sm-4">
<div class="sax-caption">
<label for="ifOrganisationAddressLine1"><span>@Localiser["label.organisation.address"]</span><span class="required">&nbsp;*</span></label>
</div>
</div>
<div class="col-sm">
<div class="sax-control row">
<div class="col"><input type="text" id="ifOrganisationAddressLine1" name="OrganisationAddressLine1" class="OrganisationAddressLine1 sax-input" autocomplete="off" maxlength="@Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Line1)" /> </div>
</div>
<div class="sax-message"></div>
</div>
</div>
<div class="sax-control row">
<div class="col"><input type="text" id="ifOrganisationAddressLine1" name="OrganisationAddressLine1" class="OrganisationAddressLine1 sax-input" autocomplete="off" maxlength="@Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Line1)" /> </div>
</div>
<div class="sax-message"></div>
</div>
@* Organisation address - Line 2 *@
<div class="sax-form-control OrganisationAddressLine2">
<div class="sax-control row">
<div class="col"><input type="text" id="ifOrganisationAddressLine2" name="OrganisationAddressLine2" class="OrganisationAddressLine2 sax-input" autocomplete="off" maxlength="@Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Line2)" /> </div>
<div class="row">
<div class="col-sm-4"></div>
<div class="col-sm">
<div class="sax-control row">
<div class="col"><input type="text" id="ifOrganisationAddressLine2" name="OrganisationAddressLine2" class="OrganisationAddressLine2 sax-input" autocomplete="off" maxlength="@Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Line2)" /> </div>
</div>
<div class="sax-message"></div>
</div>
</div>
<div class="sax-message"></div>
</div>
@* Organisation address - Line 3 *@
<div class="sax-form-control OrganisationAddressLine3">
<div class="sax-control row">
<div class="col"><input type="text" id="ifOrganisationAddressLine3" name="OrganisationAddressLine3" class="OrganisationAddressLine3 sax-input" autocomplete="off" maxlength="@Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Line3)" /> </div>
<div class="row">
<div class="col-sm-4"></div>
<div class="col-sm">
<div class="sax-control row">
<div class="col"><input type="text" id="ifOrganisationAddressLine3" name="OrganisationAddressLine3" class="OrganisationAddressLine3 sax-input" autocomplete="off" maxlength="@Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Line3)" /> </div>
</div>
<div class="sax-message"></div>
</div>
</div>
<div class="sax-message"></div>
</div>
@* Organisation address - Town *@
<div class="sax-form-control OrganisationAddressTown">
<div class="sax-label">
<label for="ifOrganisationAddressTown"><span>@Localiser["label.town"]</span><span class="required">&nbsp;*</span></label>
<div class="row">
<div class="col-sm-4">
<div class="sax-label">
<label for="ifOrganisationAddressTown"><span>@Localiser["label.town"]</span><span class="required">&nbsp;*</span></label>
</div>
</div>
<div class="col-sm">
<div class="sax-control row">
<div class="col"><input type="text" id="ifOrganisationAddressTown" name="OrganisationAddressTown" class="OrganisationAddressTown sax-input" autocomplete="off" maxlength="@Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Town)" /> </div>
</div>
<div class="sax-message"></div>
</div>
</div>
<div class="sax-control row">
<div class="col"><input type="text" id="ifOrganisationAddressTown" name="OrganisationAddressTown" class="OrganisationAddressTown sax-input" autocomplete="off" maxlength="@Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Town)" /> </div>
</div>
<div class="sax-message"></div>
</div>
@* Organisation address - Province *@
<div class="sax-form-control OrganisationAddressProvince">
<div class="sax-label">
<label for="ifOrganisationAddressProvince"><span>@Localiser["label.province"]</span><span class="required">&nbsp;*</span></label>
<div class="row">
<div class="col-sm-4">
<div class="sax-label">
<label for="ifOrganisationAddressProvince"><span>@Localiser["label.province"]</span></label>
</div>
</div>
<div class="col-sm">
<div class="sax-control row">
<div class="col"><input type="text" id="ifOrganisationAddressProvince" name="OrganisationAddressProvince" class="OrganisationAddressProvince sax-input" autocomplete="off" maxlength="@Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Province)" /> </div>
</div>
<div class="sax-message"></div>
</div>
</div>
<div class="sax-control row">
<div class="col"><input type="text" id="ifOrganisationAddressProvince" name="OrganisationAddressProvince" class="OrganisationAddressProvince sax-input" autocomplete="off" maxlength="@Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_Province)" /> </div>
</div>
<div class="sax-message"></div>
</div>
@* Organisation address - PostalCode *@
<div class="sax-form-control OrganisationAddressPostalCode">
<div class="sax-label">
<label for="ifOrganisationAddressPostalCode"><span>@Localiser["label.postalCode"]</span><span class="required">&nbsp;*</span></label>
<div class="row">
<div class="col-sm-4">
<div class="sax-label">
<label for="ifOrganisationAddressPostalCode"><span>@Localiser["label.postalCode"]</span></label>
</div>
</div>
<div class="col-sm">
<div class="sax-control row">
<div class="col"><input type="text" id="ifOrganisationAddressPostalCode" name="OrganisationAddressPostalCode" class="OrganisationAddressPostalCode sax-input" autocomplete="off" maxlength="@Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_PostalCode)" /> </div>
</div>
<div class="sax-message"></div>
</div>
</div>
<div class="sax-control row">
<div class="col"><input type="text" id="ifOrganisationAddressPostalCode" name="OrganisationAddressPostalCode" class="OrganisationAddressPostalCode sax-input" autocomplete="off" maxlength="@Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.ItemAddress_PostalCode)" /> </div>
</div>
<div class="sax-message"></div>
</div>
@* Organisation PhoneMain *@
@*
<div class="sax-form-control OrganisationPhoneMain">
<div class="sax-label">
<label for="ifOrganisationPhoneMain"><span>@Localiser["label.phone"]</span></label>
<div class="sax-form-control OrganisationPhoneMain">
<div class="row">
<div class="col-sm-4">
<div class="sax-label">
<label for="ifOrganisationPhoneMain"><span>@Localiser["label.phone"]</span></label>
</div>
</div>
<div class="sax-control row">
<div class="col"><input type="text" id="ifOrganisationPhoneMain" name="OrganisationPhoneMain" class="OrganisationPhoneMain sax-input" autocomplete="off" maxlength="@Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.Item_PhoneMain)" /> </div>
<div class="col-sm">
<div class="sax-control row">
<div class="col"><input type="text" id="ifOrganisationPhoneMain" name="OrganisationPhoneMain" class="OrganisationPhoneMain sax-input" autocomplete="off" maxlength="@Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.Organisation_PhoneMain)" /> </div>
</div>
<div class="sax-message"></div>
</div>
<div class="sax-message"></div>
</div>
*@
</div>
}
@@ -205,18 +205,19 @@
.sax-form .sax-form-control .sax-message
{
display: none;
margin-top: 8px;
margin-top: 4px;
padding-left: 24px;
font-size: 16px;
font-size: 1.00Rem;
background-position: left top;
background-repeat: no-repeat;
}
.sax-form .sax-form-control.sax-error .sax-message
{
min-height:16px;
display: block;
color: #e3120b;
background-image: url("../img/icon/error-18.png");
background-image: url("../img/icon/error-16.png");
}
/* Buttons */
Binary file not shown.

After

Width:  |  Height:  |  Size: 462 B

@@ -185,10 +185,6 @@
$('#ifOpportunityId,#ifOpportunityExists,#ifOpportunityRegionId,#ifOpportunitySportId,input[type="text"],textarea,select', $frm.opportunity).val('');
sax.clearControlErrors();
}
sax.doCreateItem = function ()
{
sax.storeItem();
}
//--------------------------------------------------------------
sax.updateItem = function (item)
@@ -219,10 +215,6 @@
$dlg.opportunity.dialog('option', 'title', sax.dlg.title.updateOpportunity);
sax.openDialog($dlg.opportunity, 600, 600);
}
sax.doUpdateItem = function ()
{
sax.storeItem();
}
//--------------------------------------------------------------
sax.storeItem = function ()
@@ -263,7 +255,7 @@
$('.sax-input', $frm.opportunity).on('input', function () { sax.clearControlError(this); });
var opt = sax.dlgOpts();
opt.buttons[sax.dlg.btn.ok] = function () { sax.doCreateItem(); };
opt.buttons[sax.dlg.btn.ok] = function () { sax.storeItem(); };
opt.buttons[sax.dlg.btn.cancel] = function () { $(this).dialog('close'); };
$dlg.opportunity = $('#dlgOpportunity').dialog(opt);
+16 -14
View File
@@ -5,16 +5,16 @@
(function (win, doc, undef)
{
"use strict";
let $pnl = sax.$pnl, $dlg = sax.$dlg, $frm = sax.$frm;
let po = sax.mdl.profileOrganisations = sax.mdl.profileOrganisations || { $pnl: {}, $dlg: {}, $frm: {} };
let $pnl = po.$pnl, $dlg = po.$dlg, $frm = po.$frm;
//--------------------------------------------------------------
sax.refreshProfileOrganisationsInfo = 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);
$pnl.section.removeClass('sax-edit').addClass('sax-populating');
$('.sax-property', $pnl.section).hide();
sax.showDataRefreshingMsg($pnl.section);
sax.refreshProfileOrganisations(po.onRefreshProfileOrganisationsInfo);
}
sax.refreshProfileOrganisations = function (callbackFn)
{
@@ -24,17 +24,16 @@
sax.ajax.profileOrganisations.callbackFn = callbackFn;
sax.doAjaxRequest(sax.ajax.profileOrganisations, 50);
}
sax.onRefreshProfileOrganisationsInfo = function (response)
po.onRefreshProfileOrganisationsInfo = function (response)
{
//sax.debug('onRefreshProfileOrganisationsInfo', 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();
$('.sax-message', $pnl.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);
let $items = $('.sax-panel-results.Organisations', $pnl.section).empty();
let $tmpl = $('.sax-panel-item-template .sax-panel-item.Organisation', $pnl.section);
for (let itemIdx = 0; itemIdx < items.length; itemIdx++)
{
let item = items[itemIdx];
@@ -47,13 +46,16 @@
$items.append($item);
}
$items.show();
sax.showNoInfoMsg($section);
$section.removeClass('sax-populating');
sax.showNoInfoMsg($pnl.section);
$pnl.section.removeClass('sax-populating');
}
//--------------------------------------------------------------
//--------------------------------------------------------------
$(function ()
{
$pnl.section = $('.sax-panel-section.ProfileOrganisations');
});
//--------------------------------------------------------------