This commit is contained in:
2021-10-14 21:08:07 +01:00
parent 46b90cea74
commit 7417981a34
51 changed files with 1418 additions and 326 deletions
@@ -19,6 +19,7 @@ namespace Saxonite.Net.Core.Web.Base.Consoles
private class DataMembers
{
public SaxInternals internals;
public Dictionary<Sax.DataItemType, Dictionary<SysId, String>> encryptedIdCache = new Dictionary<Sax.DataItemType, Dictionary<SysId, String>>();
}
private DataMembers data = new DataMembers();
@@ -59,6 +60,38 @@ namespace Saxonite.Net.Core.Web.Base.Consoles
internals.PopulateSportCache(activeSportDataList);
}
/// <summary>
/// Encrypted Ids are stored in cache to ensure that they are consistent throughout a user's session
/// by persisting them through the life of the cache (application restart).
/// <para>Required as the encrypted values are compared in javascript.</para>
/// <para>Candidate encrypted value supplied by calling routine as cache doesn't know how to encrypt - used if Id not previously encrypted.</para>
/// </summary>
public override String GetEncryptedId(Sax.DataItemType itemType, SysId id, String candidateValue)
{
// Invalid Id always has a blank encrypted value.
if (!SysId.IsValid(id)) return "";
// Only Regions and Sports are supported.
if (!(new List<Sax.DataItemType>() { Sax.DataItemType.Sport, Sax.DataItemType.Region }).Contains(itemType))
return candidateValue;
Dictionary<SysId, String> itemIds = data.encryptedIdCache.GetValue(itemType, null);
if (itemIds == null)
{
// Add cache entry for this item type.
itemIds = new Dictionary<SysId, string>();
data.encryptedIdCache.Add(itemType, itemIds);
}
String encryptedId = itemIds.GetValue(id, null);
if (encryptedId == null && !StringUtil.IsEmpty(candidateValue))
{
// Use the candidate value and store it.
encryptedId = candidateValue;
itemIds.Add(id, encryptedId);
}
return encryptedId;
}
//-------------------------------------------------------------------
// Regions.
public bool RegionsSupported { get; protected set; } = false;
+101 -85
View File
@@ -71,6 +71,7 @@ namespace Saxonite.Net.Core.Web.Base.Models
protected SaxItemDataMgr ItemDataMgr { get { return Internals.ItemDataMgr; } }
// System codes.
public List<TypeCodeDesc> DataItemTypeCodes { get { return Internals.DataItemTypeCodes; } }
public List<TypeCodeDesc> YesNoCodes { get { return Internals.YesNoCodes; } }
public List<TypeCodeDesc> SportSpecialityLabelCodes { get { return Internals.SportSpecialityLabelCodes; } }
public List<TypeCodeDesc> SportParticipationCodes { get { return Internals.SportParticipationCodes; } }
public List<TypeCodeDesc> SportOfficiatingCodes { get { return Internals.SportOfficiatingCodes; } }
@@ -127,6 +128,88 @@ namespace Saxonite.Net.Core.Web.Base.Models
return new SelectList(items, "Code", "Desc");
}
//-------------------------------------------------------------------
// Version parameter for includes.
public String HrefVersion
{
get
{
DateTime versionDate = SaxSystem.AssemblyBuildAt;
if (!DateUtil.IsValid(versionDate) || SaxSystem.DebugMode)
versionDate = DateTime.Now;
return DateUtil.Format(versionDate, "yyyyMMdd" /*+ (SacsSystem.Debug ? "HHmm" : "")*/);
}
}
// Additional includes.
public List<String> AdditionalFiles_CSS { get; set; } = new List<string>();
public List<String> AdditionalFiles_JS { get; set; } = new List<string>();
//-------------------------------------------------------------------
// Redirection locations.
public class RedirectLocationData
{
// Properties populated in Controller_Base.OnActionExecuted.
public String Base { get; internal set; }
public String Home { get; internal set; }
public String Home_SessionExpired { get; internal set; }
}
public RedirectLocationData RedirectLocation { get; } = new RedirectLocationData();
//-------------------------------------------------------------------
// Link URLs.
public class LinksData
{
public String Facebook { get; } = "https://www.facebook.com/sportierre/";
public String LinkedIn { get; } = "https://www.linkedin.com/company/sportierre/about/";
}
public LinksData Links { get; } = new LinksData();
//-------------------------------------------------------------------
// Copyright notice.
public HtmlString CopyrightNotice
{
get
{
int initialYear = 2020;
int currentYear = DateTime.Today.Year;
return Localiser.GetHtmlText("copyright.symbol.year.html", (initialYear != currentYear ? initialYear + "-" : "") + currentYear.ToString());
}
}
//-------------------------------------------------------------------
// Paging properties.
public class DataPaging
{
private DbQuery.Paging paging { get; } = new DbQuery.Paging();
public void PopulatePagingTo(DbQuery.Paging resultsPaging)
{
resultsPaging.PageLength = paging.PageLength;
resultsPaging.PageNo = paging.PageNo;
}
public bool IsPaged { get { return paging.Paged; } }
public uint PageNo { get { return paging.PageNo; } set { paging.PageNo = value; } }
public ushort PageLength { get { return paging.PageLength; } set { paging.PageLength = value; } }
public uint PageCount { get { return (PageLength > 0 ? (uint)Math.Ceiling((decimal)ItemTotal / PageLength) : 0); } }
public ushort ItemCount { get; set; }
private ulong itemTotal = 0;
public ulong ItemTotal
{
get { return itemTotal; }
set
{
itemTotal = value;
// Check whether the total number of items is less than the current page and reduce page no if needed.
if (IsPaged && (PageNo - 1) * PageLength > itemTotal)
PageNo = (uint)((itemTotal - 1) / PageLength + 1);
}
}
}
public DataPaging Paging { get; } = new DataPaging();
public void PopulatePagingTo(DbQuery.Paging resultsPaging)
{
Paging.PopulatePagingTo(resultsPaging);
}
//-------------------------------------------------------------------
/// <summary>
/// Form control value max length.
@@ -157,18 +240,6 @@ namespace Saxonite.Net.Core.Web.Base.Models
return maxLength;
}
//-------------------------------------------------------------------
// Copyright notice.
public HtmlString CopyrightNotice
{
get
{
int initialYear = 2020;
int currentYear = DateTime.Today.Year;
return Localiser.GetHtmlText("copyright.symbol.year.html", (initialYear != currentYear ? initialYear + "-" : "") + currentYear.ToString());
}
}
//-------------------------------------------------------------------
// Form data - Dates.
// Format may depend on locale, but as long as these methods are used consistently,
@@ -205,20 +276,22 @@ namespace Saxonite.Net.Core.Web.Base.Models
}
//-------------------------------------------------------------------
// Link URLs.
public class LinksData
{
public String Facebook { get; } = "https://www.facebook.com/saxonite/";
public String LinkedIn { get; } = "https://www.linkedin.com/company/saxonite/about/";
}
public LinksData Links { get; } = new LinksData();
// Form data.
//-------------------------------------------------------------------
// Common form values.
public String FormAction { get; set; }
//-------------------------------------------------------------------
// Form data.
/// <summary>List of Yes/No options for dropdown.</summary>
public IEnumerable<SelectListItem> YesNoOptionsForSelect
{
get { return new SelectList(SaxSystem.GetCodesOfType(Sax.CodeType.YesNo), "Code", "Desc"); }
get
{
List<SelectListItem> values = new List<SelectListItem>();
foreach (TypeCodeDesc yesNo in SaxSystem.GetCodesOfType(Sax.CodeType.YesNo))
values.Add(new SelectListItem(yesNo.Code, GetYesNoCaption((Sax.YesNo)yesNo.Type)));
return values;
}
}
/// <summary>List of Sport Participation options for dropdown.</summary>
@@ -270,75 +343,18 @@ namespace Saxonite.Net.Core.Web.Base.Models
}
//-------------------------------------------------------------------
// Version parameter for includes.
public String HrefVersion
{
get
{
DateTime versionDate = SaxSystem.AssemblyBuildAt;
if (!DateUtil.IsValid(versionDate) || SaxSystem.DebugMode)
versionDate = DateTime.Now;
return DateUtil.Format(versionDate, "yyyyMMdd" /*+ (SacsSystem.Debug ? "HHmm" : "")*/);
}
}
// Additional includes.
public List<String> AdditionalFiles_CSS { get; set; } = new List<string>();
public List<String> AdditionalFiles_JS { get; set; } = new List<string>();
// Localisation.
//-------------------------------------------------------------------
// Redirection locations.
public class RedirectLocationData
public String GetItemDataTypeCaption(Sax.DataItemType itemType)
{
// Properties populated in Controller_Base.OnActionExecuted.
public String Base { get; internal set; }
public String Home { get; internal set; }
public String Home_SessionExpired { get; internal set; }
// Default - return code description.
return DataItemTypeCodes.GetDescForType(itemType);
}
public RedirectLocationData RedirectLocation { get; } = new RedirectLocationData();
//-------------------------------------------------------------------
// Paging properties.
public class DataPaging
public String GetYesNoCaption(Sax.YesNo yesNo)
{
private DbQuery.Paging paging { get; } = new DbQuery.Paging();
public void PopulatePagingTo(DbQuery.Paging resultsPaging)
{
resultsPaging.PageLength = paging.PageLength;
resultsPaging.PageNo = paging.PageNo;
}
public bool IsPaged { get { return paging.Paged; } }
public uint PageNo { get { return paging.PageNo; } set { paging.PageNo = value; } }
public ushort PageLength { get { return paging.PageLength; } set { paging.PageLength = value; } }
public uint PageCount { get { return (PageLength > 0 ? (uint)Math.Ceiling((decimal)ItemTotal / PageLength) : 0); } }
public ushort ItemCount { get; set; }
private ulong itemTotal = 0;
public ulong ItemTotal
{
get { return itemTotal; }
set
{
itemTotal = value;
// Check whether the total number of items is less than the current page and reduce page no if needed.
if (IsPaged && (PageNo - 1) * PageLength > itemTotal)
PageNo = (uint)((itemTotal - 1) / PageLength + 1);
}
}
// Default - return code description.
return YesNoCodes.GetDescForType(yesNo);
}
public DataPaging Paging { get; } = new DataPaging();
public void PopulatePagingTo(DbQuery.Paging resultsPaging)
{
Paging.PopulatePagingTo(resultsPaging);
}
//-------------------------------------------------------------------
// Form properties.
/// <summary>
/// User session index to identify the site resources, eg. database.
/// <para>Equivalent to the Site index on the login form.</para>
/// <para>Populates value on logout form to identify default site for next login.</para>
/// </summary>
public ushort SessionIdx { get { return SessionContext.Index; } }
public String FormAction { get; set; }
//-------------------------------------------------------------------
// Messages.
@@ -0,0 +1,116 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Routing;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Dbas;
using Sarand.Net.Standard.Base.Utils;
using Sarand.Net.Standard.Dbas.Data;
using Saxonite.Net.Core.Web.Admin.Models;
using Saxonite.Net.Standard.Base.App;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Saxonite.Net.Core.Web.Admin.Controllers
{
//=======================================================================
// Home - Ajax - Awaiting Activation controller
//=======================================================================
partial class HomeController
{
//-------------------------------------------------------------------
// Items Awaiting Activation data.
private class ActivationItemData
{
public String ItemType { get; set; }
public String ItemTypeDesc { get; set; }
public String ItemTypeDescPlural { get; set; }
public long ItemCount { get; set; }
public String ViewLink { get; set; }
}
//-------------------------------------------------------------------
// Get Items Awaiting Activation ajax request.
//-------------------------------------------------------------------
private class AjaxResponse_ItemsAwaitingActivation : AjaxResponse_Data
{
// Construction.
public AjaxResponse_ItemsAwaitingActivation(SaxModel_Admin model) : base(model) { }
// Table list.
public List<ActivationItemData> Items { get; } = new List<ActivationItemData>();
}
//-------------------------------------------------------------------
[HttpPost]
[Route("Home/Ajax/GetItemsAwaitingActivation")]
public IActionResult Ajax_GetItemsAwaitingActivation(Model_Sport model)
{
String fn = GetType().Name + ".Ajax_GetItemsAwaitingActivation";
String messageTitle = Localiser["home.caption.application"];
AjaxResponse_ItemsAwaitingActivation responseData = new AjaxResponse_ItemsAwaitingActivation(model);
// Validate session.
if (!ValidUserSession)
return GetAjaxResult_InvalidSession(responseData);
// Core Database connection.
ISacsDatabase db = SaxGlobals.App.GetCoreDatabase(SessionContext);
// Query to count items awaiting activation.
Dictionary<String, int> tableRowCounts = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
List<String> query = new List<string>()
{
// User accounts.
"SELECT",
"ItemType = '" + DbQuery.FormatForCondition(nameof(Sax.DataItemType.UserAccount)) + "',",
"ItemCount = Count(*)",
"FROM UserAccount ua",
"WHERE ua.Status = 'AWA'",
// Organisations.
"UNION SELECT",
"ItemType = '" + DbQuery.FormatForCondition(nameof(Sax.DataItemType.Organisation)) + "',",
"ItemCount = Count(*)",
"FROM Organisation org",
"WHERE org.Status = 'AWA'",
};
using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(db, query.Concat("\n")))
{
while (dbResultSet != null && dbResultSet.NextRecord())
{
Sax.DataItemType itemType = EnumUtil.ParseEnum(dbResultSet.GetRecordValues().GetValue("ItemType").ToString(), Sax.DataItemType.Unknown);
String itemTypeDesc = nameof(itemType);
String itemTypeDescPlural = itemTypeDesc;
String viewLink = "";
switch (itemType)
{
case Sax.DataItemType.UserAccount:
itemTypeDesc = "User Account";
itemTypeDescPlural = "User Accounts";
viewLink = Url.Action("", "User", new RouteValueDictionary() { { "sta", "Await" } }).TrimStart('/');
break;
case Sax.DataItemType.Organisation:
itemTypeDesc = "Organisation";
itemTypeDescPlural = "Organisations";
viewLink = Url.Action("", "Organisation", new RouteValueDictionary() { { "sta", "Await" } }).TrimStart('/');
break;
}
ActivationItemData activationItem = new ActivationItemData()
{
ItemType = nameof(itemType),
ItemTypeDesc = itemTypeDesc,
ItemTypeDescPlural = itemTypeDescPlural,
ItemCount = dbResultSet.GetRecordValues().GetValue("ItemCount").AsLong(),
ViewLink = viewLink,
};
responseData.Items.Add(activationItem);
}
}
// Complete response.
responseData.Success = true;
return Json(responseData);
}
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -17,7 +17,7 @@ using System.Threading.Tasks;
namespace Saxonite.Net.Core.Web.Admin.Controllers
{
//=======================================================================
public class HomeController : SaxController_Admin
public partial class HomeController : SaxController_Admin
{
//-------------------------------------------------------------------
// Construction.
@@ -26,7 +26,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
//-------------------------------------------------------------------
[HttpGet]
public IActionResult Index()
public IActionResult Index(String sta)
{
// Validate session.
if (!ValidUserSession)
@@ -37,6 +37,10 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
model.Paging.PageNo = 1;
model.Paging.PageLength = 6;
// Default status.
if (sta.StartsWithCI("Awa"))
model.Filter.OrganisationStatusCategoryCode = nameof(SaxOrganisation.StatusCat.AwaitingOnly);
return View(model);
}
@@ -138,9 +138,15 @@
<data name="home.caption.application" xml:space="preserve">
<value>Admin</value>
</data>
<data name="home.caption.awaiting.activation" xml:space="preserve">
<value>Awaiting Activation</value>
</data>
<data name="home.caption.home" xml:space="preserve">
<value>Home</value>
</data>
<data name="home.msg.no.items.awaiting.activation" xml:space="preserve">
<value>No items are awaiting activation</value>
</data>
<data name="label.accounts" xml:space="preserve">
<value>Accounts</value>
</data>
@@ -237,6 +243,9 @@
<data name="label.items.available" xml:space="preserve">
<value>Available items</value>
</data>
<data name="label.items.awaiting.activation" xml:space="preserve">
<value>Items awaiting activation</value>
</data>
<data name="label.keep.signed.in" xml:space="preserve">
<value>Keep me signed-in</value>
</data>
@@ -4,9 +4,35 @@
}
<script>
sax.msg.noItemsAwaitAct = '@Localiser.GetJavascriptText("home.msg.no.items.awaiting.activation")';
sax.msg.dbSchemaValid = '@Localiser.GetJavascriptText("system.msg.database.schema.valid")';
</script>
@* Items Awaiting Activation *@
<div class="sax-panel-info sax-panel-results AwaitActivate">
<div class="sax-header">
<div class="sax-caption">@Localiser["home.caption.awaiting.activation"]</div>
</div>
<div class="sax-content">
<div class="sax-panel-messages"></div>
<div class="sax-panel-item-list"></div>
@* Items awaiting activation templates *@
<div class="sax-panel-item-template">
<div class="sax-panel-item AwaitActivateItem">
<div class="sax-header">
<div class="sax-caption sax-action sax-view AwaitActivateItemType"></div>
</div>
<div class="sax-content">
<div class="SchemaIndex">@(Localiser["label.items.awaiting.activation"]): <span class="AwaitActivateItemCount"></span></div>
</div>
</div>
</div>
</div>
</div>
@* Database Schema *@
<div class="sax-panel-info sax-panel-results DbSchema">
<div class="sax-header">
@@ -16,6 +42,7 @@
<div class="sax-panel-messages"></div>
<div class="sax-panel-item-list"></div>
<div class="sax-panel-item-template">
@* Db Schema templates *@
<div class="sax-panel-item DbSchemaItem">
<div class="sax-header">
<div class="sax-caption SchemaTable">@(Localiser["label.table"]): <span class="TableName"></span></div>
@@ -10,7 +10,7 @@
margin: 24px auto;
padding: 0;
background-color: #fff;
border: solid 2px #979797;
border: solid 1px #979797;
border-color: var(--color-primary);
border-radius: 4px;
-webkit-border-radius: 4px;
@@ -336,7 +336,7 @@ a:focus
.ui-dialog.ui-widget.ui-widget-content
{
border-width: 2px;
border-width: 1px;
border-color: #d4af37;
-moz-box-shadow: 4px 4px 6px #ccc;
-webkit-box-shadow: 4px 4px 6px #ccc;
+57 -16
View File
@@ -5,17 +5,59 @@
(function (win, doc, undef)
{
"use strict";
let $pnl = sax.$pnl, $dlg = sax.$dlg, $frm = sax.$frm;
sax.itemIdPrefix = 'Itm_';
//--------------------------------------------------------------
sax.refreshDbSchema= function (delay)
sax.refreshAwaitActivate = function (delay)
{
if (sax.awaitingLogin) return;
var $results = $('.sax-panel-results.DbSchema');
if (!sax.awaitingRefreshResponse)
{
var $items = $('.sax-panel-item-list', $results).fadeOut(200).empty();
var $msgs = $('.sax-panel-messages', $results).hide().empty().append($('<div class="sax-message">' + sax.msg.dataQuerying + '</div>')).fadeIn(200);
var $items = $('.sax-panel-item-list', $pnl.awaitAct).fadeOut(200).empty();
var $msgs = $('.sax-panel-messages', $pnl.awaitAct).hide().empty().append($('<div class="sax-message">' + sax.msg.dataQuerying + '</div>')).fadeIn(200);
}
sax.ajax.awaitAct = sax.ajax.awaitAct || { url: sax.url.base + 'Home/Ajax/GetItemsAwaitingActivation', formId: 'frmNavigate', callbackFn: sax.handleAwaitActivateResponse, noWaitIcon: true };
sax.doAjaxRequest(sax.ajax.awaitAct, delay || 50);
sax.awaitingRefreshResponse = true;
}
sax.handleAwaitActivateResponse = function (response)
{
//sax.debug('handleAwaitActivateResponse', response);
delete sax.awaitingRefreshResponse;
var $msgs = $('.sax-panel-messages', $pnl.awaitAct).hide().empty();
var $items = $('.sax-panel-item-list', $pnl.awaitAct).hide().empty();
var $tmpl = $('.sax-panel-item-template .sax-panel-item.AwaitActivateItem', $pnl.awaitAct);
if (!response.success) return;
// Items.
var items = response.items;
if (!items.length)
return $msgs.append($('<div class="sax-message">' + sax.msg.noItemsAwaitAct + '</div>')).fadeIn(500);
for (let itemIdx = 0; itemIdx < items.length; itemIdx++)
$items.append(sax.populateAwaitActivateItem($tmpl.clone(), items[itemIdx]));
$items.slideDown(750);
}
sax.populateAwaitActivateItem = function ($item, item)
{
if (!item) return;
if (item.viewLink)$('.sax-action.sax-view', $item).on('click', function () { sax.goToPage(item.viewLink); });
$('.AwaitActivateItemType', $item).text(item.itemTypeDescPlural);
$('.AwaitActivateItemCount', $item).text(item.itemCount);
return $item;
}
sax.getAwaitActivateItemTemplate = function ()
{
return $('.sax-panel-item-template .sax-panel-item.AwaitActivateItem', $pnl.results).clone();
}
//--------------------------------------------------------------
sax.refreshDbSchema = function (delay)
{
if (sax.awaitingLogin) return;
if (!sax.awaitingRefreshResponse)
{
var $items = $('.sax-panel-item-list', $pnl.dbSchema).fadeOut(200).empty();
var $msgs = $('.sax-panel-messages', $pnl.dbSchema).hide().empty().append($('<div class="sax-message">' + sax.msg.dataQuerying + '</div>')).fadeIn(200);
}
sax.ajax.dbSchema = sax.ajax.dbSchema || { url: sax.url.base + 'System/Ajax/ValidateDatabaseSchema', formId: 'frmNavigate', callbackFn: sax.handleDbSchemaResponse, noWaitIcon: true };
sax.doAjaxRequest(sax.ajax.dbSchema, delay || 50);
@@ -25,25 +67,19 @@
{
//sax.debug('handleDbSchemaResponse', response);
delete sax.awaitingRefreshResponse;
var $results = $('.sax-panel-results.DbSchema');
var $msgs = $('.sax-panel-messages', $results).hide().empty();
var $items = $('.sax-panel-item-list', $results).hide().empty();
var $tmpl = $('.sax-panel-item-template .sax-panel-item.DbSchemaItem', $results);
var $msgs = $('.sax-panel-messages', $pnl.dbSchema).hide().empty();
var $items = $('.sax-panel-item-list', $pnl.dbSchema).hide().empty();
var $tmpl = $('.sax-panel-item-template .sax-panel-item.DbSchemaItem', $pnl.dbSchema);
if (!response.success) return;
// Items.
var items = response.items;
if (!items.length)
return $msgs.append($('<div class="sax-message">' + sax.msg.dbSchemaValid + '</div>')).fadeIn(500);
for (let itemIdx = 0; itemIdx < items.length; itemIdx++)
{
let item = items[itemIdx];
let $item = $tmpl.clone();
sax.populateItem($item, item);
$items.append($item);
}
$items.fadeIn(50);
$items.append(sax.populateDbSchemaItem($tmpl.clone(), items[itemIdx]));
$items.slideDown(750);
}
sax.populateItem = function ($item, item)
sax.populateDbSchemaItem = function ($item, item)
{
if (!item) return;
$item.prop('id', sax.itemIdPrefix + item.id);
@@ -53,11 +89,16 @@
$('.ColumnName', $item).text(item.columnName);
$('.SchemaColumn', $item).toggle(!!item.columnName);
$('.Comment', $item).text(item.comment);
return $item;
}
//--------------------------------------------------------------
$(function ()
{
$pnl.awaitAct = $('.sax-panel-results.AwaitActivate');
$pnl.dbSchema = $('.sax-panel-results.DbSchema');
setTimeout(sax.refreshAwaitActivate, 250);
setTimeout(sax.refreshDbSchema, 250);
});
+1 -1
View File
@@ -62,7 +62,7 @@
$('.UserFirstName', $item).text(item.firstName);
$('.UserLastName', $item).text(item.lastName);
$('.UserRoleCount', $item).text(item.userRoleCount);
$('.StatusDesc', $item).text(item.statusDesc);
$('.StatusDesc', $item).text(item.statusDesc).addClass('sax-status-' + item.statusCode.toLowerCase());
$('.sax-caption .sax-action').toggleClass('sax-action', !item.deleted);
let $mnu = $('ul.sax-dropdown-menu', $item);
if (!item.deleted)
@@ -231,6 +231,9 @@
<data name="label.alternatively" xml:space="preserve">
<value>Alternatively</value>
</data>
<data name="label.any" xml:space="preserve">
<value>Any</value>
</data>
<data name="label.article" xml:space="preserve">
<value>Article</value>
</data>
@@ -309,6 +312,9 @@
<data name="label.first.name" xml:space="preserve">
<value>First name</value>
</data>
<data name="label.follow" xml:space="preserve">
<value>Follow</value>
</data>
<data name="label.forgotten.password" xml:space="preserve">
<value>Forgotten password?</value>
</data>
@@ -501,6 +507,9 @@
<data name="label.very.good" xml:space="preserve">
<value>Very Good</value>
</data>
<data name="label.view" xml:space="preserve">
<value>View</value>
</data>
<data name="label.year" xml:space="preserve">
<value>Year</value>
</data>
@@ -42,13 +42,13 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
public byte DobMonth { get; set; }
public short DobYear { get; set; }
// Regions.
public int RegionIdCountry { get; set; }
public String RegionIdCountry { get; set; }
public String RegionCaptionCountry { get; set; }
public int RegionIdProvince { get; set; }
public String RegionIdProvince { get; set; }
public String RegionCaptionProvince { get; set; }
public String LocationCaption { get; set; }
}
private void PopulateContactResponseData(ContactResponseData data, SaxUserAccount userAccount)
private void PopulateContactResponseData(SaxModel_Online model, ContactResponseData data, SaxUserAccount userAccount)
{
data.EmailAddress = userAccount.EmailAddress;
data.DisplayName = userAccount.GetDisplayName();
@@ -62,8 +62,8 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
data.DobMonth = (byte)userAccount.DateOfBirthMonth;
data.DobYear = (short)userAccount.DateOfBirthYear;
// Regions.
data.RegionIdCountry = SysId.ToInt(userAccount.RegionIdCountry);
data.RegionIdProvince = SysId.ToInt(userAccount.RegionIdProvince);
data.RegionIdCountry = model.GetEncryptedRegionId(userAccount.RegionIdCountry);
data.RegionIdProvince = model.GetEncryptedRegionId(userAccount.RegionIdProvince);
data.RegionCaptionCountry = Localiser.GetRegionName(Internals.GetRegion(userAccount.RegionIdCountry));
data.RegionCaptionProvince = Localiser.GetRegionName(Internals.GetRegion(userAccount.RegionIdProvince));
List<String> locations = new List<string>() { data.RegionCaptionProvince, data.RegionCaptionCountry };
@@ -134,7 +134,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
// Populate data to response.
responseData.Contact = new ContactResponseData();
PopulateContactResponseData(responseData.Contact, userAccount);
PopulateContactResponseData(model, responseData.Contact, userAccount);
responseData.Success = true;
return Json(responseData);
}
@@ -363,7 +363,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
// Construct response.
responseData.Contact = new ContactResponseData();
PopulateContactResponseData(responseData.Contact, userAccount);
PopulateContactResponseData(model, responseData.Contact, userAccount);
responseData.Success = true;
return Json(responseData);
}
@@ -35,15 +35,17 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
}
private class ProfileSportResponseData_Item : ProfileSportResponseData_List
{
public String SportAbout { get; set; }
public String SportParticipationCode { get; set; }
public String SportOfficiatingCode { get; set; }
}
private void PopulateProfileSportResponseData(Model_Account model, SaxUserSport userSport, SaxSport sport, ProfileSportResponseData_Item data)
{
data.Id = SysId.ToString(userSport.Id);
data.SportId = SysId.ToString(userSport.SportId);
data.SportId = model.GetEncryptedSportId(userSport.SportId);
data.SportName = sport.Name;
data.SportSpecialityLabel = model.GetSportSpecialityLabel(userSport.SportId);
data.SportAbout = userSport.About;
data.SportParticipationCode = SportParticipationCodes.GetCodeForType(userSport.Participation);
data.SportParticipation = Localiser.GetSportParticipationTypeCaption(userSport.Participation);
data.SportOfficiatingCode = SportOfficiatingCodes.GetCodeForType(userSport.Officiating);
@@ -112,7 +114,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
ProfileSportResponseData_List userSportData = new ProfileSportResponseData_List()
{
Id = values.GetLong(colId.DataName).ToString(),
SportId = sportId.ToString(),
SportId = model.GetEncryptedSportId(sportId),
SportName = values.GetString(colSportName.DataName),
SportSpecialityLabel = model.GetSportSpecialityLabel(sportId),
SportParticipation = Localiser.GetSportParticipationTypeCaption((Sax.SportParticipation)values.GetLong(colParticipation.DataName)),
@@ -254,14 +256,24 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
userSport = AccountMgr.GetUserSport(prmUserSport);
if (userSport != null)
{
SaLogger.Info(fn + " Resurrecting User Sport with status: " + userSport.StatusDesc + ". Id: " + SysId.ToString(userSport.Id));
userSport.Status = SaxUserSport.DefaultStatus;
if (userSport.Status == SaStatus.Deleted)
{
SaLogger.Info(fn + " Resurrecting User Sport with status: " + userSport.StatusDesc + ". Id: " + SysId.ToString(userSport.Id));
userSport.Status = SaxUserSport.DefaultStatus;
}
else
{
responseData.SetControlError(nameof(model.ProfileSportId), Localiser["msg.validation.duplicate.value"]);
return Json(responseData);
}
}
else
userSport = AccountMgr.CreateUserSport(SessionData.User.UserAccountId, sportId);
}
// Populate item properties.
if (model.ProfileSportAbout != null)
userSport.About = model.ProfileSportAbout;
if (model.ProfileSportParticipationCode != null)
userSport.Participation = model.ProfileSportParticipation;
if (model.ProfileSportOfficiatingCode != null)
@@ -70,8 +70,8 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
data.League = userSportExperience.League;
data.Speciality = userSportExperience.Speciality;
// Regions.
data.RegionIdNation = model.EncryptId(userSportExperience.RegionIdNation);
data.RegionIdProvince = model.EncryptId(userSportExperience.RegionIdProvince);
data.RegionIdNation = model.GetEncryptedRegionId(userSportExperience.RegionIdNation);
data.RegionIdProvince = model.GetEncryptedRegionId(userSportExperience.RegionIdProvince);
data.RegionCaptionNation = Localiser.GetRegionName(Internals.GetRegion(userSportExperience.RegionIdNation));
data.RegionCaptionProvince = Localiser.GetRegionName(Internals.GetRegion(userSportExperience.RegionIdProvince));
List<String> locations = new List<string>() { data.RegionCaptionProvince, data.RegionCaptionNation };
@@ -88,8 +88,8 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
private void PopulateArticleResponseData(Model_Article model, SaxArticle article, ArticleData_Full data)
{
PopulateArticleResponseData(model, article, data as ArticleData_List);
data.RegionIdPrimary = SysId.ToString(article.RegionIdPrimary);
data.SportIdPrimary = SysId.ToString(article.SportIdPrimary);
data.RegionIdPrimary = model.GetEncryptedRegionId(article.RegionIdPrimary);
data.SportIdPrimary = model.GetEncryptedSportId(article.SportIdPrimary);
data.Published = DateUtil.IsValid(article.PublishedAt);
data.PublishedOn_YYYYMMDD = DateUtil.Format(article.PublishedAt, "yyyyMMdd");
data.PublishedOn_Calendar = model.FormatDateForForm(article.PublishedAt);
@@ -57,8 +57,8 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
private void PopulateOpportunityResponseData(Model_Organisation_Opportunities model, SaxOrganisationOpportunity opportunity, OpportunityData_Detail data)
{
PopulateOpportunityResponseData(model, opportunity, data as OpportunityData_List);
data.RegionIdPrimary = SysId.ToString(opportunity.RegionIdPrimary);
data.SportIdPrimary = SysId.ToString(opportunity.SportIdPrimary);
data.RegionIdPrimary = model.GetEncryptedRegionId(opportunity.RegionIdPrimary);
data.SportIdPrimary = model.GetEncryptedSportId(opportunity.SportIdPrimary);
data.PublishedOn_YYYYMMDD = DateUtil.Format(opportunity.PublishedAt, "yyyyMMdd");
data.ExpiresOn_YYYYMMDD = DateUtil.Format(opportunity.ExpiresAt, "yyyyMMdd");
}
@@ -148,9 +148,9 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
// Organisation.
responseData.Organisation.Id = SysId.ToString(organisation.Id);
responseData.Organisation.Name = organisation.Name;
responseData.Organisation.SportId = SysId.ToString(organisation.SportIdPrimary);
responseData.Organisation.SportId = model.GetEncryptedSportId(organisation.SportIdPrimary);
responseData.Organisation.SportName = model.GetSportCaption(organisation.SportIdPrimary);
responseData.Organisation.RegionId = SysId.ToString(organisation.RegionIdPrimary);
responseData.Organisation.RegionId = model.GetEncryptedRegionId(organisation.RegionIdPrimary);
responseData.Organisation.RegionName = model.GetRegionCaption(organisation.RegionIdPrimary);
// User details.
@@ -0,0 +1,195 @@
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;
namespace Saxonite.Net.Core.Web.Online.Controllers
{
//=======================================================================
// Online Search Controller - Organisations - Ajax actions.
//=======================================================================
partial class SearchController
{
//-------------------------------------------------------------------
// Account - Get Organisations.
//-------------------------------------------------------------------
private class OrganisationListData
{
public String Id { get; set; }
public String Name { get; set; }
public String SportId { get; set; }
public String SportName { get; set; }
public String RegionId { get; set; }
public String RegionName { get; set; }
}
private class AjaxResponse_Search_Organisations : AjaxResponse_Data
{
// Construction.
public AjaxResponse_Search_Organisations(SaxModel_Online model) : base(model) { }
// Organisation list.
public List<OrganisationListData> Organisations { get; } = new List<OrganisationListData>();
}
// Ajax request.
[HttpPost]
[Route("Search/Ajax/Organisations")]
[Route("Search/Ajax/GetOrganisations")]
public IActionResult GetProfileOrganisations(Model_Search_Organisations model)
{
String fn = GetType().Name + ".GetProfileOrganisations";
AjaxResponse_Search_Organisations responseData = new AjaxResponse_Search_Organisations(model);
String messageTitle = Localiser["organisation.caption.organisations"];
// Validate session and referrer.
if (!ValidReferer) return Forbid();
if (!ValidUserSession) return GetAjaxResult_InvalidSession(responseData);
RefreshModel(model);
// Query organisations that user is a member of.
SaxOrganisation.Params prmOrganisation = new SaxOrganisation.Params();
prmOrganisation.OrganisationFilter = model.Filter.Organisation;
prmOrganisation.OrganisationType = model.FilterOrganisationType;
prmOrganisation.OrganisationCategory = model.FilterOrganisationCategory;
if (SysId.IsValid(model.FilterSportId))
prmOrganisation.SportIdsIncluded.Add(model.FilterSportId);
if (SysId.IsValid(model.FilterRegionId))
prmOrganisation.RegionIdsIncluded.Add(model.FilterRegionId);
prmOrganisation.StatusCat = SaxOrganisation.StatusCat.ActiveOnly;
model.Paging.ItemTotal = (ulong)AccountMgr.GetOrganisationCount(prmOrganisation);
model.PopulatePagingTo(prmOrganisation.ResultsPaging);
List<SaxOrganisation> organisations = AccountMgr.GetOrganisationList(prmOrganisation);
List<SysId> organisationIds = organisations.GetIds();
// Item columns.
ColumnDfn colId = AccountMgr.GetOrganisationColumnDfn(SaxOrganisation.Column.Id);
ColumnDfn colName = AccountMgr.GetOrganisationColumnDfn(SaxOrganisation.Column.Name);
ColumnDfn colSportId = AccountMgr.GetOrganisationColumnDfn(SaxOrganisation.Column.SportId);
ColumnDfn colSportName = AccountMgr.GetOrganisationColumnDfn(SaxOrganisation.Column.Sport_Name);
ColumnDfn colRegionId = AccountMgr.GetOrganisationColumnDfn(SaxOrganisation.Column.RegionId);
ColumnDfn colRegionName = AccountMgr.GetOrganisationColumnDfn(SaxOrganisation.Column.Region_Name);
List<ColumnDfn> columns = new List<ColumnDfn>()
{
colId, colName,
colSportId, colSportName,
colRegionId, colRegionName,
};
// Sort columns.
colName.SortAscending = true;
prmOrganisation.SortColumns.Add(colName);
// Query items.
using (DbResultSet resultSet = AccountMgr.ExecuteOrganisationQuery(columns, prmOrganisation))
{
while (resultSet != null && resultSet.HasRows && resultSet.NextRecord())
{
NamedValue.Map values = resultSet.GetRecordValues();
OrganisationListData organisationData = new OrganisationListData()
{
Id = model.EncryptId(new SysId(values.GetLong(colId.DataName))),
Name = values.GetString(colName.DataName),
SportId = model.GetEncryptedSportId(new SysId(values.GetLong(colSportId.DataName))),
SportName = values.GetString(colSportName.DataName),
RegionId = model.GetEncryptedRegionId(new SysId(values.GetLong(colRegionId.DataName))),
RegionName = values.GetString(colRegionName.DataName),
};
responseData.Organisations.Add(organisationData);
}
}
if (model.Paging.IsPaged)
model.Paging.ItemCount = (ushort)responseData.Organisations.Count;
// Complete response.
responseData.SetPaging(model);
responseData.Success = true;
return Json(responseData);
}
//-------------------------------------------------------------------
// Account - Get Organisations.
//-------------------------------------------------------------------
private class OrganisationData
{
public String Id { get; set; }
public String Name { get; set; }
public String SportId { get; set; }
public String SportName { get; set; }
public String RegionId { get; set; }
public String RegionName { get; set; }
}
private class AjaxResponse_Search_Organisation : AjaxResponse_Data
{
// Construction.
public AjaxResponse_Search_Organisation(SaxModel_Online model) : base(model) { }
// Organisation list.
public OrganisationData Organisation { get; set; }
}
// Ajax request.
[HttpPost]
[Route("Search/Ajax/Organisation")]
[Route("Search/Ajax/GetOrganisation")]
public IActionResult GetProfileOrganisation(Model_Search_Organisations model)
{
String fn = GetType().Name + ".GetProfileOrganisation";
AjaxResponse_Search_Organisation responseData = new AjaxResponse_Search_Organisation(model);
String messageTitle = Localiser["label.organisations"];
// 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<SacsHierarchyItem> disposableItems = new DisposableCollection<SacsHierarchyItem>())
{
// Retrieve organisation.
SysId organisationId = model.ExtractSysId(model.OrganisationId);
if (!SysId.IsValid(organisationId))
{
SaLogger.Warn(fn + " Organisation Id not supplied.");
return Json(responseData);
}
SaxOrganisation organisation = AccountMgr.GetOrganisationById(organisationId);
if (organisation == null)
{
SaLogger.Warn(fn + " Failed to retrieve organisation. Id: " + model.OrganisationId);
return Json(responseData);
}
disposableItems.Add(organisation);
// Populate response.
OrganisationData organisationData = new OrganisationData()
{
Id = model.EncryptId(organisation.Id),
Name = organisation.Name,
SportId = model.GetEncryptedSportId(organisation.SportIdPrimary),
SportName = model.GetSportCaption(organisation.SportIdPrimary),
RegionId = model.GetEncryptedRegionId(organisation.RegionIdPrimary),
RegionName = model.GetRegionCaption(organisation.RegionIdPrimary),
};
responseData.Organisation = organisationData;
}
// Complete response.
responseData.Success = true;
return Json(responseData);
}
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -0,0 +1,63 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
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.Bus;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Saxonite.Net.Core.Web.Online.Controllers
{
//=======================================================================
// Online Search Controller.
//=======================================================================
public partial class SearchController : SaxController_Online
{
//-------------------------------------------------------------------
// Construction.
public SearchController(SaxLocaliser localiser, ILogger<HomeController> logger) :
base(localiser, logger)
{
}
//-------------------------------------------------------------------
[HttpGet]
public IActionResult Index()
{
// Validate session.
if (!ValidUserSession)
return RedirectToAction("", "");
// No 'Index' view as yet - default to home page.
return RedirectToAction("", "");
}
//-------------------------------------------------------------------
/// <summary>
/// Search - Organisations.
/// </summary>
[HttpGet]
public IActionResult Organisations()
{
// Validate session.
if (!ValidUserSession)
return RedirectToAction("", "");
// Model.
Model_Search_Organisations model = new Model_Search_Organisations(Localiser);
model.Paging.PageNo = 1;
model.Paging.PageLength = 12;
return View(model);
}
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -44,8 +44,8 @@ namespace Saxonite.Net.Core.Web.Online.Models
return (Sax.Gender)StringUtil.ToShort(AccountGender);
}
public String AccountDobDay { get; set; }
public String AccountDobMonth{ get; set; }
public String AccountDobYear{ get; set; }
public String AccountDobMonth { get; set; }
public String AccountDobYear { get; set; }
// Regions.
public String AccountRegionIdCountry { get; set; }
public String AccountRegionCaptionCountry { get; }
@@ -71,6 +71,7 @@ namespace Saxonite.Net.Core.Web.Online.Models
get { return (Sax.SportOfficiating)SportOfficiatingCodes.GetTypeForCode(ProfileSportOfficiatingCode); }
set { ProfileSportOfficiatingCode = SportOfficiatingCodes.GetCodeForType(value); }
}
public String ProfileSportAbout { get; set; }
//-------------------------------------------------------------------
// Validate users's contact details.
@@ -175,6 +176,17 @@ namespace Saxonite.Net.Core.Web.Online.Models
responseData.SetControlError(nameof(ProfileSportId), Localiser["msg.validation.mandatory.value"]);
}
// About.
if (ProfileSportAbout != null)
{
responseData.SetControlValue(nameof(ProfileSportAbout), ProfileSportAbout);
if (!StringUtil.IsEmpty(ProfileSportAbout))
{
if (StringUtil.GetLength(ProfileSportAbout) > GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.UserSport_About))
responseData.SetControlError(nameof(ProfileSportAbout), Localiser["msg.validation.maximum.length", GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.UserSport_About)]);
}
}
return !responseData.HasControlErrors();
}
@@ -0,0 +1,57 @@
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_Organisations : SaxModel_Online
{
//-------------------------------------------------------------------
// Construction.
public Model_Search_Organisations(SaxLocaliser localiser) :
base(localiser)
{
//AdditionalFiles_CSS.Add("css/sax-src-org.css");
AdditionalFiles_JS.Add("js/sax-src-org.js");
}
//-------------------------------------------------------------------
// Page configuration.
//-------------------------------------------------------------------
// Form properties.
public class FilterData
{
public String Organisation { get; set; }
public String Type { get; set; }
public String Category { get; set; }
public String RegionId { get; set; }
public String SportId { get; set; }
}
public FilterData Filter { get; } = new FilterData();
public Sax.OrganisationType FilterOrganisationType { get { return (Sax.OrganisationType)OrganisationTypeCodes.GetTypeForCode(Filter.Type); } }
public Sax.OrganisationCategory FilterOrganisationCategory { get { return (Sax.OrganisationCategory)OrganisationCategoryCodes.GetTypeForCode(Filter.Category); } }
public SysId FilterSportId { get { return ExtractSysId(Filter.SportId); } }
public SysId FilterRegionId { get { return ExtractSysId(Filter.RegionId); } }
public String OrganisationId { get; set; }
//-------------------------------------------------------------------
// Validation.
//-------------------------------------------------------------------
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -127,6 +127,7 @@ namespace Saxonite.Net.Core.Web.Online.Models
public static String ParamName_IdObfuscation_Id { get; } = "iob";
public String EncryptId(SysId id)
{
if (!SysId.IsValid(id)) return "";
NameValueCollection idObfuscationParams = new NameValueCollection();
idObfuscationParams.Add(ParamName_IdObfuscation_Id, SysId.ToString(id));
return SaxController_Base.EncryptParameters(idObfuscationParams, Base64IV_IdObfuscation, Base64Key_IdObfuscation);
@@ -143,9 +144,10 @@ namespace Saxonite.Net.Core.Web.Online.Models
// Reference Data.
//-------------------------------------------------------------------
// Regions.
/// <summary>Region Data class - to be JSON serialised in Ajax responses.</summary>
/// <summary>Region Data - to be JSON serialised in Ajax responses.</summary>
public class RegionData
{
/// <summary>Encrypted Id</summary>
public String Id { get; set; }
public int RegionType { get; set; }
public String RegionTypeCode { get; set; }
@@ -162,7 +164,7 @@ namespace Saxonite.Net.Core.Web.Online.Models
{
RegionData regionData = new RegionData()
{
Id = SysId.ToString(region.Id),
Id = GetEncryptedRegionId(region.Id),
RegionType = (int)region.RegionType,
RegionTypeCode = region.RegionType.ToString(),
RegionTypeDesc = Localiser.GetRegionTypeCaption(region.RegionType),
@@ -175,6 +177,10 @@ namespace Saxonite.Net.Core.Web.Online.Models
}
return regions;
}
public String GetEncryptedRegionId(SysId regionId)
{
return DataCacheConsole.GetEncryptedRegionId(regionId, EncryptId(regionId));
}
public String GetRegionCaption(SysId regionId)
{
SaxRegion.Data region = DataCacheConsole.GetAllRegions().Find(item => item.Id.Equals(regionId));
@@ -187,9 +193,11 @@ namespace Saxonite.Net.Core.Web.Online.Models
//-------------------------------------------------------------------
// Sports.
/// <summary>Sport Data - to be JSON serialised in Ajax responses.</summary>
public class SportData
{
public Int32 Id { get; set; }
/// <summary>Encrypted Id</summary>
public String Id { get; set; }
public String Name { get; set; }
public String StatusCode { get; set; }
public String StatusDesc { get; set; }
@@ -201,7 +209,7 @@ namespace Saxonite.Net.Core.Web.Online.Models
{
SportData sportData = new SportData()
{
Id = SysId.ToInt(sport.Id),
Id = GetEncryptedSportId(sport.Id),
Name = GetSportCaption(sport),
StatusCode = sport.StatusCode,
StatusDesc = Localiser.GetStatusCaption(sport.Status)
@@ -210,6 +218,10 @@ namespace Saxonite.Net.Core.Web.Online.Models
}
return sports;
}
public String GetEncryptedSportId(SysId sportId)
{
return DataCacheConsole.GetEncryptedSportId(sportId, EncryptId(sportId));
}
// Sport caption.
public String GetSportCaption(SysId sportId)
{
@@ -18,6 +18,7 @@
<a href="#" class="dropdown" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="navbar-toggler-icon"></span></a>
<ul class="dropdown-menu dropdown-menu-right sax-dropdown-menu">
<li class="sax-dropdown-item sax-action sax-add" onclick="sax.addSportExperience()"><div class="sax-label">@(Localiser["label.add"])</div></li>
<li class="sax-dropdown-item sax-action sax-close" onclick="sax.closeProfileSportExperience()"><div class="sax-label">@(Localiser["label.close"])</div></li>
</ul>
</li>
</ul>
@@ -39,7 +39,7 @@
@* Sport template *@
<div class="sax-panel-item ProfileSport">
<div class="sax-header row">
<div class="col"><div class="SportName"></div></div>
<div class="col"><div class="sax-action sax-edit SportName"></div></div>
<div class="fixed">
@* Burger menu *@
<ul class="nav navbar-nav navbar-light navbar-right sax-burger">
@@ -77,6 +77,7 @@
<div id="dlgProfileSport" class="sax-dialog">
<div class="spacer"></div>
@using (Html.BeginForm(FormMethod.Post, new { @id = "frmProfileSport", @class = "sax-form", @onSubmit = "return false;" }))
{
<input type="hidden" class="UserSportId" name="UserSportId" />
@@ -84,39 +85,75 @@
@* Sport *@
<div class="sax-form-control ProfileSportId">
<div class="sax-label">
<label for="ifProfileSport"><span>@Localiser["label.sport"]</span><span class="required">&nbsp;*</span></label>
<div class="row">
<div class="col-sm-3">
<div class="sax-label">
<label for="ifProfileSport"><span>@Localiser["label.sport"]</span><span class="required">&nbsp;*</span></label>
</div>
</div>
<div class="col-sm">
<div class="sax-control row">
<input type="hidden" id="ifProfileSportId" class="ProfileSportId" name="ProfileSportId" />
<div class="col"><input type="text" id="ifProfileSport" class="ProfileSport sax-input" name="ProfileSport" readonly="readonly" maxlength=128 /></div>
<div class="fixed"><button class="SelectSport sax-button" style="min-width:auto;margin-left:4px;padding:4px 6px" onclick="sax.selectUserSport()">@Localiser["label.select"]</button></div>
</div>
<div class="sax-message"></div>
</div>
</div>
<div class="sax-control row">
<input type="hidden" id="ifProfileSportId" class="ProfileSportId" name="ProfileSportId" />
<div class="col"><input type="text" id="ifProfileSport" class="ProfileSport sax-input" name="ProfileSport" readonly="readonly" maxlength=128 /></div>
<div class="fixed"><button class="SelectSport sax-button" style="min-width:auto;margin-left:4px;padding:4px 6px" onclick="sax.selectUserSport()">@Localiser["label.select"]</button></div>
</div>
@* About *@
<div class="sax-form-control ProfileSportAbout">
<div class="row">
<div class="col-sm-3">
<div class="sax-label">
<label for="ifProfileSportAbout"><span>@Localiser["label.about"]</span></label>
</div>
</div>
<div class="col-sm">
<div class="sax-control">
@Html.TextAreaFor(model => model.ProfileSportAbout, new { @id = "ifProfileSportAbout", @class = "ProfileSportAbout sax-textarea", @rows = 4, @maxlength = @Model.GetControlMaxLength(SaxDbDfn_Core.ColumnIdx.UserSport_About) })
</div>
<div class="sax-message"></div>
</div>
</div>
<div class="sax-message"></div>
</div>
@* Sport Participation *@
<div class="sax-form-control ProfileSportParticipation">
<div class="sax-label">
<label for="cbProfileSportParticipation"><span>@Localiser["label.participation"]</span></label>
<div class="row">
<div class="col-sm-3">
<div class="sax-label">
<label for="cbProfileSportParticipation"><span>@Localiser["label.participation"]</span></label>
</div>
</div>
<div class="col-sm">
<div class="sax-control">
@Html.DropDownListFor(model => model.ProfileSportParticipationCode, Model.SportParticipationCodesForSelect, "", new { @id = "cbProfileSportParticipation", @class = "ProfileSportParticipation sax-select" })
</div>
<div class="sax-message"></div>
</div>
</div>
<div class="sax-control">
@Html.DropDownListFor(model => model.ProfileSportParticipationCode, Model.SportParticipationCodesForSelect, "", new { @id = "cbProfileSportParticipation", @class = "ProfileSportParticipation sax-select" })
</div>
<div class="sax-message"></div>
</div>
@* Sport Officiating *@
<div class="sax-form-control ProfileSportOfficiating">
<div class="sax-label">
<label for="cbProfileSportOfficiating"><span>@Localiser["label.officiating"]</span></label>
<div class="row">
<div class="col-sm-3">
<div class="sax-label">
<label for="cbProfileSportOfficiating"><span>@Localiser["label.officiating"]</span></label>
</div>
</div>
<div class="col-sm">
<div class="sax-control">
@Html.DropDownListFor(model => model.ProfileSportOfficiatingCode, Model.SportOfficiatingCodesForSelect, "", new { @id = "cbProfileSportOfficiating", @class = "ProfileSportOfficiating sax-select" })
</div>
<div class="sax-message"></div>
</div>
</div>
<div class="sax-control">
@Html.DropDownListFor(model => model.ProfileSportOfficiatingCode, Model.SportOfficiatingCodesForSelect, "", new { @id = "cbProfileSportOfficiating", @class = "ProfileSportOfficiating sax-select" })
</div>
<div class="sax-message"></div>
</div>
}
<div class="spacer"></div>
</div>
@@ -3,7 +3,6 @@
<link rel="stylesheet" href="~/css/sax-reg-sel.css?@Model.HrefVersion" />
<script type="text/javascript">
sax.data.selectRegion = {};
</script>
<div id="dlgSelectRegion" class="sax-dialog sax-form">
@@ -23,7 +22,7 @@
<div class="RegionFilter sax-form">
<div class="row">
<div class="col right"><div class="sax-label">@Localiser["label.search"]</div></div>
<div class="fixed"><input type="search" id="ifRegionFilter" class="sax-input" maxlength="16" autocomplete="off" onkeyup="sax.data.selectRegion.fn.displayRegions();" /></div>
<div class="fixed"><input type="search" id="ifRegionFilter" class="sax-input" maxlength="16" autocomplete="off" onkeyup="sax.mdl.selectRegion.fn.displayRegions();" /></div>
</div>
<div class="spacer2"></div>
</div>
@@ -3,7 +3,7 @@
<script src="~/js/sax-resultsPaging.js?@Model.HrefVersion"></script>
<script type="text/javascript">
sax.resultsPaging.msg.pageInfo = '@Localiser.GetJavascriptText("label.page.info","{0}","{1}")';
sax.mdl.resultsPaging.msg.pageInfo = '@Localiser.GetJavascriptText("label.page.info","{0}","{1}")';
</script>
@* Results paging *@
@@ -3,7 +3,6 @@
<link rel="stylesheet" href="~/css/sax-spt-sel.css?@Model.HrefVersion" />
<script type="text/javascript">
sax.data.selectSport = {};
</script>
<div id="dlgSelectSport" class="sax-dialog sax-form">
@@ -23,7 +22,7 @@
<div class="SportFilter sax-form">
<div class="row">
<div class="col right"><div class="sax-label">@Localiser["label.search"]</div></div>
<div class="fixed"><input type="search" id="ifSportFilter" class="sax-input" maxlength="16" autocomplete="off" onkeyup="sax.data.selectSport.fn.displaySports();" /></div>
<div class="fixed"><input type="search" id="ifSportFilter" class="sax-input" maxlength="16" autocomplete="off" oninput="sax.mdl.selectSport.fn.displaySports();" /></div>
</div>
<div class="spacer2"></div>
</div>
@@ -0,0 +1,163 @@
@model Model_Search_Organisations
@inject SaxLocaliser Localiser
@{
ViewData["Title"] = "Search Organisations";
}
<div class="sax-panel Organisations">
<script type="text/javascript">
sax.lbl.view = '@(Localiser.GetJavascriptText("label.view"))';
sax.lbl.follow = '@(Localiser.GetJavascriptText("label.follow"))';
sax.dlg.title.organisation = '@(Localiser.GetJavascriptText("label.organisation"))';
</script>
<div class="row">
<div class="col-sm-5">
@* Filter Form *@
@using (@Html.BeginForm(FormMethod.Post, new { @id = "frmOrganisationFilter", @class = "sax-form", @action = "#", @method = "POST", onsubmit = "return false;" }))
{
@* Filter panel *@
<div class="sax-panel-filter mr-sm-2">
@* Filter header *@
<div class="sax-header row">
@* Filter caption *@
<div class="col"><div class="sax-caption">@Localiser["organisation.caption.organisations"]</div></div>
<div class="fixed row">
<div class="col">
<partial name="~/Views/Common/ResultsPaging.cshtml" />
</div>
<div class="fixed">
@* Burger menu *@
<ul class="nav navbar-nav navbar-dark navbar-right sax-burger">
<li class="dropdown-toggle caret-off">
<a href="#" class="dropdown" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="navbar-toggler-icon"></span></a>
<ul class="dropdown-menu dropdown-menu-right sax-dropdown-menu">@* Menu items will be inserted here. *@</ul>
</li>
</ul>
</div>
</div>
</div>
<div class="sax-content">
@* Generic Organisation filter - name etc. *@
<div class="sax-control row">
<div class="col-sm-4"><div class="sax-label text-left text-sm-right">@Localiser["label.search"]</div></div>
<div class="col-sm row">
<div class="col"><input type="search" name="Filter.Organisation" class="sax-input FilterOrganisation" maxlength="32" autocomplete="off" /></div>
</div>
</div>
@* Organisation type *@
<div class="sax-control row">
<div class="col-sm-4"><div class="sax-label text-left text-sm-right">@Localiser["label.type"]</div></div>
<div class="col-sm">
@Html.DropDownListFor(model => model.Filter.Category, Model.OrganisationCategoriesForSelect, Localiser["label.any"], new { @id = "", @class = "FilterCategory sax-select" })
</div>
</div>
@* Organisation sport *@
<div class="row pb4">
<div class="col-sm-4 sax-label text-left text-sm-right">@Localiser["label.sport"]</div>
<div class="col-sm">
<div class="row">
@Html.HiddenFor(model => model.Filter.SportId, new { @id = "", @class = "FilterSportId" })
<div class="col"><input type="text" class="FilterSportCaption sax-input" readonly="readonly" ondblclick="sax.searchOrganisations.selectFilterSport()" /> </div>
<div class="fixed row">
<div class="sax-action" onclick="sax.searchOrganisations.selectFilterSport();"><img src="~/img/action/search24.png" alt="@(Localiser["label.search"])" title="@(Localiser["label.search"])" /></div>
<div class="sax-action" onclick="sax.searchOrganisations.clearFilterSport();"><img src="~/img/action/delete24.png" alt="@(Localiser["label.clear"])" title="@(Localiser["label.clear"])" /></div>
</div>
</div>
</div>
</div>
@* Organisation region *@
<div class="row pb4">
<div class="col-sm-4 sax-label text-left text-sm-right">@Localiser["label.region"]</div>
<div class="col-sm">
<div class="row">
@Html.HiddenFor(model => model.Filter.RegionId, new { @id = "", @class = "FilterRegionId" })
<div class="col"><input type="text" class="FilterRegionCaption sax-input" readonly="readonly" ondblclick="sax.searchOrganisations.selectFilterRegion()" /> </div>
<div class="fixed row">
<div class="sax-action" onclick="sax.searchOrganisations.selectFilterRegion();"><img src="~/img/action/search24.png" alt="@(Localiser["label.search"])" title="@(Localiser["label.search"])" /></div>
<div class="sax-action" onclick="sax.searchOrganisations.clearFilterRegion();"><img src="~/img/action/delete24.png" alt="@(Localiser["label.clear"])" title="@(Localiser["label.clear"])" /></div>
</div>
</div>
</div>
</div>
</div>
@* Filter item templates *@
<div class="sax-panel-item-template">
@* Burger dropdown item template - ul is ignored *@
<ul class="sax-dropdown-menu Organisations">
<li class="sax-dropdown-item sax-action"><div class="sax-label">...</div></li>
</ul>
</div>
</div>
}
</div>
<div class="col">
@* Results Panel *@
<div class="sax-panel-results">
<div class="sax-panel-messages"></div>
<div class="sax-panel-item-list"></div>
@* Element templates *@
<div class="sax-panel-item-template">
@* Item template *@
<div class="sax-panel-item Organisation">
<div class="sax-header row">
<div class="col">
@* Organisation caption *@
<div class="sax-caption"><div class="sax-action"><span class="OrganisationName"></span></div></div>
</div>
<div class="fixed sax-actions">
@* Burger menu *@
<ul class="nav navbar-nav navbar-light navbar-right sax-burger">
<li class="dropdown-toggle caret-off">
<a href="#" class="dropdown" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="navbar-toggler-icon"></span></a>
<ul class="dropdown-menu dropdown-menu-right sax-dropdown-menu">@* Menu items will be inserted here. *@</ul>
</li>
</ul>
</div>
</div>
<div class="sax-content">
<div class="row">
<div class="col-sm-6"><div class="OrganisationCategory"></div></div>
<div class="col-sm-6 text-sm-right"><div class="OrganisationLocation"></div></div>
</div>
<div class="row">
<div class="col-sm-6"><div class="OrganisationSport"></div></div>
<div class="col-sm-6 text-sm-right"><div class="OrganisationLocation"></div></div>
</div>
</div>
</div>
@* Burger dropdown item template - ul is ignored *@
<ul class="sax-dropdown-menu Organisation">
<li class="sax-dropdown-item sax-action"><div class="sax-label">...</div></li>
</ul>
</div>
</div>
</div>
</div>
</div>
<partial name="~/Views/Common/RegionSelect.cshtml" />
<partial name="~/Views/Common/SportSelect.cshtml" />
<partial name="Panel-OrganisationDialog.cshtml" />
@@ -0,0 +1,22 @@
@model Model_Search_Organisations
@inject SaxLocaliser Localiser
@{
/* Organisation dialog panel */
}
<script type="text/javascript">
</script>
@using (@Html.BeginForm(FormMethod.Post, new { @id = "frmOrganisationId", @class = "sax-form" }))
{
<input type="hidden" name="OrganisationId" class="OrganisationId" />
}
<div id="dlgOrganisation" class="sax-dialog" title="">
@using (@Html.BeginForm(FormMethod.Post, new { @id = "frmOrganisation", @class = "sax-form", @onSubmit = "return false;" }))
{
}
</div>
@@ -55,7 +55,8 @@
@* Scripts *@
<script>
var sax = sax || { page: {}, url: {}, links: {}, data: {}, form: {}, ajax: {}, msg: {}, lbl: {}, dlg: { title: {}, btn: {} }, $frm: {}, $dlg: {}, $pnl: {} };
var sax = sax || {
page: {}, url: {}, links: {}, data: {}, form: {}, mdl: {}, ajax: {}, msg: {}, lbl: {}, dlg: { title: {}, btn: {} }, $frm: {}, $dlg: {}, $pnl: {} };
sax.url.base = '@Model.RedirectLocation.Base';
sax.url.home = '@Model.RedirectLocation.Home';
sax.url.sessionExpired = '@Model.RedirectLocation.Home_SessionExpired';
@@ -143,6 +144,14 @@
}
</div>
</li>
<li class="nav-item dropdown">
<a class="nav-link text-dark dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
@Localiser["label.search"]
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<div class="dropdown-item text-dark sax-action" onclick="sax.goToPage('Search/Organisations');">@Localiser["organisation.caption.organisations"]</div>
</div>
</li>
<li class="nav-item dropdown">
<a class="nav-link text-dark dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
@Localiser["label.security"]
@@ -8,7 +8,7 @@
{
margin: 8px auto;
background-color: #f8f8f8;
border: solid 2px var(--color-primary);
border: solid 1px var(--color-primary);
border-radius: 6px;
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
@@ -159,6 +159,11 @@
background-image: url('../img/action/process24.png');
}
.sax-header ul.nav.sax-burger ul.sax-dropdown-menu li.sax-action.sax-dropdown-item.sax-close
{
background-image: url('../img/action/prev24.png');
}
.sax-header ul.nav.sax-burger ul.sax-dropdown-menu li.sax-action.sax-dropdown-item:hover
{
background-color: #f8f8f8;
@@ -223,9 +223,9 @@
/* Buttons */
.sax-form button.sax-button,
.sax-form input[type="button"].sax-button,
.sax-form input[type="submit"].sax-button
button.sax-button,
input[type="button"].sax-button,
input[type="submit"].sax-button
{
height: auto;
width: auto;
@@ -242,9 +242,9 @@
border-radius: 4px;
}
.sax-form button.sax-button:hover,
.sax-form input[type="button"].sax-button:hover,
.sax-form input[type="submit"].sax-button:hover
button.sax-button:hover,
input[type="button"].sax-button:hover,
input[type="submit"].sax-button:hover
{
background-color: #EFE8F0;
}
@@ -288,7 +288,7 @@ a:focus
.ui-dialog.ui-widget.ui-widget-content
{
border-width: 2px;
border-width: 1px;
border-color: #606060;
border-color: var(--color-dialog);
-moz-box-shadow: 4px 4px 6px var(--color-dialog);
+3 -3
View File
@@ -32,7 +32,7 @@
var $items = $('.sax-panel-item-list', $pnl.results).hide().empty();
if (!response.success) return;
sax.data.articleOrganisations = response.organisations;
sax.refreshPaging(response);
sax.refreshPaging(response, '#frmArticleFilter', sax.refreshResults);
// Menu.
let $mnu = $('.sax-burger ul.sax-dropdown-menu', $pnl.filter).empty();
$mnu.append(sax.getFilterMenuOption(sax.lbl.refresh, function () { sax.refreshResults(); }, 'sax-refresh'));
@@ -405,7 +405,7 @@
//--------------------------------------------------------------
sax.selectSport = function ()
{
sax.data.selectSport.fn.selectSport({ caption: sax.dlg.title.selectSport, sportId: $('#ifArticleSportId').val(), fnCallback: sax.onSelectSport })
sax.mdl.selectSport.fn.selectSport({ caption: sax.dlg.title.selectSport, sportId: $('#ifArticleSportId').val(), fnCallback: sax.onSelectSport })
}
sax.onSelectSport = function (sport)
{
@@ -416,7 +416,7 @@
//--------------------------------------------------------------
sax.selectRegion = function ()
{
sax.data.selectRegion.fn.selectRegion({ caption: sax.dlg.title.selectRegion, regionId: $('#ifArticleRegionId').val(), fnCallback: sax.onSelectRegion })
sax.mdl.selectRegion.fn.selectRegion({ caption: sax.dlg.title.selectRegion, regionId: $('#ifArticleRegionId').val(), fnCallback: sax.onSelectRegion })
}
sax.onSelectRegion = function (region)
{
+2 -2
View File
@@ -135,8 +135,8 @@
}
sax.refreshPaging = function (response, context, refreshFn)
{
if (sax.resultsPaging.fn.refreshPaging)
sax.resultsPaging.fn.refreshPaging(response.paging, context, refreshFn);
if (sax.mdl.resultsPaging.fn.refreshPaging)
sax.mdl.resultsPaging.fn.refreshPaging(response.paging, context, refreshFn);
}
//--------------------------------------------------------------
@@ -154,10 +154,6 @@
$('.MemberDisplayName,.MemberTitle,.MemberFirstName,.MemberLastName', $frmM).hide();
sax.clearControlErrors();
}
sax.doCreateItem = function ()
{
sax.storeItem();
}
//--------------------------------------------------------------
sax.updateItem = function (item)
@@ -189,10 +185,6 @@
$dlg.member.dialog('option', 'title', sax.dlg.title.updateMember);
sax.openDialog($dlg.member, 600, 600);
}
sax.doUpdateItem = function ()
{
sax.storeItem();
}
//--------------------------------------------------------------
// Member Roles.
@@ -315,7 +307,7 @@
$('.sax-input', $frm.member).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()onUpdateItem; };
opt.buttons[sax.dlg.btn.cancel] = function () { $(this).dialog('close'); };
$dlg.member = $('#dlgMember').dialog(opt);
+12 -12
View File
@@ -145,21 +145,10 @@
sax.refreshResults(50);
}
//--------------------------------------------------------------
sax.selectRegion = function ()
{
sax.data.selectRegion.fn.selectRegion({ caption: sax.dlg.title.selectRegion, regionId: $('#ifOpportunityRegionId').val(), fnCallback: sax.onSelectRegion })
}
sax.onSelectRegion = function (region)
{
sax.clearControlError($('#ifOpportunityRegionId').val(region.id));
$('#ifOpportunityRegionCaption').val(region ? region.name : '');
}
//--------------------------------------------------------------
sax.selectSport = function ()
{
sax.data.selectSport.fn.selectSport({ caption: sax.dlg.title.selectSport, sportId: $('#ifOpportunitySportId').val(), fnCallback: sax.onSelectSport })
sax.mdl.selectSport.fn.selectSport({ caption: sax.dlg.title.selectSport, sportId: $('#ifOpportunitySportId').val(), fnCallback: sax.onSelectSport })
}
sax.onSelectSport = function (sport)
{
@@ -167,6 +156,17 @@
$('#ifOpportunitySportCaption').val(sport ? sport.name : '');
}
//--------------------------------------------------------------
sax.selectRegion = function ()
{
sax.mdl.selectRegion.fn.selectRegion({ caption: sax.dlg.title.selectRegion, regionId: $('#ifOpportunityRegionId').val(), fnCallback: sax.onSelectRegion })
}
sax.onSelectRegion = function (region)
{
sax.clearControlError($('#ifOpportunityRegionId').val(region.id));
$('#ifOpportunityRegionCaption').val(region ? region.name : '');
}
//--------------------------------------------------------------
sax.createItem = function ()
{
@@ -40,7 +40,7 @@
//--------------------------------------------------------------
sax.selectOrgSport = function ()
{
sax.data.selectSport.fn.selectSport({ caption: sax.dlg.title.selectSport, sportId: $('.OrganisationSportId', or.$frm).val(), fnCallback: sax.onSelectOrgSport })
sax.mdl.selectSport.fn.selectSport({ caption: sax.dlg.title.selectSport, sportId: $('.OrganisationSportId', or.$frm).val(), fnCallback: sax.onSelectOrgSport })
}
sax.onSelectOrgSport = function (sport)
{
@@ -51,7 +51,7 @@
//--------------------------------------------------------------
sax.selectOrgRegion = function ()
{
sax.data.selectRegion.fn.selectRegion({ caption: sax.dlg.title.selectRegion, regionId: $('.OrganisationRegionIdCountry', or.$frm).val(), typesInc:[30], fnCallback: sax.onSelectOrgRegion })
sax.mdl.selectRegion.fn.selectRegion({ caption: sax.dlg.title.selectRegion, regionId: $('.OrganisationRegionIdCountry', or.$frm).val(), typesInc:[30], fnCallback: sax.onSelectOrgRegion })
}
sax.onSelectOrgRegion = function (region)
{
+10 -10
View File
@@ -5,7 +5,7 @@
(function (win, doc, undef)
{
"use strict";
let sr = sax.data.selectRegion;
let sr = sax.mdl.selectRegion = sax.mdl.selectRegion || {};
sr.regions = {}; sr.fn = {}; sr.ajax = {}; sr.itemIdPrefix = 'Rgn_';
//--------------------------------------------------------------
@@ -31,9 +31,9 @@
}
sr.fn.refreshRegionsAndSelect = function (response)
{
//sax.debug('refreshRegionsAndSelect', response);
if (!response || !response.success) return;
sr.regions = response.regions;
//sax.debug(sr.cfg);
sr.fn.showSelectRegion();
}
sr.fn.showSelectRegion = function ()
@@ -61,8 +61,8 @@
let $regionsAvail = $('.sax-selectRegion-regions.AvailableRegions', sr.$dlg).empty();
let $regionTmpl = $('.sax-panel-item-template .sax-panel-item.Region', sr.$dlg);
let regions = [...sr.regions];
let typesInc = sr.cfg.typesInc||[];
let typesExc = sr.cfg.typesExc||[];
let typesInc = sr.cfg.typesInc || [];
let typesExc = sr.cfg.typesExc || [];
regions.sort(sr.fn.compareRegions);
for (let rgnIdx = 0; rgnIdx < regions.length; rgnIdx++)
{
@@ -72,7 +72,7 @@
if (typesInc.length && !typesInc.includes(region.regionType)) continue;
if (typesExc.length && typesExc.includes(region.regionType)) continue;
let $region = $regionTmpl.clone();
$region.prop('id', sr.itemIdPrefix + id).on('click', function () { sr.fn.onClickRegion(id); }).on('dblclick', function () { sr.fn.onDblClickRegion(id); }).find('.RegionName').text(region.name).end();
$region.on('click', function () { sr.fn.onClickRegion(region, $region); }).on('dblclick', function () { sr.fn.onDblClickRegion(region, $region); }).find('.RegionName').text(region.name).end();
if (id == sr.regionId) $region.addClass('sel');
$regionsAvail.append($region);
}
@@ -92,15 +92,15 @@
}
//--------------------------------------------------------------
sr.fn.onClickRegion = function (id)
sr.fn.onClickRegion = function (region, $region)
{
$('.SelectedRegionName', sr.$dlg).text(sr.fn.getRegionName(sr.regionId = id));
$('.SelectedRegionName', sr.$dlg).text(sr.fn.getRegionName(sr.regionId = region.id));
$('.sax-panel-item.Region', sr.$dlg).removeClass('sel');
$('.sax-panel-item.Region#' + sr.itemIdPrefix + id, sr.$dlg).addClass('sel');
$region.addClass('sel');
}
sr.fn.onDblClickRegion = function (id)
sr.fn.onDblClickRegion = function (region, $region)
{
sr.regionId = id;
sr.regionId = region.id;
sr.fn.storeSelectRegion();
}
sr.fn.storeSelectRegion = function ()
@@ -5,59 +5,77 @@
(function (win, doc, undef)
{
"use strict";
let rp = sax.resultsPaging = sax.resultsPaging || { fn: {}, msg: {} };
let rp = sax.mdl.resultsPaging = sax.mdl.resultsPaging || { fn: {}, msg: {}, contexts: [] };
//--------------------------------------------------------------
rp.fn.refreshPaging = function (paging)
rp.fn.refreshPaging = function (paging, contextSel, refreshFn)
{
//sax.debug('refreshPaging', paging);
rp.fn.init();
rp.paging = paging = paging || {};
rp.$rp.toggle(paging.paged);
$('.sax-paging-info', rp.$rp).text(sax.resultsPaging.msg.pageInfo.format(paging.pageNo, paging.pageCount));
//$('.sax-paging-first,.sax-paging-prev', rp.$rp).toggle(paging.pageNo > 1);
//$('.sax-paging-next,.sax-paging-last', rp.$rp).toggle(paging.pageNo < paging.pageCount);
let context = rp.fn.getContext(contextSel, refreshFn);
rp.fn.init(context);
context.paging = paging = paging || {};
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));
//$('.sax-paging-first,.sax-paging-prev', context.$rp).toggle(paging.pageNo > 1);
//$('.sax-paging-next,.sax-paging-last', context.$rp).toggle(paging.pageNo < paging.pageCount);
}
//--------------------------------------------------------------
rp.fn.firstPage = function ()
rp.fn.getContext = function (contextSel, refreshFn)
{
let page = rp.$pageNo.val() * 1;
for (let idx = 0; idx < rp.contexts.length; idx++)
{
if (rp.contexts[idx].sel == contextSel) return rp.contexts[idx];
}
//sax.debug('getContext Creating new context for: ', contextSel);
let context = { sel: contextSel, refreshFn: refreshFn }
rp.contexts.push(context);
return context;
}
//--------------------------------------------------------------
rp.fn.firstPage = function (context)
{
let page = context.$pageNo.val() * 1;
if (page < 2) return;
rp.$pageNo.val(1);
sax.refreshResults();
context.$pageNo.val(1);
context.refreshFn();
}
rp.fn.prevPage = function ()
rp.fn.prevPage = function (context)
{
let page = rp.$pageNo.val() * 1;
let page = context.$pageNo.val() * 1;
if (page < 2) return;
rp.$pageNo.val(page - 1);
sax.refreshResults();
context.$pageNo.val(page - 1);
context.refreshFn();
}
rp.fn.nextPage = function ()
rp.fn.nextPage = function (context)
{
let page = rp.$pageNo.val() * 1;
if (page > rp.paging.pageCount - 1) return;
rp.$pageNo.val(page + 1);
sax.refreshResults();
let page = context.$pageNo.val() * 1;
if (page > context.paging.pageCount - 1) return;
context.$pageNo.val(page + 1);
context.refreshFn();
}
rp.fn.lastPage = function ()
rp.fn.lastPage = function (context)
{
let page = rp.$pageNo.val() * 1;
if (page > rp.paging.pageCount - 1) return;
rp.$pageNo.val(rp.paging.pageCount);
sax.refreshResults();
let page = context.$pageNo.val() * 1;
if (page > context.paging.pageCount - 1) return;
context.$pageNo.val(context.paging.pageCount);
context.refreshFn();
}
//--------------------------------------------------------------
rp.fn.init = function ()
rp.fn.init = function (context)
{
rp.$rp = $('.sax-results-paging');
rp.$pageNo = $('.PagingPageNo', rp.$rp);
$('.sax-paging-first', rp.$rp).on('click',rp.fn.firstPage);
$('.sax-paging-prev', rp.$rp).on('click', rp.fn.prevPage);
$('.sax-paging-next', rp.$rp).on('click', rp.fn.nextPage);
$('.sax-paging-last', rp.$rp).on('click', rp.fn.lastPage);
if (context.$rp) return;
//sax.debug('resultsPaging.init Initialising Paging.', context);
context.$rp = $('.sax-results-paging', $(context.sel));
context.$pageNo = $('.PagingPageNo', context.$rp);
context.$pageLen = $('.PagingPageLength', context.$rp);
$('.sax-paging-first', context.$rp).off('click').on('click', function () { rp.fn.firstPage(context); });
$('.sax-paging-prev', context.$rp).off('click').on('click', function () { rp.fn.prevPage(context); });
$('.sax-paging-next', context.$rp).off('click').on('click', function () { rp.fn.nextPage(context); });
$('.sax-paging-last', context.$rp).off('click').on('click', function () { rp.fn.lastPage(context); });
}
}(window, window.document));
@@ -5,8 +5,8 @@
(function (win, doc, undef)
{
"use strict";
let ss = sax.data.selectSport;
ss.sports = {}; ss.fn = {}; ss.ajax = {}; ss.itemIdPrefix = 'Spt_';
let ss = sax.mdl.selectSport = sax.mdl.selectSport || {};
ss.sports = {}; ss.fn = {}; ss.ajax = {};;
//--------------------------------------------------------------
/*
@@ -30,6 +30,7 @@
}
ss.fn.refreshSportsAndSelect = function (response)
{
//sax.debug('refreshSportsAndSelect', response);
if (!response || !response.success) return;
ss.sports = response.sports;
ss.fn.showSelectSport();
@@ -67,7 +68,7 @@
let id = sport.id;
if (filter && !sport.name.match(reFilter)) continue;
let $sport = $sportTmpl.clone();
$sport.prop('id', ss.itemIdPrefix + id).on('click', function () { ss.fn.onClickSport(id); }).on('dblclick', function () { ss.fn.onDblClickSport(id); }).find('.SportName').text(sport.name).end();
$sport.on('click', function () { ss.fn.onClickSport(sport, $sport); }).on('dblclick', function () { ss.fn.onDblClickSport(sport, $sport); }).find('.SportName').text(sport.name).end();
if (id == ss.sportId) $sport.addClass('sel');
$sportsAvail.append($sport);
}
@@ -87,15 +88,15 @@
}
//--------------------------------------------------------------
ss.fn.onClickSport = function (id)
ss.fn.onClickSport = function (sport, $sport)
{
$('.SelectedSportName', ss.$dlg).text(ss.fn.getSportName(ss.sportId = id) || ' ');
$('.SelectedSportName', ss.$dlg).text(ss.fn.getSportName(ss.sportId = sport.id) || ' ');
$('.sax-panel-item.Sport', ss.$dlg).removeClass('sel');
$('.sax-panel-item.Sport#' + ss.itemIdPrefix + id, ss.$dlg).addClass('sel');
$sport.addClass('sel');
}
ss.fn.onDblClickSport = function (id)
ss.fn.onDblClickSport = function (sport, $sport)
{
ss.sportId = id;
ss.sportId = sport.id;
ss.fn.storeSelectSport();
}
ss.fn.storeSelectSport = function ()
@@ -0,0 +1,175 @@
/*
* Search - Organisations.
*/
(function (win, doc, undef)
{
"use strict";
let so = sax.searchOrganisations = {};
so.ajax = {}; so.data = {}; so.fn = {};
let $pnl = so.$pnl = {}, $frm = so.$frm = {}, $dlg = so.$dlg = {};
//--------------------------------------------------------------
so.refreshResults = function (delay)
{
if (!so.awaitingRefreshResponse)
{
$('.sax-burger', $pnl.filter).hide();
$('.sax-panel-item-list', $pnl.results).fadeOut(200).empty();
$('.sax-panel-messages', $pnl.results).hide().empty().append($('<div class="sax-message">' + sax.msg.dataQuerying + '</div>')).fadeIn(200);
}
so.ajax.refreshResults = so.ajax.refreshResults || { url: sax.url.base + 'Search/Ajax/Organisations', formId: 'frmOrganisationFilter', callbackFn: so.doRefreshResults };
sax.doAjaxRequest(so.ajax.refreshResults, delay || 50);
so.awaitingRefreshResponse = true;
}
so.doRefreshResults = function (response)
{
sax.debug('doRefreshResults', 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, '#frmOrganisationFilter', so.refreshResults);
// Menu.
let $bgr = $('.sax-burger', $pnl.filter);
let $mnu = $('ul.sax-dropdown-menu', $bgr).empty();
$mnu.append(so.getFilterMenuOption(sax.lbl.refresh, function () { so.refreshResults(); }, 'sax-refresh'));
$bgr.toggle(!!$('.sax-dropdown-item', $mnu).length);
// Items.
var items = response.organisations;
if (!items.length)
return $msgs.append($('<div class="sax-message">' + sax.msg.dataNoneFound + '</div>')).fadeIn(500);
for (let itemIdx = 0; itemIdx < items.length; itemIdx++)
$items.append(so.populateItem(so.getItemTemplate(), items[itemIdx]));
$items.fadeIn(50);
}
so.populateItem = function ($item, item)
{
if (!item) return;
$('.sax-panel-messages', $pnl.results).hide().empty();
$('.OrganisationName', $item).text(item.name);
$('.OrganisationEmail', $item).text(item.emailAddress);
let $bgr = $('.sax-burger', $item);
let $mnu = $('ul.sax-dropdown-menu', $bgr).empty();
{
let fnView = function () { so.viewItem(item) };
// ToDo $mnu.append(so.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;
}
//--------------------------------------------------------------
so.getFilterDropdownTemplate = function ()
{
return $('.sax-panel-item-template .sax-dropdown-menu.Organisations li.sax-dropdown-item', $pnl.filter).clone();
}
so.getFilterMenuOption = function (lbl, fn, cls)
{
return so.getMenuOption(so.getFilterDropdownTemplate(), lbl, fn, cls);
}
so.getItemTemplate = function ()
{
return $('.sax-panel-item-template .sax-panel-item.Organisation', $pnl.results).clone();
}
so.getItemDropdownTemplate = function ()
{
return $('.sax-panel-item-template .sax-dropdown-menu.Organisation li.sax-dropdown-item', $pnl.results).clone();
}
so.getItemMenuOption = function (lbl, fn, cls)
{
return so.getMenuOption(so.getItemDropdownTemplate(), lbl, fn, cls);
}
so.getMenuOption = function ($opt, lbl, fn, cls)
{
return $opt.find('div.sax-label').text(lbl).end().on('click', fn).addClass(cls);
}
//--------------------------------------------------------------
so.selectFilterSport = function ()
{
sax.debug('selectFilterSport');
let excludeIds = [];
sax.mdl.selectSport.fn.selectSport({ caption: sax.dlg.title.selectSport, sportId: $('.FilterSportId', $frm.filter).val(), excludeIds: excludeIds, fnCallback: so.onFilterSportSelected })
}
so.onFilterSportSelected = function (spt)
{
sax.debug('onFilterSportSelected', spt)
$('.FilterSportId', $frm.filter).val(spt ? spt.id : '');
$('.FilterSportCaption', $frm.filter).val(spt ? spt.name : '');
so.refreshResults();
}
so.clearFilterSport = function ()
{
$('.FilterSportId,.FilterSportCaption', $frm.filter).val('');
so.refreshResults();
}
//--------------------------------------------------------------
so.selectFilterRegion = function ()
{
sax.debug('selectFilterRegion');
let excludeIds = [];
sax.mdl.selectRegion.fn.selectRegion({ caption: sax.dlg.title.selectRegion, regionId: $('.FilterRegionId', $frm.filter).val(), excludeIds: excludeIds, fnCallback: so.onFilterRegionSelected })
}
so.onFilterRegionSelected = function (rgn)
{
sax.debug('onFilterRegionSelected', rgn)
$('.FilterRegionId', $frm.filter).val(rgn ? rgn.id : '');
$('.FilterRegionCaption', $frm.filter).val(rgn ? rgn.name : '');
so.refreshResults();
}
so.clearFilterRegion = function ()
{
$('.FilterRegionId,.FilterRegionCaption', $frm.filter).val('');
so.refreshResults();
}
//--------------------------------------------------------------
so.viewItem = function (item)
{
$('.OrganisationId', $frm.orgId).val(item.id);
so.ajax.organisation = so.ajax.organisation || { url: sax.url.base + 'Search/Ajax/GetOrganisation', formId: 'frmOrganisationId', callbackFn: so.onViewItem };
sax.doAjaxRequest(so.ajax.organisation, 50);
}
so.onViewItem = function (response)
{
sax.debug('onViewItem', response);
if (!response.success) return;
let frm = $frm.org;
let item = so.data.organisation = response.organisation;
$('.OrganisationName', frm).toggle(!item.awaiting).val(item.name);
sax.clearControlErrors();
$dlg.org.dialog('option', 'title', sax.dlg.title.organisation);
sax.openDialog($dlg.org, 600, 600);
}
//--------------------------------------------------------------
$(function ()
{
$pnl.orgs = $('.sax-panel.Organisations');
$pnl.filter = $('.sax-panel-filter', $pnl.orgs);
$pnl.results = $('.sax-panel-results', $pnl.orgs);
$frm.filter = $('#frmOrganisationFilter', $pnl.orgs);
$('.FilterOrganisation', $frm.filter).on('input', function () { so.refreshResults(250); }).on('keypress', function (event)
{
if (event.keyCode == 13) setTimeout(so.refreshResults, 50);
});
$('.FilterCategory', $frm.filter).on('change', function () { so.refreshResults(); });
var opt = sax.dlgOpts();
opt.buttons[sax.dlg.btn.cancel] = function () { $(this).dialog('close'); };
$dlg.org = $('#dlgOrganisation').dialog(opt);
$frm.orgId = $('#frmOrganisationId');
$frm.org = $('#frmOrganisation', $dlg.org);
setTimeout(so.refreshResults, 250);
});
}(window, window.document));
/* The End */
+43 -44
View File
@@ -10,10 +10,10 @@
//--------------------------------------------------------------
sax.refreshProfileContactInfo = function ()
{
var $section = $('.sax-panel-section.ProfileContact');
$section.removeClass('sax-edit').addClass('sax-populating');
$('.sax-property', $section).hide();
sax.showDataRefreshingMsg($section);
if ($pnl.proCon.hasClass('sax-edit'))
$pnl.proCon.slideUp(750, function () { $pnl.proCon.removeClass('sax-edit').addClass('sax-populating').slideDown(750); });
$('.sax-property', $pnl.proCon).hide();
sax.showDataRefreshingMsg($pnl.proCon);
sax.refreshProfileContact(sax.onRefreshProfileContactInfo);
}
sax.refreshProfileContactForm = function ()
@@ -32,16 +32,15 @@
{
//sax.debug('onRefreshProfileContactInfo', response);
if (!response || !response.success || !response.contact) return;
$('.sax-panel-section').show();
var $section = $('.sax-panel-section.ProfileContact');
$('.sax-message', $section).stop(true, false).fadeOut(200).empty();
$('.sax-value', $section).empty();
sax.refreshInfo($section, 'AccountEmailAddress', response.contact.emailAddress);
sax.refreshInfo($section, 'AccountName', response.contact.displayName);
sax.refreshInfo($section, 'AccountLocation', response.contact.locationCaption);
$('img.AccountContact', $section).prop('src', 'Image/Account/Contact/Profile?' + (new Date()).getTime());
sax.showNoInfoMsg($section);
$section.removeClass('sax-populating');
$('.sax-panel-section').slideDown(750);
$('.sax-message', $pnl.proCon).stop(true, false).fadeOut(200).empty();
$('.sax-value', $pnl.proConInf).empty();
sax.refreshInfo($pnl.proConInf, 'AccountEmailAddress', response.contact.emailAddress);
sax.refreshInfo($pnl.proConInf, 'AccountName', response.contact.displayName);
sax.refreshInfo($pnl.proConInf, 'AccountLocation', response.contact.locationCaption);
$('img.AccountContact', $pnl.proConInf).prop('src', 'Image/Account/Contact/Profile?' + (new Date()).getTime());
sax.showNoInfoMsg($pnl.proConInf);
$pnl.proCon.removeClass('sax-populating');
}
sax.onRefreshProfileContactForm = function (response)
{
@@ -49,30 +48,28 @@
if (!response || !response.success) return;
sax.data.genders = response.genders;
sax.data.months = response.months;
$('.sax-panel-section').hide();
var $section = $('.sax-panel-section.ProfileContact').show();
$('.sax-message', $section).stop(true, false).fadeOut(200).empty();
sax.refreshInput($section, 'AccountEmailAddress', response.contact.emailAddress);
sax.refreshSelect($section, 'AccountTitle', response.contact.title);
sax.refreshInput($section, 'AccountFirstName', response.contact.firstName);
sax.refreshInput($section, 'AccountLastName', response.contact.lastName);
sax.refreshTextArea($section, 'AccountAbout', response.contact.about);
$('.sax-message', $pnl.proCon).stop(true, false).fadeOut(200).empty();
sax.refreshInput($pnl.proConFrm, 'AccountEmailAddress', response.contact.emailAddress);
sax.refreshSelect($pnl.proConFrm, 'AccountTitle', response.contact.title);
sax.refreshInput($pnl.proConFrm, 'AccountFirstName', response.contact.firstName);
sax.refreshInput($pnl.proConFrm, 'AccountLastName', response.contact.lastName);
sax.refreshTextArea($pnl.proConFrm, 'AccountAbout', response.contact.about);
let $selGender = $('#cbAccountGender');
if (response.genders && response.genders.length)
sax.populateSelectCodeDesc($('#cbAccountGender'), response.genders);
sax.refreshSelect($section, 'AccountGender', response.contact.gender || '');
sax.refreshSelect($pnl.proConFrm, 'AccountGender', response.contact.gender || '');
sax.refreshDob();
sax.refreshSelect($section, 'AccountDobYear', response.contact.dobYear);
sax.refreshSelect($pnl.proConFrm, 'AccountDobYear', response.contact.dobYear);
sax.refreshDob();
sax.refreshSelect($section, 'AccountDobMonth', response.contact.dobMonth);
sax.refreshSelect($pnl.proConFrm, 'AccountDobMonth', response.contact.dobMonth);
sax.refreshDob();
sax.refreshSelect($section, 'AccountDobDay', response.contact.dobDay);
sax.refreshInput($section, 'AccountRegionIdCountry', response.contact.regionIdCountry);
sax.refreshInput($section, 'AccountRegionCaptionCountry', response.contact.regionCaptionCountry);
sax.refreshInput($section, 'AccountRegionIdProvince', response.contact.regionIdProvince);
sax.refreshInput($section, 'AccountRegionCaptionProvince', response.contact.regionCaptionProvince);
$('img.AccountContact', $section).prop('src', 'Image/Account/Contact/Profile?' + (new Date()).getTime());
$section.addClass('sax-edit');
sax.refreshSelect($pnl.proConFrm, 'AccountDobDay', response.contact.dobDay);
sax.refreshInput($pnl.proConFrm, 'AccountRegionIdCountry', response.contact.regionIdCountry);
sax.refreshInput($pnl.proConFrm, 'AccountRegionCaptionCountry', response.contact.regionCaptionCountry);
sax.refreshInput($pnl.proConFrm, 'AccountRegionIdProvince', response.contact.regionIdProvince);
sax.refreshInput($pnl.proConFrm, 'AccountRegionCaptionProvince', response.contact.regionCaptionProvince);
$('img.AccountContact', $pnl.proConFrm).prop('src', 'Image/Account/Contact/Profile?' + (new Date()).getTime());
$('.sax-panel-section').slideUp(750, function () { $pnl.proCon.addClass('sax-edit').slideDown(750); });
}
sax.storeProfileContact = function ()
{
@@ -129,7 +126,7 @@
//--------------------------------------------------------------
sax.selectRegionCountry = function ()
{
sax.data.selectRegion.fn.selectRegion({ caption: sax.dlg.title.selectRegionCountry, regionId: $('#ifAccountRegionIdCountry').val(), fnCallback: sax.onSelectRegionCountry })
sax.mdl.selectRegion.fn.selectRegion({ caption: sax.dlg.title.selectRegionCountry, regionId: $('#ifAccountRegionIdCountry').val(), fnCallback: sax.onSelectRegionCountry })
}
sax.onSelectRegionCountry = function (region)
{
@@ -154,7 +151,7 @@
if (file.type != 'image/jpg' && file.type != 'image/jpeg' && file.type != 'image/png') return sax.doAlert(sax.dlg.title.imageUpload, sax.msg.uploadFileTypeInvalid.format(sax.getFileType(file)));
$(".UploadMessage", context).text(sax.msg.uploadingFile.format(file.name));
$('img.ContactImageUploadProgress', context).fadeIn(200);
sax.clearControlError(sax.$pnl.contactImageDrag);
sax.clearControlError($pnl.contactImageDrag);
sax.data.contactImageUploadContext = context;
sax.ajax.uploadContactImage = sax.ajax.uploadContactImage || { url: sax.url.base + 'Account/Ajax/UploadContactImage', callbackFn: sax.handleContactImageUploadResponse, noWaitIcon: true };
@@ -168,14 +165,13 @@
let context = sax.data.contactImageUploadContext;
//sax.debug('handleContactImageUploadResponse', response, context);
if (!response) return;
var $section = $('.sax-panel-section.ProfileContact');
sax.refreshControlValues(response.controlValues, context);
$(".UploadMessage", context).empty();
$('img.ContactImageUploadProgress', context).hide();
if (response.success)
{
$dlg.selectContactImage.dialog('close');
$('img.AccountContact', $section).prop('src', 'Image/Account/Contact/Profile?' + (new Date()).getTime());
$('img.AccountContact', $pnl.proConFrm).prop('src', 'Image/Account/Contact/Profile?' + (new Date()).getTime());
}
}
sax.selectContactImage = function ()
@@ -198,16 +194,19 @@
//--------------------------------------------------------------
$(function ()
{
sax.$pnl.proCon = $('.sax-panel-section.ProfileContact');
$('.sax-action.sax-edit', sax.$pnl.proCon).on('click', function (evt) { sax.refreshProfileContactForm(); });
$('input,textarea', sax.$pnl.proCon).on('input', function () { sax.clearControlErrors(); sax.page.profileContactChanged = true; });
$('select', sax.$pnl.proCon).on('change', function () { sax.clearControlErrors(); sax.page.profileContactChanged = true; });
$pnl.proCon = $('.sax-panel-section.ProfileContact');
$pnl.proConInf = $('.sax-panel-info', $pnl.proCon);
$pnl.proConFrm = $('.sax-panel-form', $pnl.proCon);
$('.sax-action.sax-edit', $pnl.proConInf).on('click', function (evt) { sax.refreshProfileContactForm(); });
$('.sax-content', $pnl.proConInf).on('dblclick', function (evt) { sax.refreshProfileContactForm(); });
$('input,textarea', $pnl.proConFrm).on('input', function () { sax.clearControlErrors(); sax.page.profileContactChanged = true; });
$('select', $pnl.proConFrm).on('change', function () { sax.clearControlErrors(); sax.page.profileContactChanged = true; });
sax.$pnl.contactImageDrag = $('#pnlContactImageDrop')
$pnl.contactImageDrag = $('#pnlContactImageDrop')
.on("dragenter", function (evt) { sax.haltEvent(evt); })
.on("dragover", function (evt) { sax.haltEvent(evt); if (!sax.$pnl.contactImageDrag.hasClass(sax.classFileDrag)) sax.$pnl.contactImageDrag.addClass(sax.classFileDrag); })
.on("dragleave", function (evt) { sax.haltEvent(evt); sax.$pnl.contactImageDrag.removeClass(sax.classFileDrag); })
.on("drop", function (evt) { sax.haltEvent(evt); sax.$pnl.contactImageDrag.removeClass(sax.classFileDrag); sax.onDropContactImage(evt); });
.on("dragover", function (evt) { sax.haltEvent(evt); if (!$pnl.contactImageDrag.hasClass(sax.classFileDrag)) $pnl.contactImageDrag.addClass(sax.classFileDrag); })
.on("dragleave", function (evt) { sax.haltEvent(evt); $pnl.contactImageDrag.removeClass(sax.classFileDrag); })
.on("drop", function (evt) { sax.haltEvent(evt); $pnl.contactImageDrag.removeClass(sax.classFileDrag); sax.onDropContactImage(evt); });
var opt = sax.dlgOpts();
opt.buttons[sax.dlg.btn.ok] = function () { sax.uploadContactImage(); };
opt.buttons[sax.dlg.btn.cancel] = function () { $(this).dialog('close'); };
+35 -32
View File
@@ -5,16 +5,17 @@
(function (win, doc, undef)
{
"use strict";
let $pnl = sax.$pnl, $dlg = sax.$dlg, $frm = sax.$frm;
let ps = sax.mdl.profileSports = sax.mdl.profileSports || {};
let $pnl = ps.$pnl = {}, $dlg = ps.$dlg = {}, $frm = ps.$frm = {};
ps.data = { };
//--------------------------------------------------------------
sax.refreshProfileSportsInfo = function (delay)
{
var $section = $('.sax-panel-section.ProfileSports');
$section.removeClass('sax-edit').addClass('sax-populating');
$('.sax-property', $section).hide();
sax.showDataRefreshingMsg($section);
sax.refreshProfileSports(sax.onRefreshProfileSportsInfo);
$pnl.proSpt.removeClass('sax-edit').addClass('sax-populating');
$('.sax-property', $pnl.proSpt).hide();
sax.showDataRefreshingMsg($pnl.proSpt);
sax.refreshProfileSports(ps.onRefreshProfileSportsInfo);
}
sax.refreshProfileSports = function (callbackFn)
{
@@ -24,23 +25,23 @@
sax.ajax.profileSports.callbackFn = callbackFn;
sax.doAjaxRequest(sax.ajax.profileSports, 50);
}
sax.onRefreshProfileSportsInfo = function (response)
ps.onRefreshProfileSportsInfo = function (response)
{
//sax.debug('onRefreshProfileSportsInfo', response);
if (!response || !response.success) return;
var $section = $('.sax-panel-section.ProfileSports');
$('.sax-message', $section).stop(true, false).fadeOut(200).empty();
$('.sax-message', $pnl.proSpt).stop(true, false).fadeOut(200).empty();
sax.profile.sports.Ids = [];
let items = response.sports;
if (!items) return;
let $items = $('.sax-panel-results.ProfileSports', $section).empty();
let $tmpl = $('.sax-panel-item-template .sax-panel-item.ProfileSport', $section);
let $items = $('.sax-panel-results.ProfileSports', $pnl.proSpt).empty();
let $tmpl = $('.sax-panel-item-template .sax-panel-item.ProfileSport', $pnl.proSpt);
for (let itemIdx = 0; itemIdx < items.length; itemIdx++)
{
let item = items[itemIdx];
sax.profile.sports.Ids.push(item.sportId);
let $item = $tmpl.clone().prop('id', 'ProSpt_' + item.id);
$('.sax-header .sax-action.sax-edit', $item).on('click', function (evt) { sax.updateProfileSport(item.id); });
$('.sax-header .sax-action.sax-edit', $item).on('click', function (evt) { ps.updateProfileSport(item.id); });
$('.sax-content', $item).on('dblclick', function (evt) { ps.updateProfileSport(item.id); });
$('.sax-header .sax-action.sax-experience', $item).on('click', function (evt) { sax.showSportExperience(item); });
$('.SportName', $item).text(item.sportName);
$('.SportParticipationValue', $item).text(item.sportParticipation);
@@ -50,74 +51,76 @@
$items.append($item);
}
$items.show();
sax.showNoInfoMsg($section);
$section.removeClass('sax-populating');
sax.showNoInfoMsg($pnl.proSpt);
$pnl.proSpt.removeClass('sax-populating');
}
sax.addProfileSport = function ()
ps.addProfileSport = function ()
{
//sax.debug('addProfileSport');
let dlg = $dlg.profileSport;
$('.UserSportId,.ProfileSportExists,#ifProfileSportId,input.sax-input,select.sax-select', dlg).val('');
let dlg = $dlg.proSpt;
$('.UserSportId,.ProfileSportExists,#ifProfileSportId,input.sax-input,textarea.sax-textarea,select.sax-select', dlg).val('');
$('.SelectSport', dlg).show();
dlg.dialog('option', 'title', sax.dlg.title.addUserSport);
sax.openDialog(dlg, 480, 400);
sax.openDialog(dlg, 640, 480);
}
sax.updateProfileSport = function (id)
ps.updateProfileSport = function (id)
{
//sax.debug('updateProfileSport', id);
$('#frmProfileSportId .UserSportId').val(id);
sax.ajax.profileSport = sax.ajax.profileSport || { url: sax.url.base + 'Account/Ajax/GetProfileSport', formId: 'frmProfileSportId', callbackFn: sax.doUpdateProfileSport };
sax.ajax.profileSport = sax.ajax.profileSport || { url: sax.url.base + 'Account/Ajax/GetProfileSport', formId: 'frmProfileSportId', callbackFn: ps.doUpdateProfileSport };
sax.doAjaxRequest(sax.ajax.profileSport, 50);
}
sax.doUpdateProfileSport = function (response)
ps.doUpdateProfileSport = function (response)
{
//sax.debug('doUpdateProfileSport', response);
let dlg = $dlg.profileSport;
let dlg = $dlg.proSpt;
let item = response.sport;
$('.UserSportId', dlg).val(item.id);
$('.ProfileSportExists', dlg).val(1);
$('#ifProfileSportId', dlg).val(item.sportId);
$('#ifProfileSport', dlg).val(item.sportName);
$('#ifProfileSportAbout', dlg).val(item.sportAbout);
$('#cbProfileSportParticipation', dlg).val(item.sportParticipationCode);
$('#cbProfileSportOfficiating', dlg).val(item.sportOfficiatingCode);
$('.SelectSport', dlg).hide();
dlg.dialog('option', 'title', sax.dlg.title.updateUserSport);
sax.openDialog(dlg, 480, 400);
sax.openDialog(dlg, 640, 480);
}
sax.selectUserSport = function (sport)
{
//sax.debug('selectUserSport');
let excludeIds = $.grep(sax.profile.sports.Ids, function (value) { return !sport || value != sport.id; });
sax.data.selectSport.fn.selectSport({ caption: sax.dlg.title.selectSport, sportId: $('#frmProfileSport #ifProfileSportId').val(), excludeIds: excludeIds, fnCallback: sax.onSelectUserSport })
sax.mdl.selectSport.fn.selectSport({ caption: sax.dlg.title.selectSport, sportId: $('#frmProfileSport #ifProfileSportId').val(), excludeIds: excludeIds, fnCallback: ps.onSelectUserSport })
}
sax.onSelectUserSport = function (sport)
ps.onSelectUserSport = function (sport)
{
sax.clearControlError($('#ifProfileSportId').val(sport ? sport.id : ''));
$('#ifProfileSport').val(sport ? sport.name : '');
}
sax.storeProfileSport = function ()
ps.storeProfileSport = function ()
{
//sax.debug('storeProfileSport');
sax.clearControlErrors();
sax.ajax.storeProfileSport = sax.ajax.storeProfileSport || { url: sax.url.base + 'Account/Ajax/StoreProfileSport', formId: 'frmProfileSport', callbackFn: sax.onStoreProfileSport };
sax.ajax.storeProfileSport = sax.ajax.storeProfileSport || { url: sax.url.base + 'Account/Ajax/StoreProfileSport', formId: 'frmProfileSport', callbackFn: ps.onStoreProfileSport };
sax.doAjaxRequest(sax.ajax.storeProfileSport, 50);
}
sax.onStoreProfileSport = function (response)
ps.onStoreProfileSport = function (response)
{
sax.refreshControlValues(response.controlValues);
if (!response || !response.success) return;
$dlg.profileSport.dialog('close');
$dlg.proSpt.dialog('close');
sax.refreshProfileSportsInfo();
}
//--------------------------------------------------------------
$(function ()
{
$('.sax-panel-section.ProfileSports .sax-action.sax-add').on('click', function (evt) { sax.addProfileSport(); });
$pnl.proSpt = $('.sax-panel-section.ProfileSports');
$('.sax-action.sax-add', $pnl.proSpt).on('click', function (evt) { ps.addProfileSport(); });
var opt = sax.dlgOpts();
opt.buttons[sax.dlg.btn.ok] = function () { sax.storeProfileSport(); };
opt.buttons[sax.dlg.btn.ok] = function () { ps.storeProfileSport(); };
opt.buttons[sax.dlg.btn.cancel] = function () { $(this).dialog('close'); };
$dlg.profileSport = $('#dlgProfileSport').dialog(opt);
$dlg.proSpt = $('#dlgProfileSport').dialog(opt);
});
//--------------------------------------------------------------
+11 -3
View File
@@ -18,7 +18,7 @@ namespace Saxonite.Net.Standard.Base.App
//-------------------------------------------------------------------
public static class Version
{
private static String version { get; } = "1.1.6.0";
private static String version { get; } = "1.1.6.1";
// Retrieve version.
public static String GetFullVersion () { return version; }
public static String GetAppVersion ()
@@ -40,8 +40,16 @@ namespace Saxonite.Net.Standard.Base.App
//-------------------------------------------------------------------
// Version history.
//-------------------------------------------------------------------
// 1.1.6 ?-Aug-2021 ?
// - ?
// 1.1.8 ?-Oct-2021 ?
// -
// 1.1.7 14-Oct-2021 Online Organisation Search
// - Online Profile Sport About & snags.
// - Online Organisation Search.
// - Admin Awaiting item counts on home page.
// 1.1.6 19-Sep-2021 Online profile.
// - Online burger menus - all menus with icons.
// - Online Profile - About.
// - Sport specific speciality label.
// 1.1.5 19-Aug-2021 Profile Sport Experience.
// - Online Profile Sport Experience.
// 1.1.4 9-Aug-2021 Organisation Articles.
@@ -88,6 +88,7 @@ namespace Saxonite.Net.Standard.Base.App
// System codes.
private readonly Dictionary<Sax.CodeType, List<TypeCodeDesc>> codeTypes = new Dictionary<Sax.CodeType, List<TypeCodeDesc>>();
public List<TypeCodeDesc> DataItemTypeCodes { get { return GetCodesOfType(Sax.CodeType.DataItemType); } }
public List<TypeCodeDesc> YesNoCodes { get { return GetCodesOfType(Sax.CodeType.YesNo); } }
public List<TypeCodeDesc> GenderCodes { get { return GetCodesOfType(Sax.CodeType.Gender); } }
public List<TypeCodeDesc> SportSpecialityLabelCodes { get { return GetCodesOfType(Sax.CodeType.SportSpecialityLabel); } }
public List<TypeCodeDesc> SportParticipationCodes { get { return GetCodesOfType(Sax.CodeType.SportParticipation); } }
@@ -3,6 +3,7 @@ using Sarand.Net.Standard.Base.Core;
using Saxonite.Net.Standard.Base.App;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Saxonite.Net.Standard.Base.Bus
@@ -282,6 +283,15 @@ namespace Saxonite.Net.Standard.Base.Bus
// Item list extension methods.
public static class SaxOrganisationList
{
//-------------------------------------------------------------------
/// <summary>
/// Extract the Organisation Ids.
/// </summary>
public static List<SysId>GetIds(this List<SaxOrganisation> values)
{
return values.Select(item => item.Id).ToList();
}
//-------------------------------------------------------------------
/// <summary>
/// Extract the first Organisation in list with the specified Id.
+15 -1
View File
@@ -28,6 +28,7 @@ namespace Saxonite.Net.Standard.Base.Bus
// Sport.
SportId,
Sport_Name,
About,
SportParticipation,
SportParticipation_Code,
SportParticipation_Desc,
@@ -51,6 +52,7 @@ namespace Saxonite.Net.Standard.Base.Bus
{
public SysId UserAccountId { get; set; }
public SysId SportId { get; set; }
public String About { get; set; } = String.Empty;
public Sax.SportParticipation Participation { get; set; }
public Sax.SportOfficiating Officiating { get; set; }
public String UserSportData { get; set; }
@@ -78,6 +80,11 @@ namespace Saxonite.Net.Standard.Base.Bus
get { return data.SportId; }
set { CheckChanged(data.SportId, value); data.SportId = value; }
}
public String About
{
get { return data.About; }
set { CheckChanged(data.About, value); data.About = value; }
}
public Sax.SportParticipation Participation
{
get { return data.Participation; }
@@ -98,6 +105,7 @@ namespace Saxonite.Net.Standard.Base.Bus
{
UserAccountId = data.UserAccountId;
SportId = data.SportId;
About = data.About;
Participation = data.Participation;
Officiating = data.Officiating;
UserSportData = data.UserSportData;
@@ -117,9 +125,10 @@ namespace Saxonite.Net.Standard.Base.Bus
{
// Identifies the field that has invalid data.
public ValidValue UserAccountId { get; set; } = ValidValue.Valid;
public ValidValue SportId { get; set; } = ValidValue.Valid;
public ValidValue About { get; set; } = ValidValue.Valid;
public ValidValue Participation { get; set; } = ValidValue.Valid;
public ValidValue Officiating { get; set; } = ValidValue.Valid;
public ValidValue SportId { get; set; } = ValidValue.Valid;
public ValidValue UserSportData { get; set; } = ValidValue.Valid;
}
@@ -187,6 +196,11 @@ namespace Saxonite.Net.Standard.Base.Bus
get { return data.SportId; }
protected set { data.SportId = value; }
}
public String About
{
get { return data.About; }
set { data.About = value; }
}
public Sax.SportParticipation Participation
{
get { return data.Participation; }
@@ -1,4 +1,5 @@
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
using Saxonite.Net.Standard.Base.App;
using Saxonite.Net.Standard.Base.Bus;
using System;
@@ -25,6 +26,13 @@ namespace Saxonite.Net.Standard.Base.Consoles
//-------------------------------------------------------------------
// Utilities.
public abstract void PopulateCachedDataToInternals(SaxInternals internals);
/// <summary>
/// Encrypted Ids are stored in cache to ensure that they are consistent throughout a user's session
/// by persisting them through the life of the cache (application restart).
/// <para>Required as the encrypted values are compared in javascript.</para>
/// <para>Candidate encrypted value supplied by calling routine as cache doesn't know how to encrypt - used if Id not previously encrypted.</para>
/// </summary>
public abstract String GetEncryptedId(Sax.DataItemType itemType, SysId id, String candidateValue);
//-------------------------------------------------------------------
// Regions.
@@ -36,6 +44,13 @@ namespace Saxonite.Net.Standard.Base.Consoles
/// Get the cached list of active regions.
/// </summary>
public abstract List<SaxRegion.Data> GetActiveRegions();
/// <summary>
/// Persistent encrypted Region Ids.
/// </summary>
public String GetEncryptedRegionId(SysId regionId, String candidateValue)
{
return GetEncryptedId(Sax.DataItemType.Region, regionId, candidateValue);
}
//-------------------------------------------------------------------
// Sports.
@@ -47,6 +62,13 @@ namespace Saxonite.Net.Standard.Base.Consoles
/// Get the cached list of active sports.
/// </summary>
public abstract List<SaxSport.Data> GetActiveSports();
/// <summary>
/// Persistent encrypted Sport Ids.
/// </summary>
public String GetEncryptedSportId(SysId sportId, String candidateValue)
{
return GetEncryptedId(Sax.DataItemType.Sport, sportId, candidateValue);
}
//-------------------------------------------------------------------
}
@@ -91,6 +91,12 @@ namespace Saxonite.Net.Standard.Base.Mgr
errField.SportId = SacsHierarchyItem.ValidValue.Invalid;
return SetErrorState("User Sport must be specified");
}
// About.
if (errField.About != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.About, "about", (long)SaxDbDfn_Core.GetColTextLen(SaxDbDfn_Core.ColumnIdx.UserSport_About)))
{
errField.About = SacsHierarchyItem.ValidValue.Invalid;
return false;
}
//---------------------------------------------------------------
// Common properties.
@@ -214,6 +214,7 @@ namespace Saxonite.Net.Standard.Dbas.Mgr
dbUserSport._Id = SysId.ToLong(userSport.Id);
dbUserSport._UserAccountId = SysId.ToInt(userSport.UserAccountId);
dbUserSport._SportId = SysId.ToInt(userSport.SportId);
dbUserSport._About = userSport.About;
dbUserSport._Participation = (short)userSport.Participation;
dbUserSport._Officiating = (short)userSport.Officiating;
dbUserSport._UserSportData = userSport.UserSportData;
@@ -236,6 +237,7 @@ namespace Saxonite.Net.Standard.Dbas.Mgr
//userSport.Id = new SysId(dbUserSport._Id);
//userSport.UserAccountId = new SysId(dbUserSport._UserAccountId);
//userSport.SportId = new SysId(dbUserSport._SportId);
userSport.About = dbUserSport._About;
userSport.Participation = (Sax.SportParticipation)dbUserSport._Participation;
userSport.Officiating = (Sax.SportOfficiating)dbUserSport._Officiating;
userSport.UserSportData = dbUserSport._UserSportData;