From ea61d378405c0678bfe4cb742fe1dd16ef5d74b2 Mon Sep 17 00:00:00 2001 From: Andy Howard Date: Thu, 21 Oct 2021 18:04:57 +0100 Subject: [PATCH] v1.1.8 --- SaxoniteCoreWeb/Base/App/SaxLocaliser.cs | 12 +- SaxoniteCoreWeb/Base/Models/SaxModel_Base.cs | 14 +- .../Controllers/OrganisationController.cs | 2 +- .../Admin/Controllers/UserController-Ajax.cs | 6 +- .../Admin/Controllers/UserController.cs | 8 +- .../Admin/Models/Model_Organisation.cs | 2 +- .../Admin/Models/Model_User.cs | 27 +- .../Views/Organisation/Index.cshtml | 90 ++--- .../Panel-ActivationDialog.cshtml | 2 - .../Panel-OrganisationDialog.cshtml | 93 +++-- .../Views/Shared/_Layout.cshtml | 2 +- SaxoniteCoreWebAdmin/Views/User/Index.cshtml | 204 +++++++---- .../Views/User/Panel-UserDialog.cshtml | 183 ++++++---- .../wwwroot/js/sax-organisation.js | 341 +++++++++--------- SaxoniteCoreWebAdmin/wwwroot/js/sax-user.js | 69 ++++ .../Localisation/SaxOnlineProperties.resx | 6 + .../SearchController-Ajax-Organisations.cs | 4 + .../SearchController-Ajax-Users.cs | 193 ++++++++++ .../Online/Controllers/SearchController.cs | 22 +- .../Online/Models/Model_Search_Users.cs | 53 +++ .../Views/Search/Panel-UserDialog.cshtml | 25 ++ .../Views/Search/Users.cshtml | 154 ++++++++ .../Views/Shared/_Layout.cshtml | 1 + .../wwwroot/js/sax-resultsPaging.js | 2 +- .../wwwroot/js/sax-src-org.js | 2 - .../wwwroot/js/sax-src-usr.js | 169 +++++++++ SaxoniteStandardBase/Base/App/Sax-Config.cs | 99 +++++ SaxoniteStandardBase/Base/App/Sax-Version.cs | 7 +- SaxoniteStandardBase/Base/App/Sax.cs | 71 ---- .../Base/Bus/SaxUserAccount.cs | 33 +- .../Mgr/SaxAccountMgr_Dbas-UserAccount.cs | 103 +++++- .../SaxAccountMgr_Dbas-UserOrganisation.cs | 10 +- 32 files changed, 1486 insertions(+), 523 deletions(-) create mode 100644 SaxoniteCoreWebOnline/Online/Controllers/SearchController-Ajax-Users.cs create mode 100644 SaxoniteCoreWebOnline/Online/Models/Model_Search_Users.cs create mode 100644 SaxoniteCoreWebOnline/Views/Search/Panel-UserDialog.cshtml create mode 100644 SaxoniteCoreWebOnline/Views/Search/Users.cshtml create mode 100644 SaxoniteCoreWebOnline/wwwroot/js/sax-src-usr.js create mode 100644 SaxoniteStandardBase/Base/App/Sax-Config.cs diff --git a/SaxoniteCoreWeb/Base/App/SaxLocaliser.cs b/SaxoniteCoreWeb/Base/App/SaxLocaliser.cs index b8cc30d..dbdce7f 100644 --- a/SaxoniteCoreWeb/Base/App/SaxLocaliser.cs +++ b/SaxoniteCoreWeb/Base/App/SaxLocaliser.cs @@ -149,11 +149,15 @@ namespace Saxonite.Net.Core.Web.Base.App private Dictionary> codeTypeCache { get; } = new Dictionary>(); public List GetCodesOfType(Sax.CodeType codeType) { - List codes = codeTypeCache.GetValue(codeType, null); - if (codes == null) + List codes = null; + lock (codeTypeCache) { - codes = SaxSystem.GetCodesOfType(codeType); - codeTypeCache.Add(codeType, codes); + codes = codeTypeCache.GetValue(codeType, null); + if (codes == null) + { + codes = SaxSystem.GetCodesOfType(codeType); + codeTypeCache.Add(codeType, codes); + } } return codes; } diff --git a/SaxoniteCoreWeb/Base/Models/SaxModel_Base.cs b/SaxoniteCoreWeb/Base/Models/SaxModel_Base.cs index 65d76d4..ecb2bba 100644 --- a/SaxoniteCoreWeb/Base/Models/SaxModel_Base.cs +++ b/SaxoniteCoreWeb/Base/Models/SaxModel_Base.cs @@ -289,7 +289,7 @@ namespace Saxonite.Net.Core.Web.Base.Models { List values = new List(); foreach (TypeCodeDesc yesNo in YesNoCodes) - values.Add(new SelectListItem(yesNo.Code, Localiser.GetYesNoCaption((Sax.YesNo)yesNo.Type))); + values.Add(new SelectListItem(Localiser.GetYesNoCaption((Sax.YesNo)yesNo.Type), yesNo.Code)); return values; } } @@ -302,7 +302,7 @@ namespace Saxonite.Net.Core.Web.Base.Models List values = new List(); values.Add(new SelectListItem("Default", "")); foreach (TypeCodeDesc sportSpecialityLabel in SportSpecialityLabelCodes) - values.Add(new SelectListItem(sportSpecialityLabel.Code, Localiser.GetSportSpecialityLabelCaption((Sax.SportSpecialityLabel)sportSpecialityLabel.Type))); + values.Add(new SelectListItem(Localiser.GetSportSpecialityLabelCaption((Sax.SportSpecialityLabel)sportSpecialityLabel.Type), sportSpecialityLabel.Code)); return values; } } @@ -314,7 +314,7 @@ namespace Saxonite.Net.Core.Web.Base.Models { List values = new List(); foreach (TypeCodeDesc sportParticipation in SportParticipationCodes) - values.Add(new SelectListItem(sportParticipation.Code, Localiser.GetSportParticipationCaption((Sax.SportParticipation)sportParticipation.Type))); + values.Add(new SelectListItem(Localiser.GetSportParticipationCaption((Sax.SportParticipation)sportParticipation.Type), sportParticipation.Code)); return values; } } @@ -326,7 +326,7 @@ namespace Saxonite.Net.Core.Web.Base.Models { List values = new List(); foreach (TypeCodeDesc sportOfficiating in SportOfficiatingCodes) - values.Add(new SelectListItem(sportOfficiating.Code, Localiser.GetSportOfficiatingCaption((Sax.SportOfficiating)sportOfficiating.Type))); + values.Add(new SelectListItem(Localiser.GetSportOfficiatingCaption((Sax.SportOfficiating)sportOfficiating.Type), sportOfficiating.Code)); return values; } } @@ -338,7 +338,7 @@ namespace Saxonite.Net.Core.Web.Base.Models { List values = new List(); foreach (TypeCodeDesc organisationType in RegionTypeCodes.FindAll(item => item.Type != (int)Sax.RegionType.Universe && item.Type != (int)Sax.RegionType.Galaxy)) - values.Add(new SelectListItem(organisationType.Code, Localiser.GetRegionTypeCaption((Sax.RegionType)organisationType.Type))); + values.Add(new SelectListItem(Localiser.GetRegionTypeCaption((Sax.RegionType)organisationType.Type), organisationType.Code)); return values; } } @@ -356,7 +356,7 @@ namespace Saxonite.Net.Core.Web.Base.Models { List values = new List(); foreach (TypeCodeDesc organisationType in OrganisationTypeCodes) - values.Add(new SelectListItem(organisationType.Code, Localiser.GetOrganisationTypeCaption((Sax.OrganisationType)organisationType.Type))); + values.Add(new SelectListItem(Localiser.GetOrganisationTypeCaption((Sax.OrganisationType)organisationType.Type), organisationType.Code)); return values; } } @@ -368,7 +368,7 @@ namespace Saxonite.Net.Core.Web.Base.Models { List values = new List(); foreach (TypeCodeDesc organisationCategory in OrganisationCategoryCodes) - values.Add(new SelectListItem(organisationCategory.Code, Localiser.GetOrganisationCategoryCaption((Sax.OrganisationCategory)organisationCategory.Type))); + values.Add(new SelectListItem(Localiser.GetOrganisationCategoryCaption((Sax.OrganisationCategory)organisationCategory.Type), organisationCategory.Code)); return values; } } diff --git a/SaxoniteCoreWebAdmin/Admin/Controllers/OrganisationController.cs b/SaxoniteCoreWebAdmin/Admin/Controllers/OrganisationController.cs index ffd4efe..3f18543 100644 --- a/SaxoniteCoreWebAdmin/Admin/Controllers/OrganisationController.cs +++ b/SaxoniteCoreWebAdmin/Admin/Controllers/OrganisationController.cs @@ -35,7 +35,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers // Paging. Model_Organisation model = new Model_Organisation(Localiser); model.Paging.PageNo = 1; - model.Paging.PageLength = 6; + model.Paging.PageLength = 8; // Default status. if (sta.StartsWithCI("Awa")) diff --git a/SaxoniteCoreWebAdmin/Admin/Controllers/UserController-Ajax.cs b/SaxoniteCoreWebAdmin/Admin/Controllers/UserController-Ajax.cs index 06bc13d..7aa969e 100644 --- a/SaxoniteCoreWebAdmin/Admin/Controllers/UserController-Ajax.cs +++ b/SaxoniteCoreWebAdmin/Admin/Controllers/UserController-Ajax.cs @@ -109,8 +109,10 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers // Item filter. SaxUserAccount.Params prmUserAccount = new SaxUserAccount.Params(); - prmUserAccount.UserAccountFilter = model.Filter.User; - prmUserAccount.StatusCat = SaxUserAccount.StatusCat.NotDeleted; + prmUserAccount.UserFilterPartial = model.Filter.User; + prmUserAccount.SportIdsIncluded.AddId(model.Filter.UserSportId.ToSysId()); + prmUserAccount.RegionIdsIncluded.AddId(model.Filter.UserRegionId.ToSysId()); + prmUserAccount.StatusCat = model.Filter.UserStatusCategoryCode != null ? model.FilterUserStatusCategory : SaxUserAccount.StatusCat.NotDeleted; model.Paging.ItemTotal = (ulong)AccountMgr.GetUserAccountCount(prmUserAccount); model.PopulatePagingTo(prmUserAccount.ResultsPaging); diff --git a/SaxoniteCoreWebAdmin/Admin/Controllers/UserController.cs b/SaxoniteCoreWebAdmin/Admin/Controllers/UserController.cs index 3136c69..c7c4b8e 100644 --- a/SaxoniteCoreWebAdmin/Admin/Controllers/UserController.cs +++ b/SaxoniteCoreWebAdmin/Admin/Controllers/UserController.cs @@ -1,8 +1,10 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; +using Sarand.Net.Standard.Base.Utils; using Saxonite.Net.Core.Web.Admin.Models; using Saxonite.Net.Core.Web.Base.App; using Saxonite.Net.Core.Web.Base.Controllers; +using Saxonite.Net.Standard.Base.Bus; using System; using System.Collections.Generic; using System.Diagnostics; @@ -23,7 +25,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers //------------------------------------------------------------------- [HttpGet] - public IActionResult Index() + public IActionResult Index(String sta) { // Validate session. if (!ValidUserSession) @@ -34,6 +36,10 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers model.Paging.PageNo = 1; model.Paging.PageLength = 12; + // Default status. + if (sta.StartsWithCI("Awa")) + model.Filter.UserStatusCategoryCode = nameof(SaxUserAccount.StatusCat.AwaitingOnly); + return View(model); } diff --git a/SaxoniteCoreWebAdmin/Admin/Models/Model_Organisation.cs b/SaxoniteCoreWebAdmin/Admin/Models/Model_Organisation.cs index 1930d99..041f274 100644 --- a/SaxoniteCoreWebAdmin/Admin/Models/Model_Organisation.cs +++ b/SaxoniteCoreWebAdmin/Admin/Models/Model_Organisation.cs @@ -28,7 +28,7 @@ namespace Saxonite.Net.Core.Web.Admin.Models } //------------------------------------------------------------------- - // List configuration. + // Organisation filter properties. public class FilterData { public String Organisation { get; set; } diff --git a/SaxoniteCoreWebAdmin/Admin/Models/Model_User.cs b/SaxoniteCoreWebAdmin/Admin/Models/Model_User.cs index c98d030..e545b5d 100644 --- a/SaxoniteCoreWebAdmin/Admin/Models/Model_User.cs +++ b/SaxoniteCoreWebAdmin/Admin/Models/Model_User.cs @@ -1,4 +1,5 @@ -using Sarand.Net.Standard.Base.App; +using Microsoft.AspNetCore.Mvc.Rendering; +using Sarand.Net.Standard.Base.App; using Sarand.Net.Standard.Base.Bus; using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Helpers; @@ -29,12 +30,34 @@ namespace Saxonite.Net.Core.Web.Admin.Models } //------------------------------------------------------------------- - // User list configuration. + // User filter properties. public class FilterData { public String User { get; set; } + public String UserSportId { get; set; } + public String UserRegionId { get; set; } + public String UserStatusCategoryCode { get; set; } } public FilterData Filter { get; } = new FilterData(); + public SaxUserAccount.StatusCat FilterUserStatusCategory + { + get { return EnumUtil.ParseEnum(Filter.UserStatusCategoryCode, SaxUserAccount.StatusCat.Any); } + } + /// User Status Categories for filter. + public IEnumerable UserFilterStatusCategoriesForSelect + { + get + { + List statusCategories = new List(); + statusCategories.Add(SaxUserAccount.StatusCat.Any.ToString(), Localiser["label.any"]); + statusCategories.Add(SaxUserAccount.StatusCat.AwaitingOnly.ToString(), "Awaiting"); + statusCategories.Add(SaxUserAccount.StatusCat.ActiveOnly.ToString(), "Active"); + statusCategories.Add(SaxUserAccount.StatusCat.InactiveOnly.ToString(), "Inactive"); + statusCategories.Add(SaxUserAccount.StatusCat.NotDeleted.ToString(), "Not deleted"); + statusCategories.Add(SaxUserAccount.StatusCat.DeletedOnly.ToString(), "Deleted"); + return new SelectList(statusCategories, "Code", "Desc", SaxUserAccount.StatusCat.Any.ToString()); + } + } //------------------------------------------------------------------- // User properties. diff --git a/SaxoniteCoreWebAdmin/Views/Organisation/Index.cshtml b/SaxoniteCoreWebAdmin/Views/Organisation/Index.cshtml index a396ae5..97d6811 100644 --- a/SaxoniteCoreWebAdmin/Views/Organisation/Index.cshtml +++ b/SaxoniteCoreWebAdmin/Views/Organisation/Index.cshtml @@ -5,7 +5,7 @@ ViewData["Title"] = "Organisations"; } -
+
- @using (@Html.BeginForm(FormMethod.Post, new { @id = "frmUserFilter", @class = "sax-form", @onSubmit = "return false;" })) - { +
+ +
+ +
+ + @* Filter Panel *@ + @using (@Html.BeginForm(FormMethod.Post, new { @id = "frmUserFilter", @class = "sax-form", @onSubmit = "return false;" })) + { + +
+ @* Header - Page caption, paging controls, actions. *@ +
+
@Localiser["user.caption.users"]
+
+
+ +
+
+ @* Burger menu *@ + +
+
+
+
+ @* User filter - email, name etc. *@ +
+
@Localiser["user.caption.user"]
+
@Html.TextBoxFor(model => model.Filter.User, new { @id = "ifFilterUser", @class = "FilterUser", @maxlength = "32" })
+
+ @* User sport *@ +
+
@Localiser["label.sport"]
+
+
+ @Html.HiddenFor(model => model.Filter.UserSportId, new { @id = "", @class = "FilterUserSportId" }) +
+
+
@(Localiser[
+
@(Localiser[
+
+
+
+
+ @* User region *@ +
+
@Localiser["label.region"]
+
+
+ @Html.HiddenFor(model => model.Filter.UserRegionId, new { @id = "", @class = "FilterUserRegionId" }) +
+
+
@(Localiser[
+
@(Localiser[
+
+
+
+
+ @* Organisation Status *@ +
+
@Localiser["label.status"]
+
+ @Html.DropDownListFor(model => model.Filter.UserStatusCategoryCode, Model.UserFilterStatusCategoriesForSelect, new { @id = "", @class = "FilterUserStatusCategory sax-select" }) +
+
+
+ + @* Filter element templates *@ +
+ @* Burger dropdown item template - ul is ignored *@ +
    +
  • XXX
  • +
+
- @* Filter Panel *@ -
- @* Header - Page caption, paging controls, actions. *@ -
-
@Localiser["user.caption.users"]
-
-
-
-
- @* Burger menu *@ - -
-
-
-
-
- @* User filter - email, name etc. *@ -
@Localiser["user.caption.user"]
-
@Html.TextBoxFor(model => model.Filter.User, new { @id = "ifFilterUser", @class = "FilterUser", @maxlength = "32" })
-
+ } +
- @* Filter element templates *@ -
- @* Burger dropdown item template - ul is ignored *@ -
    -
  • XXX
  • -
-
+ @* Separate filter from results when alondside each other. *@ +
- } - @* Results Panel *@ -
-
-
+
- @* Element templates *@ -
+ @* Results Panel *@ +
+
+
- @* User item template *@ -
-
-
- @* User email *@ -
-
-
- @* Burger menu *@ - -
-
-
-
-
-
Roles:
-
-
-
-
-
+ @* Element templates *@ +
+ + @* User item template *@ +
+
+
+ @* User email *@ +
+
+
+ @* Burger menu *@ + +
+
+
+
+
+
Roles:
+
+
+
+
+
+
+
+ + @* Burger dropdown item template - ul is ignored *@ +
    +
  • XXX
  • +
+
- - @* Burger dropdown item template - ul is ignored *@ -
    -
  • XXX
  • -
-
- - -
- + + diff --git a/SaxoniteCoreWebAdmin/Views/User/Panel-UserDialog.cshtml b/SaxoniteCoreWebAdmin/Views/User/Panel-UserDialog.cshtml index b30e105..45c205b 100644 --- a/SaxoniteCoreWebAdmin/Views/User/Panel-UserDialog.cshtml +++ b/SaxoniteCoreWebAdmin/Views/User/Panel-UserDialog.cshtml @@ -16,6 +16,7 @@ @Html.HiddenFor(model => model.UserAccountId, new { @class = "UserAccountId" }) }
+
@using (@Html.BeginForm(FormMethod.Post, new { @id = "frmUser", @class = "sax-form", @onSubmit = "return false;" })) { @@ -23,125 +24,183 @@ @* User email *@
-
- +
+
+
+ +
+
+
+
+ @Html.TextBoxFor(model => model.UserEmailAddress, new { @id = "ifUserEmailAddress", @class = "UserEmailAddress sax-input", @maxlength = @Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.UserAccount_EmailAddress) }) +
+
+
-
- @Html.TextBoxFor(model => model.UserEmailAddress, new { @id = "ifUserEmailAddress", @class = "UserEmailAddress sax-input", @maxlength = @Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.UserAccount_EmailAddress) }) -
-
/* Title */
-
- +
+
+
+ +
+
+
+
+ @Html.DropDownListFor(model => model.UserTitle, Model.TitlesForSelect, Localiser["label.not.specified"], new { @id = "cbUserTitle", @class = "UserTitle sax-select" }) +
+
+
-
- @Html.DropDownListFor(model => model.UserTitle, Model.TitlesForSelect, Localiser["label.not.specified"], new { @id = "cbUserTitle", @class = "UserTitle sax-select" }) -
-
@* User first name *@
-
- +
+
+
+ +
+
+
+
+ @Html.TextBoxFor(model => model.UserFirstName, new { @id = "ifUserFirstName", @class = "UserFirstName sax-input", @maxlength = @Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.UserAccount_FirstName) }) +
+
+
-
- @Html.TextBoxFor(model => model.UserFirstName, new { @id = "ifUserFirstName", @class = "UserFirstName sax-input", @maxlength = @Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.UserAccount_FirstName) }) -
-
@* User last name *@
-
- +
+
+
+ +
+
+
+
+ @Html.TextBoxFor(model => model.UserLastName, new { @id = "ifUserLastName", @class = "UserLastName sax-input", @maxlength = @Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.UserAccount_LastName) }) +
+
+
-
- @Html.TextBoxFor(model => model.UserLastName, new { @id = "ifUserLastName", @class = "UserLastName sax-input", @maxlength = @Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.UserAccount_LastName) }) -
-
@* User roles *@
-
- +
+
+
+ +
+
+
+
+ @Html.HiddenFor(model => model.UserRoleCodes, new { @id = "ifUserRoleCodes", @class = "UserRoleCodes sax-input" }) +
+
+
+
+
-
- @Html.HiddenFor(model => model.UserRoleCodes, new { @id = "ifUserRoleCodes", @class = "UserRoleCodes sax-input" }) -
-
-
-
@* User status *@
-
- +
+
+
+ +
+
+
+
+ +
+
+
-
- -
-
} +
+
@using (@Html.BeginForm(FormMethod.Post, new { @id = "frmUserEmails", @class = "sax-form", @onSubmit = "return false;" })) { @Html.HiddenFor(model => model.UserAccountId, new { @class = "UserAccountId" })
@Localiser["user.emails.intro"]
+
@* User email *@
-
- +
+
+
+ +
+
+
+
+ +
+
+
-
- -
-
@* User display name *@
-
- +
+
+
+ +
+
+
+
+ +
+
+
-
- -
-
@* User emails *@
-
- -
-
-
-  @Localiser["user.email.account.activation.online"] +
+
+
+ +
-
-  @Localiser["user.email.request.password.online"] -
-
-  @Localiser["user.email.request.password.admin"] +
+
+
+  @Localiser["user.email.account.activation.online"] +
+
+  @Localiser["user.email.request.password.online"] +
+
+  @Localiser["user.email.request.password.admin"] +
+
+
-
} +
diff --git a/SaxoniteCoreWebAdmin/wwwroot/js/sax-organisation.js b/SaxoniteCoreWebAdmin/wwwroot/js/sax-organisation.js index d92b48e..8ea9c4e 100644 --- a/SaxoniteCoreWebAdmin/wwwroot/js/sax-organisation.js +++ b/SaxoniteCoreWebAdmin/wwwroot/js/sax-organisation.js @@ -5,37 +5,38 @@ (function (win, doc, undef) { "use strict"; + let op = sax.mdl.organisations = sax.mdl.organisations || { data: {}, ajax: {} }; + let $pnl = sax.$pnl, $frm = sax.$frm, $dlg = sax.$dlg; sax.itemIdPrefix = 'Itm_'; - var $results; //-------------------------------------------------------------- sax.refreshResults = function (delay) { - if (!sax.awaitingRefreshResponse) + if (!op.awaitingRefreshResponse) { - var $items = $('.sax-panel-item-list', $results).fadeOut(200).empty(); - var $msgs = $('.sax-panel-messages', $results).hide().empty().append($('
' + sax.msg.dataQuerying + '
')).fadeIn(200); + var $items = $('.sax-panel-item-list', $pnl.results).fadeOut(200).empty(); + var $msgs = $('.sax-panel-messages', $pnl.results).hide().empty().append($('
' + sax.msg.dataQuerying + '
')).fadeIn(200); } - sax.ajax.refreshResults = sax.ajax.refreshResults || { url: sax.url.base + 'Organisation/Ajax/GetList', formId: 'frmOrganisationFilter', callbackFn: sax.doRefreshResults }; - sax.doAjaxRequest(sax.ajax.refreshResults, delay || 50); - sax.awaitingRefreshResponse = true; + op.ajax.refreshResults = op.ajax.refreshResults || { url: sax.url.base + 'Organisation/Ajax/GetList', formId: 'frmOrganisationFilter', callbackFn: op.doRefreshResults }; + sax.doAjaxRequest(op.ajax.refreshResults, delay || 50); + op.awaitingRefreshResponse = true; } - sax.getItemTemplate = function () + op.getItemTemplate = function () { - return $('.sax-panel-item-template .sax-panel-item.Organisation', $results); + return $('.sax-panel-item-template .sax-panel-item.Organisation', $pnl.results); } - sax.getDropdownItemTemplate = function () + op.getDropdownItemTemplate = function () { - return $('.sax-panel-item-template .sax-dropdown-menu.Organisation li.sax-dropdown-item', $results); + return $('.sax-panel-item-template .sax-dropdown-menu.Organisation li.sax-dropdown-item', $pnl.results); } - sax.doRefreshResults = function (response) + op.doRefreshResults = function (response) { //sax.debug('doRefreshResults', response); - delete sax.awaitingRefreshResponse; + delete op.awaitingRefreshResponse; sax.refreshControlValues(response.controlValues); - var $msgs = $('.sax-panel-messages', $results).hide().empty(); - var $items = $('.sax-panel-item-list', $results).hide().empty(); - var $tmpl = sax.getItemTemplate(); + var $msgs = $('.sax-panel-messages', $pnl.results).hide().empty(); + var $items = $('.sax-panel-item-list', $pnl.results).hide().empty(); + var $tmpl = op.getItemTemplate(); sax.refreshPaging(response, '#frmOrganisationFilter', sax.refreshResults); if (!response.success) return; // Reference data - Statuses. @@ -50,12 +51,12 @@ { let item = items[itemIdx]; let $item = $tmpl.clone(); - sax.populateItem($item, item); + op.populateItem($item, item); $items.append($item); } $items.fadeIn(50); } - sax.populateItem = function ($item, item) + op.populateItem = function ($item, item) { if (!item) return; $item.prop('id', sax.itemIdPrefix + item.id); @@ -70,233 +71,210 @@ if (!item.deleted) { let $mnu = $('ul.sax-dropdown-menu', $item); - $mnu.append(sax.getDropdownItemTemplate().clone().find('div.sax-label').text(sax.lbl.edit).end().on('click', function () { sax.updateItem(item.id) })); + $mnu.append(op.getDropdownItemTemplate().clone().find('div.sax-label').text(sax.lbl.edit).end().on('click', function () { sax.updateItem(item.id) })); if (item.awaiting) - $mnu.append(sax.getDropdownItemTemplate().clone().find('div.sax-label').text(sax.lbl.activate).end().on('click', function () { sax.activateItem(item.id) })); + $mnu.append(op.getDropdownItemTemplate().clone().find('div.sax-label').text(sax.lbl.activate).end().on('click', function () { sax.activateItem(item.id) })); $('.sax-header .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-burger', $item).toggle(!!$('.sax-burger .sax-dropdown-menu .sax-dropdown-item', $item).length); - $('.sax-panel-messages', $results).hide().empty(); + $('.sax-panel-messages', $pnl.results).hide().empty(); return $item; } + //-------------------------------------------------------------- + op.selectFilterSport = function () + { + if (!op.data.sports) + op.populateSports(op.showSelectFilterSport); + else op.showSelectFilterSport(); + } + op.showSelectFilterSport = function () + { + sax.data.selectItem.fn.selectItem({ caption: sax.dlg.title.selectSport, items: op.data.sports, fnCallback: op.onFilterSportSelected }); + } + op.onFilterSportSelected = function (spt) + { + let frm = $frm.filter; + $('.FilterOrganisationSportId', frm).val(spt.id); + $('.FilterOrganisationSportCaption', frm).val(spt.name); + sax.refreshResults(); + } + op.clearFilterSport = function () + { + $('.FilterOrganisationSportId,.FilterOrganisationSportCaption', $frm.filter).val(''); + sax.refreshResults(); + } + op.populateSports = function (nextFn) + { + let handleResponse = function (response) + { + if (response && response.success && response.sports) + op.data.sports = response.sports; + if (nextFn) nextFn(); + } + op.ajax.sports = op.ajax.sports || { url: sax.url.base + 'Sport/Ajax/GetList', formId: 'frmNavigate', callbackFn: handleResponse }; + sax.doAjaxRequest(op.ajax.sports, 50); + } + //-------------------------------------------------------------- sax.selectSport = function () { - if (!sax.data.sports) - { - let handleSportsResponse = function (response) - { - if (response && response.success && response.sports) - sax.data.sports = response.sports; - sax.showSelectSport(); - } - sax.ajax.sports = sax.ajax.sports || { url: sax.url.base + 'Sport/Ajax/GetList', formId: 'frmNavigate', callbackFn: handleSportsResponse }; - sax.doAjaxRequest(sax.ajax.sports, 50); - } + if (!op.data.sports) + op.populateSports(sax.showSelectSport); else sax.showSelectSport(); } sax.showSelectSport = function () { - sax.data.selectItem.fn.selectItem({ caption: sax.dlg.title.selectSport, items: sax.data.sports, fnCallback: sax.onSportSelected }); + sax.data.selectItem.fn.selectItem({ caption: sax.dlg.title.selectSport, items: op.data.sports, fnCallback: sax.onSportSelected }); } sax.onSportSelected = function (spt) { - let $frm = sax.$frm.organisation; - $('.OrganisationSportId', $frm).val(spt.id); - $('.OrganisationSportCaption', $frm).val(spt.name); - sax.clearControlError($('.OrganisationSportCaption', $frm)); + let frm = $frm.org; + $('.OrganisationSportId', frm).val(spt.id); + $('.OrganisationSportCaption', frm).val(spt.name); + sax.clearControlError($('.OrganisationSportCaption', frm)); } //-------------------------------------------------------------- - sax.selectFilterSport = function () + op.selectFilterRegion = function () { - if (!sax.data.sports) + if (!op.data.regions) + op.populateRegions(op.showSelectFilterRegion); + else op.showSelectFilterRegion(); + } + op.showSelectFilterRegion = function () + { + sax.data.selectItem.fn.selectItem({ caption: sax.dlg.title.selectFilterRegion, items: op.data.regions, fnCallback: op.onFilterRegionSelected }); + } + op.onFilterRegionSelected = function (rgn) + { + //sax.debug('onFilterRegionSelected', rgn); + let frm = $frm.filter; + $('.FilterOrganisationRegionId', frm).val(rgn.id); + $('.FilterOrganisationRegionCaption', frm).val(rgn.name); + sax.refreshResults(); + } + op.clearFilterRegion = function () + { + $('.FilterOrganisationRegionId,.FilterOrganisationRegionCaption', $frm.filter).val(''); + sax.refreshResults(); + } + op.populateRegions = function (nextFn) + { + let handleResponse = function (response) { - let handleFilterSportsResponse = function (response) - { - if (response && response.success && response.sports) - sax.data.sports = response.sports; - sax.showSelectFilterSport(); - } - sax.ajax.filterSports = sax.ajax.filterSports || { url: sax.url.base + 'Sport/Ajax/GetList', formId: 'frmNavigate', callbackFn: handleFilterSportsResponse }; - sax.doAjaxRequest(sax.ajax.filterSports, 50); + if (response && response.success && response.regions) + op.data.regions = response.regions; + if (nextFn) nextFn(); } - else sax.showSelectFilterSport(); - } - sax.showSelectFilterSport = function () - { - sax.data.selectItem.fn.selectItem({ caption: sax.dlg.title.selectSport, items: sax.data.sports, fnCallback: sax.onFilterSportSelected }); - } - sax.onFilterSportSelected = function (spt) - { - //sax.debug('onFilterSportSelected', sax.$frm.filter) - let $frm = sax.$frm.filter; - $('.FilterOrganisationSportId', $frm).val(spt.id); - $('.FilterOrganisationSportCaption', $frm).val(spt.name); - sax.refreshResults(); - } - sax.clearFilterSport = function () - { - $('.FilterOrganisationSportId,.FilterOrganisationSportCaption', sax.$frm.filter).val(''); - sax.refreshResults(); + op.ajax.regions = op.ajax.regions || { url: sax.url.base + 'Region/Ajax/GetList', formId: 'frmNavigate', callbackFn: handleResponse }; + sax.doAjaxRequest(op.ajax.regions, 50); } //-------------------------------------------------------------- sax.selectRegion = function () { - if (!sax.data.regions) - { - let handleRegionsResponse = function (response) - { - if (response && response.success && response.regions) - sax.data.regions = response.regions; - sax.showSelectRegion(); - } - sax.ajax.regions = sax.ajax.regions || { url: sax.url.base + 'Region/Ajax/GetList', formId: 'frmNavigate', callbackFn: handleRegionsResponse }; - sax.doAjaxRequest(sax.ajax.regions, 50); - } + if (!op.data.regions) + op.populateRegions(sax.showSelectRegion); else sax.showSelectRegion(); } sax.showSelectRegion = function () { - sax.data.selectItem.fn.selectItem({ caption: sax.dlg.title.selectRegion, items: sax.data.regions, fnCallback: sax.onRegionSelected }); + sax.data.selectItem.fn.selectItem({ caption: sax.dlg.title.selectRegion, items: op.data.regions, fnCallback: sax.onRegionSelected }); } sax.onRegionSelected = function (rgn) { //sax.debug('onRegionSelected', rgn); - let $frm = sax.$frm.organisation; - $('.OrganisationRegionIdCountry', $frm).val(rgn.id); - $('.OrganisationRegionCaptionCountry', $frm).val(rgn.name); - sax.clearControlError($('.OrganisationRegionCaptionCountry', $frm)); - } - - //-------------------------------------------------------------- - sax.selectFilterRegion = function () - { - if (!sax.data.regions) - { - let handleFilterRegionsResponse = function (response) - { - if (response && response.success && response.regions) - sax.data.regions = response.regions; - sax.showSelectFilterRegion(); - } - sax.ajax.regions = sax.ajax.regions || { url: sax.url.base + 'Region/Ajax/GetList', formId: 'frmNavigate', callbackFn: handleFilterRegionsResponse }; - sax.doAjaxRequest(sax.ajax.regions, 50); - } - else sax.showSelectFilterRegion(); - } - sax.showSelectFilterRegion = function () - { - sax.data.selectItem.fn.selectItem({ caption: sax.dlg.title.selectFilterRegion, items: sax.data.regions, fnCallback: sax.onFilterRegionSelected }); - } - sax.onFilterRegionSelected = function (rgn) - { - //sax.debug('onFilterRegionSelected', rgn); - let $frm = sax.$frm.filter; - $('.FilterOrganisationRegionId', $frm).val(rgn.id); - $('.FilterOrganisationRegionCaption', $frm).val(rgn.name); - sax.refreshResults(); - } - sax.clearFilterRegion = function () - { - $('.FilterOrganisationRegionId,.FilterOrganisationRegionCaption', sax.$frm.filter).val(''); - sax.refreshResults(); + let frm = $frm.org; + $('.OrganisationRegionIdCountry', frm).val(rgn.id); + $('.OrganisationRegionCaptionCountry', frm).val(rgn.name); + sax.clearControlError($('.OrganisationRegionCaptionCountry', frm)); } //-------------------------------------------------------------- sax.createItem = function () { - let $frm = sax.$frm.organisation; - $('.OrganisationId,.OrganisationSportId,.OrganisationRegionIdCountry,input[type="text"],textarea,select', $frm).val(''); - $('.OrganisationStatus', $frm).val(sax.data.defaultStatusCode); + let frm = $frm.org; + $('.OrganisationId,.OrganisationSportId,.OrganisationRegionIdCountry,input[type="text"],textarea,select', frm).val(''); + $('.OrganisationStatus', frm).val(sax.data.defaultStatusCode); sax.clearControlErrors(); - sax.$dlg.organisation.dialog('option', 'title', sax.dlg.title.createOrganisation); - sax.openDialog(sax.$dlg.organisation, 600, 600); - } - sax.doCreateItem = function () - { - sax.storeItem(); + $dlg.organisation.dialog('option', 'title', sax.dlg.title.createOrganisation); + sax.openDialog($dlg.organisation, 600, 600); } //-------------------------------------------------------------- sax.updateItem = function (id) { - $('.OrganisationId', sax.$frm.organisationId).val(id); - sax.ajax.updateItem = sax.ajax.updateItem || { url: sax.url.base + 'Organisation/Ajax/GetItem', formId: 'frmOrganisationId', callbackFn: sax.onUpdateItem }; - sax.doAjaxRequest(sax.ajax.updateItem, 50); + $('.OrganisationId', $frm.orgId).val(id); + op.ajax.updateItem = op.ajax.updateItem || { url: sax.url.base + 'Organisation/Ajax/GetItem', formId: 'frmOrganisationId', callbackFn: sax.onUpdateItem }; + sax.doAjaxRequest(op.ajax.updateItem, 50); } sax.onUpdateItem = function (response) { //sax.debug('onUpdateItem', response); - let $frm = sax.$frm.organisation; - $('.OrganisationId,input[type="text"],textarea,select', $frm).val(''); + let frm = $frm.org; + $('.OrganisationId,input[type="text"],textarea,select', frm).val(''); if (!response.success) return; let item = response.organisation; - $('.OrganisationId', $frm).val(item.id); - $('.OrganisationName', $frm).val(item.name); - $('.OrganisationType', $frm).val(item.typeCode); - $('.OrganisationCategory', $frm).val(item.categoryCode); - $('.OrganisationSportId', $frm).val(item.sportId); - $('.OrganisationSportCaption', $frm).val(item.sportName); - $('.OrganisationRegionIdCountry', $frm).val(item.regionIdCountry); - $('.OrganisationRegionCaptionCountry', $frm).val(item.regionNameCountry); - $('.OrganisationStatus', $frm).val(item.statusCode); + $('.OrganisationId', frm).val(item.id); + $('.OrganisationName', frm).val(item.name); + $('.OrganisationType', frm).val(item.typeCode); + $('.OrganisationCategory', frm).val(item.categoryCode); + $('.OrganisationSportId', frm).val(item.sportId); + $('.OrganisationSportCaption', frm).val(item.sportName); + $('.OrganisationRegionIdCountry', frm).val(item.regionIdCountry); + $('.OrganisationRegionCaptionCountry', frm).val(item.regionNameCountry); + $('.OrganisationStatus', frm).val(item.statusCode); sax.clearControlErrors(); - sax.$dlg.organisation.dialog('option', 'title', sax.dlg.title.updateOrganisation); - sax.openDialog(sax.$dlg.organisation, 600, 600); - } - sax.doUpdateItem = function () - { - sax.storeItem(); + $dlg.organisation.dialog('option', 'title', sax.dlg.title.updateOrganisation); + sax.openDialog($dlg.organisation, 600, 600); } //-------------------------------------------------------------- sax.storeItem = function () { - sax.ajax.storeItem = sax.ajax.storeItem || { url: sax.url.base + 'Organisation/Ajax/StoreItem', formId: 'frmOrganisation', callbackFn: sax.onStoreItem }; - sax.doAjaxRequest(sax.ajax.storeItem, 50); + op.ajax.storeItem = op.ajax.storeItem || { url: sax.url.base + 'Organisation/Ajax/StoreItem', formId: 'frmOrganisation', callbackFn: sax.onStoreItem }; + sax.doAjaxRequest(op.ajax.storeItem, 50); } sax.onStoreItem = function (response) { //sax.debug('onStoreItem', response); sax.refreshControlValues(response.controlValues); if (!response.success) return; - sax.$dlg.organisation.dialog('close'); + $dlg.organisation.dialog('close'); sax.refreshItem(response.organisation); } - sax.refreshItem=function(item) + sax.refreshItem = function (item) { var $item = $('#' + sax.itemIdPrefix + item.id); if (!$item.length) { - $item = $('.sax-panel-item-template .sax-panel-item.Organisation', $results).clone(); - $('.sax-panel-item-list', $results).prepend($item).show(); + $item = $('.sax-panel-item-template .sax-panel-item.Organisation', $pnl.results).clone(); + $('.sax-panel-item-list', $pnl.results).prepend($item).show(); } - $item.replaceWith(sax.populateItem(sax.getItemTemplate(), item)); + $item.replaceWith(op.populateItem(op.getItemTemplate(), item)); } //-------------------------------------------------------------- sax.activateItem = function (id) { //sax.debug('activateItem(' + id + ')') - $('.OrganisationId', sax.$frm.organisationId).val(id); - sax.ajax.getActivationInfo = sax.ajax.getActivationInfo || { url: sax.url.base + 'Organisation/Ajax/GetActivationInfo', formId: 'frmOrganisationId', callbackFn: sax.showActivationInfo }; - sax.doAjaxRequest(sax.ajax.getActivationInfo, 50); + $('.OrganisationId', $frm.orgId).val(id); + op.ajax.getActivationInfo = op.ajax.getActivationInfo || { url: sax.url.base + 'Organisation/Ajax/GetActivationInfo', formId: 'frmOrganisationId', callbackFn: sax.showActivationInfo }; + sax.doAjaxRequest(op.ajax.getActivationInfo, 50); } sax.showActivationInfo = function (response) { sax.debug('showActivationInfo', response); if (!response.success || !response.organisation) return; let item = response.organisation; - let $dlg = sax.$dlg.activate; - let $frm = $('#frmOrganisationActivation'); - $('.OrganisationId', $frm).val($('.OrganisationId', sax.$frm.organisationId).val()); + let $dlg = $dlg.activate; + let frm = $('#frmOrganisationActivation'); + $('.OrganisationId', frm).val($('.OrganisationId', $frm.orgId).val()); let popItemValue = function (sel, val) { - $(sel, $frm).toggle(!!val).find('.sax-value').text(val); + $(sel, frm).toggle(!!val).find('.sax-value').text(val); } popItemValue('.OrganisationName', item.name); popItemValue('.OrganisationSport', item.sportName); @@ -311,7 +289,7 @@ let item = response.members[idx]; let $item = $mbrTmpl.clone(); $('.MemberId', $item).val(item.id); - $('.MemberActivate', $item).prop('name','MemberActivate_' + item.id) + $('.MemberActivate', $item).prop('name', 'MemberActivate_' + item.id) $('.MemberEmail', $item).text(item.emailAddress); $('.MemberName', $item).text(item.displayName); $orgMbrs.append($item); @@ -321,15 +299,15 @@ } sax.activateOrganisation = function () { - let $frm = $('#frmOrganisationActivation'); - sax.ajax.activateOrganisation = sax.ajax.activateOrganisation || { url: sax.url.base + 'Organisation/Ajax/Activate', formId: $frm.prop('id'), callbackFn: sax.handleAtivateResponse }; - sax.doAjaxRequest(sax.ajax.activateOrganisation, 50); + let frm = $('#frmOrganisationActivation'); + op.ajax.activateOrganisation = op.ajax.activateOrganisation || { url: sax.url.base + 'Organisation/Ajax/Activate', formId: frm.prop('id'), callbackFn: sax.handleAtivateResponse }; + sax.doAjaxRequest(op.ajax.activateOrganisation, 50); } sax.handleAtivateResponse = function (response) { sax.debug('handleAtivateResponse', response); if (!response.success) return; - sax.$dlg.activate.dialog('close'); + $dlg.activate.dialog('close'); sax.refreshItem(response.organisation); } @@ -338,35 +316,40 @@ { if (!(id * 1)) return; sax.doPleaseWait(); - let $frm = $('#frmOrganisationId'); - $('.OrganisationId', $frm).val(id); - $frm.prop('action', sax.url.base + 'Organisation/Members').submit(); + let frm = $('#frmOrganisationId'); + $('.OrganisationId', frm).val(id); + frm.prop('action', sax.url.base + 'Organisation/Members').submit(); } //-------------------------------------------------------------- $(function () { - $('.sax-panel-filter .sax-action.sax-item-create').on('click', function () { sax.createItem(); }); - $('.sax-panel-filter .sax-action.sax-results-refresh').on('click', function () { sax.refreshResults(); }); - $('.sax-input, .sax-textarea').on('input', function () { sax.clearControlError(this); }); - $('.sax-select').on('change', function () { sax.clearControlError(this); }); + $pnl.orgs = $('.sax-panel.Organisations'); + $pnl.filter = $('.sax-panel-filter', $pnl.orgs); + $pnl.results = $('.sax-panel-results', $pnl.orgs); - sax.$frm.filter = $('#frmOrganisationFilter'); - $('.FilterOrganisation', sax.$frm.filter).on('input', function () { sax.refreshResults(250); }); - $('.FilterOrganisationCategory,.FilterOrganisationStatusCategory', sax.$frm.filter).on('change', function () { sax.refreshResults(50); }); - sax.$frm.organisationId = $('#frmOrganisationId'); - sax.$frm.organisation = $('#frmOrganisation'); - $results = $('.sax-panel-results'); + $('.sax-action.sax-item-create', $pnl.filter).on('click', function () { sax.createItem(); }); + $('.sax-action.sax-results-refresh', $pnl.filter).on('click', function () { sax.refreshResults(); }); + + $frm.filter = $('#frmOrganisationFilter'); + $('.FilterOrganisation', $frm.filter).on('input', function () { sax.refreshResults(250); }); + $('.FilterOrganisationCategory,.FilterOrganisationStatusCategory', $frm.filter).on('change', function () { sax.refreshResults(50); }); + $frm.filter.on('dblclick', '.FilterOrganisationSportCaption', op.selectFilterSport).on('click', '.FilterSportSelect', op.selectFilterSport).on('click', '.FilterSportClear', op.clearFilterSport); + $frm.filter.on('dblclick', '.FilterOrganisationRegionCaption', op.selectFilterRegion).on('click', '.FilterRegionSelect', op.selectFilterRegion).on('click', '.FilterRegionClear', op.clearFilterRegion); + $frm.orgId = $('#frmOrganisationId'); + $frm.org = $('#frmOrganisation'); + $('.sax-input, .sax-textarea', $frm.org).on('input', function () { sax.clearControlError(this); }); + $('.sax-select', $frm.org).on('change', 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'); }; - sax.$dlg.organisation = $('#dlgOrganisation').dialog(opt); + $dlg.organisation = $('#dlgOrganisation').dialog(opt); var opt = sax.dlgOpts(); opt.buttons[sax.dlg.btn.ok] = function () { sax.activateOrganisation(); }; opt.buttons[sax.dlg.btn.cancel] = function () { $(this).dialog('close'); }; - sax.$dlg.activate = $('#dlgOrganisationActivation').dialog(opt); + $dlg.activate = $('#dlgOrganisationActivation').dialog(opt); setTimeout(sax.refreshResults, 250); }); diff --git a/SaxoniteCoreWebAdmin/wwwroot/js/sax-user.js b/SaxoniteCoreWebAdmin/wwwroot/js/sax-user.js index ade268e..3514548 100644 --- a/SaxoniteCoreWebAdmin/wwwroot/js/sax-user.js +++ b/SaxoniteCoreWebAdmin/wwwroot/js/sax-user.js @@ -103,6 +103,74 @@ return $opt.find('div.sax-label').text(lbl).end().on('click', fn); } + //-------------------------------------------------------------- + sax.selectFilterSport = function () + { + if (!sax.data.sports) + { + let handleFilterSportsResponse = function (response) + { + if (response && response.success && response.sports) + sax.data.sports = response.sports; + sax.showSelectFilterSport(); + } + sax.ajax.filterSports = sax.ajax.filterSports || { url: sax.url.base + 'Sport/Ajax/GetList', formId: 'frmNavigate', callbackFn: handleFilterSportsResponse }; + sax.doAjaxRequest(sax.ajax.filterSports, 50); + } + else sax.showSelectFilterSport(); + } + sax.showSelectFilterSport = function () + { + sax.data.selectItem.fn.selectItem({ caption: sax.dlg.title.selectSport, items: sax.data.sports, fnCallback: sax.onFilterSportSelected }); + } + sax.onFilterSportSelected = function (spt) + { + //sax.debug('onFilterSportSelected', sax.$frm.filter) + let $frm = sax.$frm.filter; + $('.FilterUserSportId', $frm).val(spt.id); + $('.FilterUserSportCaption', $frm).val(spt.name); + sax.refreshResults(); + } + sax.clearFilterSport = function () + { + $('.FilterUserSportId,.FilterUserSportCaption', sax.$frm.filter).val(''); + sax.refreshResults(); + } + + //-------------------------------------------------------------- + sax.selectFilterRegion = function () + { + if (!sax.data.regions) + { + let handleFilterRegionsResponse = function (response) + { + if (response && response.success && response.regions) + sax.data.regions = response.regions; + sax.showSelectFilterRegion(); + } + sax.ajax.regions = sax.ajax.regions || { url: sax.url.base + 'Region/Ajax/GetList', formId: 'frmNavigate', callbackFn: handleFilterRegionsResponse }; + sax.doAjaxRequest(sax.ajax.regions, 50); + } + else sax.showSelectFilterRegion(); + } + sax.showSelectFilterRegion = function () + { + sax.data.selectItem.fn.selectItem({ caption: sax.dlg.title.selectFilterRegion, items: sax.data.regions, fnCallback: sax.onFilterRegionSelected }); + } + sax.onFilterRegionSelected = function (rgn) + { + //sax.debug('onFilterRegionSelected', rgn); + let $frm = sax.$frm.filter; + $('.FilterUserRegionId', $frm).val(rgn.id); + $('.FilterUserRegionCaption', $frm).val(rgn.name); + sax.refreshResults(); + } + sax.clearFilterRegion = function () + { + $('.FilterUserRegionId,.FilterUserRegionCaption', sax.$frm.filter).val(''); + sax.refreshResults(); + } + //-------------------------------------------------------------- // User Roles. sax.selectUserRoles = function () @@ -228,6 +296,7 @@ $frm.filter = $('#frmUserFilter'); $('.FilterUser', $frm.filter).on('input', function () { sax.refreshResults(250); }); + $('.FilterUserStatusCategory', $frm.filter).on('change', function () { sax.refreshResults(50); }); $frm.userId = $('#frmUserId'); $frm.user = $('#frmUser'); $('.sax-input, .sax-textarea', $frm.user).on('input', function () { sax.clearControlError(this); }); diff --git a/SaxoniteCoreWebOnline/Localisation/SaxOnlineProperties.resx b/SaxoniteCoreWebOnline/Localisation/SaxOnlineProperties.resx index 3cc1f19..28c5598 100644 --- a/SaxoniteCoreWebOnline/Localisation/SaxOnlineProperties.resx +++ b/SaxoniteCoreWebOnline/Localisation/SaxOnlineProperties.resx @@ -519,6 +519,12 @@ Upload + + User + + + Users + Very Good diff --git a/SaxoniteCoreWebOnline/Online/Controllers/SearchController-Ajax-Organisations.cs b/SaxoniteCoreWebOnline/Online/Controllers/SearchController-Ajax-Organisations.cs index 39936fe..609326f 100644 --- a/SaxoniteCoreWebOnline/Online/Controllers/SearchController-Ajax-Organisations.cs +++ b/SaxoniteCoreWebOnline/Online/Controllers/SearchController-Ajax-Organisations.cs @@ -59,6 +59,10 @@ namespace Saxonite.Net.Core.Web.Online.Controllers if (!ValidUserSession) return GetAjaxResult_InvalidSession(responseData); RefreshModel(model); + // Ensure data is paged to avoid leaking large volumes. + model.Paging.PageNo = Math.Max(1, model.Paging.PageNo); + model.Paging.PageLength = Math.Max(Math.Min(Sax.Config.Online.Search.Organisations.PageLengthMax, model.Paging.PageLength), (ushort)1); + // Query organisations that user is a member of. SaxOrganisation.Params prmOrganisation = new SaxOrganisation.Params(); prmOrganisation.OrganisationFilter = model.Filter.Organisation; diff --git a/SaxoniteCoreWebOnline/Online/Controllers/SearchController-Ajax-Users.cs b/SaxoniteCoreWebOnline/Online/Controllers/SearchController-Ajax-Users.cs new file mode 100644 index 0000000..3d84a4b --- /dev/null +++ b/SaxoniteCoreWebOnline/Online/Controllers/SearchController-Ajax-Users.cs @@ -0,0 +1,193 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using Saxonite.Net.Core.Web.Online.Models; +using Saxonite.Net.Core.Web.Base.App; +using Saxonite.Net.Core.Web.Base.Controllers; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Threading.Tasks; +using Saxonite.Net.Standard.Base.Bus; +using Sarand.Net.Standard.Base.App; +using Sarand.Net.Standard.Base.Bus; +using Sarand.Net.Standard.Base.Utils; +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 +{ + //======================================================================= + // Online Search Controller - Users - Ajax actions. + //======================================================================= + partial class SearchController + { + //------------------------------------------------------------------- + // Account - Get Users. + //------------------------------------------------------------------- + private class UserListData + { + public String Id { get; set; } + public String Name { get; set; } + public String Location { get; set; } + } + private class AjaxResponse_Search_Users : AjaxResponse_Data + { + // Construction. + public AjaxResponse_Search_Users(SaxModel_Online model) : base(model) { } + // User list. + public List Users { get; } = new List(); + } + // Ajax request. + [HttpPost] + [Route("Search/Ajax/Users")] + [Route("Search/Ajax/GetUsers")] + public IActionResult GetProfileUsers(Model_Search_Users model) + { + String fn = GetType().Name + ".GetProfileUsers"; + AjaxResponse_Search_Users responseData = new AjaxResponse_Search_Users(model); + String messageTitle = Localiser["label.users"]; + + // Validate session and referrer. + if (!ValidReferer) return Forbid(); + if (!ValidUserSession) return GetAjaxResult_InvalidSession(responseData); + RefreshModel(model); + + // Ensure filter has something to restrict the list. + // ToDo May be able to show some results, such as friends when no filter provided. + if (StringUtil.IsEmpty(StringUtil.TrimAll(model.Filter.User))) + { + responseData.Success = true; + return Json(responseData); + } + + // Ensure data is paged to avoid leaking large volumes. + model.Paging.PageNo = Math.Max(1, model.Paging.PageNo); + model.Paging.PageLength = Math.Max(Math.Min(Sax.Config.Online.Search.Users.PageLengthMax, model.Paging.PageLength), (ushort)1); + + // Query users that user is a member of. + SaxUserAccount.Params prmUserAccount = new SaxUserAccount.Params(); + prmUserAccount.UserFilter = model.Filter.User; + if (SysId.IsValid(model.FilterSportId)) + prmUserAccount.SportIdsIncluded.Add(model.FilterSportId); + if (SysId.IsValid(model.FilterRegionId)) + prmUserAccount.RegionIdsIncluded.Add(model.FilterRegionId); + prmUserAccount.StatusCat = SaxUserAccount.StatusCat.ActiveOnly; + model.Paging.ItemTotal = (ulong)AccountMgr.GetUserAccountCount(prmUserAccount); + model.PopulatePagingTo(prmUserAccount.ResultsPaging); + + List users = AccountMgr.GetUserAccountList(prmUserAccount); + List userIds = users.GetIds(); + + // Item columns. + ColumnDfn colId = AccountMgr.GetUserAccountColumnDfn(SaxUserAccount.Column.Id); + ColumnDfn colTitle = AccountMgr.GetUserAccountColumnDfn(SaxUserAccount.Column.Title); + ColumnDfn colFirstName = AccountMgr.GetUserAccountColumnDfn(SaxUserAccount.Column.FirstName); + ColumnDfn colLastName = AccountMgr.GetUserAccountColumnDfn(SaxUserAccount.Column.LastName); + ColumnDfn colRegionCountryName = AccountMgr.GetUserAccountColumnDfn(SaxUserAccount.Column.RegionCountry_Name); + ColumnDfn colRegionProvinceName = AccountMgr.GetUserAccountColumnDfn(SaxUserAccount.Column.RegionProvince_Name); + List columns = new List() + { + colId, colTitle, colFirstName, colLastName, + colRegionCountryName,colRegionProvinceName, + }; + + // Sort columns. + colLastName.SortAscending = true; + prmUserAccount.SortColumns.Add(colLastName); + + // Query items. + using (DbResultSet resultSet = AccountMgr.ExecuteUserAccountQuery(columns, prmUserAccount)) + { + while (resultSet != null && resultSet.HasRows && resultSet.NextRecord()) + { + NamedValue.Map values = resultSet.GetRecordValues(); + String displayName = SaxUserAccount.GetDisplayName(values.GetString(colTitle.DataName), values.GetString(colFirstName.DataName), values.GetString(colLastName.DataName)); + List location = new List() { values.GetString(colRegionProvinceName.DataName), values.GetString(colRegionCountryName.DataName) }; + UserListData userData = new UserListData() + { + Id = model.EncryptId(new SysId(values.GetLong(colId.DataName))), + Name = displayName, + Location = location.Concat(", ", "", "", true, true), + }; + responseData.Users.Add(userData); + } + } + if (model.Paging.IsPaged) + model.Paging.ItemCount = (ushort)responseData.Users.Count; + + // Complete response. + responseData.SetPaging(model); + responseData.Success = true; + return Json(responseData); + } + //------------------------------------------------------------------- + // Account - Get Users. + //------------------------------------------------------------------- + private class UserData + { + public String Id { get; set; } + public String Name { get; set; } + public String Location { get; set; } + } + private class AjaxResponse_Search_User : AjaxResponse_Data + { + // Construction. + public AjaxResponse_Search_User(SaxModel_Online model) : base(model) { } + // User list. + public UserData User { get; set; } + } + // Ajax request. + [HttpPost] + [Route("Search/Ajax/User")] + [Route("Search/Ajax/GetUser")] + public IActionResult GetProfileUser(Model_Search_Users model) + { + String fn = GetType().Name + ".GetProfileUser"; + AjaxResponse_Search_User responseData = new AjaxResponse_Search_User(model); + String messageTitle = Localiser["label.user"]; + + // Validate session and referrer. + if (!ValidReferer) return Forbid(); + if (!ValidUserSession) return GetAjaxResult_InvalidSession(responseData); + RefreshModel(model); + + // Record disposable items as they are created so all can be disposed when needed. + using (DisposableCollection disposableItems = new DisposableCollection()) + { + // Retrieve user. + SysId userAccountId = model.ExtractSysId(model.UserId); + if (!SysId.IsValid(userAccountId)) + { + SaLogger.Warn(fn + " User Id not supplied."); + return Json(responseData); + } + SaxUserAccount userAccount = AccountMgr.GetUserAccountById(userAccountId); + if (userAccount == null) + { + SaLogger.Warn(fn + " Failed to retrieve user. Id: " + model.UserId); + return Json(responseData); + } + disposableItems.Add(userAccount); + + // Populate response. + List location = new List() { model.GetRegionCaption(userAccount.RegionIdProvince), model.GetRegionCaption(userAccount.RegionIdCountry) }; + UserData userData = new UserData() + { + Id = model.EncryptId(userAccount.Id), + Name = userAccount.GetDisplayName(), + Location = location.Concat(", ", "", "", true, true), + }; + responseData.User = userData; + } + + // Complete response. + responseData.Success = true; + return Json(responseData); + } + + //------------------------------------------------------------------- + } + //======================================================================= +} diff --git a/SaxoniteCoreWebOnline/Online/Controllers/SearchController.cs b/SaxoniteCoreWebOnline/Online/Controllers/SearchController.cs index 282ef94..01c4cf8 100644 --- a/SaxoniteCoreWebOnline/Online/Controllers/SearchController.cs +++ b/SaxoniteCoreWebOnline/Online/Controllers/SearchController.cs @@ -6,6 +6,7 @@ using Sarand.Net.Standard.Base.Dbas; using Sarand.Net.Standard.Base.Utils; using Saxonite.Net.Core.Web.Base.App; using Saxonite.Net.Core.Web.Online.Models; +using Saxonite.Net.Standard.Base.App; using Saxonite.Net.Standard.Base.Bus; using System; using System.Collections.Generic; @@ -38,6 +39,25 @@ namespace Saxonite.Net.Core.Web.Online.Controllers return RedirectToAction("", ""); } + //------------------------------------------------------------------- + /// + /// Search - Users. + /// + [HttpGet] + public IActionResult Users() + { + // Validate session. + if (!ValidUserSession) + return RedirectToAction("", ""); + + // Model. + Model_Search_Users model = new Model_Search_Users(Localiser); + model.Paging.PageNo = 1; + model.Paging.PageLength = Sax.Config.Online.Search.Organisations.PageLengthDefault; + + return View(model); + } + //------------------------------------------------------------------- /// /// Search - Organisations. @@ -52,7 +72,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers // Model. Model_Search_Organisations model = new Model_Search_Organisations(Localiser); model.Paging.PageNo = 1; - model.Paging.PageLength = 12; + model.Paging.PageLength = Sax.Config.Online.Search.Users.PageLengthDefault; return View(model); } diff --git a/SaxoniteCoreWebOnline/Online/Models/Model_Search_Users.cs b/SaxoniteCoreWebOnline/Online/Models/Model_Search_Users.cs new file mode 100644 index 0000000..3610389 --- /dev/null +++ b/SaxoniteCoreWebOnline/Online/Models/Model_Search_Users.cs @@ -0,0 +1,53 @@ +using Sarand.Net.Standard.Base.Bus; +using Sarand.Net.Standard.Base.Core; +using Sarand.Net.Standard.Base.Helpers; +using Sarand.Net.Standard.Base.Utils; +using Saxonite.Net.Core.Web.Base.App; +using Saxonite.Net.Core.Web.Base.Controllers; +using Saxonite.Net.Core.Web.Base.Models; +using Saxonite.Net.Standard.Base.App; +using Saxonite.Net.Standard.Base.Bus; +using Saxonite.Net.Standard.Base.Helpers; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Saxonite.Net.Core.Web.Online.Models +{ + //======================================================================= + public class Model_Search_Users : SaxModel_Online + { + //------------------------------------------------------------------- + // Construction. + public Model_Search_Users(SaxLocaliser localiser) : + base(localiser) + { + //AdditionalFiles_CSS.Add("css/sax-src-usr.css"); + AdditionalFiles_JS.Add("js/sax-src-usr.js"); + } + + //------------------------------------------------------------------- + // Page configuration. + + //------------------------------------------------------------------- + // Form properties. + public class FilterData + { + public String User { get; set; } + public String RegionId { get; set; } + public String SportId { get; set; } + } + public FilterData Filter { get; } = new FilterData(); + public SysId FilterSportId { get { return ExtractSysId(Filter.SportId); } } + public SysId FilterRegionId { get { return ExtractSysId(Filter.RegionId); } } + public String UserId { get; set; } + + //------------------------------------------------------------------- + // Validation. + //------------------------------------------------------------------- + + //------------------------------------------------------------------- + } + //======================================================================= +} diff --git a/SaxoniteCoreWebOnline/Views/Search/Panel-UserDialog.cshtml b/SaxoniteCoreWebOnline/Views/Search/Panel-UserDialog.cshtml new file mode 100644 index 0000000..0e6f491 --- /dev/null +++ b/SaxoniteCoreWebOnline/Views/Search/Panel-UserDialog.cshtml @@ -0,0 +1,25 @@ +@model Model_Search_Users +@inject SaxLocaliser Localiser +@{ + /* User dialog panel */ +} + + + +@using (@Html.BeginForm(FormMethod.Post, new { @id = "frmUserId", @class = "sax-form" })) +{ + +} +
+ +
+ +
+
@Localiser["label.location"]
+
+
+ +
+ +
diff --git a/SaxoniteCoreWebOnline/Views/Search/Users.cshtml b/SaxoniteCoreWebOnline/Views/Search/Users.cshtml new file mode 100644 index 0000000..1ed7500 --- /dev/null +++ b/SaxoniteCoreWebOnline/Views/Search/Users.cshtml @@ -0,0 +1,154 @@ +@model Model_Search_Users +@inject SaxLocaliser Localiser +@{ + ViewData["Title"] = "Search Users"; +} + +
+ + + +
+ +
+ + @* Filter Form *@ + @using (@Html.BeginForm(FormMethod.Post, new { @id = "frmUserFilter", @class = "sax-form", @action = "#", @method = "POST", onsubmit = "return false;" })) + { + + @* Filter panel *@ +
+ @* Filter header *@ +
+ @* Filter caption *@ +
@Localiser["label.users"]
+
+
+ +
+
+ @* Burger menu *@ + +
+
+
+
+ + @* Generic User filter - name etc. *@ +
+
@Localiser["label.search"]
+
+
+
+
+ + @* User sport *@ +
+
@Localiser["label.sport"]
+
+
+ @Html.HiddenFor(model => model.Filter.SportId, new { @id = "", @class = "FilterSportId" }) +
+
+
@(Localiser[
+
@(Localiser[
+
+
+
+
+ + @* User region *@ +
+
@Localiser["label.region"]
+
+
+ @Html.HiddenFor(model => model.Filter.RegionId, new { @id = "", @class = "FilterRegionId" }) +
+
+
@(Localiser[
+
@(Localiser[
+
+
+
+
+ +
+ + @* Filter item templates *@ +
+ @* Burger dropdown item template - ul is ignored *@ +
    +
  • ...
  • +
+
+ +
+ + } + +
+ +
+ + @* Results Panel *@ +
+
+
+ + @* Element templates *@ +
+ + @* Item template *@ +
+
+
+ @* User caption *@ +
+
+
+
+
+
+ @* Burger menu *@ + +
+
+
+
+
+
+
+
+
+ + @* Burger dropdown item template - ul is ignored *@ +
    +
  • ...
  • +
+ +
+
+ +
+ +
+ +
+ + + + diff --git a/SaxoniteCoreWebOnline/Views/Shared/_Layout.cshtml b/SaxoniteCoreWebOnline/Views/Shared/_Layout.cshtml index 57cf11f..adfb91a 100644 --- a/SaxoniteCoreWebOnline/Views/Shared/_Layout.cshtml +++ b/SaxoniteCoreWebOnline/Views/Shared/_Layout.cshtml @@ -149,6 +149,7 @@ @Localiser["label.search"] diff --git a/SaxoniteCoreWebOnline/wwwroot/js/sax-resultsPaging.js b/SaxoniteCoreWebOnline/wwwroot/js/sax-resultsPaging.js index ab46dad..365cda9 100644 --- a/SaxoniteCoreWebOnline/wwwroot/js/sax-resultsPaging.js +++ b/SaxoniteCoreWebOnline/wwwroot/js/sax-resultsPaging.js @@ -13,7 +13,7 @@ let context = rp.fn.getContext(contextSel, refreshFn); rp.fn.init(context); context.paging = paging = paging || {}; - context.$rp.toggle(paging.paged); + context.$rp.toggle(!!paging.paged); context.$pageNo.val(paging.pageNo); context.$pageLen.val(paging.pageLength); $('.sax-paging-info', context.$rp).text(sax.mdl.resultsPaging.msg.pageInfo.format(paging.pageNo, paging.pageCount)); diff --git a/SaxoniteCoreWebOnline/wwwroot/js/sax-src-org.js b/SaxoniteCoreWebOnline/wwwroot/js/sax-src-org.js index 1b7daf7..0be8af6 100644 --- a/SaxoniteCoreWebOnline/wwwroot/js/sax-src-org.js +++ b/SaxoniteCoreWebOnline/wwwroot/js/sax-src-org.js @@ -24,7 +24,6 @@ } so.doRefreshResults = function (response) { - //sax.debug('doRefreshResults', response); delete sax.awaitingRefreshResponse; sax.refreshControlValues(response.controlValues); var $msgs = $('.sax-panel-messages', $pnl.results).hide().empty(); @@ -135,7 +134,6 @@ } so.onViewItem = function (response) { - sax.debug('onViewItem', response); if (!response.success) return; let dlg = $dlg.org; let item = so.data.organisation = response.organisation; diff --git a/SaxoniteCoreWebOnline/wwwroot/js/sax-src-usr.js b/SaxoniteCoreWebOnline/wwwroot/js/sax-src-usr.js new file mode 100644 index 0000000..4862037 --- /dev/null +++ b/SaxoniteCoreWebOnline/wwwroot/js/sax-src-usr.js @@ -0,0 +1,169 @@ +/* + * Search - Users. + */ + +(function (win, doc, undef) +{ + "use strict"; + let su = sax.searchUsers = {}; + su.ajax = {}; su.data = {}; su.fn = {}; + let $pnl = su.$pnl = {}, $frm = su.$frm = {}, $dlg = su.$dlg = {}; + + //-------------------------------------------------------------- + su.refreshResults = function (delay) + { + if (!su.awaitingRefreshResponse) + { + $('.sax-burger', $pnl.filter).hide(); + $('.sax-panel-item-list', $pnl.results).fadeOut(200).empty(); + $('.sax-panel-messages', $pnl.results).hide().empty().append($('
' + sax.msg.dataQuerying + '
')).fadeIn(200); + } + su.ajax.refreshResults = su.ajax.refreshResults || { url: sax.url.base + 'Search/Ajax/Users', formId: 'frmUserFilter', callbackFn: su.doRefreshResults }; + sax.doAjaxRequest(su.ajax.refreshResults, delay || 50); + su.awaitingRefreshResponse = true; + } + su.doRefreshResults = function (response) + { + delete sax.awaitingRefreshResponse; + sax.refreshControlValues(response.controlValues); + var $msgs = $('.sax-panel-messages', $pnl.results).hide().empty(); + var $items = $('.sax-panel-item-list', $pnl.results).hide().empty(); + if (!response.success) return; + sax.refreshPaging(response, '#frmUserFilter', su.refreshResults); + // Menu. + let $bgr = $('.sax-burger', $pnl.filter); + let $mnu = $('ul.sax-dropdown-menu', $bgr).empty(); + $mnu.append(su.getFilterMenuOption(sax.lbl.refresh, function () { su.refreshResults(); }, 'sax-refresh')); + $bgr.toggle(!!$('.sax-dropdown-item', $mnu).length); + // Items. + var items = response.users; + if (!items.length) + return $msgs.append($('
' + sax.msg.dataNoneFound + '
')).fadeIn(500); + for (let itemIdx = 0; itemIdx < items.length; itemIdx++) + $items.append(su.populateItem(su.getItemTemplate(), items[itemIdx])); + $items.fadeIn(50); + } + su.populateItem = function ($item, item) + { + if (!item) return; + $('.sax-panel-messages', $pnl.results).hide().empty(); + $('.UserName', $item).text(item.name); + $('.UserLocation', $item).text(item.location); + let $bgr = $('.sax-burger', $item); + let $mnu = $('ul.sax-dropdown-menu', $bgr).empty(); + { + let fnView = function () { su.viewItem(item) }; + // ToDo $mnu.append(su.getItemMenuOption(sax.lbl.view, fnView, 'sax-view')); + $('.sax-caption .sax-action', $item).off('click').on('click', fnView); + $('.sax-content', $item).off('dblclick').on('dblclick', fnView); + } + $bgr.toggle(!!$('.sax-dropdown-menu .sax-dropdown-item', $item).length); + return $item; + } + + //-------------------------------------------------------------- + su.getFilterDropdownTemplate = function () + { + return $('.sax-panel-item-template .sax-dropdown-menu.Users li.sax-dropdown-item', $pnl.filter).clone(); + } + su.getFilterMenuOption = function (lbl, fn, cls) + { + return su.getMenuOption(su.getFilterDropdownTemplate(), lbl, fn, cls); + } + su.getItemTemplate = function () + { + return $('.sax-panel-item-template .sax-panel-item.User', $pnl.results).clone(); + } + su.getItemDropdownTemplate = function () + { + return $('.sax-panel-item-template .sax-dropdown-menu.User li.sax-dropdown-item', $pnl.results).clone(); + } + su.getItemMenuOption = function (lbl, fn, cls) + { + return su.getMenuOption(su.getItemDropdownTemplate(), lbl, fn, cls); + } + su.getMenuOption = function ($opt, lbl, fn, cls) + { + return $opt.find('div.sax-label').text(lbl).end().on('click', fn).addClass(cls); + } + + //-------------------------------------------------------------- + su.selectFilterSport = function () + { + let excludeIds = []; + sax.mdl.selectSport.fn.selectSport({ caption: sax.dlg.title.selectSport, sportId: $('.FilterSportId', $frm.filter).val(), excludeIds: excludeIds, fnCallback: su.onFilterSportSelected }) + } + su.onFilterSportSelected = function (spt) + { + $('.FilterSportId', $frm.filter).val(spt ? spt.id : ''); + $('.FilterSportCaption', $frm.filter).val(spt ? spt.name : ''); + su.refreshResults(); + } + su.clearFilterSport = function () + { + $('.FilterSportId,.FilterSportCaption', $frm.filter).val(''); + su.refreshResults(); + } + + //-------------------------------------------------------------- + su.selectFilterRegion = function () + { + let excludeIds = []; + sax.mdl.selectRegion.fn.selectRegion({ caption: sax.dlg.title.selectRegion, regionId: $('.FilterRegionId', $frm.filter).val(), excludeIds: excludeIds, fnCallback: su.onFilterRegionSelected }) + } + su.onFilterRegionSelected = function (rgn) + { + $('.FilterRegionId', $frm.filter).val(rgn ? rgn.id : ''); + $('.FilterRegionCaption', $frm.filter).val(rgn ? rgn.name : ''); + su.refreshResults(); + } + su.clearFilterRegion = function () + { + $('.FilterRegionId,.FilterRegionCaption', $frm.filter).val(''); + su.refreshResults(); + } + + //-------------------------------------------------------------- + su.viewItem = function (item) + { + $('.UserId', $frm.usrId).val(item.id); + su.ajax.user = su.ajax.user || { url: sax.url.base + 'Search/Ajax/GetUser', formId: 'frmUserId', callbackFn: su.onViewItem }; + sax.doAjaxRequest(su.ajax.user, 50); + } + su.onViewItem = function (response) + { + if (!response.success) return; + let dlg = $dlg.usr; + let item = su.data.user = response.user; + $('.UserName', dlg).val(item.name); + $('.UserLocation', dlg).toggle(!!item.location).find('.sax-value').text(item.location); + sax.clearControlErrors(); + $dlg.usr.dialog('option', 'title', item.name || sax.dlg.title.user); + sax.openDialog($dlg.usr, 600, 600); + } + + //-------------------------------------------------------------- + $(function () + { + $pnl.usrs = $('.sax-panel.Users'); + $pnl.filter = $('.sax-panel-filter', $pnl.usrs); + $pnl.results = $('.sax-panel-results', $pnl.usrs); + + $frm.filter = $('#frmUserFilter', $pnl.usrs); + $('.FilterUser', $frm.filter).on('input', function () { su.refreshResults(250); }).on('keypress', function (event) + { + if (event.keyCode == 13) setTimeout(su.refreshResults, 50); + }); + $('.FilterCategory', $frm.filter).on('change', function () { su.refreshResults(); }); + + var opt = sax.dlgOpts(); + opt.buttons[sax.dlg.btn.cancel] = function () { $(this).dialog('close'); }; + $dlg.usr = $('#dlgUser').dialog(opt); + $frm.usrId = $('#frmUserId'); + + setTimeout(su.refreshResults, 250); + }); + +}(window, window.document)); + +/* The End */ \ No newline at end of file diff --git a/SaxoniteStandardBase/Base/App/Sax-Config.cs b/SaxoniteStandardBase/Base/App/Sax-Config.cs new file mode 100644 index 0000000..609af8a --- /dev/null +++ b/SaxoniteStandardBase/Base/App/Sax-Config.cs @@ -0,0 +1,99 @@ +using Sarand.Net.Standard.Base.App; +using System; +using System.Collections.Generic; +using System.Text; + +namespace Saxonite.Net.Standard.Base.App +{ + //======================================================================= + // S A X S y s t e m - C o n f i g + //======================================================================= + static partial class Sax + { + //------------------------------------------------------------------- + // Application configuration defaults. + public static class Config + { + public static String Context_Defaults { get; } = "Defaults"; + public static class Security + { + public static class Password + { + } + public static class Activation + { + public static int EmailLinkExpiresMins_Default { get; } = 60; + public static int EmailLinkExpiresMins_Min { get; } = 30; + public static int EmailLinkExpiresMins_Max { get; } = 60 * 24; + } + public static class SignIn + { + public static class PasswordRequest + { + public static int EmailLinkExpiresMins_Default { get; } = 60; + public static int EmailLinkExpiresMins_Min { get; } = 30; + public static int EmailLinkExpiresMins_Max { get; } = 60 * 24; + } + public static class KeepLoggedIn + { + public static bool Allowed_Default { get; } = true; + public static int CookieExpiresDays_Default { get; } = 10; + public static int CookieExpiresDays_Min { get; } = 1; + public static int CookieExpiresDays_Max { get; } = 30; + } + } + } + public class Online + { + public static class Session + { + public static class Cookie + { + /// Default cookie name: '.AspNetCore.Session' + public static String Name { get; } = "Saxonite.Online.Session"; + public static bool HttpOnly { get; } = true; + public static TimeSpan IdleTimeout { get; } = SacsSystem.DebugMode ? TimeSpan.FromMinutes(5) : TimeSpan.FromMinutes(60); + public static long RememberMeTimeoutMilis { get; } = (long)(SacsSystem.DebugMode ? TimeSpan.FromMinutes(2) : TimeSpan.FromMinutes(10)).TotalMilliseconds; + } + } + public static class DataCache + { + public static class RefreshIntervalSecs + { + public static int Initial { get; } = SacsSystem.DebugMode ? 2 : 5; + public static int Periodic { get; } = SacsSystem.DebugMode ? 60 : 1800; + } + } + public static class Search + { + public static class Users + { + public static ushort PageLengthDefault { get; } = 12; + public static ushort PageLengthMax { get; } = 20; + } + public static class Organisations + { + public static ushort PageLengthDefault { get; } = 12; + public static ushort PageLengthMax { get; } = 20; + } + } + } + public class Admin + { + public static class Session + { + public static class Cookie + { + /// Default cookie name: '.AspNetCore.Session' + public static String Name { get; } = "Saxonite.Admin.Session"; + public static bool HttpOnly { get; } = true; + public static TimeSpan IdleTimeout { get; } = SacsSystem.DebugMode ? TimeSpan.FromMinutes(5) : TimeSpan.FromMinutes(15); + public static long KeepLoggedInTimeoutMillis { get; } = (long)(SacsSystem.DebugMode ? TimeSpan.FromMinutes(2) : TimeSpan.FromMinutes(10)).TotalMilliseconds; + } + } + } + } + + //------------------------------------------------------------------- + } +} diff --git a/SaxoniteStandardBase/Base/App/Sax-Version.cs b/SaxoniteStandardBase/Base/App/Sax-Version.cs index 945d8d8..89d2d16 100644 --- a/SaxoniteStandardBase/Base/App/Sax-Version.cs +++ b/SaxoniteStandardBase/Base/App/Sax-Version.cs @@ -18,7 +18,7 @@ namespace Saxonite.Net.Standard.Base.App //------------------------------------------------------------------- public static class Version { - private static String version { get; } = "1.1.7.1"; + private static String version { get; } = "1.1.8.0"; // Retrieve version. public static String GetFullVersion () { return version; } public static String GetAppVersion () @@ -40,8 +40,9 @@ namespace Saxonite.Net.Standard.Base.App //------------------------------------------------------------------- // Version history. //------------------------------------------------------------------- - // 1.1.8 ?-Oct-2021 ? - // - + // 1.1.8 21-Oct-2021 Online Users Search + // - ONlien Search - Users. + // - Admin Account Users filter. // 1.1.7 14-Oct-2021 Online Organisation Search // - Online Profile Sport About & snags. // - Online Organisation Search. diff --git a/SaxoniteStandardBase/Base/App/Sax.cs b/SaxoniteStandardBase/Base/App/Sax.cs index a2dd971..8c4d2d1 100644 --- a/SaxoniteStandardBase/Base/App/Sax.cs +++ b/SaxoniteStandardBase/Base/App/Sax.cs @@ -8,77 +8,6 @@ namespace Saxonite.Net.Standard.Base.App //======================================================================= public static partial class Sax { - //------------------------------------------------------------------- - // Application configuration defaults. - public static class Config - { - public static String Context_Defaults { get; } = "Defaults"; - public static class Security - { - public static class Password - { - } - public static class Activation - { - public static int EmailLinkExpiresMins_Default { get; } = 60; - public static int EmailLinkExpiresMins_Min { get; } = 30; - public static int EmailLinkExpiresMins_Max { get; } = 60 * 24; - } - public static class SignIn - { - public static class PasswordRequest - { - public static int EmailLinkExpiresMins_Default { get; } = 60; - public static int EmailLinkExpiresMins_Min { get; } = 30; - public static int EmailLinkExpiresMins_Max { get; } = 60 * 24; - } - public static class KeepLoggedIn - { - public static bool Allowed_Default { get; } = true; - public static int CookieExpiresDays_Default { get; } = 10; - public static int CookieExpiresDays_Min { get; } = 1; - public static int CookieExpiresDays_Max { get; } = 30; - } - } - } - public class Online - { - public static class Session - { - public static class Cookie - { - /// Default cookie name: '.AspNetCore.Session' - public static String Name { get; } = "Saxonite.Online.Session"; - public static bool HttpOnly { get; } = true; - public static TimeSpan IdleTimeout { get; } = SacsSystem.DebugMode ? TimeSpan.FromMinutes(5) : TimeSpan.FromMinutes(60); - public static long RememberMeTimeoutMilis { get; } = (long)(SacsSystem.DebugMode ? TimeSpan.FromMinutes(2) : TimeSpan.FromMinutes(10)).TotalMilliseconds; - } - } - public static class DataCache - { - public static class RefreshIntervalSecs - { - public static int Initial { get; } = SacsSystem.DebugMode ? 2 : 5; - public static int Periodic { get; } = SacsSystem.DebugMode ? 60 : 1800; - } - } - } - public class Admin - { - public static class Session - { - public static class Cookie - { - /// Default cookie name: '.AspNetCore.Session' - public static String Name { get; } = "Saxonite.Admin.Session"; - public static bool HttpOnly { get; } = true; - public static TimeSpan IdleTimeout { get; } = SacsSystem.DebugMode ? TimeSpan.FromMinutes(5) : TimeSpan.FromMinutes(15); - public static long KeepLoggedInTimeoutMillis { get; } = (long)(SacsSystem.DebugMode ? TimeSpan.FromMinutes(2) : TimeSpan.FromMinutes(10)).TotalMilliseconds; - } - } - } - } - //------------------------------------------------------------------- /// /// Code types (static lists). diff --git a/SaxoniteStandardBase/Base/Bus/SaxUserAccount.cs b/SaxoniteStandardBase/Base/Bus/SaxUserAccount.cs index 869a99f..0c770dc 100644 --- a/SaxoniteStandardBase/Base/Bus/SaxUserAccount.cs +++ b/SaxoniteStandardBase/Base/Bus/SaxUserAccount.cs @@ -4,6 +4,7 @@ using Sarand.Net.Standard.Base.Utils; using Saxonite.Net.Standard.Base.App; using System; using System.Collections.Generic; +using System.Linq; using System.Text; namespace Saxonite.Net.Standard.Base.Bus @@ -74,7 +75,7 @@ namespace Saxonite.Net.Standard.Base.Bus public byte DateOfBirthMonth { get; set; } public short DateOfBirthYear { get; set; } public SysId RegionIdCountry { get; set; } - public SysId RegionIdProvince{ get; set; } + public SysId RegionIdProvince { get; set; } // Security. public String PasswordHashed { get; set; } = String.Empty; public List PasswordHistory { get; } = new List(); @@ -493,12 +494,19 @@ namespace Saxonite.Net.Standard.Base.Bus public List IdsExcluded { get; } = new List(); public String EmailAddress { get; set; } public String NamePartial { get; set; } - /// Partial match on various user account properties including name, countries etc. - public String UserAccountFilter { get; set; } + /// Exact match on various user account properties including name, email etc. + public String UserFilter { get; set; } + /// Partial match on various user account properties including name, countries etc. Not to be use din Online application! + public String UserFilterPartial { get; set; } + public List SportIdsIncluded { get; } = new List(); + public List RegionIdsIncluded { get; } = new List(); public List ActiveRoles { get; } = new List(); // Common properties. public String NotesPartial { get; set; } public StatusCat StatusCat { get; set; } = StatusCat.ActiveOnly; + // Table aliases - blank if not linked. + public String Alias_UserSport { get; set; } + public String Alias_UserRole { get; set; } } //------------------------------------------------------------------- @@ -507,6 +515,25 @@ namespace Saxonite.Net.Standard.Base.Bus // Item list extension methods. public static class SaxUserAccountList { + //------------------------------------------------------------------- + /// + /// Extract the User Account Ids. + /// + public static List GetIds(this List values) + { + return values.Select(item => item.Id).ToList(); + } + + //------------------------------------------------------------------- + /// + /// Extract the first User Account in list with the specified Id. + /// + public static SaxUserAccount GetUserAccountById(this List values, SysId userAccountId) + { + return values.Find(item => item.Id.Equals(userAccountId)); + } + + //------------------------------------------------------------------- } //======================================================================= diff --git a/SaxoniteStandardDbas/Dbas/Mgr/SaxAccountMgr_Dbas-UserAccount.cs b/SaxoniteStandardDbas/Dbas/Mgr/SaxAccountMgr_Dbas-UserAccount.cs index e5e467f..5c3ea0e 100644 --- a/SaxoniteStandardDbas/Dbas/Mgr/SaxAccountMgr_Dbas-UserAccount.cs +++ b/SaxoniteStandardDbas/Dbas/Mgr/SaxAccountMgr_Dbas-UserAccount.cs @@ -289,6 +289,10 @@ namespace Saxonite.Net.Standard.Dbas.Mgr private static readonly String prefixUserAccount_Region_Country = "UsrAct_Ctr_"; private static readonly String aliasUserAccount_Region_Province = "UsrAct_Prv"; private static readonly String prefixUserAccount_Region_Province = "UsrAct_Prv_"; + private static readonly String aliasUserAccount_UserSport = "UsrAct_UsrSpt"; + //private static readonly String prefixUserAccount_UserSport = "UsrAct_UsrSpt_"; + private static readonly String aliasUserAccount_UserRole = "UsrAct_UsrRol"; + //private static readonly String prefixUserAccount_UserRole = "UsrAct_UsrRol_"; private static readonly String colUserAccount_UserRoleCount = "UsrAct_RoleCount"; private static readonly String colUserAccount_SystemAdminRole = "UsrAct_SystemAdminRole"; private void SetUserAccountColDfn @@ -462,18 +466,73 @@ namespace Saxonite.Net.Standard.Dbas.Mgr // Name. if (!StringUtil.IsEmpty(prm.NamePartial)) { - List nameFilter = new List(); - nameFilter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserAccount_Title, aliasUserAccount) + "Like'%" + DbQuery.FormatForLike(prm.NamePartial) + "%'"); - nameFilter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserAccount_FirstName, aliasUserAccount) + "Like'%" + DbQuery.FormatForLike(prm.NamePartial) + "%'"); - nameFilter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserAccount_LastName, aliasUserAccount) + "Like'%" + DbQuery.FormatForLike(prm.NamePartial) + "%'"); - filter.Add(nameFilter.Concat(" OR ", "(", ")")); + // Split filter into words. + List filterWords = prm.NamePartial.Split((char[])null, StringSplitOptions.RemoveEmptyEntries).ToList(); + filterWords.RemoveDuplicatesCI(); + filterWords.RemoveBlanks(); + foreach (String filterWord in filterWords) + { + List userFilter = new List(); + userFilter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserAccount_Title, aliasUserAccount) + "Like'%" + DbQuery.FormatForLike(filterWord) + "%'"); + userFilter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserAccount_FirstName, aliasUserAccount) + "Like'%" + DbQuery.FormatForLike(filterWord) + "%'"); + userFilter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserAccount_LastName, aliasUserAccount) + "Like'%" + DbQuery.FormatForLike(filterWord) + "%'"); + filter.Add(userFilter.Concat(" OR ", "(", ")")); + } } - // User Account filter. - if (!StringUtil.IsEmpty(prm.UserAccountFilter)) + // Sport Ids. + String sportIdsIncluded = prm.SportIdsIncluded.Concat(","); + if (!sportIdsIncluded.IsEmpty()) + { + if (prm.Alias_UserSport.IsEmpty()) + { + // User Sport table is not linked in query. + DbQuery userSportQuery = new DbQuery(CoreDatabase.DbmsType); + userSportQuery.Tables.Add(SaxDbDfn_Core.GetTableName(SaxDbDfn_Core.TableIdx.UserSport), aliasUserAccount_UserSport); + userSportQuery.Columns.Add("1"); + userSportQuery.Filters.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserSport_UserAccountId, aliasUserAccount_UserSport) + "=" + SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserAccount_Id, aliasUserAccount)); + userSportQuery.Filters.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserSport_SportId, aliasUserAccount_UserSport) + " IN (" + sportIdsIncluded + ")"); + filter.Add("Exists(" + userSportQuery.BuildQuery() + ")"); + } + else + // User Sport table is already linked in th equery. + filter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserSport_SportId, prm.Alias_UserSport) + " IN (" + sportIdsIncluded + ")"); + } + + // Region Ids. + String regionIdsIncluded = prm.RegionIdsIncluded.Concat(","); + if (!regionIdsIncluded.IsEmpty()) + { + List regionFilter = new List(); + regionFilter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserAccount_RegionIdCountry, aliasUserAccount) + " IN (" + regionIdsIncluded + ")"); + regionFilter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserAccount_RegionIdProvince, aliasUserAccount) + " IN (" + regionIdsIncluded + ")"); + filter.Add(regionFilter.Concat(" OR ", "(", ")")); + } + + // User filter. + if (!StringUtil.IsEmpty(prm.UserFilter)) { // Split filter into words. - List filterWords = prm.UserAccountFilter.Split((char[])null).ToList(); + List filterWords = prm.UserFilter.Split((char[])null, StringSplitOptions.RemoveEmptyEntries).ToList(); + filterWords.RemoveDuplicatesCI(); + filterWords.RemoveBlanks(); + foreach (String filterWord in filterWords) + { + List userFilter = new List(); + // Exact match for each word to avoid Online user search allowing partial lookup. + userFilter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserAccount_EmailAddress, aliasUserAccount) + "='" + DbQuery.FormatForCondition(filterWord) + "'"); + userFilter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserAccount_Title, aliasUserAccount) + "='" + DbQuery.FormatForCondition(filterWord) + "'"); + userFilter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserAccount_FirstName, aliasUserAccount) + "='" + DbQuery.FormatForCondition(filterWord) + "'"); + userFilter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserAccount_LastName, aliasUserAccount) + "='" + DbQuery.FormatForCondition(filterWord) + "'"); + filter.Add(userFilter.Concat(" OR ", "(", ")")); + } + } + + // User filter - partial. + if (!StringUtil.IsEmpty(prm.UserFilterPartial)) + { + // Split filter into words. + List filterWords = prm.UserFilterPartial.Split((char[])null, StringSplitOptions.RemoveEmptyEntries).ToList(); filterWords.RemoveDuplicatesCI(); filterWords.RemoveBlanks(); foreach (String filterWord in filterWords) @@ -488,21 +547,27 @@ namespace Saxonite.Net.Standard.Dbas.Mgr } // Active roles. - if (!prm.ActiveRoles.IsEmpty()) + List roleCodes = new List(); + foreach (Sax.UserRole userRole in prm.ActiveRoles) + roleCodes.Add(UserRoleCodes.GetCodeForType(userRole)); + if (roleCodes.Exists(item => !item.Trim().IsEmpty())) { - String aliasUserRole = "UsrRol"; - DbQuery roleQuery = new DbQuery(CoreDatabase.DbmsType); - roleQuery.Tables.Add(SaxDbDfn_Core.GetTableName(SaxDbDfn_Core.TableIdx.UserRole), aliasUserRole); - roleQuery.Columns.Add("1"); - roleQuery.Filters.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserRole_UserAccountId, aliasUserRole) + "=" + SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserAccount_Id, aliasUserAccount)); - - foreach (Sax.UserRole userRole in prm.ActiveRoles) + if (prm.Alias_UserRole.IsEmpty()) { - roleQuery.Filters.Clear(); - roleQuery.Filters.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserRole_UserAccountId, aliasUserRole) + "=" + SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserAccount_Id, aliasUserAccount)); - roleQuery.Filters.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserRole_UserRoleCode, aliasUserRole) + "='" + UserRoleCodes.GetCodeForType(userRole) + "'"); + // User Role table is not linked in the query. + DbQuery roleQuery = new DbQuery(CoreDatabase.DbmsType); + roleQuery.Tables.Add(SaxDbDfn_Core.GetTableName(SaxDbDfn_Core.TableIdx.UserRole), aliasUserAccount_UserRole); + roleQuery.Columns.Add("1"); + roleQuery.Filters.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserRole_UserAccountId, aliasUserAccount_UserRole) + "=" + SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserAccount_Id, aliasUserAccount)); + roleQuery.Filters.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserRole_UserRoleCode, aliasUserAccount_UserRole) + " IN (" + DbQuery.FormatForIn(roleCodes) + ")"); filter.Add("Exists(" + roleQuery.BuildQuery() + ")"); } + else + { + // User Role table is already linked in the query. + filter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserRole_UserAccountId, prm.Alias_UserRole) + "=" + SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserAccount_Id, aliasUserAccount)); + filter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserRole_UserRoleCode, prm.Alias_UserRole) + " IN (" + DbQuery.FormatForIn(roleCodes) + ")"); + } } // Notes. diff --git a/SaxoniteStandardDbas/Dbas/Mgr/SaxAccountMgr_Dbas-UserOrganisation.cs b/SaxoniteStandardDbas/Dbas/Mgr/SaxAccountMgr_Dbas-UserOrganisation.cs index f583d92..c6f83c4 100644 --- a/SaxoniteStandardDbas/Dbas/Mgr/SaxAccountMgr_Dbas-UserOrganisation.cs +++ b/SaxoniteStandardDbas/Dbas/Mgr/SaxAccountMgr_Dbas-UserOrganisation.cs @@ -445,20 +445,19 @@ namespace Saxonite.Net.Standard.Dbas.Mgr // User Account status. if (prm.UserAccountStatusCat != SaxUserAccount.StatusCat.Any) { - String aliasUserOrganisation_UserAccount = StringUtil.OnEmpty(prm.Alias_UserAccount, SaxAccountMgr_Dbas.aliasUserOrganisation_UserAccount); if (StringUtil.IsEmpty(prm.Alias_UserAccount)) { // User Account table isn't linked. DbQuery qry = new DbQuery(CoreDatabase.DbmsType); qry.Tables.Add(SaxDbDfn_Core.GetTableName(SaxDbDfn_Core.TableIdx.UserAccount), aliasUserOrganisation_UserAccount); - qry.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserAccount_Id, aliasUserOrganisation_UserAccount)); + qry.Columns.Add("1"); qry.Filters.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserAccount_Id, aliasUserOrganisation_UserAccount) + "=" + SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserOrganisation_UserAccountId, aliasUserOrganisation)); qry.Filters.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserAccount_Status, aliasUserOrganisation_UserAccount) + GetUserAccountStatusCatFilterCondition(prm.UserAccountStatusCat)); filter.Add("Exists (" + qry.BuildQuery() + ")"); } else // User Account table is linked - filter directly. - filter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserAccount_Status, aliasUserOrganisation_UserAccount) + GetUserAccountStatusCatFilterCondition(prm.UserAccountStatusCat)); + filter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserAccount_Status, prm.Alias_UserAccount) + GetUserAccountStatusCatFilterCondition(prm.UserAccountStatusCat)); } // Organisations. @@ -469,20 +468,19 @@ namespace Saxonite.Net.Standard.Dbas.Mgr // Organisation status. if (prm.OrganisationStatusCat != SaxOrganisation.StatusCat.Any) { - String aliasUserOrganisation_Organisation = StringUtil.OnEmpty(prm.Alias_Organisation, SaxAccountMgr_Dbas.aliasUserOrganisation_Organisation); if (StringUtil.IsEmpty(prm.Alias_Organisation)) { // User Account table isn't linked. DbQuery qry = new DbQuery(CoreDatabase.DbmsType); qry.Tables.Add(SaxDbDfn_Core.GetTableName(SaxDbDfn_Core.TableIdx.Organisation), aliasUserOrganisation_Organisation); - qry.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.Organisation_Id, aliasUserOrganisation_Organisation)); + qry.Columns.Add("1"); qry.Filters.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.Organisation_Id, aliasUserOrganisation_Organisation) + "=" + SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserOrganisation_OrganisationId, aliasUserOrganisation)); qry.Filters.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.Organisation_Status, aliasUserOrganisation_Organisation) + GetOrganisationStatusCatFilterCondition(prm.OrganisationStatusCat)); filter.Add("Exists (" + qry.BuildQuery() + ")"); } else // User Account table is linked - filter directly. - filter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.Organisation_Status, aliasUserOrganisation_Organisation) + GetOrganisationStatusCatFilterCondition(prm.OrganisationStatusCat)); + filter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.Organisation_Status, prm.Alias_Organisation) + GetOrganisationStatusCatFilterCondition(prm.OrganisationStatusCat)); } // Organisation roles.