From 806ebb4024a9a67225da5f24891c1e82d8f4457e Mon Sep 17 00:00:00 2001 From: Andy Howard Date: Mon, 1 Nov 2021 18:14:21 +0000 Subject: [PATCH] v1.2.0 --- SaxoniteCoreWeb/Base/App/SaxSystem_Web.cs | 2 +- .../Admin/App/SaxApplication_Admin.cs | 12 + .../OrganisationController-Activation-Ajax.cs | 2 - .../Localisation/SaxAdminProperties.resx | 6 + .../profile.arm.json | 113 +++++++ .../Views/Common/SelectCode.cshtml | 91 +++--- .../Organisation/Panel-MemberDialog.cshtml | 84 ++++-- .../Panel-OrganisationDialog.cshtml | 4 +- .../Views/Shared/_Layout.cshtml | 114 +++---- .../appsettings.Machine.dw0sdwk000010.json | 55 ++++ SaxoniteCoreWebAdmin/wwwroot/css/sax-main.css | 2 +- .../wwwroot/js/sax-organisation.js | 11 +- .../wwwroot/js/sax-organisationMembers.js | 14 +- SaxoniteCoreWebAdmin/wwwroot/js/sax-region.js | 10 +- SaxoniteCoreWebAdmin/wwwroot/js/sax-sys-db.js | 6 +- SaxoniteCoreWebAdmin/wwwroot/js/sax-user.js | 6 +- .../AccountController-Ajax-Organisations.cs | 21 +- .../Controllers/ArticleController-Ajax.cs | 4 +- .../Online/Controllers/ArticleController.cs | 2 +- .../OrganisationController-Ajax-Members.cs | 125 ++++---- ...ganisationController-Ajax-Opportunities.cs | 4 +- .../OrganisationController-Ajax-Request.cs | 4 +- .../Online/Models/SaxModel_Online.cs | 59 ++-- .../Views/Common/OrganisationRequest.cshtml | 280 +++++++++++------- .../wwwroot/css/sax-form.css | 7 +- .../wwwroot/img/icon/error-16.png | Bin 0 -> 462 bytes .../wwwroot/js/sax-org-opp.js | 10 +- .../wwwroot/js/sax-usr-org.js | 30 +- SaxoniteStandardBase/Base/App/Sax-Version.cs | 7 +- SaxoniteStandardBase/Base/App/Sax.cs | 1 + .../Base/App/SaxSystem-Statics.cs | 9 +- .../Base/Bus/SaxUserOrganisation.cs | 23 +- .../Mgr/SaxAccountMgr-UserOrganisation.cs | 46 ++- .../SaxAccountMgr_Dbas-UserOrganisation.cs | 13 +- 34 files changed, 766 insertions(+), 411 deletions(-) create mode 100644 SaxoniteCoreWebAdmin/Properties/ServiceDependencies/SportierreAdmin - Web Deploy/profile.arm.json create mode 100644 SaxoniteCoreWebAdmin/appsettings.Machine.dw0sdwk000010.json create mode 100644 SaxoniteCoreWebOnline/wwwroot/img/icon/error-16.png diff --git a/SaxoniteCoreWeb/Base/App/SaxSystem_Web.cs b/SaxoniteCoreWeb/Base/App/SaxSystem_Web.cs index d37d267..ac48ea3 100644 --- a/SaxoniteCoreWeb/Base/App/SaxSystem_Web.cs +++ b/SaxoniteCoreWeb/Base/App/SaxSystem_Web.cs @@ -55,7 +55,7 @@ namespace Saxonite.Net.Core.Web.Base.App try { if (StringUtil.IsEmpty(ComputerName)) - ComputerName = Environment.GetEnvironmentVariable("CUMPUTERNAME") ?? Environment.GetEnvironmentVariable("HOSTNAME"); + ComputerName = Environment.GetEnvironmentVariable("COMPUTERNAME") ?? Environment.GetEnvironmentVariable("HOSTNAME"); } catch (Exception exc) { diff --git a/SaxoniteCoreWebAdmin/Admin/App/SaxApplication_Admin.cs b/SaxoniteCoreWebAdmin/Admin/App/SaxApplication_Admin.cs index 6288ffe..71cd833 100644 --- a/SaxoniteCoreWebAdmin/Admin/App/SaxApplication_Admin.cs +++ b/SaxoniteCoreWebAdmin/Admin/App/SaxApplication_Admin.cs @@ -69,6 +69,7 @@ namespace Saxonite.Net.Core.Web.Admin.App //------------------------------------------------------------------- // Properties. public static SaxApplication_Admin AppInstance { get; private set; } + public List Messages { get; } = new List(); public override ISacsDatabase GetCoreDatabase(SaxSessionContext sessionContext) { return sessionContexts.GetValue(sessionContext.Index, null)?.CoreDatabase; @@ -106,6 +107,9 @@ namespace Saxonite.Net.Core.Web.Admin.App .AddEnvironmentVariables(); SaxConfiguration = builder.Build(); + //Messages.Add($"Host: {SaxSystem.ComputerName}"); + //Messages.Add($"Config file: appsettings.machine.{SaxSystem.ComputerName}.json"); + // Application configuration. appConfigs = SaxAppConfigHelper.ExtractAppConfigs(SaxConfiguration.GetSection("AppConfigs")); emailConfigs = SaxEmailConfigHelper.ExtractEmailConfigs(SaxConfiguration.GetSection("EmailConfigs")); @@ -127,6 +131,9 @@ namespace Saxonite.Net.Core.Web.Admin.App SaLogger.LogFolder = LoggingRootFolder; LogApplicationStart(fn); + //Messages.Add($"Database location: {AppConfig.CoreDatabase.Location}"); + //Messages.Add($"LoggingRootFolder: {SaLogger.LogFolder}"); + // Configure database connection. SacsDatabaseConsole.OdbcConfig config = new SacsDatabaseConsole.OdbcConfig(); config.location = AppConfig.CoreDatabase.Location; @@ -136,6 +143,11 @@ namespace Saxonite.Net.Core.Web.Admin.App if (coreDatabase.HasErrorState()) SaLogger.Warn(fn + " Database initialisation error: " + coreDatabase.ErrorStateMessage); + //Messages.Add($"Database location: {AppConfig.CoreDatabase.Location}"); + //Messages.Add($"LoggingRootFolder: {SaLogger.LogFolder}"); + //Messages.Add($"OdbcDrivers: {OdbcUtil.GetOdbcDriverNames().Concat(", ")}"); + //Messages.Add($"DbConnection: {coreDatabase.ConnectionString}"); + // Session context - only one context available/necessary (for now). SessionContextData sessionContextData = new SessionContextData(new SaxSessionContext_Web(100, Sax.Application.Admin)); sessionContextData.CoreDatabase = coreDatabase; diff --git a/SaxoniteCoreWebAdmin/Admin/Controllers/OrganisationController-Activation-Ajax.cs b/SaxoniteCoreWebAdmin/Admin/Controllers/OrganisationController-Activation-Ajax.cs index 05b493f..9364a14 100644 --- a/SaxoniteCoreWebAdmin/Admin/Controllers/OrganisationController-Activation-Ajax.cs +++ b/SaxoniteCoreWebAdmin/Admin/Controllers/OrganisationController-Activation-Ajax.cs @@ -181,9 +181,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers // Activate awaiting members and send welcome email to each. foreach (OrganisationMemberData organisationMember in organisationMembersToActivate) { - // Ensure that User Organisation has 'Member Admin' role. if (organisationMember.UserOrganisation == null) continue; - organisationMember.UserOrganisation.AddOrganisationRole(Sax.OrganisationRole.MemberAdmin); if (AccountMgr.UpdateUserOrganisation(organisationMember.UserOrganisation, DbUpdateInfo)) { if (organisationMember.UserAccount == null) continue; diff --git a/SaxoniteCoreWebAdmin/Localisation/SaxAdminProperties.resx b/SaxoniteCoreWebAdmin/Localisation/SaxAdminProperties.resx index 4ba3c66..1bf6e98 100644 --- a/SaxoniteCoreWebAdmin/Localisation/SaxAdminProperties.resx +++ b/SaxoniteCoreWebAdmin/Localisation/SaxAdminProperties.resx @@ -159,6 +159,12 @@ Any + + Assigned + + + Available + Cancel diff --git a/SaxoniteCoreWebAdmin/Properties/ServiceDependencies/SportierreAdmin - Web Deploy/profile.arm.json b/SaxoniteCoreWebAdmin/Properties/ServiceDependencies/SportierreAdmin - Web Deploy/profile.arm.json new file mode 100644 index 0000000..ff759b3 --- /dev/null +++ b/SaxoniteCoreWebAdmin/Properties/ServiceDependencies/SportierreAdmin - Web Deploy/profile.arm.json @@ -0,0 +1,113 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "metadata": { + "_dependencyType": "appService.windows" + }, + "parameters": { + "resourceGroupName": { + "type": "string", + "defaultValue": "Sportierre", + "metadata": { + "description": "Name of the resource group for the resource. It is recommended to put resources under same resource group for better tracking." + } + }, + "resourceGroupLocation": { + "type": "string", + "defaultValue": "westeurope", + "metadata": { + "description": "Location of the resource group. Resource groups could have different location than resources, however by default we use API versions from latest hybrid profile which support all locations for resource types we support." + } + }, + "resourceName": { + "type": "string", + "defaultValue": "SportierreAdmin", + "metadata": { + "description": "Name of the main resource to be created by this template." + } + }, + "resourceLocation": { + "type": "string", + "defaultValue": "[parameters('resourceGroupLocation')]", + "metadata": { + "description": "Location of the resource. By default use resource group's location, unless the resource provider is not supported there." + } + } + }, + "variables": { + "appServicePlan_name": "[concat('Plan', uniqueString(concat(parameters('resourceName'), subscription().subscriptionId)))]", + "appServicePlan_ResourceId": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', parameters('resourceGroupName'), '/providers/Microsoft.Web/serverFarms/', variables('appServicePlan_name'))]" + }, + "resources": [ + { + "type": "Microsoft.Resources/resourceGroups", + "name": "[parameters('resourceGroupName')]", + "location": "[parameters('resourceGroupLocation')]", + "apiVersion": "2019-10-01" + }, + { + "type": "Microsoft.Resources/deployments", + "name": "[concat(parameters('resourceGroupName'), 'Deployment', uniqueString(concat(parameters('resourceName'), subscription().subscriptionId)))]", + "resourceGroup": "[parameters('resourceGroupName')]", + "apiVersion": "2019-10-01", + "dependsOn": [ + "[parameters('resourceGroupName')]" + ], + "properties": { + "mode": "Incremental", + "template": { + "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "resources": [ + { + "location": "[parameters('resourceLocation')]", + "name": "[parameters('resourceName')]", + "type": "Microsoft.Web/sites", + "apiVersion": "2015-08-01", + "tags": { + "[concat('hidden-related:', variables('appServicePlan_ResourceId'))]": "empty" + }, + "dependsOn": [ + "[variables('appServicePlan_ResourceId')]" + ], + "kind": "app", + "properties": { + "name": "[parameters('resourceName')]", + "kind": "app", + "httpsOnly": true, + "reserved": false, + "serverFarmId": "[variables('appServicePlan_ResourceId')]", + "siteConfig": { + "metadata": [ + { + "name": "CURRENT_STACK", + "value": "dotnetcore" + } + ] + } + }, + "identity": { + "type": "SystemAssigned" + } + }, + { + "location": "[parameters('resourceLocation')]", + "name": "[variables('appServicePlan_name')]", + "type": "Microsoft.Web/serverFarms", + "apiVersion": "2015-08-01", + "sku": { + "name": "S1", + "tier": "Standard", + "family": "S", + "size": "S1" + }, + "properties": { + "name": "[variables('appServicePlan_name')]" + } + } + ] + } + } + } + ] +} \ No newline at end of file diff --git a/SaxoniteCoreWebAdmin/Views/Common/SelectCode.cshtml b/SaxoniteCoreWebAdmin/Views/Common/SelectCode.cshtml index fe3f9f2..4455b49 100644 --- a/SaxoniteCoreWebAdmin/Views/Common/SelectCode.cshtml +++ b/SaxoniteCoreWebAdmin/Views/Common/SelectCode.cshtml @@ -1,60 +1,65 @@ @model SaxModel_Admin @inject SaxLocaliser Localiser - - - + + + -
+
- @* Filter *@ -
+ @* Filter *@ +
-
+
-
+
- @* Available codes *@ -
+ @* Available codes *@ +
-
- -
- -
- - @* Code selection *@ -
- -
- -
- -
- -
- -
- -
- -
- - @* Selected codes *@ -
- -
- -
+
+
@Localiser["label.available"]:
+
+
-
-
-
+ @* Code selection *@ +
+ +
+
+ +
+ +
+ +
+ +
+ +
+ +
+ + @* Selected codes *@ +
+ +
+
@Localiser["label.assigned"]:
+
+
+ +
+
+
+
+
+ +
diff --git a/SaxoniteCoreWebAdmin/Views/Organisation/Panel-MemberDialog.cshtml b/SaxoniteCoreWebAdmin/Views/Organisation/Panel-MemberDialog.cshtml index 2afe071..c6924ce 100644 --- a/SaxoniteCoreWebAdmin/Views/Organisation/Panel-MemberDialog.cshtml +++ b/SaxoniteCoreWebAdmin/Views/Organisation/Panel-MemberDialog.cshtml @@ -16,12 +16,13 @@ { @Html.HiddenFor(model => model.UserOrganisationId, new { @id = "", @class = "UserOrganisationId" }) } -@using (@Html.BeginForm(FormMethod.Post, new { @id = "frmUserEmail"})) +@using (@Html.BeginForm(FormMethod.Post, new { @id = "frmUserEmail" })) { }
+
@using (@Html.BeginForm(FormMethod.Post, new { @id = "frmMember", @class = "sax-form", @onSubmit = "return false;" })) { @Html.HiddenFor(model => model.UserOrganisationId, new { @id = "", @class = "UserOrganisationId" }) @@ -29,52 +30,77 @@ @* User email *@
-
- +
+
+
+ +
+
+
+
+ @Html.TextBoxFor(model => model.MemberUserEmailAddress, new { @id = "ifMemberUserEmailAddress", @class = "MemberUserEmailAddress sax-input", @maxlength = @Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.UserAccount_EmailAddress) }) +
+
+
-
- @Html.TextBoxFor(model => model.MemberUserEmailAddress, new { @id = "ifMemberUserEmailAddress", @class = "MemberUserEmailAddress sax-input", @maxlength = @Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.UserAccount_EmailAddress) }) -
-
@* User email *@
-
- +
+
+
+ +
+
+
+
+ +
+
+
-
- -
-
@* Member roles *@
-
- +
+
+
+ +
+
+
+
+ @Html.HiddenFor(model => model.MemberRoleCodes, new { @id = "ifMemberRoleCodes", @class = "MemberRoleCodes sax-input" }) +
+
+
+
+
-
- @Html.HiddenFor(model => model.MemberRoleCodes, new { @id = "ifMemberRoleCodes", @class = "MemberRoleCodes sax-input" }) -
-
-
-
@* Member status *@
-
- +
+
+
+ +
+
+
+
+ +
+
+
-
- -
-
} - - +
+ + diff --git a/SaxoniteCoreWebAdmin/Views/Organisation/Panel-OrganisationDialog.cshtml b/SaxoniteCoreWebAdmin/Views/Organisation/Panel-OrganisationDialog.cshtml index 4df3e68..a2800a6 100644 --- a/SaxoniteCoreWebAdmin/Views/Organisation/Panel-OrganisationDialog.cshtml +++ b/SaxoniteCoreWebAdmin/Views/Organisation/Panel-OrganisationDialog.cshtml @@ -41,7 +41,7 @@
-
+
@* Organisation category *@
@@ -56,7 +56,7 @@
-
+
@* Organisation type *@
diff --git a/SaxoniteCoreWebAdmin/Views/Shared/_Layout.cshtml b/SaxoniteCoreWebAdmin/Views/Shared/_Layout.cshtml index 81ea84f..4b8c994 100644 --- a/SaxoniteCoreWebAdmin/Views/Shared/_Layout.cshtml +++ b/SaxoniteCoreWebAdmin/Views/Shared/_Layout.cshtml @@ -24,9 +24,9 @@ @if (Model.ProhibitCache) { - - - + + + } @@ -50,7 +50,7 @@ @foreach (var cssFile in Model.AdditionalFiles_CSS) { - + } @* Scripts *@ @@ -109,52 +109,52 @@ *@ @if (Model.AwaitingLogin) { - - + + } else { - - - - + + + + }
@@ -164,9 +164,9 @@ @* Page caption *@ @if (!StringUtil.IsEmpty(Model.PageCaption)) { -
-
@(Model.PageCaption)
-
+
+
@(Model.PageCaption)
+
} @@ -181,7 +181,15 @@ @* Footer *@
- @(Model.CopyrightNotice) - @Localiser["company.name"] @(Model.InstanceVersion) +
+
@(Model.CopyrightNotice) - @Localiser["company.name"] @(Model.InstanceVersion)
+
+
+ @* Application messages - for debugging. *@ + @(new Microsoft.AspNetCore.Html.HtmlString(Saxonite.Net.Core.Web.Admin.App.SaxApplication_Admin.AppInstance.Messages.Concat("
"))) +
+
+
@@ -212,11 +220,11 @@ @foreach (var jsFile in Model.AdditionalFiles_JS) { - + } @if (Model.IncludeGoogleAnalytics) { - + } @RenderSection("Scripts", required: false) diff --git a/SaxoniteCoreWebAdmin/appsettings.Machine.dw0sdwk000010.json b/SaxoniteCoreWebAdmin/appsettings.Machine.dw0sdwk000010.json new file mode 100644 index 0000000..d04e9b8 --- /dev/null +++ b/SaxoniteCoreWebAdmin/appsettings.Machine.dw0sdwk000010.json @@ -0,0 +1,55 @@ +{ + "AppConfigs": { + "SAX-Prod": { + "Environments": [ "Production" ], + "Instance": "", + "URLs": { + "Online": { + "Root": "https://sportierre.com/" + } + }, + "CoreDatabase": { + "Location": "MsSql:sportierre.database.windows.net\\Saxonite_Core_Demo", + "User": "dbadmin", + "Password": "azdb-sport-1970!" + }, + "Security": { + "Password": { + "MinLength": 9 + }, + "SignIn": { + "KeepLoggedIn": { + "Allowed": true, + "CookieExpiresDays": 5 + }, + "PasswordRequest": { + "LinkExpiresMins": 30 + } + } + }, + "Email": { + "Context": "SAX-SF-Prod", + "ContactUs": { + "AddressesTo": [], + "AddressesBcc": [ "info@sportierre.com" ] + }, + "Signup": { + "Activate": { + "AddressesBcc": [ "info@sportierre.com" ] + }, + "Welcome": { + "AddressesBcc": [ "info@sportierre.com" ] + } + } + }, + "Documents": { + "RootFolder": "D:\\Home\\Logfiles\\Application\\Saxonite\\Admin\\Docs" + }, + "Logging": { + "RootFolder": "D:\\Home\\Logfiles\\Application\\Saxonite\\Admin\\Logs" + }, + "Variants": [ + ] + } + } +} diff --git a/SaxoniteCoreWebAdmin/wwwroot/css/sax-main.css b/SaxoniteCoreWebAdmin/wwwroot/css/sax-main.css index ab5728e..0684bb4 100644 --- a/SaxoniteCoreWebAdmin/wwwroot/css/sax-main.css +++ b/SaxoniteCoreWebAdmin/wwwroot/css/sax-main.css @@ -28,7 +28,7 @@ html { html { - font-size: 16px; + font-size: 14px; } } diff --git a/SaxoniteCoreWebAdmin/wwwroot/js/sax-organisation.js b/SaxoniteCoreWebAdmin/wwwroot/js/sax-organisation.js index 8ea9c4e..db669fd 100644 --- a/SaxoniteCoreWebAdmin/wwwroot/js/sax-organisation.js +++ b/SaxoniteCoreWebAdmin/wwwroot/js/sax-organisation.js @@ -6,7 +6,7 @@ { "use strict"; let op = sax.mdl.organisations = sax.mdl.organisations || { data: {}, ajax: {} }; - let $pnl = sax.$pnl, $frm = sax.$frm, $dlg = sax.$dlg; + let $pnl = op.$pnl = {}, $frm = op.$frm = {}, $dlg = op.$dlg = {}; sax.itemIdPrefix = 'Itm_'; //-------------------------------------------------------------- @@ -200,7 +200,7 @@ $('.OrganisationStatus', frm).val(sax.data.defaultStatusCode); sax.clearControlErrors(); $dlg.organisation.dialog('option', 'title', sax.dlg.title.createOrganisation); - sax.openDialog($dlg.organisation, 600, 600); + sax.openDialog($dlg.organisation, 600, 480); } //-------------------------------------------------------------- @@ -228,7 +228,7 @@ $('.OrganisationStatus', frm).val(item.statusCode); sax.clearControlErrors(); $dlg.organisation.dialog('option', 'title', sax.dlg.title.updateOrganisation); - sax.openDialog($dlg.organisation, 600, 600); + sax.openDialog($dlg.organisation, 600, 480); } //-------------------------------------------------------------- @@ -269,7 +269,6 @@ sax.debug('showActivationInfo', response); if (!response.success || !response.organisation) return; let item = response.organisation; - let $dlg = $dlg.activate; let frm = $('#frmOrganisationActivation'); $('.OrganisationId', frm).val($('.OrganisationId', $frm.orgId).val()); let popItemValue = function (sel, val) @@ -281,7 +280,7 @@ popItemValue('.OrganisationRegion', item.regionNameCountry); popItemValue('.OrganisationCategory', item.categoryDesc); popItemValue('.OrganisationAddress', item.addressSummary); - let $orgMbrs = $('.OrganisationMembers', $dlg).empty(); + let $orgMbrs = $('.OrganisationMembers', $dlg.activate).empty(); let $mbrTmpl = $('.sax-panel-item-template tr.sax-item.Member'); sax.debug(response.members, $orgMbrs, $mbrTmpl); for (let idx = 0; idx < response.members.length; idx++) @@ -295,7 +294,7 @@ $orgMbrs.append($item); sax.debug($item); } - sax.openDialog($dlg, 480, 640); + sax.openDialog($dlg.activate, 480, 420); } sax.activateOrganisation = function () { diff --git a/SaxoniteCoreWebAdmin/wwwroot/js/sax-organisationMembers.js b/SaxoniteCoreWebAdmin/wwwroot/js/sax-organisationMembers.js index 9ad1b51..6b1dd7c 100644 --- a/SaxoniteCoreWebAdmin/wwwroot/js/sax-organisationMembers.js +++ b/SaxoniteCoreWebAdmin/wwwroot/js/sax-organisationMembers.js @@ -135,11 +135,7 @@ sax.clearControlErrors(); sax.member = { roleCodes: [] }; sax.$dlg.member.dialog('option', 'title', sax.dlg.title.createMember); - sax.openDialog(sax.$dlg.member, 600, 600); - } - sax.doCreateItem = function () - { - sax.storeItem(); + sax.openDialog(sax.$dlg.member, 600, 480); } //-------------------------------------------------------------- @@ -165,11 +161,7 @@ $('.MemberStatus', $frm).val(item.statusCode); sax.clearControlErrors(); sax.$dlg.member.dialog('option', 'title', sax.dlg.title.updateMember); - sax.openDialog(sax.$dlg.member, 600, 600); - } - sax.doUpdateItem = function () - { - sax.storeItem(); + sax.openDialog(sax.$dlg.member, 600, 480); } //-------------------------------------------------------------- @@ -208,7 +200,7 @@ $('#ifMemberUserEmailAddress', sax.$frm.member).on('change', function () { sax.onChangeEmail(); }); 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.member = $('#dlgMember').dialog(opt); diff --git a/SaxoniteCoreWebAdmin/wwwroot/js/sax-region.js b/SaxoniteCoreWebAdmin/wwwroot/js/sax-region.js index 849bafb..14ebdb2 100644 --- a/SaxoniteCoreWebAdmin/wwwroot/js/sax-region.js +++ b/SaxoniteCoreWebAdmin/wwwroot/js/sax-region.js @@ -101,10 +101,6 @@ sax.$dlg.region.dialog('option', 'title', sax.dlg.title.createRegion); sax.openDialog(sax.$dlg.region, 600, 600); } - sax.doCreateItem = function () - { - sax.storeItem(); - } //-------------------------------------------------------------- sax.updateItem = function (id) @@ -131,10 +127,6 @@ sax.$dlg.region.dialog('option', 'title', sax.dlg.title.updateRegion); sax.openDialog(sax.$dlg.region, 600, 600); } - sax.doUpdateItem = function () - { - sax.storeItem(); - } //-------------------------------------------------------------- sax.storeItem = function () @@ -174,7 +166,7 @@ sax.$frm.region = $('#frmRegion'); 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.region = $('#dlgRegion').dialog(opt); diff --git a/SaxoniteCoreWebAdmin/wwwroot/js/sax-sys-db.js b/SaxoniteCoreWebAdmin/wwwroot/js/sax-sys-db.js index abc8fd1..0568dea 100644 --- a/SaxoniteCoreWebAdmin/wwwroot/js/sax-sys-db.js +++ b/SaxoniteCoreWebAdmin/wwwroot/js/sax-sys-db.js @@ -75,10 +75,6 @@ sax.$dlg.dbTable.dialog('option', 'title', sax.dlg.title.viewDatabaseTable); sax.openDialog(sax.$dlg.dbTable, 600, 600); } - sax.doUpdateItem = function () - { - sax.storeItem(); - } //-------------------------------------------------------------- $(function () @@ -92,7 +88,7 @@ sax.$frm.dbTable = $('#frmDatabaseTable'); 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.dbTable = $('#dlgDatabaseTable').dialog(opt); diff --git a/SaxoniteCoreWebAdmin/wwwroot/js/sax-user.js b/SaxoniteCoreWebAdmin/wwwroot/js/sax-user.js index 3514548..973713f 100644 --- a/SaxoniteCoreWebAdmin/wwwroot/js/sax-user.js +++ b/SaxoniteCoreWebAdmin/wwwroot/js/sax-user.js @@ -210,7 +210,7 @@ sax.clearControlErrors(); sax.userAccount = { userRoleCodes: [] }; $dlg.user.dialog('option', 'title', sax.dlg.title.createUser); - sax.openDialog($dlg.user, 600, 600); + sax.openDialog($dlg.user, 600, 480); } //-------------------------------------------------------------- @@ -237,7 +237,7 @@ $('#ifUserRoleCodes').val(item.userRoleCodes.join(sax.data.userRoleCodeDelim)); $('.UserStatus', frm).val(item.statusCode); $dlg.user.dialog('option', 'title', sax.dlg.title.updateUser); - sax.openDialog($dlg.user, 600, 600); + sax.openDialog($dlg.user, 600, 480); } //-------------------------------------------------------------- @@ -274,7 +274,7 @@ $('.RequestPasswordAdminOption', frm).toggle(item.systemAdmin); $('input[type="checkbox"]', frm).prop('checked', false); $dlg.emails.dialog('option', { 'title': sax.dlg.title.selectUserEmails }); - sax.openDialog($dlg.emails, 600, 600); + sax.openDialog($dlg.emails, 600, 360); } sax.sendUserEmails = function () { diff --git a/SaxoniteCoreWebOnline/Online/Controllers/AccountController-Ajax-Organisations.cs b/SaxoniteCoreWebOnline/Online/Controllers/AccountController-Ajax-Organisations.cs index 1979b58..31c1d75 100644 --- a/SaxoniteCoreWebOnline/Online/Controllers/AccountController-Ajax-Organisations.cs +++ b/SaxoniteCoreWebOnline/Online/Controllers/AccountController-Ajax-Organisations.cs @@ -14,6 +14,7 @@ using Sarand.Net.Standard.Base.Bus; using Sarand.Net.Standard.Base.Utils; using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Dbas; +using Saxonite.Net.Standard.Base.App; namespace Saxonite.Net.Core.Web.Online.Controllers { @@ -35,6 +36,11 @@ namespace Saxonite.Net.Core.Web.Online.Controllers public String RegionName { get; set; } public long MemberCount { get; set; } public long OpportunityCount { get; set; } + public bool? Admin { get; set; } = null; + public bool? MemberAdmin { get; set; } = null; + public bool? OpportunitiyAdmin { get; set; } = null; + public bool? ScheduleAdmin { get; set; } = null; + public bool? ArticleAdmin { get; set; } = null; } private class AjaxResponse_ProfileOrganisationsData : AjaxResponse_Data { @@ -78,13 +84,15 @@ namespace Saxonite.Net.Core.Web.Online.Controllers ColumnDfn colOpportunityCount = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Organisation_Opportunity_Count); ColumnDfn colStatus = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Status); ColumnDfn colCreatedOn = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.CreateOn_Date); + ColumnDfn colRoleCodes = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.OrganisationRoleCodes); List columns = new List() { colId, colOrganisationId , colOrganisationName, colOrganisationSportId, colOrganisationSportName, colOrganisationRegionId, colOrganisationRegionName, colMemberCount, colOpportunityCount, - colStatus, colStatus, colCreatedOn + colStatus, colStatus, colCreatedOn, + colRoleCodes }; // Sort columns. @@ -97,6 +105,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers while (resultSet != null && resultSet.HasRows && resultSet.NextRecord()) { NamedValue.Map values = resultSet.GetRecordValues(); + List roleCodes = StringListUtil.Split(values.GetString(colRoleCodes.DataName), ","); ProfileOrganisationData organisationData = new ProfileOrganisationData() { Id = values.GetLong(colId.DataName), @@ -108,6 +117,16 @@ namespace Saxonite.Net.Core.Web.Online.Controllers MemberCount = values.GetLong(colMemberCount.DataName), OpportunityCount = values.GetLong(colOpportunityCount.DataName) }; + if (roleCodes.ContainsCI(OrganisationRoleCodes.GetCodeForType(Sax.OrganisationRole.Admin))) + organisationData.Admin = true; + if (roleCodes.ContainsCI(OrganisationRoleCodes.GetCodeForType(Sax.OrganisationRole.MemberAdmin))) + organisationData.MemberAdmin = true; + if (roleCodes.ContainsCI(OrganisationRoleCodes.GetCodeForType(Sax.OrganisationRole.OpportunityAdmin))) + organisationData.OpportunitiyAdmin = true; + if (roleCodes.ContainsCI(OrganisationRoleCodes.GetCodeForType(Sax.OrganisationRole.ScheduleAdmin))) + organisationData.ScheduleAdmin = true; + if (roleCodes.ContainsCI(OrganisationRoleCodes.GetCodeForType(Sax.OrganisationRole.ArticleAdmin))) + organisationData.ArticleAdmin = true; responseData.Organisations.Add(organisationData); } } diff --git a/SaxoniteCoreWebOnline/Online/Controllers/ArticleController-Ajax.cs b/SaxoniteCoreWebOnline/Online/Controllers/ArticleController-Ajax.cs index be76719..270f1ef 100644 --- a/SaxoniteCoreWebOnline/Online/Controllers/ArticleController-Ajax.cs +++ b/SaxoniteCoreWebOnline/Online/Controllers/ArticleController-Ajax.cs @@ -145,7 +145,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers RefreshModel(model); // Organisations that the user has rights to author articles for. - foreach (SaxAccountMgr.OrganisationIdName organisation in AccountMgr.GetOrganisationsForUserRole(userAccountId, Sax.OrganisationRole.ArticleAdmin)) + foreach (SaxAccountMgr.OrganisationIdName organisation in AccountMgr.GetOrganisationsForAnyUserRole(userAccountId, new [] { Sax.OrganisationRole.Admin, Sax.OrganisationRole.ArticleAdmin })) { if (responseData.Organisations == null) responseData.Organisations = new List(); OrganisationData organisationData = new OrganisationData() @@ -450,7 +450,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers if (SysId.IsValid(organisationId)) { // Organisation specified - User must have Article Admin role. - if (!AccountMgr.UserHasOrganisationRole(userAccountId, organisationId, Sax.OrganisationRole.ArticleAdmin)) + if (!AccountMgr.UserHasAnyOrganisationRole(userAccountId, organisationId, new [] { Sax.OrganisationRole.Admin, Sax.OrganisationRole.ArticleAdmin })) { SaLogger.Warn(fn + " User does not have Article Admin role for organisation." + GetLogSuffix()); return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"])); diff --git a/SaxoniteCoreWebOnline/Online/Controllers/ArticleController.cs b/SaxoniteCoreWebOnline/Online/Controllers/ArticleController.cs index a3f7140..547bf72 100644 --- a/SaxoniteCoreWebOnline/Online/Controllers/ArticleController.cs +++ b/SaxoniteCoreWebOnline/Online/Controllers/ArticleController.cs @@ -34,7 +34,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers return RedirectToAction("", ""); // User must either be a Journalist or have Article Admin rights with at least one organisation. - List organisations = AccountMgr.GetOrganisationsForUserRole(SessionData.User.UserAccountId, Sax.OrganisationRole.ArticleAdmin); + List organisations = AccountMgr.GetOrganisationsForAnyUserRole(SessionData.User.UserAccountId, new [] { Sax.OrganisationRole.Admin, Sax.OrganisationRole.ArticleAdmin }); if (organisations.Count < 1 && !UserIsJournalist) return RedirectToAction("", ""); diff --git a/SaxoniteCoreWebOnline/Online/Controllers/OrganisationController-Ajax-Members.cs b/SaxoniteCoreWebOnline/Online/Controllers/OrganisationController-Ajax-Members.cs index 3447e13..d5fee26 100644 --- a/SaxoniteCoreWebOnline/Online/Controllers/OrganisationController-Ajax-Members.cs +++ b/SaxoniteCoreWebOnline/Online/Controllers/OrganisationController-Ajax-Members.cs @@ -104,17 +104,20 @@ namespace Saxonite.Net.Core.Web.Online.Controllers if (!ValidUserSession) return GetAjaxResult_InvalidSession(responseData); RefreshModel(model); - // Organisation. - SysId organisationId = model.ExtractSysId(model.Filter.OrganisationId); - SaxOrganisation organisation = AccountMgr.GetOrganisationById(organisationId); - if (organisation == null || !organisation.IsStatusActive) + // Record disposable items as they are created so all can be disposed when needed. + using (DisposableCollection disposableItems = new DisposableCollection()) { - SaLogger.Warn(fn + " " + (organisation == null ? "Invalid" : "Inactive") + " organisation for Member list. OrganisationId: '" + model.Filter.OrganisationId + "'"); - return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"])); - } - if (organisation != null) - { + // Organisation. + SysId organisationId = model.ExtractSysId(model.Filter.OrganisationId); + SaxOrganisation organisation = AccountMgr.GetOrganisationById(organisationId); + disposableItems.Add(organisation); + if (organisation == null || !organisation.IsStatusActive) + { + SaLogger.Warn(fn + " " + (organisation == null ? "Invalid" : "Inactive") + " organisation for Member list. OrganisationId: '" + model.Filter.OrganisationId + "'"); + return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"])); + } + // Store filter data. SessionData_Online.Filter.SetMemberOrganisation(organisation); @@ -124,11 +127,11 @@ namespace Saxonite.Net.Core.Web.Online.Controllers responseData.Titles.Add(title.Code, title.Desc); // Reference data - member roles. - foreach (TypeCodeDesc memberRole in OrganisationRoleCodes.FindAll( item => item.Type != (int)Sax.OrganisationRole.Member)) + foreach (TypeCodeDesc memberRole in OrganisationRoleCodes.FindAll(item => item.Type != (int)Sax.OrganisationRole.Member)) responseData.MemberRoles.Add(memberRole.Code, Localiser.GetOrganisationRoleCaption((Sax.OrganisationRole)memberRole.Type)); // Session User roles. - responseData.User.CanManage = AccountMgr.UserHasOrganisationRole(SessionData.User.UserAccountId, organisationId, Sax.OrganisationRole.MemberAdmin); + responseData.User.CanManage = AccountMgr.UserHasAnyOrganisationRole(SessionData.User.UserAccountId, organisation.Id, new List { Sax.OrganisationRole.Admin, Sax.OrganisationRole.MemberAdmin }); // Item filter. SaxUserOrganisation.Params prmMember = new SaxUserOrganisation.Params(); @@ -150,11 +153,11 @@ namespace Saxonite.Net.Core.Web.Online.Controllers ColumnDfn colAdminComment = responseData.User.CanManage ? AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.AdminComment) : new ColumnDfn(-1, ""); ColumnDfn colCreatedOn = AccountMgr.GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.CreateOn_Date); List columns = new List() - { - colId, colUserAccountId , colEmailAddress, colDisplayName, - colOrganisationRoleCodes, colUserStatus, - colAdminComment, colCreatedOn - }; + { + colId, colUserAccountId , colEmailAddress, colDisplayName, + colOrganisationRoleCodes, colUserStatus, + colAdminComment, colCreatedOn + }; // Sort columns. colCreatedOn.SortAscending = false; @@ -230,9 +233,13 @@ namespace Saxonite.Net.Core.Web.Online.Controllers if (!SysId.IsValid(memberId)) return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.specified"])); - // Retrieve item. - using (SaxUserOrganisation userOrganisation = AccountMgr.GetUserOrganisationById(memberId)) + // Record disposable items as they are created so all can be disposed when needed. + using (DisposableCollection disposableItems = new DisposableCollection()) { + + // Retrieve item. + SaxUserOrganisation userOrganisation = AccountMgr.GetUserOrganisationById(memberId); + disposableItems.Add(userOrganisation); if (userOrganisation == null) { SaLogger.Warn(fn + " Failed to retrieve Organisation Member for Id: '" + model.MemberId + "'"); @@ -240,33 +247,31 @@ namespace Saxonite.Net.Core.Web.Online.Controllers } // Validate organisation. - using (SaxOrganisation organisation = AccountMgr.GetOrganisationById(userOrganisation.OrganisationId)) + SaxOrganisation organisation = AccountMgr.GetOrganisationById(userOrganisation.OrganisationId); + disposableItems.Add(organisation); + if (organisation == null || !organisation.IsStatusActive) { - if (organisation == null || !organisation.IsStatusActive) - { - SaLogger.Warn(fn + " " + (organisation == null ? "Invalid" : "Inactive") + " Organisation for Member. Id: '" + userOrganisation.OrganisationId + "'"); - return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"])); - } - - // Session User roles. - bool userCanManageMembers = AccountMgr.UserHasOrganisationRole(SessionData.User.UserAccountId, organisation.Id, Sax.OrganisationRole.MemberAdmin); - - // Validate user account. - using (SaxUserAccount userAccount = AccountMgr.GetUserAccountById(userOrganisation.UserAccountId)) - { - bool userActive = userAccount.IsStatusActive || (userAccount.IsStatusAwaiting && userCanManageMembers); - if (userAccount == null || !userActive) - { - SaLogger.Warn(fn + " " + (organisation == null ? "Invalid" : "Inactive") + " User Account for Member. Id: '" + userOrganisation.UserAccountId + "'"); - return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"])); - } - - // Make a note of the selected Organisation. - SessionData_Online.Filter.SetMemberOrganisation(organisation); - - PopulateMemberResponseData(model, userOrganisation, userAccount, organisation, responseData.Member); - } + SaLogger.Warn(fn + " " + (organisation == null ? "Invalid" : "Inactive") + " Organisation for Member. Id: '" + userOrganisation.OrganisationId + "'"); + return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"])); } + + // Session User roles. + bool userCanManageMembers = AccountMgr.UserHasAnyOrganisationRole(SessionData.User.UserAccountId, organisation.Id, new List { Sax.OrganisationRole.Admin, Sax.OrganisationRole.MemberAdmin }); + + // Validate user account. + SaxUserAccount userAccount = AccountMgr.GetUserAccountById(userOrganisation.UserAccountId); + disposableItems.Add(userAccount); + bool userActive = userAccount.IsStatusActive || (userAccount.IsStatusAwaiting && userCanManageMembers); + if (userAccount == null || !userActive) + { + SaLogger.Warn(fn + " " + (organisation == null ? "Invalid" : "Inactive") + " User Account for Member. Id: '" + userOrganisation.UserAccountId + "'"); + return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"])); + } + + // Make a note of the selected Organisation. + SessionData_Online.Filter.SetMemberOrganisation(organisation); + + PopulateMemberResponseData(model, userOrganisation, userAccount, organisation, responseData.Member); } // Construct response. @@ -361,7 +366,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers } // Ensure that the user has the correct role to update Members for this organisation. - bool userCanManageMembers = AccountMgr.UserHasOrganisationRole(SessionData.User.UserAccountId, organisationId, Sax.OrganisationRole.MemberAdmin); + bool userCanManageMembers = AccountMgr.UserHasAnyOrganisationRole(SessionData.User.UserAccountId, organisationId, new List { Sax.OrganisationRole.Admin, Sax.OrganisationRole.MemberAdmin }); if (!userCanManageMembers) { SaLogger.Warn(fn + " User doesn't have 'Member Admin' role for Organisation Id: " + organisationId); @@ -385,6 +390,23 @@ namespace Saxonite.Net.Core.Web.Online.Controllers SaLogger.Warn(fn + " Inconsistent User Account Id specified for User Organisation. Expected: " + userOrganisation.UserAccountId + ". Found: " + userAccount.Id); return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"])); } + + // Validate roles for current user. + if (userOrganisation.UserAccountId.Equals(SessionData.User.UserAccountId)) + { + // User is modifying their own organisation member. + if (userOrganisation.CanManageOrganisation && !model.OrganisationRoleCodes.Any(item => item.Type == (int)Sax.OrganisationRole.Admin)) + { + // User has removed their own 'Admin' role. + SaLogger.Warn(fn + " Unable to store member - user is attempting to remove their own 'Admin' role."); + return Json(responseData.SetMessage(messageTitle, Localiser["organisation.members.msg.remove.own.admin.role"])); + } + if (!userOrganisation.CanManageMembers) + { + SaLogger.Warn(fn + " Unable to store member - user is attempting to remove their own 'Admin' and/or 'Member Admin' role."); + return Json(responseData.SetMessage(messageTitle, Localiser["organisation.members.msg.remove.own.admin.role"])); + } + } } // New member - Lookup user by email and create new account if needed. @@ -458,17 +480,6 @@ namespace Saxonite.Net.Core.Web.Online.Controllers // Ensure user has member role. userOrganisation.AddOrganisationRole(Sax.OrganisationRole.Member); - // Validate roles. - if (userOrganisation.UserAccountId.Equals(SessionData.User.UserAccountId)) - { - // User is modifying their own member. - if (!userOrganisation.HasOrganisationRole(Sax.OrganisationRole.MemberAdmin)) - { - SaLogger.Warn(fn + " Unable to store member - user is attempting to remove their own 'Member Admin' role."); - return Json(responseData.SetMessage(messageTitle, Localiser["organisation.members.msg.remove.own.admin.role"])); - } - } - // User organisation properties. if (model.MemberAdminComment != null) userOrganisation.AdminComment = model.MemberAdminComment; @@ -548,7 +559,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers } // Ensure that the user has the correct role to update Members for this organisation. - bool userCanManageMembers = AccountMgr.UserHasOrganisationRole(SessionData.User.UserAccountId, organisation.Id, Sax.OrganisationRole.MemberAdmin); + bool userCanManageMembers = AccountMgr.UserHasAnyOrganisationRole(SessionData.User.UserAccountId, organisation.Id, new List { Sax.OrganisationRole.Admin, Sax.OrganisationRole.MemberAdmin }); if (!userCanManageMembers) { SaLogger.Warn(fn + " User doesn't have 'Member Admin' role for Organisation Id: " + organisation.Id); @@ -664,7 +675,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers } // Ensure that the user has the correct role to update Members for this organisation. - bool userCanManageMembers = AccountMgr.UserHasOrganisationRole(SessionData.User.UserAccountId, organisation.Id, Sax.OrganisationRole.MemberAdmin); + bool userCanManageMembers = AccountMgr.UserHasAnyOrganisationRole(SessionData.User.UserAccountId, organisation.Id, new List { Sax.OrganisationRole.Admin, Sax.OrganisationRole.MemberAdmin }); if (!userCanManageMembers) { SaLogger.Warn(fn + " User doesn't have 'Member Admin' role for Organisation Id: " + organisation.Id); diff --git a/SaxoniteCoreWebOnline/Online/Controllers/OrganisationController-Ajax-Opportunities.cs b/SaxoniteCoreWebOnline/Online/Controllers/OrganisationController-Ajax-Opportunities.cs index 251a619..0a1e7bb 100644 --- a/SaxoniteCoreWebOnline/Online/Controllers/OrganisationController-Ajax-Opportunities.cs +++ b/SaxoniteCoreWebOnline/Online/Controllers/OrganisationController-Ajax-Opportunities.cs @@ -154,7 +154,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers responseData.Organisation.RegionName = model.GetRegionCaption(organisation.RegionIdPrimary); // User details. - responseData.User.CanManage = userOrganisation?.HasOrganisationRole(Sax.OrganisationRole.OpportunityAdmin) ?? false; + responseData.User.CanManage = userOrganisation.CanManageOpportunities; // Item filter. SaxOrganisationOpportunity.Params prmOpportunity = new SaxOrganisationOpportunity.Params(); @@ -354,7 +354,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers } // Ensure that the user has the correct role to update Opportunities for this organisation. - if (!AccountMgr.UserHasOrganisationRole(SessionData.User.UserAccountId, organisationId, Sax.OrganisationRole.OpportunityAdmin)) + if (!AccountMgr.UserHasAnyOrganisationRole(SessionData.User.UserAccountId, organisationId, new [] { Sax.OrganisationRole.Admin, Sax.OrganisationRole.OpportunityAdmin })) { SaLogger.Warn(fn + " User doesn't have 'Opportunity Admin' role for Organisation Id: " + organisationId); return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"])); diff --git a/SaxoniteCoreWebOnline/Online/Controllers/OrganisationController-Ajax-Request.cs b/SaxoniteCoreWebOnline/Online/Controllers/OrganisationController-Ajax-Request.cs index f2b4050..71a5b40 100644 --- a/SaxoniteCoreWebOnline/Online/Controllers/OrganisationController-Ajax-Request.cs +++ b/SaxoniteCoreWebOnline/Online/Controllers/OrganisationController-Ajax-Request.cs @@ -152,7 +152,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers // Add user as member of organisation. SaxUserOrganisation userOrganisation = AccountMgr.CreateUserOrganisation(userAccount.Id, organisation.Id); - userOrganisation.OrganisationRoles = new List() { Sax.OrganisationRole.Member, Sax.OrganisationRole.MemberAdmin }; + userOrganisation.OrganisationRoles = new [] { Sax.OrganisationRole.Member, Sax.OrganisationRole.Admin }; if (!AccountMgr.InsertUserOrganisation(userOrganisation, DbUpdateInfo)) { SaLogger.Warn(fn + " Failed to insert user organisation - " + AccountMgr.ErrorStateMessage); @@ -181,7 +181,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers } // Complete response. - responseData.SetMessage(messageTitle, Localiser["msg.organisation.request.success"].ToString().ReplaceAll("\n", "
")); + responseData.SetMessage(messageTitle, Localiser["msg.organisation.request.success"].ToString().ReplaceAll("\n", "

")); responseData.Success = true; return Json(responseData); } diff --git a/SaxoniteCoreWebOnline/Online/Models/SaxModel_Online.cs b/SaxoniteCoreWebOnline/Online/Models/SaxModel_Online.cs index dc52025..c64afb2 100644 --- a/SaxoniteCoreWebOnline/Online/Models/SaxModel_Online.cs +++ b/SaxoniteCoreWebOnline/Online/Models/SaxModel_Online.cs @@ -22,8 +22,9 @@ namespace Saxonite.Net.Core.Web.Online.Models //------------------------------------------------------------------- // Data members. private bool? userCanManageOrganisationMembers = null; - private bool? userCanManageOrganisationArticles = null; private bool? userCanManageOrganisationOpportunities = null; + private bool? userCanManageOrganisationSchedule = null; + private bool? userCanManageOrganisationArticles = null; //------------------------------------------------------------------- // Protected construction. @@ -51,29 +52,14 @@ namespace Saxonite.Net.Core.Web.Online.Models SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params(); prmUserOrganisation.UserAccountIdsIncluded.Add(SessionData.User.UserAccountId); prmUserOrganisation.OrganisationMembersOnly = true; - prmUserOrganisation.OrganisationRoles.Add(Sax.OrganisationRole.OpportunityAdmin); + prmUserOrganisation.OrganisationRolesAny.Add(Sax.OrganisationRole.Admin); + prmUserOrganisation.OrganisationRolesAny.Add(Sax.OrganisationRole.MemberAdmin); prmUserOrganisation.StatusCat = SaxUserOrganisation.StatusCat.ActiveOnly; userCanManageOrganisationMembers = (AccountMgr.GetUserOrganisationCount(prmUserOrganisation) > 0); } return userCanManageOrganisationMembers == true ? true : false; } } - public bool UserCanManageOrganisationArticles - { - get - { - if (userCanManageOrganisationArticles == null && ValidUserSession) - { - SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params(); - prmUserOrganisation.UserAccountIdsIncluded.Add(SessionData.User.UserAccountId); - prmUserOrganisation.OrganisationMembersOnly = true; - prmUserOrganisation.OrganisationRoles.Add(Sax.OrganisationRole.ArticleAdmin); - prmUserOrganisation.StatusCat = SaxUserOrganisation.StatusCat.ActiveOnly; - userCanManageOrganisationArticles = (AccountMgr.GetUserOrganisationCount(prmUserOrganisation) > 0); - } - return userCanManageOrganisationArticles == true ? true : false; - } - } public bool UserCanManageOrganisationOpportunities { get @@ -83,13 +69,48 @@ namespace Saxonite.Net.Core.Web.Online.Models SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params(); prmUserOrganisation.UserAccountIdsIncluded.Add(SessionData.User.UserAccountId); prmUserOrganisation.OrganisationMembersOnly = true; - prmUserOrganisation.OrganisationRoles.Add(Sax.OrganisationRole.OpportunityAdmin); + prmUserOrganisation.OrganisationRolesAny.Add(Sax.OrganisationRole.Admin); + prmUserOrganisation.OrganisationRolesAny.Add(Sax.OrganisationRole.OpportunityAdmin); prmUserOrganisation.StatusCat = SaxUserOrganisation.StatusCat.ActiveOnly; userCanManageOrganisationOpportunities = (AccountMgr.GetUserOrganisationCount(prmUserOrganisation) > 0); } return userCanManageOrganisationOpportunities == true ? true : false; } } + public bool UserCanManageOrganisationSchedule + { + get + { + if (userCanManageOrganisationSchedule == null && ValidUserSession) + { + SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params(); + prmUserOrganisation.UserAccountIdsIncluded.Add(SessionData.User.UserAccountId); + prmUserOrganisation.OrganisationMembersOnly = true; + prmUserOrganisation.OrganisationRolesAny.Add(Sax.OrganisationRole.Admin); + prmUserOrganisation.OrganisationRolesAny.Add(Sax.OrganisationRole.ScheduleAdmin); + prmUserOrganisation.StatusCat = SaxUserOrganisation.StatusCat.ActiveOnly; + userCanManageOrganisationSchedule = (AccountMgr.GetUserOrganisationCount(prmUserOrganisation) > 0); + } + return userCanManageOrganisationSchedule == true ? true : false; + } + } + public bool UserCanManageOrganisationArticles + { + get + { + if (userCanManageOrganisationArticles == null && ValidUserSession) + { + SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params(); + prmUserOrganisation.UserAccountIdsIncluded.Add(SessionData.User.UserAccountId); + prmUserOrganisation.OrganisationMembersOnly = true; + prmUserOrganisation.OrganisationRolesAny.Add(Sax.OrganisationRole.Admin); + prmUserOrganisation.OrganisationRolesAny.Add(Sax.OrganisationRole.ArticleAdmin); + prmUserOrganisation.StatusCat = SaxUserOrganisation.StatusCat.ActiveOnly; + userCanManageOrganisationArticles = (AccountMgr.GetUserOrganisationCount(prmUserOrganisation) > 0); + } + return userCanManageOrganisationArticles == true ? true : false; + } + } //------------------------------------------------------------------- // Item Id Obfuscation. diff --git a/SaxoniteCoreWebOnline/Views/Common/OrganisationRequest.cshtml b/SaxoniteCoreWebOnline/Views/Common/OrganisationRequest.cshtml index da45731..4a3083e 100644 --- a/SaxoniteCoreWebOnline/Views/Common/OrganisationRequest.cshtml +++ b/SaxoniteCoreWebOnline/Views/Common/OrganisationRequest.cshtml @@ -1,13 +1,13 @@ @model SaxModel_Online @inject SaxLocaliser Localiser @{ - int regionIdCountry = Model.ValidUserSession ? Model.SessionData.User.RegionIdCountry.ToInt() : 0; + String regionIdCountry = Model.ValidUserSession ? Model.SessionData.User.RegionIdCountry.ToString() : ""; String regionNameCountry = Model.ValidUserSession ? Localiser.EscapeJavascriptText(Model.GetRegionCaption(Model.SessionData.User.RegionIdCountry)) : ""; } @@ -28,47 +28,52 @@ @* Contact Email Address *@
-
- +
+
+
+ +
+
+
+
+ +
+
+
-
- -
-
- -
+
@* No label. *@
+
@* Contact First Name *@ -
-
- +
+
+
+ +
+
+ +
+
-
- -
-
-
- -
- @* Contact Last Name *@ -
-
- +
+
+
+ +
+
+ +
+
-
- -
-
-
} @@ -81,147 +86,202 @@ @* Organisation name *@
-
- +
+
+
+ +
+
+
+
+ +
+
+
-
- -
-
- -
+
+
@* Organisation category *@ -
-
- +
+
+
+ +
+
+ @Html.DropDownList("", Model.OrganisationCategoriesForSelect, Localiser["label.select"], new { @id = "cbOrganisationCategory", @name = "OrganisationCategory", @class = "OrganisationCategory sax-select" }) +
+
-
- @Html.DropDownList("", Model.OrganisationCategoriesForSelect, Localiser["label.select"], new { @id = "cbOrganisationCategory", @name = "OrganisationCategory", @class = "OrganisationCategory sax-select" }) -
-
-
- -
- @* Organisation type *@ -
-
- +
+
+
+ +
+
+ @Html.DropDownList("", Model.OrganisationTypesForSelect, Localiser["label.select"], new { @id = "cbOrganisationType", @name = "OrganisationType", @class = "OrganisationType sax-select" }) +
+
-
- @Html.DropDownList("", Model.OrganisationTypesForSelect, Localiser["label.select"], new { @id = "cbOrganisationType", @name = "OrganisationType", @class = "OrganisationType sax-select" }) -
-
-
@* Organisation sport *@
-
- +
+
+
+ +
+
+
+
+ +
+
+
+
+
-
- -
-
-
-
@* Organisation country *@
-
- +
+
+
+ +
+
+
+
+ +
+
+
+
+
-
- -
-
-
-
@* Organisation address - Line 1 *@
-
- +
+
+
+ +
+
+
+
+
+
+
+
-
-
-
-
@* Organisation address - Line 2 *@
-
-
+
+
+
+
+
+
+
+
-
@* Organisation address - Line 3 *@
-
-
+
+
+
+
+
+
+
+
-
@* Organisation address - Town *@
-
- +
+
+
+ +
+
+
+
+
+
+
+
-
-
-
-
@* Organisation address - Province *@
-
- +
+
+
+ +
+
+
+
+
+
+
+
-
-
-
-
@* Organisation address - PostalCode *@
-
- +
+
+
+ +
+
+
+
+
+
+
+
-
-
-
-
@* Organisation PhoneMain *@ - @* -
-
- +
+
+
+
+ +
-
-
+
+
+
+
+
-
- *@ +
} diff --git a/SaxoniteCoreWebOnline/wwwroot/css/sax-form.css b/SaxoniteCoreWebOnline/wwwroot/css/sax-form.css index 90ba3f1..7da78a6 100644 --- a/SaxoniteCoreWebOnline/wwwroot/css/sax-form.css +++ b/SaxoniteCoreWebOnline/wwwroot/css/sax-form.css @@ -205,18 +205,19 @@ .sax-form .sax-form-control .sax-message { display: none; - margin-top: 8px; + margin-top: 4px; padding-left: 24px; - font-size: 16px; + font-size: 1.00Rem; background-position: left top; background-repeat: no-repeat; } .sax-form .sax-form-control.sax-error .sax-message { + min-height:16px; display: block; color: #e3120b; - background-image: url("../img/icon/error-18.png"); + background-image: url("../img/icon/error-16.png"); } /* Buttons */ diff --git a/SaxoniteCoreWebOnline/wwwroot/img/icon/error-16.png b/SaxoniteCoreWebOnline/wwwroot/img/icon/error-16.png new file mode 100644 index 0000000000000000000000000000000000000000..8a5b8f77578f5caf45fb0b108993e2b345e99acb GIT binary patch literal 462 zcmV;<0WtoGP)Mg_q_8}DKf z!~~*T4v9O?J2ae|Qxh`W!0ya@vwJgd6_wcCG));B)X3^3?0s$T{dRUUOZ4VqRdMqy z#4ejHV%j97=G0f7@i9MXro#y@-Jf}(*MR~_HJm3_XR@pd{8Tc>9@|^wK9pXO*oMT` zWqU=6*A`mc#*dSe$Xv#eX+BoXD*a-}0VCK8aQcZx#q3D%-6h9SxC?iS02>P@4>XA; zrD~E?%!zxV#LwYw99VF`)maqO(J=fo4Qs#(rxyh^jZvZ7-whkafCZ;#^|JpLkd<`& zAM;7u2bP-osH8{5_#D4_-~M!ht$9b%707*qoM6N<$ Ef&mb}l>h($ literal 0 HcmV?d00001 diff --git a/SaxoniteCoreWebOnline/wwwroot/js/sax-org-opp.js b/SaxoniteCoreWebOnline/wwwroot/js/sax-org-opp.js index d0890eb..6e72a6d 100644 --- a/SaxoniteCoreWebOnline/wwwroot/js/sax-org-opp.js +++ b/SaxoniteCoreWebOnline/wwwroot/js/sax-org-opp.js @@ -185,10 +185,6 @@ $('#ifOpportunityId,#ifOpportunityExists,#ifOpportunityRegionId,#ifOpportunitySportId,input[type="text"],textarea,select', $frm.opportunity).val(''); sax.clearControlErrors(); } - sax.doCreateItem = function () - { - sax.storeItem(); - } //-------------------------------------------------------------- sax.updateItem = function (item) @@ -219,10 +215,6 @@ $dlg.opportunity.dialog('option', 'title', sax.dlg.title.updateOpportunity); sax.openDialog($dlg.opportunity, 600, 600); } - sax.doUpdateItem = function () - { - sax.storeItem(); - } //-------------------------------------------------------------- sax.storeItem = function () @@ -263,7 +255,7 @@ $('.sax-input', $frm.opportunity).on('input', function () { sax.clearControlError(this); }); var opt = sax.dlgOpts(); - opt.buttons[sax.dlg.btn.ok] = function () { sax.doCreateItem(); }; + opt.buttons[sax.dlg.btn.ok] = function () { sax.storeItem(); }; opt.buttons[sax.dlg.btn.cancel] = function () { $(this).dialog('close'); }; $dlg.opportunity = $('#dlgOpportunity').dialog(opt); diff --git a/SaxoniteCoreWebOnline/wwwroot/js/sax-usr-org.js b/SaxoniteCoreWebOnline/wwwroot/js/sax-usr-org.js index 3026f52..624cb07 100644 --- a/SaxoniteCoreWebOnline/wwwroot/js/sax-usr-org.js +++ b/SaxoniteCoreWebOnline/wwwroot/js/sax-usr-org.js @@ -5,16 +5,16 @@ (function (win, doc, undef) { "use strict"; - let $pnl = sax.$pnl, $dlg = sax.$dlg, $frm = sax.$frm; + let po = sax.mdl.profileOrganisations = sax.mdl.profileOrganisations || { $pnl: {}, $dlg: {}, $frm: {} }; + let $pnl = po.$pnl, $dlg = po.$dlg, $frm = po.$frm; //-------------------------------------------------------------- sax.refreshProfileOrganisationsInfo = function (delay) { - var $section = $('.sax-panel-section.ProfileOrganisations'); - $section.removeClass('sax-edit').addClass('sax-populating'); - $('.sax-property', $section).hide(); - sax.showDataRefreshingMsg($section); - sax.refreshProfileOrganisations(sax.onRefreshProfileOrganisationsInfo); + $pnl.section.removeClass('sax-edit').addClass('sax-populating'); + $('.sax-property', $pnl.section).hide(); + sax.showDataRefreshingMsg($pnl.section); + sax.refreshProfileOrganisations(po.onRefreshProfileOrganisationsInfo); } sax.refreshProfileOrganisations = function (callbackFn) { @@ -24,17 +24,16 @@ sax.ajax.profileOrganisations.callbackFn = callbackFn; sax.doAjaxRequest(sax.ajax.profileOrganisations, 50); } - sax.onRefreshProfileOrganisationsInfo = function (response) + po.onRefreshProfileOrganisationsInfo = function (response) { - //sax.debug('onRefreshProfileOrganisationsInfo', response); + sax.debug('onRefreshProfileOrganisationsInfo', response); if (!response || !response.success) return; - var $section = $('.sax-panel-section.ProfileOrganisations'); - $('.sax-message', $section).stop(true, false).fadeOut(200).empty(); + $('.sax-message', $pnl.section).stop(true, false).fadeOut(200).empty(); let items = response.organisations; if (!items) return; - let $items = $('.sax-panel-results.Organisations', $section).empty(); - let $tmpl = $('.sax-panel-item-template .sax-panel-item.Organisation', $section); + let $items = $('.sax-panel-results.Organisations', $pnl.section).empty(); + let $tmpl = $('.sax-panel-item-template .sax-panel-item.Organisation', $pnl.section); for (let itemIdx = 0; itemIdx < items.length; itemIdx++) { let item = items[itemIdx]; @@ -47,13 +46,16 @@ $items.append($item); } $items.show(); - sax.showNoInfoMsg($section); - $section.removeClass('sax-populating'); + sax.showNoInfoMsg($pnl.section); + $pnl.section.removeClass('sax-populating'); } + //-------------------------------------------------------------- + //-------------------------------------------------------------- $(function () { + $pnl.section = $('.sax-panel-section.ProfileOrganisations'); }); //-------------------------------------------------------------- diff --git a/SaxoniteStandardBase/Base/App/Sax-Version.cs b/SaxoniteStandardBase/Base/App/Sax-Version.cs index 89d2d16..cb07fcd 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.8.0"; + private static String version { get; } = "1.2.0.0"; // Retrieve version. public static String GetFullVersion () { return version; } public static String GetAppVersion () @@ -40,8 +40,11 @@ namespace Saxonite.Net.Standard.Base.App //------------------------------------------------------------------- // Version history. //------------------------------------------------------------------- + // 1.2.0 1-Nov-2021 'Admin' Organisation role + // - 'Admin' Organisation role + // - Azure App Service configuration. // 1.1.8 21-Oct-2021 Online Users Search - // - ONlien Search - Users. + // - Online Search - Users. // - Admin Account Users filter. // 1.1.7 14-Oct-2021 Online Organisation Search // - Online Profile Sport About & snags. diff --git a/SaxoniteStandardBase/Base/App/Sax.cs b/SaxoniteStandardBase/Base/App/Sax.cs index 8c4d2d1..d9f4138 100644 --- a/SaxoniteStandardBase/Base/App/Sax.cs +++ b/SaxoniteStandardBase/Base/App/Sax.cs @@ -232,6 +232,7 @@ namespace Saxonite.Net.Standard.Base.App Unknown = 0, /* Do not change the values/codes - tied to database. */ Member, + Admin, MemberAdmin, ScheduleAdmin, OpportunityAdmin, diff --git a/SaxoniteStandardBase/Base/App/SaxSystem-Statics.cs b/SaxoniteStandardBase/Base/App/SaxSystem-Statics.cs index 2edd137..a4b94d9 100644 --- a/SaxoniteStandardBase/Base/App/SaxSystem-Statics.cs +++ b/SaxoniteStandardBase/Base/App/SaxSystem-Statics.cs @@ -144,10 +144,11 @@ namespace Saxonite.Net.Standard.Base.App //--------------------------------------------------------------- // Organisation roles. organisationRoleCodes.Add(Sax.OrganisationRole.Member, "MBR", "Member"); - organisationRoleCodes.Add(Sax.OrganisationRole.MemberAdmin, "MBA", "Member Admin"); - organisationRoleCodes.Add(Sax.OrganisationRole.ScheduleAdmin, "SCA", "Schedule Admin"); - organisationRoleCodes.Add(Sax.OrganisationRole.OpportunityAdmin, "OPA", "Opportunity Admin"); - organisationRoleCodes.Add(Sax.OrganisationRole.ArticleAdmin, "ARA", "Article Admin"); + organisationRoleCodes.Add(Sax.OrganisationRole.Admin, "ADM", "Admin"); + organisationRoleCodes.Add(Sax.OrganisationRole.MemberAdmin, "MBA", "Members"); + organisationRoleCodes.Add(Sax.OrganisationRole.ScheduleAdmin, "SCA", "Schedule"); + organisationRoleCodes.Add(Sax.OrganisationRole.OpportunityAdmin, "OPA", "Opportunities"); + organisationRoleCodes.Add(Sax.OrganisationRole.ArticleAdmin, "ARA", "Articles"); //--------------------------------------------------------------- // Opportunity types. diff --git a/SaxoniteStandardBase/Base/Bus/SaxUserOrganisation.cs b/SaxoniteStandardBase/Base/Bus/SaxUserOrganisation.cs index 3557cb1..a1ef2b9 100644 --- a/SaxoniteStandardBase/Base/Bus/SaxUserOrganisation.cs +++ b/SaxoniteStandardBase/Base/Bus/SaxUserOrganisation.cs @@ -101,9 +101,9 @@ namespace Saxonite.Net.Standard.Base.Bus if (!Changed) Changed = !data.OrganisationRoles.IsEmpty(); data.OrganisationRoles.Clear(); } - public bool HasOrganisationRole(Sax.OrganisationRole organisationRole) + public bool HasAnyOrganisationRole(IEnumerable organisationRoles) { - return data.OrganisationRoles.Contains(organisationRole); + return data.OrganisationRoles.Any(item => organisationRoles.Contains(item)); } public void AddOrganisationRole(Sax.OrganisationRole organisationRole) { @@ -114,7 +114,7 @@ namespace Saxonite.Net.Standard.Base.Bus } } /// Store organisation roles. - public List OrganisationRoles + public IEnumerable OrganisationRoles { set { @@ -240,6 +240,16 @@ namespace Saxonite.Net.Standard.Base.Bus { return GetOrganisationRoleCodes().Concat(UserOrgnisationRoleDelim); } + // Query roles. + public bool CanManageOrganisation{ get { return HasAnyOrganisationRole(new [] { Sax.OrganisationRole.Admin }); } } + public bool CanManageMembers { get { return HasAnyOrganisationRole(new [] { Sax.OrganisationRole.Admin, Sax.OrganisationRole.MemberAdmin }); } } + public bool CanManageOpportunities { get { return HasAnyOrganisationRole(new [] { Sax.OrganisationRole.Admin, Sax.OrganisationRole.OpportunityAdmin }); } } + public bool CanManageSchedule { get { return HasAnyOrganisationRole(new [] { Sax.OrganisationRole.Admin, Sax.OrganisationRole.ScheduleAdmin }); } } + public bool CanManageArticles { get { return HasAnyOrganisationRole(new [] { Sax.OrganisationRole.Admin, Sax.OrganisationRole.ArticleAdmin }); } } + public bool HasAnyOrganisationRole(IEnumerable organisationRoles) + { + return data.HasAnyOrganisationRole(organisationRoles); + } //------------------------------------------------------------------- // Properties. @@ -290,7 +300,7 @@ namespace Saxonite.Net.Standard.Base.Bus return data.GetOrganisationRoles(); } /// Store Organisation Roles. - public List OrganisationRoles + public IEnumerable OrganisationRoles { set { data.OrganisationRoles = value; } } @@ -298,10 +308,6 @@ namespace Saxonite.Net.Standard.Base.Bus { data.ClearOrganisationRoles(); } - public bool HasOrganisationRole(Sax.OrganisationRole organisationRole) - { - return data.HasOrganisationRole(organisationRole); - } public void AddOrganisationRole(Sax.OrganisationRole organisationRole) { data.AddOrganisationRole(organisationRole); @@ -347,6 +353,7 @@ namespace Saxonite.Net.Standard.Base.Bus /// Set true to restruct to User Organisations with at least one Organisation Role. public bool OrganisationMembersOnly { get; set; } public List OrganisationRoles { get; } = new List(); + public List OrganisationRolesAny { get; } = new List(); // Common properties. public String NotesPartial { get; set; } public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted; diff --git a/SaxoniteStandardBase/Base/Mgr/SaxAccountMgr-UserOrganisation.cs b/SaxoniteStandardBase/Base/Mgr/SaxAccountMgr-UserOrganisation.cs index 12eeaec..2d24711 100644 --- a/SaxoniteStandardBase/Base/Mgr/SaxAccountMgr-UserOrganisation.cs +++ b/SaxoniteStandardBase/Base/Mgr/SaxAccountMgr-UserOrganisation.cs @@ -39,8 +39,16 @@ namespace Saxonite.Net.Standard.Base.Mgr /// public bool UserHasOrganisationRole(SysId userAccountId, SysId organisationId, Sax.OrganisationRole organisationRole, SaxUserOrganisation.StatusCat statusCat = SaxUserOrganisation.StatusCat.ActiveOnly) { - if (!SysId.IsValid(userAccountId) || !SysId.IsValid(organisationId) || organisationRole <= 0) return false; - return GetOrganisationRolesForUser(userAccountId, organisationId, statusCat).Contains(organisationRole); + return UserHasAnyOrganisationRole(userAccountId, organisationId, new [] { organisationRole }, statusCat); + } + + /// + /// Does the user have any of the specified roles with the organisation. + /// + public bool UserHasAnyOrganisationRole(SysId userAccountId, SysId organisationId, IEnumerable organisationRoles, SaxUserOrganisation.StatusCat statusCat = SaxUserOrganisation.StatusCat.ActiveOnly) + { + if (!SysId.IsValid(userAccountId) || !SysId.IsValid(organisationId) || organisationRoles.IsEmpty() || !organisationRoles.Any(item => item > 0)) return false; + return GetOrganisationRolesForUser(userAccountId, organisationId, statusCat).Any(item => organisationRoles.Contains(item)); } /// @@ -67,24 +75,40 @@ namespace Saxonite.Net.Standard.Base.Mgr } /// - /// Get list of organisation Ids that the user has the specified role with. + /// Get list of organisation Ids and names that the user has the specified role with. /// public List GetOrganisationsForUserRole(SysId userAccountId, Sax.OrganisationRole organisationRole, SaxUserOrganisation.StatusCat statusCat = SaxUserOrganisation.StatusCat.ActiveOnly) { - List organisationsData = new List(); - String organisationRoleCode = Internals.OrganisationRoleCodes.GetCodeForType(organisationRole); - if (!SysId.IsValid(userAccountId) || StringUtil.IsEmpty(organisationRoleCode)) return organisationsData; - // Columns. - ColumnDfn colOrganisationId = GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.OrganisationId); - ColumnDfn colOrganisationName = GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Organisation_Name); + return GetOrganisationsForAnyUserRole(userAccountId, new [] { organisationRole }, statusCat); + } + + /// + /// Get list of organisation Ids and names that the user has any of the specified roles with. + /// + public List GetOrganisationsForAnyUserRole(SysId userAccountId, IEnumerable organisationRoles, SaxUserOrganisation.StatusCat statusCat = SaxUserOrganisation.StatusCat.ActiveOnly) + { + if (!SysId.IsValid(userAccountId) || organisationRoles.IsEmpty() || !organisationRoles.Any(item => item > 0)) return null; // Filter. SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params(); prmUserOrganisation.UserAccountIdsIncluded.Add(userAccountId); prmUserOrganisation.OrganisationStatusCat = SaxOrganisation.StatusCat.ActiveOnly; prmUserOrganisation.OrganisationMembersOnly = true; - prmUserOrganisation.OrganisationRoles.Add(organisationRole); + prmUserOrganisation.OrganisationRolesAny.AddRange(organisationRoles); prmUserOrganisation.StatusCat = statusCat; - prmUserOrganisation.SortColumns.Add(colOrganisationName); + return GetOrganisations(prmUserOrganisation); + } + + /// + /// Get list of organisation Ids and names that matc the specified parameters. + /// + public List GetOrganisations(SaxUserOrganisation.Params prmUserOrganisation) + { + List organisationsData = new List(); + // Columns. + ColumnDfn colOrganisationId = GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.OrganisationId); + ColumnDfn colOrganisationName = GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Organisation_Name); + if (prmUserOrganisation.SortColumns.IsEmpty()) + prmUserOrganisation.SortColumns.Add(colOrganisationName); // Query. using (DbResultSet resultSet = ExecuteUserOrganisationQuery(new List() { colOrganisationId, colOrganisationName }, prmUserOrganisation)) { diff --git a/SaxoniteStandardDbas/Dbas/Mgr/SaxAccountMgr_Dbas-UserOrganisation.cs b/SaxoniteStandardDbas/Dbas/Mgr/SaxAccountMgr_Dbas-UserOrganisation.cs index c6f83c4..2ead669 100644 --- a/SaxoniteStandardDbas/Dbas/Mgr/SaxAccountMgr_Dbas-UserOrganisation.cs +++ b/SaxoniteStandardDbas/Dbas/Mgr/SaxAccountMgr_Dbas-UserOrganisation.cs @@ -488,7 +488,6 @@ namespace Saxonite.Net.Standard.Dbas.Mgr filter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserOrganisation_OrganisationRoleCount, aliasUserOrganisation) + ">0"); if (!prm.OrganisationRoles.IsEmpty()) { - List organisationRoleCodes = new List(); foreach (Sax.OrganisationRole organisationRole in prm.OrganisationRoles) { String organisationRoleCode = OrganisationRoleCodes.GetCodeForType(organisationRole).TrimAll(); @@ -496,6 +495,18 @@ namespace Saxonite.Net.Standard.Dbas.Mgr filter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserOrganisation_OrganisationRoleCodes, aliasUserOrganisation) + " LIKE '%" + DbQuery.FormatForLike(organisationRoleCode) + "%'"); } } + if (!prm.OrganisationRolesAny.IsEmpty()) + { + List roleFilter = new List(); + foreach (Sax.OrganisationRole organisationRole in prm.OrganisationRolesAny) + { + String organisationRoleCode = OrganisationRoleCodes.GetCodeForType(organisationRole).TrimAll(); + if (!StringUtil.IsEmpty(organisationRoleCode)) + roleFilter.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.UserOrganisation_OrganisationRoleCodes, aliasUserOrganisation) + " LIKE '%" + DbQuery.FormatForLike(organisationRoleCode) + "%'"); + } + if (!roleFilter.IsEmpty()) + filter.Add(roleFilter.Concat(" OR ")); + } // Notes. if (!StringUtil.IsEmpty(prm.NotesPartial))