v1.2.6.1
This commit is contained in:
@@ -40,6 +40,8 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
}
|
||||
private class OrganisationData_Full : OrganisationData_List
|
||||
{
|
||||
public String About { get; set; }
|
||||
public String Facilities { get; set; }
|
||||
}
|
||||
private void PopulateOrganisationResponseData(SaxOrganisation organisation, OrganisationData_List data)
|
||||
{
|
||||
@@ -65,6 +67,9 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
private void PopulateOrganisationResponseData(SaxOrganisation organisation, OrganisationData_Full data)
|
||||
{
|
||||
PopulateOrganisationResponseData(organisation, data as OrganisationData_List);
|
||||
data.About = organisation.About;
|
||||
data.Facilities = organisation.Facilities;
|
||||
data.Notes = organisation.Notes;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -261,6 +266,10 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
organisation.SportIdPrimary = model.OrganisationSportId.ToSysId();
|
||||
if (model.OrganisationRegionIdCountry != null)
|
||||
organisation.RegionIdPrimary = model.OrganisationRegionIdCountry.ToSysId();
|
||||
if (model.OrganisationAbout != null)
|
||||
organisation.About = model.OrganisationAbout;
|
||||
if (model.OrganisationFacilities != null)
|
||||
organisation.Facilities = model.OrganisationFacilities;
|
||||
// Common properties.
|
||||
if (model.OrganisationStatusCode != null)
|
||||
organisation.Status = model.OrganisationStatus;
|
||||
|
||||
@@ -21,40 +21,55 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Member data.
|
||||
private class MemberData_List
|
||||
private class MemberData_List : AjaxResponse_Data.ItemData_Base
|
||||
{
|
||||
public String Id { get; set; }
|
||||
// User.
|
||||
public String UserAccountId { get; set; }
|
||||
public bool? Self { get; set; } = null;
|
||||
public String EmailAddress { get; set; }
|
||||
public String DisplayName { get; set; }
|
||||
public String UserStatusCode { get; set; }
|
||||
public String UserStatusDesc { get; set; }
|
||||
public bool? UserActive { get { return UserStatusCode.EqualsCI(SacsSystem.GetStatusCode(SaStatus.Active)) ? true : (bool?)null; } }
|
||||
// Organisation.
|
||||
public String OrganisationId { get; set; }
|
||||
public String OrganisationName { get; set; }
|
||||
public List<String> RoleCodes { get; } = new List<string>();
|
||||
// Organisation user.
|
||||
public int RoleCount { get; set; }
|
||||
public String StatusCode { get; set; }
|
||||
public String StatusDesc { get; set; }
|
||||
public bool? Member { get; set; } = null;
|
||||
}
|
||||
private class MemberData_Full : MemberData_List
|
||||
{
|
||||
// Organisation user.
|
||||
public List<String> RoleCodes { get; } = new List<string>();
|
||||
}
|
||||
private void PopulateMemberResponseData(MemberData_List data, SaxUserOrganisation userOrganisation, SaxUserAccount userAccount, SaxOrganisation organisation)
|
||||
{
|
||||
data.Id = SysId.ToString(userOrganisation.Id);
|
||||
// User.
|
||||
data.UserAccountId = SysId.ToString(userAccount.Id);
|
||||
if (userAccount.Id.Equals(UserAccountId)) data.Self = true;
|
||||
data.EmailAddress = userAccount.EmailAddress;
|
||||
data.DisplayName = userAccount.GetDisplayName();
|
||||
data.UserStatusCode = userAccount.StatusCode;
|
||||
data.UserStatusDesc = userAccount.StatusDesc;
|
||||
// Organisation.
|
||||
data.OrganisationId = SysId.ToString(organisation.Id);
|
||||
data.OrganisationName = organisation.Name;
|
||||
// Exclude 'Member' role.
|
||||
foreach (Sax.OrganisationRole organisationRole in userOrganisation.GetOrganisationRoles().ToList().FindAll(item => item != Sax.OrganisationRole.Member))
|
||||
data.RoleCodes.Add(OrganisationRoleCodes.GetCodeForType(organisationRole));
|
||||
// Organisation user:
|
||||
data.RoleCount = userOrganisation.OrganisationRoleCount - 1;
|
||||
data.StatusCode = userOrganisation.StatusCode;
|
||||
data.StatusDesc = userOrganisation.StatusDesc;
|
||||
if (userOrganisation.GetOrganisationRoles().ToList().Exists(item => item == Sax.OrganisationRole.Member))
|
||||
data.Member = true;
|
||||
}
|
||||
private void PopulateMemberResponseData(MemberData_Full data, SaxUserOrganisation userOrganisation, SaxUserAccount userAccount, SaxOrganisation organisation)
|
||||
{
|
||||
PopulateMemberResponseData(data as MemberData_List, userOrganisation, userAccount, organisation);
|
||||
// Organisation user:
|
||||
// Exclude 'Member' role.
|
||||
foreach (Sax.OrganisationRole organisationRole in userOrganisation.GetOrganisationRoles().ToList().FindAll(item => item != Sax.OrganisationRole.Member))
|
||||
data.RoleCodes.Add(OrganisationRoleCodes.GetCodeForType(organisationRole));
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -119,7 +134,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params();
|
||||
prmUserOrganisation.OrganisationIdsIncluded.Add(organisationId);
|
||||
prmUserOrganisation.OrganisationMembersOnly = true;
|
||||
prmUserOrganisation.UserAccountStatusCat = SaxUserAccount.StatusCat.AwaitingOnly;
|
||||
prmUserOrganisation.UserAccountStatusCat = SaxUserAccount.StatusCat.NotDeleted;
|
||||
prmUserOrganisation.StatusCat = SaxUserOrganisation.StatusCat.NotDeleted;
|
||||
model.Paging.ItemTotal = (ulong)AccountMgr.GetUserOrganisationCount(prmUserOrganisation);
|
||||
model.PopulatePagingTo(prmUserOrganisation.ResultsPaging);
|
||||
@@ -129,6 +144,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
ColumnDfn colUserAccountId = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.UserAccountId);
|
||||
ColumnDfn colUserEmailAddress = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.User_EmailAddress);
|
||||
ColumnDfn colUserDisplayName = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.User_DisplayName);
|
||||
ColumnDfn colUserStatus = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.User_Status);
|
||||
ColumnDfn colOrganisationId = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.OrganisationId);
|
||||
ColumnDfn colOrganisationName = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Organisation_Name);
|
||||
ColumnDfn colRoleCodes = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.OrganisationRoleCodes);
|
||||
@@ -136,14 +152,10 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
ColumnDfn colStatus = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Status);
|
||||
List<ColumnDfn> columns = new List<ColumnDfn>()
|
||||
{
|
||||
colId,
|
||||
colUserAccountId,
|
||||
colUserEmailAddress,
|
||||
colUserDisplayName,
|
||||
colOrganisationId,
|
||||
colOrganisationName,
|
||||
colRoleCodes,
|
||||
colRoleCount,
|
||||
colId, colUserAccountId,
|
||||
colUserEmailAddress, colUserDisplayName, colUserStatus,
|
||||
colOrganisationId, colOrganisationName,
|
||||
colRoleCodes, colRoleCount,
|
||||
colStatus
|
||||
};
|
||||
|
||||
@@ -156,15 +168,20 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
MemberData_List memberData = new MemberData_List()
|
||||
{
|
||||
Id = values.GetString(colId.DataName),
|
||||
// User.
|
||||
UserAccountId = values.GetString(colUserAccountId.DataName),
|
||||
EmailAddress = values.GetString(colUserEmailAddress.DataName),
|
||||
DisplayName = AccountMgr.GetUserOrganisationDataValue(colUserDisplayName, values).ToString(),
|
||||
UserStatusCode = values.GetString(colUserStatus.DataName),
|
||||
UserStatusDesc = SacsSystem.GetStatusDescForCode(values.GetString(colUserStatus.DataName)),
|
||||
// Organisation.
|
||||
OrganisationId = values.GetString(colOrganisationId.DataName),
|
||||
OrganisationName = values.GetString(colOrganisationName.DataName),
|
||||
// Role count - 1 to ignore 'Member' role.
|
||||
RoleCount = (int)values.GetLong(colRoleCount.DataName) - 1,
|
||||
StatusCode = values.GetString(colStatus.DataName),
|
||||
StatusDesc = SacsSystem.GetStatusDescForCode(values.GetString(colStatus.DataName))
|
||||
StatusDesc = SacsSystem.GetStatusDescForCode(values.GetString(colStatus.DataName)),
|
||||
Member = (values.GetLong(colRoleCount.DataName) > 0) ? true : (bool?)null
|
||||
};
|
||||
members.Add(memberData);
|
||||
}
|
||||
@@ -365,6 +382,88 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
return Json(responseData);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Remove Organisation Member ajax request.
|
||||
//-------------------------------------------------------------------
|
||||
[HttpPost]
|
||||
[Route("Organisation/Ajax/RemoveMember")]
|
||||
public IActionResult Ajax_RemoveMember(Model_OrganisationMembers model)
|
||||
{
|
||||
String fn = GetType().Name + ".Ajax_RemoveMember";
|
||||
String messageTitle = Localiser["organisation.caption.member"];
|
||||
AjaxResponse_Member responseData = new AjaxResponse_Member(model);
|
||||
|
||||
// Validate session.
|
||||
if (!ValidUserSession)
|
||||
return GetAjaxResult_InvalidSession(responseData);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposableItems = new DisposableCollection<SacsHierarchyItem>())
|
||||
{
|
||||
|
||||
// Organisation.
|
||||
SysId organisationId = model.OrganisationId.ToSysId();
|
||||
SaxOrganisation organisation = AccountMgr.GetOrganisationById(organisationId);
|
||||
if (organisation == null)
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to retrieve Organisation for Id: '" + model.OrganisationId + "'");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.data.incomplete"]));
|
||||
}
|
||||
disposableItems.Add(organisation);
|
||||
|
||||
// User Organisation.
|
||||
SysId userOrganisationId = model.UserOrganisationId.ToSysId();
|
||||
SaxUserOrganisation userOrganisation = AccountMgr.GetUserOrganisationById(userOrganisationId);
|
||||
disposableItems.Add(userOrganisation);
|
||||
if (userOrganisation == null)
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to retrieve user organisation for Id: '" + userOrganisationId + "'");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.found"]));
|
||||
}
|
||||
if (!userOrganisation.OrganisationId.Equals(organisation.Id))
|
||||
{
|
||||
SaLogger.Warn(fn + " Inconsistent user organisation properties. OrganisationId: " + userOrganisation.OrganisationId + " vs " + organisation.Id + ".");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.data.inconsistent"]));
|
||||
}
|
||||
|
||||
// User Account.
|
||||
SaxUserAccount userAccount = AccountMgr.GetUserAccountById(userOrganisation.UserAccountId);
|
||||
disposableItems.Add(userAccount);
|
||||
if (userAccount == null)
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to retrieve user account for Id: '" + userOrganisation.UserAccountId + "'");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
|
||||
// Remove all roles and store.
|
||||
userOrganisation.ClearOrganisationRoles();
|
||||
|
||||
// Store item.
|
||||
if (!SysId.IsValid(userOrganisation.Id))
|
||||
{
|
||||
if (!AccountMgr.InsertUserOrganisation(userOrganisation, DbUpdateInfo))
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to insert user organisation: " + AccountMgr.ErrorStateMessage);
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.insert.failed"] + "\n\n" + AccountMgr.ErrorStateMessage));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!AccountMgr.UpdateUserOrganisation(userOrganisation, DbUpdateInfo))
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to update user organisation [Id:" + SysId.ToString(userOrganisation.Id) + "]: " + AccountMgr.ErrorStateMessage);
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.update.failed"] + "\n\n" + AccountMgr.ErrorStateMessage));
|
||||
}
|
||||
}
|
||||
|
||||
// Construct response.
|
||||
PopulateMemberResponseData(responseData.Member, userOrganisation, userAccount, organisation);
|
||||
}
|
||||
|
||||
responseData.Success = true;
|
||||
return Json(responseData);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
|
||||
@@ -77,6 +77,8 @@ namespace Saxonite.Net.Core.Web.Admin.Models
|
||||
public Sax.OrganisationCategory OrganisationCategory { get { return (Sax.OrganisationCategory)OrganisationCategoryCodes.GetTypeForCode(OrganisationCategoryValue); } }
|
||||
public String OrganisationSportId { get; set; }
|
||||
public String OrganisationRegionIdCountry { get; set; }
|
||||
public String OrganisationAbout { get; set; }
|
||||
public String OrganisationFacilities { get; set; }
|
||||
// Common properties.
|
||||
public String OrganisationNotes { get; set; }
|
||||
public String OrganisationStatusCode { get; set; }
|
||||
@@ -131,15 +133,15 @@ namespace Saxonite.Net.Core.Web.Admin.Models
|
||||
}
|
||||
}
|
||||
|
||||
// Organisation country.
|
||||
// Organisation region.
|
||||
if (OrganisationRegionIdCountry != null)
|
||||
{
|
||||
using (SaxRegion region = ReferenceMgr.GetRegionById(OrganisationRegionIdCountry.ToSysId()))
|
||||
{
|
||||
if (region == null)
|
||||
responseData.SetControlError(nameof(OrganisationRegionIdCountry), Localiser["msg.validation.invalid.value"]);
|
||||
else if (region.RegionType != Sax.RegionType.Country)
|
||||
responseData.SetControlError(nameof(OrganisationRegionIdCountry), "Organisation region must be a country");
|
||||
else if (region.RegionType != Sax.RegionType.Country && region.RegionType != Sax.RegionType.Continent && region.RegionType != Sax.RegionType.World)
|
||||
responseData.SetControlError(nameof(OrganisationRegionIdCountry), "Organisation region must be a country or international region");
|
||||
}
|
||||
|
||||
if (!StringUtil.IsEmpty(OrganisationName))
|
||||
@@ -156,6 +158,30 @@ namespace Saxonite.Net.Core.Web.Admin.Models
|
||||
}
|
||||
}
|
||||
|
||||
// Organisation about.
|
||||
if (OrganisationAbout != null)
|
||||
{
|
||||
responseData.SetControlValue(nameof(OrganisationAbout), OrganisationAbout);
|
||||
if (StringUtil.GetLength(OrganisationAbout) > GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.Organisation_About))
|
||||
responseData.SetControlError(nameof(OrganisationAbout), Localiser["msg.validation.maximum.length", GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.Organisation_About)]);
|
||||
}
|
||||
|
||||
// Organisation facilities.
|
||||
if (OrganisationFacilities != null)
|
||||
{
|
||||
responseData.SetControlValue(nameof(OrganisationFacilities), OrganisationFacilities);
|
||||
if (StringUtil.GetLength(OrganisationFacilities) > GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.Organisation_Facilities))
|
||||
responseData.SetControlError(nameof(OrganisationFacilities), Localiser["msg.validation.maximum.length", GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.Organisation_Facilities)]);
|
||||
}
|
||||
|
||||
// Organisation notes.
|
||||
if (OrganisationNotes != null)
|
||||
{
|
||||
responseData.SetControlValue(nameof(OrganisationNotes), OrganisationNotes);
|
||||
if (StringUtil.GetLength(OrganisationNotes) > GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.Organisation_Notes))
|
||||
responseData.SetControlError(nameof(OrganisationNotes), Localiser["msg.validation.maximum.length", GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.Organisation_Notes)]);
|
||||
}
|
||||
|
||||
// Organisation status.
|
||||
if (OrganisationStatusCode != null)
|
||||
{
|
||||
|
||||
@@ -153,12 +153,18 @@
|
||||
<data name="info.chars.available" xml:space="preserve">
|
||||
<value>[{0} chars available]</value>
|
||||
</data>
|
||||
<data name="label.about" xml:space="preserve">
|
||||
<value>About</value>
|
||||
</data>
|
||||
<data name="label.accounts" xml:space="preserve">
|
||||
<value>Accounts</value>
|
||||
</data>
|
||||
<data name="label.activate" xml:space="preserve">
|
||||
<value>Activate</value>
|
||||
</data>
|
||||
<data name="label.add" xml:space="preserve">
|
||||
<value>Add</value>
|
||||
</data>
|
||||
<data name="label.address" xml:space="preserve">
|
||||
<value>Address</value>
|
||||
</data>
|
||||
@@ -228,6 +234,9 @@
|
||||
<data name="label.emails" xml:space="preserve">
|
||||
<value>Emails</value>
|
||||
</data>
|
||||
<data name="label.facilities" xml:space="preserve">
|
||||
<value>Facilities</value>
|
||||
</data>
|
||||
<data name="label.filename" xml:space="preserve">
|
||||
<value>Filename</value>
|
||||
</data>
|
||||
@@ -288,6 +297,9 @@
|
||||
<data name="label.not.specified" xml:space="preserve">
|
||||
<value>Not specified</value>
|
||||
</data>
|
||||
<data name="label.notes" xml:space="preserve">
|
||||
<value>Notes</value>
|
||||
</data>
|
||||
<data name="label.ok" xml:space="preserve">
|
||||
<value>OK</value>
|
||||
</data>
|
||||
@@ -426,6 +438,9 @@
|
||||
<data name="msg.error.data.incomplete" xml:space="preserve">
|
||||
<value>Data is incomplete</value>
|
||||
</data>
|
||||
<data name="msg.error.data.inconsistent" xml:space="preserve">
|
||||
<value>Data is inconsistent.</value>
|
||||
</data>
|
||||
<data name="msg.error.item.delete.failed" xml:space="preserve">
|
||||
<value>Item deletion failed</value>
|
||||
</data>
|
||||
|
||||
@@ -142,14 +142,12 @@
|
||||
</div>
|
||||
<div class="sax-content">
|
||||
<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 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"]: <span class="MemberCount"></span></div></div>
|
||||
<div class="col-sm-4 text-left text-sm-right"><div class="StatusDesc"></div></div>
|
||||
<div class="col-6 col-sm-4"><div class="OrganisationCategory"></div></div>
|
||||
<div class="col-6 col-sm-4"><div class="OrganisationType"></div></div>
|
||||
<div class="col-6 col-sm-4 text-left text-sm-right"><div class="OrganisationRegion"></div></div>
|
||||
<div class="col-6 col-sm-4"><div class="OrganisationSport"></div></div>
|
||||
<div class="col-6 col-sm-4"><div class="OrganisationMemberCount sax-action-text">@Localiser["label.members"]: <span class="MemberCount"></span></div></div>
|
||||
<div class="col-6 col-sm-4 text-left text-sm-right"><div class="StatusDesc"></div></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -5,22 +5,41 @@
|
||||
ViewData["Title"] = "Organisation Members";
|
||||
}
|
||||
|
||||
<div class="">
|
||||
<div class="sax-panel OrganisationMembers">
|
||||
|
||||
<script type="text/javascript">
|
||||
sax.lbl.refresh = '@(Localiser.GetJavascriptText("label.refresh"))';
|
||||
sax.lbl.add = '@(Localiser.GetJavascriptText("label.add"))';
|
||||
sax.lbl.create = '@(Localiser.GetJavascriptText("label.create"))';
|
||||
sax.lbl.edit = '@(Localiser.GetJavascriptText("label.edit"))';
|
||||
sax.lbl.remove = '@(Localiser.GetJavascriptText("label.remove"))';
|
||||
</script>
|
||||
|
||||
@* Filter Panel *@
|
||||
@using (@Html.BeginForm(FormMethod.Post, new { @id = "frmMemberFilter", @class = "sax-form", @onSubmit = "return false;" }))
|
||||
{
|
||||
<div class="sax-panel-filter OrganisationMembers">
|
||||
<div class="sax-panel-filter">
|
||||
|
||||
@* Header - Page caption, paging controls, actions. *@
|
||||
<div class="sax-header row">
|
||||
<div class="col"><div class="sax-caption">@Localiser["organisation.caption.members"]</div></div>
|
||||
<div class="fixed row">
|
||||
<div>
|
||||
<partial name="~/Views/Common/ResultsPaging.cshtml" />
|
||||
</div>
|
||||
<div class="fixed sax-action sax-results-refresh"><img src="~/img/action/refresh24.png" alt="@(Localiser["label.refresh"])" title="@(Localiser["label.refresh"])" /></div>
|
||||
<div class="fixed sax-action sax-item-create"><img src="~/img/action/add24.png" alt="@(Localiser["label.create"])" title="@(Localiser["label.create"])" /></div>
|
||||
<div class="fixed">
|
||||
@* Burger menu *@
|
||||
<ul class="nav navbar-nav navbar-dark navbar-right sax-burger">
|
||||
<li class="dropdown-toggle caret-off">
|
||||
<a href="#" class="dropdown" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="navbar-toggler-icon"></span></a>
|
||||
<ul class="dropdown-menu dropdown-menu-right sax-dropdown-menu">@* Menu items will be inserted here. *@</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sax-content">
|
||||
@* Organisation Member filter - Organisation etc. *@
|
||||
<div class="row">
|
||||
<div class="col-sm-3 sax-label text-left text-sm-right">@Localiser["organisation.caption.organisation"]</div>
|
||||
<div class="col-sm-9">
|
||||
@@ -29,39 +48,65 @@
|
||||
@Html.HiddenFor(model => model.Filter.OrganisationId, new { @id = "ifFilterOrganisationId" })
|
||||
<input type="text" id="ifFilterOrganisation" class="sax-input" readonly="readonly" value="@(Model.MemberOrganisationName)" />
|
||||
</div>
|
||||
<div class="fixed"><button id="" class="sax-button" onclick="sax.selectFilterOrganisation()">@Localiser["label.select"]</button></div>
|
||||
<div class="fixed"><button id="pbFilterOrganisationSelect" class="sax-button">@Localiser["label.select"]</button></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@* Filter element templates *@
|
||||
<div class="sax-panel-item-template">
|
||||
@* Burger dropdown item template - ul is ignored *@
|
||||
<ul class="sax-dropdown-menu MemberFilter">
|
||||
<li class="sax-dropdown-item sax-action"><div class="sax-label">XXX</div></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@* Results Panel *@
|
||||
<div class="sax-panel-results">
|
||||
<div class="sax-panel-messages"></div>
|
||||
<div class="sax-panel-item-list"></div>
|
||||
|
||||
@* element templates *@
|
||||
<div class="sax-panel-item-template">
|
||||
@* Organisation Member item template *@
|
||||
<div class="sax-panel-item Member">
|
||||
<div class="sax-header row">
|
||||
<div class="col">
|
||||
<div class="sax-caption"><div class="sax-action UserDisplayName"></div></div>
|
||||
@* User name *@
|
||||
<div class="sax-caption sax-action"><div class="UserDisplayName"></div></div>
|
||||
</div>
|
||||
<div class="fixed sax-actions">
|
||||
<div class="sax-action sax-item-update"><img src="~/img/action/edit24.png" alt="@(Localiser["label.update"])" title="@(Localiser["label.update"])" /></div>
|
||||
@* Burger menu *@
|
||||
<ul class="nav navbar-nav navbar-light navbar-right sax-burger">
|
||||
<li class="dropdown-toggle caret-off">
|
||||
<a href="#" class="dropdown" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="navbar-toggler-icon"></span></a>
|
||||
<ul class="dropdown-menu dropdown-menu-right sax-dropdown-menu">@* Menu items will be inserted here. *@</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sax-content">
|
||||
<div class="row">
|
||||
<div class="col-sm-6"><div class="UserEmailAddress"></div></div>
|
||||
@* User email address and status (if not active) *@
|
||||
<div class="col-sm-6"><span class="UserEmailAddress"></span><span class="UserStatus" style="color:#a0a0a0;"> [<span class="UserStatusDesc"></span>]</span></div>
|
||||
@* Role count *@
|
||||
<div class="col-sm-6 right"><div class="MemberRoleCount">@Localiser["label.roles"]: <span class="RoleCount"></span></div></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-4"></div>
|
||||
<div class="col-sm-4"><div class=""></div></div>
|
||||
<div class="col-sm-4 right"><div class="StatusDesc"></div></div>
|
||||
@* Member status *@
|
||||
<div class="col-sm-4 sax-note right"><span class="StatusDesc"></span></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@* Burger dropdown item template - ul is ignored *@
|
||||
<ul class="sax-dropdown-menu Member">
|
||||
<li class="sax-dropdown-item sax-action"><div class="sax-label">...</div></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
</script>
|
||||
@using (@Html.BeginForm(FormMethod.Post, new { @id = "frmMemberId" }))
|
||||
{
|
||||
@Html.HiddenFor(model => model.OrganisationId, new { @id = "", @class = "OrganisationId" })
|
||||
@Html.HiddenFor(model => model.UserOrganisationId, new { @id = "", @class = "UserOrganisationId" })
|
||||
}
|
||||
@using (@Html.BeginForm(FormMethod.Post, new { @id = "frmUserEmail" }))
|
||||
@@ -73,8 +74,8 @@
|
||||
<div class="col-sm">
|
||||
<div class="sax-control row">
|
||||
@Html.HiddenFor(model => model.MemberRoleCodes, new { @id = "ifMemberRoleCodes", @class = "MemberRoleCodes sax-input" })
|
||||
<div class="col"><textarea id="ifMemberRoles" class="MemberRoles sax-input" rows="6" readonly="readonly" ondblclick="sax.selectMemberRoles()"></textarea></div>
|
||||
<div class="fixed"><button id="" class="sax-button" style="min-width:auto;margin-left:4px;padding:4px 6px" onclick="sax.selectMemberRoles()">@Localiser["label.select"]</button></div>
|
||||
<div class="col"><textarea id="ifMemberRoles" class="MemberRoles sax-input" rows="6" readonly="readonly"></textarea></div>
|
||||
<div class="fixed"><button id="pbMemberRolesSelect" class="sax-button" style="min-width:auto;margin-left:4px;padding:4px 6px">@Localiser["label.select"]</button></div>
|
||||
</div>
|
||||
<div class="sax-message"></div>
|
||||
</div>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
@* Organisation name *@
|
||||
<div class="sax-form-control OrganisationName">
|
||||
<div class="row">
|
||||
<div class="col-sm-4">
|
||||
<div class="col-sm-3">
|
||||
<div class="sax-label">
|
||||
<label for="ifOrganisationName"><span>@Localiser["label.name"]</span> <span class="required">*</span></label>
|
||||
</div>
|
||||
@@ -39,44 +39,45 @@
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-4"></div>
|
||||
<div class="col-sm-3"></div>
|
||||
|
||||
<div class="col-sm-4">
|
||||
<div class="col-sm row">
|
||||
<div class="col-sm-6">
|
||||
|
||||
@* Organisation category *@
|
||||
<div class="sax-form-control OrganisationCategory pr4">
|
||||
<div class="sax-label">
|
||||
<label for="cbOrganisationCategory"><span>@Localiser["label.category"]</span> <span class="required">*</span></label>
|
||||
@* Organisation category *@
|
||||
<div class="sax-form-control OrganisationCategory pr4">
|
||||
<div class="sax-label">
|
||||
<label for="cbOrganisationCategory"><span>@Localiser["label.category"]</span> <span class="required">*</span></label>
|
||||
</div>
|
||||
<div class="sax-control">
|
||||
@Html.DropDownListFor(model => model.OrganisationCategoryValue, Model.AdminOrganisationCategoriesForSelect, Localiser["label.select"], new { @id = "cbOrganisationCategory", @class = "OrganisationCategory sax-select" })
|
||||
</div>
|
||||
<div class="sax-message"></div>
|
||||
</div>
|
||||
<div class="sax-control">
|
||||
@Html.DropDownListFor(model => model.OrganisationCategoryValue, Model.AdminOrganisationCategoriesForSelect, Localiser["label.select"], new { @id = "cbOrganisationCategory", @class = "OrganisationCategory sax-select" })
|
||||
</div>
|
||||
<div class="sax-message"></div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
|
||||
<div class="col-sm-4">
|
||||
@* Organisation type *@
|
||||
<div class="sax-form-control OrganisationType">
|
||||
<div class="sax-label">
|
||||
<label for="cbOrganisationType"><span>@Localiser["label.type"]</span> <span class="required">*</span></label>
|
||||
</div>
|
||||
<div class="sax-control">
|
||||
@Html.DropDownListFor(model => model.OrganisationTypeValue, Model.OrganisationTypesForSelect, Localiser["label.select"], new { @id = "cbOrganisationType", @class = "OrganisationType sax-select" })
|
||||
</div>
|
||||
<div class="sax-message"></div>
|
||||
</div>
|
||||
|
||||
@* Organisation type *@
|
||||
<div class="sax-form-control OrganisationType">
|
||||
<div class="sax-label">
|
||||
<label for="cbOrganisationType"><span>@Localiser["label.type"]</span> <span class="required">*</span></label>
|
||||
</div>
|
||||
<div class="sax-control">
|
||||
@Html.DropDownListFor(model => model.OrganisationTypeValue, Model.OrganisationTypesForSelect, Localiser["label.select"], new { @id = "cbOrganisationType", @class = "OrganisationType sax-select" })
|
||||
</div>
|
||||
<div class="sax-message"></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@* Organisation sport *@
|
||||
<div class="sax-form-control OrganisationSportId">
|
||||
<div class="row">
|
||||
<div class="col-sm-4">
|
||||
<div class="col-sm-3">
|
||||
<div class="sax-label">
|
||||
<label for="ifOrganisationSportCaption"><span>@Localiser["label.sport"]</span> <span class="required">(*)</span></label>
|
||||
</div>
|
||||
@@ -96,7 +97,7 @@
|
||||
@* Organisation country *@
|
||||
<div class="sax-form-control OrganisationRegionIdCountry">
|
||||
<div class="row">
|
||||
<div class="col-sm-4">
|
||||
<div class="col-sm-3">
|
||||
<div class="sax-label">
|
||||
<label for="ifOrganisationRegionCaptionCountry"><span>@Localiser["label.country"]</span> <span class="required">*</span></label>
|
||||
</div>
|
||||
@@ -112,10 +113,61 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@* Organisation About *@
|
||||
<div class="sax-form-control OrganisationAbout">
|
||||
<div class="row">
|
||||
<div class="col-sm-3">
|
||||
<div class="sax-label">
|
||||
<label for="ifOrganisationAbout"><span>@Localiser["label.about"]</span></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm">
|
||||
<div class="sax-control">
|
||||
@Html.TextAreaFor(model => model.OrganisationAbout, new { @id = "ifOrganisationAbout", @class = "OrganisationAbout sax-input", @rows = 6, @maxlength = @Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.Organisation_About) })
|
||||
</div>
|
||||
<div class="sax-message"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@* Organisation Facilities *@
|
||||
<div class="sax-form-control OrganisationFacilities">
|
||||
<div class="row">
|
||||
<div class="col-sm-3">
|
||||
<div class="sax-label">
|
||||
<label for="ifOrganisationFacilities"><span>@Localiser["label.facilities"]</span></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm">
|
||||
<div class="sax-control">
|
||||
@Html.TextAreaFor(model => model.OrganisationFacilities, new { @id = "ifOrganisationFacilities", @class = "OrganisationFacilities sax-input", @rows = 6, @maxlength = @Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.Organisation_Facilities) })
|
||||
</div>
|
||||
<div class="sax-message"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@* Organisation Notes *@
|
||||
<div class="sax-form-control OrganisationNotes">
|
||||
<div class="row">
|
||||
<div class="col-sm-3">
|
||||
<div class="sax-label">
|
||||
<label for="ifOrganisationNotes"><span>@Localiser["label.notes"]</span></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm">
|
||||
<div class="sax-control">
|
||||
@Html.TextAreaFor(model => model.OrganisationNotes, new { @id = "ifOrganisationNotes", @class = "OrganisationNotes sax-input", @rows = 3, @maxlength = @Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.Organisation_Notes) })
|
||||
</div>
|
||||
<div class="sax-message"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@* Organisation status *@
|
||||
<div class="sax-form-control OrganisationStatus">
|
||||
<div class="row">
|
||||
<div class="col-sm-4">
|
||||
<div class="col-sm-3">
|
||||
<div class="sax-label">
|
||||
<label for="cbOrganisationStatus"><span>@Localiser["label.status"]</span> <span class="required">*</span></label>
|
||||
</div>
|
||||
|
||||
@@ -105,30 +105,11 @@
|
||||
{
|
||||
}
|
||||
|
||||
.sax-form .sax-form-control .sax-label
|
||||
{
|
||||
margin: 0 0 8px 0;
|
||||
font-size: 1rem;
|
||||
line-height: 1.25;
|
||||
}
|
||||
|
||||
.sax-form .sax-form-control .sax-label-text
|
||||
{
|
||||
font-size: 1rem;
|
||||
line-height: 1.25;
|
||||
}
|
||||
|
||||
.sax-form .sax-form-control .sax-note
|
||||
{
|
||||
font-size: 0.9rem;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
/* Controls */
|
||||
|
||||
.sax-form .sax-form-control
|
||||
{
|
||||
margin: 0 0 16px 0;
|
||||
margin: 0 0 8px 0;
|
||||
}
|
||||
|
||||
.sax-form .sax-form-control .sax-label
|
||||
|
||||
@@ -5,63 +5,101 @@
|
||||
(function (win, doc, undef)
|
||||
{
|
||||
"use strict";
|
||||
sax.itemIdPrefix = 'Itm_';
|
||||
let om = sax.mdl.organisationMembers = { data: {}, ajax: {} };
|
||||
let $pnl = om.$pnl = {}, $frm = om.$frm = {}, $dlg = om.$dlg = {};
|
||||
om.itemIdPrefix = 'Itm_';
|
||||
|
||||
//--------------------------------------------------------------
|
||||
sax.refreshResults = function (delay)
|
||||
om.refreshResults = function (delay)
|
||||
{
|
||||
var $results = $('.sax-panel-results');
|
||||
if (!sax.awaitingRefreshResponse)
|
||||
if (!om.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);
|
||||
var $items = $('.sax-panel-item-list', $pnl.results).fadeOut(200).empty();
|
||||
var $msgs = $('.sax-panel-messages', $pnl.results).hide().empty().append($('<div class="sax-message">' + sax.msg.dataQuerying + '</div>')).fadeIn(200);
|
||||
}
|
||||
sax.ajax.refreshResults = sax.ajax.refreshResults || { url: sax.url.base + 'Organisation/Ajax/GetMemberList', formId: 'frmMemberFilter', callbackFn: sax.doRefreshResults };
|
||||
sax.doAjaxRequest(sax.ajax.refreshResults, delay || 50);
|
||||
sax.awaitingRefreshResponse = true;
|
||||
om.ajax.refreshResults = om.ajax.refreshResults || { url: sax.url.base + 'Organisation/Ajax/GetMemberList', formId: 'frmMemberFilter', callbackFn: om.doRefreshResults };
|
||||
sax.doAjaxRequest(om.ajax.refreshResults, delay || 50);
|
||||
om.awaitingRefreshResponse = true;
|
||||
}
|
||||
sax.doRefreshResults = function (response)
|
||||
om.doRefreshResults = function (response)
|
||||
{
|
||||
//sax.debug('doRefreshResults', response);
|
||||
delete sax.awaitingRefreshResponse;
|
||||
delete om.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 $tmpl = $('.sax-panel-item-template .sax-panel-item.Member', $results);
|
||||
sax.refreshPaging(response, '#frmMemberFilter', sax.refreshResults);
|
||||
var $msgs = $('.sax-panel-messages', $pnl.results).hide().empty();
|
||||
var $items = $('.sax-panel-item-list', $pnl.results).hide().empty();
|
||||
sax.refreshPaging(response, '#frmMemberFilter', om.refreshResults);
|
||||
if (!response.success) return;
|
||||
// Reference data - roles.
|
||||
if (response.memberRoles && response.memberRoles.length)
|
||||
sax.data.memberRoles = response.memberRoles;
|
||||
om.data.memberRoles = response.memberRoles;
|
||||
// Reference data - Statuses.
|
||||
if (response.defaultStatusCode) sax.data.defaultStatusCode = response.defaultStatusCode;
|
||||
if (response.defaultStatusCode) om.data.defaultStatusCode = response.defaultStatusCode;
|
||||
if (response.statuses)
|
||||
sax.populateSelectCodeDesc('#cbMemberStatus', response.statuses);
|
||||
// Menu.
|
||||
var $bgr = $('.sax-burger', $pnl.filter).hide();
|
||||
var $mnu = $('ul.sax-dropdown-menu', $bgr).empty();
|
||||
$mnu.append(om.getFilterMenuOption(sax.lbl.refresh, function () { om.refreshResults(); }, 'sax-refresh'));
|
||||
$mnu.append(om.getFilterMenuOption(sax.lbl.add, function () { om.createItem(); }, 'sax-add'));
|
||||
$bgr.toggle(!!$('.sax-dropdown-item', $mnu).length);
|
||||
// Items.
|
||||
var items = response.members;
|
||||
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 = $tmpl.clone();
|
||||
sax.populateItem($item, item);
|
||||
$items.append($item);
|
||||
}
|
||||
$items.append(sax.populateItem(om.getItemTemplate(), items[itemIdx]));
|
||||
$items.fadeIn(50);
|
||||
}
|
||||
sax.populateItem = function ($item, item)
|
||||
{
|
||||
if (!item) return;
|
||||
$item.prop('id', sax.itemIdPrefix + item.id);
|
||||
$item.prop('id', om.itemIdPrefix + item.id);
|
||||
$('.UserEmailAddress', $item).text(item.emailAddress);
|
||||
$('.UserStatusDesc', $item).text(item.userStatusDesc).addClass('sax-status-' + (item.userStatusCode || '').toLowerCase());
|
||||
$('.UserStatus', $item).toggle(!item.userActive);
|
||||
$('.UserDisplayName', $item).text(item.displayName);
|
||||
$('.MemberRoleCount .RoleCount', $item).text(item.roleCount);
|
||||
$('.StatusDesc', $item).text(item.statusDesc);
|
||||
$('.sax-caption .sax-action, .sax-actions .sax-action.sax-item-update', $item).off('click').on('click', function () { sax.updateItem(item.id) })
|
||||
$item.off('dblclick').on('dblclick', function () { sax.updateItem(item.id) })
|
||||
$('.sax-panel-results .sax-panel-messages').hide().empty();
|
||||
$('.StatusDesc', $item).text(item.statusDesc).addClass('sax-status-' + item.statusCode.toLowerCase());
|
||||
$('.sax-caption .sax-action').toggleClass('sax-action', !item.deleted);
|
||||
let $mnu = $('ul.sax-dropdown-menu', $item).empty();
|
||||
if (!item.deleted)
|
||||
{
|
||||
let fnUpdItm = function () { om.updateItem(item, $item) };
|
||||
$mnu.append(om.getItemMenuOption(sax.lbl.edit, fnUpdItm, 'sax-edit'));
|
||||
$item.on('click', '.sax-header .sax-caption', fnUpdItm).on('dblclick', fnUpdItm);
|
||||
if (item.member)
|
||||
$mnu.append(om.getItemMenuOption(sax.lbl.remove, function () { om.removeItem(item, $item) }, 'sax-remove'));
|
||||
}
|
||||
$('.sax-burger', $item).toggle(!!$('.sax-dropdown-item', $mnu).length);
|
||||
$('.sax-panel-messages', $pnl.results).hide().empty();
|
||||
return $item;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
om.getFilterDropdownTemplate = function ()
|
||||
{
|
||||
return $('.sax-panel-item-template .sax-dropdown-menu.MemberFilter li.sax-dropdown-item', $pnl.filter).clone();
|
||||
}
|
||||
om.getItemTemplate = function ()
|
||||
{
|
||||
return $('.sax-panel-item-template .sax-panel-item.Member', $pnl.results).clone();
|
||||
}
|
||||
om.getItemDropdownTemplate = function ()
|
||||
{
|
||||
return $('.sax-panel-item-template .sax-dropdown-menu.Member li.sax-dropdown-item', $pnl.results).clone();
|
||||
}
|
||||
om.getFilterMenuOption = function (lbl, fn, cls)
|
||||
{
|
||||
return om.getMenuOption(om.getFilterDropdownTemplate(), lbl, fn, cls);
|
||||
}
|
||||
om.getItemMenuOption = function (lbl, fn, cls)
|
||||
{
|
||||
return om.getMenuOption(om.getItemDropdownTemplate(), lbl, fn, cls);
|
||||
}
|
||||
om.getMenuOption = function ($opt, lbl, fn, cls)
|
||||
{
|
||||
return $opt.find('div.sax-label').text(lbl).end().on('click', fn).addClass(cls);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
@@ -73,138 +111,170 @@
|
||||
sax.onFilterOrganisationSelected = function (id, name)
|
||||
{
|
||||
//sax.debug('sax.onOrganisationSelected', id, name);
|
||||
$('#frmMemberFilter #ifFilterOrganisationId').val(id);
|
||||
$('#frmMemberFilter #ifFilterOrganisation').val(name);
|
||||
sax.refreshResults(50);
|
||||
$('#ifFilterOrganisationId', $frm.filter).val(id);
|
||||
$('#ifFilterOrganisation', $frm.filter).val(name);
|
||||
om.refreshResults(50);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
sax.onChangeEmail = function ()
|
||||
// Member Roles.
|
||||
om.selectMemberRoles = function ()
|
||||
{
|
||||
let $frm = sax.$frm.member;
|
||||
let $mbrName = $('.MemberUserName', $frm);
|
||||
$('#frmUserEmail .UserEmailAddress').val($('.MemberUserEmailAddress', $frm).val());
|
||||
//sax.debug('selectMemberRoles',sax.data);
|
||||
om.data.cfgSelMbrRol = om.data.cfgSelMbrRol || { caption: sax.dlg.title.selectMemberRoles, width: 520, fnCallback: om.updateMemberRoles };
|
||||
om.data.cfgSelMbrRol.codes = om.data.memberRoles;
|
||||
om.data.cfgSelMbrRol.selectedCodes = sax.member.roleCodes || [];
|
||||
sax.selectCode.fn.openSelectCode(om.data.cfgSelMbrRol);
|
||||
}
|
||||
om.updateMemberRoles = function (memberRoleCodes)
|
||||
{
|
||||
//sax.debug('updateMemberRoles', MemberRoleCodes);
|
||||
sax.member.roleCodes = memberRoleCodes;
|
||||
$('#ifMemberRoleCodes').val(memberRoleCodes.join(om.data.memberRoleCodeDelim));
|
||||
$('#ifMemberRoles').val(om.getSelectedMemberRoleDescs().join('\n'));
|
||||
}
|
||||
om.getSelectedMemberRoleDescs = function ()
|
||||
{
|
||||
let roles = [];
|
||||
sax.member.roleCodes.forEach(function (value) { roles.push(om.getMemberRoleDesc(value)); })
|
||||
return roles.sortCI();
|
||||
}
|
||||
om.getMemberRoleDesc = function (roleCode)
|
||||
{
|
||||
let roleDesc = '';
|
||||
om.data.memberRoles.some(function (value) { if (value.code == roleCode) { roleDesc = value.desc; return true; } return false; })
|
||||
return roleDesc || roleCode;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
om.createItem = function ()
|
||||
{
|
||||
om.clearItem();
|
||||
$dlg.mbr.dialog('option', 'title', sax.dlg.title.createMember);
|
||||
om.openMemberDialog();
|
||||
}
|
||||
om.clearItem = function ()
|
||||
{
|
||||
let frm = $frm.mbr;
|
||||
$('.UserOrganisationId,.MemberRoleCodes,input[type="text"],textarea,select', frm).val('');
|
||||
$('.MemberOrganisationId', frm).val($('#frmMemberFilter #ifFilterOrganisationId').val());
|
||||
$('.MemberUserEmailAddress', frm).prop('readonly', false);
|
||||
$('.MemberUserName', frm).prop('readonly', true);
|
||||
$('.MemberStatus', frm).val(om.data.defaultStatusCode);
|
||||
sax.clearControlErrors();
|
||||
sax.member = { roleCodes: [] };
|
||||
}
|
||||
om.openMemberDialog = function ()
|
||||
{
|
||||
sax.openDialog($dlg.mbr, 600, 480);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
om.updateItem = function (item, $item)
|
||||
{
|
||||
$('.UserOrganisationId', $frm.mbrId).val(item.id);
|
||||
om.ajax.updateItem = om.ajax.updateItem || { url: sax.url.base + 'Organisation/Ajax/GetMember', formId: 'frmMemberId', callbackFn: om.onUpdateItem };
|
||||
sax.doAjaxRequest(om.ajax.updateItem, 50);
|
||||
}
|
||||
om.onUpdateItem = function (response)
|
||||
{
|
||||
//sax.debug('onUpdateItem', response);
|
||||
om.clearItem();
|
||||
if (!response.success) return;
|
||||
let item = sax.member = response.member;
|
||||
let frm = $frm.mbr;
|
||||
$('.UserOrganisationId', frm).val(item.id);
|
||||
$('.MemberOrganisationId', frm).val($('#frmMemberFilter #ifFilterOrganisationId').val());
|
||||
$('.MemberUserEmailAddress', frm).val(item.emailAddress).prop('readonly', true);
|
||||
$('.MemberUserName', frm).val(item.displayName).prop('readonly', true);
|
||||
$('.MemberRoleCodes', frm).val(item.roleCodes);
|
||||
$('#ifMemberRoles', frm).val(om.getSelectedMemberRoleDescs().join('\n'));
|
||||
$('.MemberStatus', frm).val(item.statusCode);
|
||||
sax.clearControlErrors();
|
||||
$dlg.mbr.dialog('option', 'title', sax.dlg.title.updateMember);
|
||||
om.openMemberDialog();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
om.onChangeEmail = function ()
|
||||
{
|
||||
let $mbrName = $('.MemberUserName', $frm.mbr);
|
||||
$('#frmUserEmail .UserEmailAddress').val($('.MemberUserEmailAddress', $frm.mbr).val());
|
||||
$mbrName.val('');
|
||||
let fn = function (response)
|
||||
{
|
||||
if (!response || !response.success || !response.user) return;
|
||||
$mbrName.val(response.user.displayName);
|
||||
}
|
||||
sax.ajax.userByEmail = sax.ajax.userByEmail || { url: sax.url.base + 'User/Ajax/GetUserByEmail', formId: 'frmUserEmail', callbackFn: fn };
|
||||
sax.doAjaxRequest(sax.ajax.userByEmail, 100);
|
||||
om.ajax.userByEmail = om.ajax.userByEmail || { url: sax.url.base + 'User/Ajax/GetUserByEmail', formId: 'frmUserEmail', callbackFn: fn };
|
||||
sax.doAjaxRequest(om.ajax.userByEmail, 100);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
// Member Roles.
|
||||
sax.selectMemberRoles = function ()
|
||||
om.storeItem = function ()
|
||||
{
|
||||
//sax.debug('selectMemberRoles',sax.data);
|
||||
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.selectCode.fn.openSelectCode(sax.selectMemberRoleConfig);
|
||||
om.ajax.storeItem = om.ajax.storeItem || { url: sax.url.base + 'Organisation/Ajax/StoreMember', formId: 'frmMember', callbackFn: om.onStoreItem };
|
||||
sax.doAjaxRequest(om.ajax.storeItem, 50);
|
||||
}
|
||||
sax.updateMemberRoles = function (memberRoleCodes)
|
||||
{
|
||||
//sax.debug('updateMemberRoles', MemberRoleCodes);
|
||||
sax.member.roleCodes = memberRoleCodes;
|
||||
$('#ifMemberRoleCodes').val(memberRoleCodes.join(sax.data.memberRoleCodeDelim));
|
||||
$('#ifMemberRoles').val(sax.getSelectedMemberRoleDescs().join('\n'));
|
||||
}
|
||||
sax.getSelectedMemberRoleDescs = function ()
|
||||
{
|
||||
let roles = [];
|
||||
sax.member.roleCodes.forEach(function (value) { roles.push(sax.getMemberRoleDesc(value)); })
|
||||
return roles.sortCI();
|
||||
}
|
||||
sax.getMemberRoleDesc = function (roleCode)
|
||||
{
|
||||
let roleDesc = '';
|
||||
sax.data.memberRoles.some(function (value) { if (value.code == roleCode) { roleDesc = value.desc; return true; } return false; })
|
||||
return roleDesc || roleCode;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
sax.createItem = function ()
|
||||
{
|
||||
let $frm = sax.$frm.member;
|
||||
$('.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);
|
||||
sax.openDialog(sax.$dlg.member, 600, 480);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
sax.updateItem = function (id)
|
||||
{
|
||||
$('.UserOrganisationId', sax.$frm.memberId).val(id);
|
||||
sax.ajax.updateItem = sax.ajax.updateItem || { url: sax.url.base + 'Organisation/Ajax/GetMember', formId: 'frmMemberId', callbackFn: sax.onUpdateItem };
|
||||
sax.doAjaxRequest(sax.ajax.updateItem, 50);
|
||||
}
|
||||
sax.onUpdateItem = function (response)
|
||||
{
|
||||
//sax.debug('onUpdateItem', response);
|
||||
let $frm = sax.$frm.member;
|
||||
$('.UserOrganisationId,input[type="text"],textarea,select', $frm).val('');
|
||||
if (!response.success) return;
|
||||
let item = sax.member = response.member;
|
||||
$('.UserOrganisationId', $frm).val(item.id);
|
||||
$('.MemberOrganisationId', $frm).val($('#frmMemberFilter #ifFilterOrganisationId').val());
|
||||
$('.MemberUserEmailAddress', $frm).val(item.emailAddress).prop('readonly', true);
|
||||
$('.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, 480);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
sax.storeItem = function ()
|
||||
{
|
||||
sax.ajax.storeItem = sax.ajax.storeItem || { url: sax.url.base + 'Organisation/Ajax/StoreMember', formId: 'frmMember', callbackFn: sax.onStoreItem };
|
||||
sax.doAjaxRequest(sax.ajax.storeItem, 50);
|
||||
}
|
||||
sax.onStoreItem = function (response)
|
||||
om.onStoreItem = function (response)
|
||||
{
|
||||
//sax.debug('onStoreItem', response);
|
||||
sax.refreshControlValues(response.controlValues);
|
||||
if (!response.success) return;
|
||||
sax.$dlg.member.dialog('close');
|
||||
$dlg.mbr.dialog('close');
|
||||
|
||||
var item = response.member;
|
||||
var $item = $('#' + sax.itemIdPrefix + item.id);
|
||||
var $item = $('#' + om.itemIdPrefix + item.id);
|
||||
if (!$item.length)
|
||||
{
|
||||
var $results = $('.sax-panel-results');
|
||||
$item = $('.sax-panel-item-template .sax-panel-item.Member', $results).clone();
|
||||
$('.sax-panel-item-list', $results).prepend($item).show();
|
||||
$item = $('.sax-panel-item-template .sax-panel-item.Member', $pnl.results).clone();
|
||||
$('.sax-panel-item-list', $pnl.results).prepend($item).show();
|
||||
}
|
||||
sax.populateItem($item, item)
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
om.removeItem = function (item, $item)
|
||||
{
|
||||
$('.OrganisationId', $frm.mbrId).val(item.organisationId);
|
||||
$('.UserOrganisationId', $frm.mbrId).val(item.id);
|
||||
om.ajax.removeItem = om.ajax.removeItem || { url: sax.url.base + 'Organisation/Ajax/RemoveMember', formId: 'frmMemberId', callbackFn: om.onRemoveItem };
|
||||
sax.doAjaxRequest(om.ajax.removeItem, 50);
|
||||
}
|
||||
om.onRemoveItem = function (response)
|
||||
{
|
||||
sax.debug('onRemoveItem', response);
|
||||
if (!response.success) return;
|
||||
|
||||
var item = response.member;
|
||||
$('#' + om.itemIdPrefix + item.id).remove();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
$(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); });
|
||||
$pnl.mbrs = $('.sax-panel.OrganisationMembers');
|
||||
$pnl.filter = $('.sax-panel-filter', $pnl.mbrs);
|
||||
$pnl.results = $('.sax-panel-results', $pnl.mbrs);
|
||||
|
||||
sax.$frm.memberId = $('#frmMemberId');
|
||||
sax.$frm.member = $('#frmMember');
|
||||
$('#ifMemberUserEmailAddress', sax.$frm.member).on('change', function () { sax.onChangeEmail(); });
|
||||
$frm.filter = $('#frmOrganisationFilter');
|
||||
$frm.filter.on('dblclick', '#ifFilterOrganisation', sax.selectFilterOrganisation);
|
||||
$frm.filter.on('click', '#pbFilterOrganisationSelect', sax.selectFilterOrganisation);
|
||||
|
||||
$frm.mbrId = $('#frmMemberId');
|
||||
$frm.mbr = $('#frmMember');
|
||||
$frm.mbr.on('input', '.sax-input', function () { sax.clearControlError(this); });
|
||||
$frm.mbr.on('change', '.sax-select', function () { sax.clearControlError(this); });
|
||||
$frm.mbr.on('change', '#ifMemberUserEmailAddress', function () { om.onChangeEmail(); });
|
||||
$frm.mbr.on('dblclick', '#ifMemberRoles', om.selectMemberRoles);
|
||||
$frm.mbr.on('click', '#pbMemberRolesSelect', om.selectMemberRoles);
|
||||
|
||||
var opt = sax.dlgOpts();
|
||||
opt.buttons[sax.dlg.btn.ok] = function () { sax.storeItem(); };
|
||||
opt.buttons[sax.dlg.btn.ok] = function () { om.storeItem(); };
|
||||
opt.buttons[sax.dlg.btn.cancel] = function () { $(this).dialog('close'); };
|
||||
sax.$dlg.member = $('#dlgMember').dialog(opt);
|
||||
$dlg.mbr = $('#dlgMember').dialog(opt);
|
||||
|
||||
setTimeout(sax.refreshResults, 250);
|
||||
setTimeout(om.refreshResults, 250);
|
||||
});
|
||||
|
||||
}(window, window.document));
|
||||
|
||||
@@ -56,18 +56,18 @@
|
||||
$('.OrganisationType', $item).text(item.typeDesc);
|
||||
$('.OrganisationCategory', $item).text(item.categoryDesc);
|
||||
$('.OrganisationSport', $item).text(item.sportName);
|
||||
$('.OrganisationRegion', $item).text(item.regionName);
|
||||
$('.OrganisationRegion', $item).text(item.regionNameCountry);
|
||||
$('.OrganisationMemberCount', $item).on('click', function () { op.onClickMemberCount(item.id); }).find('.MemberCount').text(item.memberCount);
|
||||
$('.StatusDesc', $item).text(item.statusDesc).addClass('sax-status-' + item.statusCode.toLowerCase());
|
||||
$('.sax-caption .sax-action').toggleClass('sax-action', !item.deleted);
|
||||
let $mnu = $('ul.sax-dropdown-menu', $item).empty();
|
||||
if (!item.deleted)
|
||||
{
|
||||
$mnu.append(op.getItemMenuOption(sax.lbl.edit, function () { op.updateItem(item, $item) }, 'sax-edit'));
|
||||
let fnUpdItm = function () { op.updateItem(item, $item) };
|
||||
$mnu.append(op.getItemMenuOption(sax.lbl.edit, fnUpdItm, 'sax-edit'));
|
||||
if (item.awaiting)
|
||||
$mnu.append(op.getItemMenuOption(sax.lbl.activate, function () { op.activateItem(item) }, 'sax-unlock'));
|
||||
$('.sax-header .sax-action.sax-item-update', $item).off('click').on('click', function () { op.updateItem(item, $item) });
|
||||
$item.off('dblclick').on('dblclick', function () { op.updateItem(item, $item) });
|
||||
$item.on('click', '.sax-header .sax-action.sax-item-update', fnUpdItm).on('dblclick', fnUpdItm);
|
||||
}
|
||||
$('.sax-burger', $item).toggle(!!$('.sax-dropdown-item', $mnu).length);
|
||||
$('.sax-panel-messages', $pnl.results).hide().empty();
|
||||
@@ -101,6 +101,11 @@
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
op.getFilterSport = function ()
|
||||
{
|
||||
let frm = $frm.filter;
|
||||
return { id: $('.FilterOrganisationSportId', frm).val(), name: $('.FilterOrganisationSportCaption', frm).val() };
|
||||
}
|
||||
op.selectFilterSport = function ()
|
||||
{
|
||||
if (!op.data.sports)
|
||||
@@ -109,7 +114,7 @@
|
||||
}
|
||||
op.showSelectFilterSport = function ()
|
||||
{
|
||||
sax.data.selectItem.fn.selectItem({ caption: sax.dlg.title.selectSport, itemId: $('.FilterOrganisationSportId', $frm.filter).val(), items: op.data.sports, fnCallback: op.onFilterSportSelected });
|
||||
sax.data.selectItem.fn.selectItem({ caption: sax.dlg.title.selectSport, itemId: op.getFilterSport().id, items: op.data.sports, fnCallback: op.onFilterSportSelected });
|
||||
}
|
||||
op.onFilterSportSelected = function (spt)
|
||||
{
|
||||
@@ -159,6 +164,11 @@
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
op.getFilterRegion = function ()
|
||||
{
|
||||
let frm = $frm.filter;
|
||||
return { id: $('.FilterOrganisationRegionId', frm).val(), name: $('.FilterOrganisationRegionCaption', frm).val() };
|
||||
}
|
||||
op.selectFilterRegion = function ()
|
||||
{
|
||||
if (!op.data.regions)
|
||||
@@ -167,7 +177,7 @@
|
||||
}
|
||||
op.showSelectFilterRegion = function ()
|
||||
{
|
||||
sax.data.selectItem.fn.selectItem({ caption: sax.dlg.title.selectFilterRegion, itemId: $('.FilterOrganisationRegionId', $frm.filter).val(), items: op.data.regions, fnCallback: op.onFilterRegionSelected });
|
||||
sax.data.selectItem.fn.selectItem({ caption: sax.dlg.title.selectFilterRegion, itemId: op.getFilterRegion().id, items: op.data.regions, fnCallback: op.onFilterRegionSelected });
|
||||
}
|
||||
op.onFilterRegionSelected = function (rgn)
|
||||
{
|
||||
@@ -218,8 +228,14 @@
|
||||
op.createItem = function ()
|
||||
{
|
||||
op.clearItem();
|
||||
let spt = op.getFilterSport();
|
||||
if (spt.id && spt.name)
|
||||
{
|
||||
$('.OrganisationSportId', $frm.org).val(spt.id);
|
||||
$('.OrganisationSportCaption', $frm.org).val(spt.name);
|
||||
}
|
||||
$dlg.organisation.dialog('option', 'title', sax.dlg.title.createOrganisation);
|
||||
sax.openDialog($dlg.organisation, 600, 480);
|
||||
sax.openOrgDialog();
|
||||
}
|
||||
op.clearItem = function ()
|
||||
{
|
||||
@@ -228,6 +244,14 @@
|
||||
$('.OrganisationStatus', frm).val(sax.data.defaultStatusCode);
|
||||
sax.clearControlErrors();
|
||||
}
|
||||
sax.openOrgDialog = function ()
|
||||
{
|
||||
sax.openDialog($dlg.organisation, 640, 720);
|
||||
}
|
||||
sax.onOpenOrgDialog = function ()
|
||||
{
|
||||
$('textarea').scrollTop(0);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
op.updateItem = function (item, $item)
|
||||
@@ -251,10 +275,13 @@
|
||||
$('.OrganisationSportCaption', frm).val(item.sportName);
|
||||
$('.OrganisationRegionIdCountry', frm).val(item.regionIdCountry);
|
||||
$('.OrganisationRegionCaptionCountry', frm).val(item.regionNameCountry);
|
||||
$('.OrganisationAbout', frm).val(item.about);
|
||||
$('.OrganisationFacilities', frm).val(item.facilities);
|
||||
$('.OrganisationNotes', frm).val(item.notes);
|
||||
$('.OrganisationStatus', frm).val(item.statusCode);
|
||||
sax.clearControlErrors();
|
||||
$dlg.organisation.dialog('option', 'title', sax.dlg.title.updateOrganisation);
|
||||
sax.openDialog($dlg.organisation, 600, 480);
|
||||
sax.openOrgDialog();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
@@ -367,6 +394,7 @@
|
||||
$frm.org.on('dblclick', '.OrganisationRegionCaptionCountry', op.selectOrgRegion).on('click', '#pbSelectRegion', op.selectOrgRegion);
|
||||
|
||||
var opt = sax.dlgOpts();
|
||||
opt.open = sax.onOpenOrgDialog;
|
||||
opt.buttons[sax.dlg.btn.ok] = function () { op.storeItem(); };
|
||||
opt.buttons[sax.dlg.btn.cancel] = function () { $(this).dialog('close'); };
|
||||
$dlg.organisation = $('#dlgOrganisation').dialog(opt);
|
||||
|
||||
Reference in New Issue
Block a user