v1.2.10.2
This commit is contained in:
@@ -15,6 +15,8 @@ using Sarand.Net.Standard.Base.Utils;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using static Saxonite.Net.Standard.Base.App.Sax.Config;
|
||||
using static Saxonite.Net.Standard.Base.Bus.SaxArticle;
|
||||
|
||||
namespace Saxonite.Net.Core.Web.Online.Controllers
|
||||
{
|
||||
@@ -37,10 +39,21 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
|
||||
private class ProfileSportResponseItemData : ProfileSportResponseListData
|
||||
{
|
||||
public String SportAbout { get; set; }
|
||||
public List<SportContactData> Contacts { get; set; }
|
||||
public String SportParticipatingCode { get; set; }
|
||||
public String SportPreparingCode { get; set; }
|
||||
public String SportOfficiatingCode { get; set; }
|
||||
}
|
||||
public class SportContactData
|
||||
{
|
||||
public String ContactType { get; set; }
|
||||
public String ContactTypeDesc { get; set; }
|
||||
public String Title { get; set; }
|
||||
public String FirstName { get; set; }
|
||||
public String LastName { get; set; }
|
||||
public String EmailAddress { get; set; }
|
||||
public String Phone { get; set; }
|
||||
}
|
||||
private void PopulateProfileSportResponseListData(Model_Account model, SaxUserSport userSport, SaxSport sport, ProfileSportResponseListData data)
|
||||
{
|
||||
data.Id = model.EncryptId(userSport.Id);
|
||||
@@ -55,6 +68,24 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
|
||||
{
|
||||
PopulateProfileSportResponseListData(model, userSport, sport, data);
|
||||
data.SportAbout = userSport.About;
|
||||
// Sport Contacts.
|
||||
SaxSportContactsData sportContacts = new SaxSportContactsData(userSport.ContactsData);
|
||||
foreach (Sax.SportContactType contactType in sportContacts.ContactTypes)
|
||||
{
|
||||
if (data.Contacts == null) data.Contacts = new List<SportContactData>();
|
||||
SportContactData sportContact =
|
||||
new SportContactData()
|
||||
{
|
||||
ContactType = SportContactTypeCodes.GetCodeForType(contactType),
|
||||
ContactTypeDesc = Localiser.GetSportContactTypeCaption(contactType),
|
||||
Title = sportContacts.GetContactTitle(contactType),
|
||||
FirstName = sportContacts.GetContactFirstName(contactType),
|
||||
LastName = sportContacts.GetContactLastName(contactType),
|
||||
EmailAddress = sportContacts.GetContactEmailAddress(contactType),
|
||||
Phone = sportContacts.GetContactPhone(contactType),
|
||||
};
|
||||
data.Contacts.Add(sportContact);
|
||||
}
|
||||
data.SportParticipatingCode = SportParticipatingCodes.GetCodeForType(userSport.Participating);
|
||||
data.SportPreparingCode = SportPreparingCodes.GetCodeForType(userSport.Preparing);
|
||||
data.SportOfficiatingCode = SportOfficiatingCodes.GetCodeForType(userSport.Officiating);
|
||||
@@ -352,6 +383,8 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
|
||||
// Populate item properties.
|
||||
if (model.ProfileSportAbout != null)
|
||||
userSport.About = model.ProfileSportAbout;
|
||||
if (model.Contacts.ContactsData != null)
|
||||
userSport.ContactsData = model.Contacts.ContactsData.ToXml();
|
||||
if (model.ProfileSportParticipatingCode != null)
|
||||
userSport.Participating = model.ProfileSportParticipating;
|
||||
if (model.ProfileSportPreparingCode != null)
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace Saxonite.Net.Core.Web.Online.Models
|
||||
{
|
||||
String methodValue = ContactMethod[idx];
|
||||
String value = ContactValue[idx];
|
||||
if (methodValue == null & value == null) continue;
|
||||
if (methodValue == null && value == null) continue;
|
||||
Sax.ContactMethod method = EnumUtil.ParseEnum(methodValue, Sax.ContactMethod.Unknown);
|
||||
if (method > 0 && !value.IsEmpty() && SaxContactMethodHelper.IsValidContactMethodValue(method, value))
|
||||
ContactData.SetContactMethodValue(method, value);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
@@ -8,10 +9,13 @@ 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;
|
||||
using static Saxonite.Net.Standard.Base.App.Sax;
|
||||
using static Saxonite.Net.Standard.Base.Bus.SaxArticle;
|
||||
|
||||
namespace Saxonite.Net.Core.Web.Online.Models
|
||||
{
|
||||
@@ -87,11 +91,13 @@ namespace Saxonite.Net.Core.Web.Online.Models
|
||||
public String Count { get; set; }
|
||||
public String[] ContactType { get; set; }
|
||||
public String[] UserAccountId { get; set; }
|
||||
public String[] ContactName { get; set; }
|
||||
public String[] ContactPhone { get; set; }
|
||||
public String[] ContactEmail { get; set; }
|
||||
public String[] Title { get; set; }
|
||||
public String[] FirstName { get; set; }
|
||||
public String[] LastName { get; set; }
|
||||
public String[] EmailAddress { get; set; }
|
||||
public String[] Phone { get; set; }
|
||||
/// <summary>Sport Contacts to be populated during validation.</summary>
|
||||
public SaxSportContactsData SportContactsData { get; set; }
|
||||
public SaxSportContactsData ContactsData { get; set; }
|
||||
}
|
||||
public SportsContactsData Contacts {get; } = new SportsContactsData();
|
||||
|
||||
@@ -197,6 +203,8 @@ namespace Saxonite.Net.Core.Web.Online.Models
|
||||
// Validate Sport data.
|
||||
public bool ValidateProfileSportData(SaxController_Base.AjaxResponse_Data responseData)
|
||||
{
|
||||
String fn = GetType().Name + ".ValidateProfileSportData";
|
||||
|
||||
// Sport.
|
||||
if (ProfileSportId != null)
|
||||
{
|
||||
@@ -216,6 +224,40 @@ namespace Saxonite.Net.Core.Web.Online.Models
|
||||
}
|
||||
}
|
||||
|
||||
// Sport Contacts.
|
||||
if (Contacts != null)
|
||||
{
|
||||
Contacts.ContactsData = new SaxSportContactsData("");
|
||||
Contacts.ContactType= Contacts.ContactType ?? new String[0];
|
||||
Contacts.Title= Contacts.Title ?? new String[0];
|
||||
Contacts.FirstName = Contacts.FirstName ?? new String[0];
|
||||
Contacts.LastName = Contacts.LastName ?? new String[0];
|
||||
Contacts.EmailAddress = Contacts.EmailAddress ?? new String[0];
|
||||
for (int idx = 0; idx < Contacts.ContactType.Length; idx++)
|
||||
{
|
||||
String contactTypeValue = Contacts.ContactType[idx];
|
||||
String title = idx < Contacts.Title.Length ? Contacts.Title[idx] : null;
|
||||
String firstName = idx < Contacts.FirstName.Length ? Contacts.FirstName[idx] : null;
|
||||
String lastName = idx < Contacts.LastName.Length ? Contacts.LastName[idx] : null;
|
||||
String emailAddress = idx < Contacts.EmailAddress.Length ? Contacts.EmailAddress[idx] : null;
|
||||
String phone = idx < Contacts.Phone.Length ? Contacts.Phone[idx] : null;
|
||||
if (StringUtil.IsBlank(contactTypeValue) && StringUtil.IsBlank(lastName)) continue;
|
||||
Sax.SportContactType contactType= (Sax.SportContactType)SportContactTypeCodes.GetTypeForCode(contactTypeValue);
|
||||
if (contactType > 0)
|
||||
{
|
||||
Contacts.ContactsData.SetContactName(contactType, title, firstName, lastName);
|
||||
Contacts.ContactsData.SetContactEmailAddress(contactType, emailAddress);
|
||||
Contacts.ContactsData.SetContactPhone(contactType, phone);
|
||||
}
|
||||
else SaLogger.Warn(fn + " Invalid Sport Contact data. Type: " + contactTypeValue + ". Last name: " + lastName);
|
||||
}
|
||||
if (Contacts.ContactsData.ContactTypes.Count != Contacts.Count.ToInt())
|
||||
{
|
||||
SaLogger.Warn(fn + " Inconsistent Contact Methods received. Expected: " + Contacts.Count + ". Received: " + Contacts.ContactsData.ContactTypes.Count);
|
||||
responseData.SetMessage("caption.contact.method", "System error");
|
||||
}
|
||||
}
|
||||
|
||||
return !responseData.HasControlErrors();
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
@* Sport Contacts *@
|
||||
<div class="sax-form-control SportContacts">
|
||||
<input type="hidden" name="Sport.Contacts" value="0" />
|
||||
<input type="hidden" name="Contacts.Count" value="0" />
|
||||
<div class="row">
|
||||
<div class="col-sm-3 row">
|
||||
<div class="col">
|
||||
@@ -56,13 +56,15 @@
|
||||
<table class="sax-panel-item-template">
|
||||
<tr class="Contact">
|
||||
<td style="width:20px;"><div class="sax-label nowrap"></div></td>
|
||||
<td class="sax-name" style="width:70%;word-break: break-all;"></td>
|
||||
<td class="sax-details" style="width:70%;word-break: break-all;"></td>
|
||||
<td class="sax-value Name" style="width:40%;word-break: break-all;"></td>
|
||||
<td class="sax-value Details" style="width:40%;overflow-x:hidden;"></td>
|
||||
<td class="sax-actions right nowrap" style="min-width:10px;">
|
||||
<input type="hidden" name="Contacts.ContactType" />
|
||||
<input type="hidden" name="Contacts.ContactName" />
|
||||
<input type="hidden" name="Contacts.ContactPhone" />
|
||||
<input type="hidden" name="Contacts.ContactEmail" />
|
||||
<input type="hidden" name="Contacts.Title" />
|
||||
<input type="hidden" name="Contacts.FirstName" />
|
||||
<input type="hidden" name="Contacts.LastName" />
|
||||
<input type="hidden" name="Contacts.Phone" />
|
||||
<input type="hidden" name="Contacts.EmailAddress" />
|
||||
<div class="nowrap">
|
||||
<div class="inlineb sax-action sax-edit"><img src="~/img/action/edit16.png" alt="@(Localiser["label.edit"])" title="@(Localiser["label.edit"])" /></div>
|
||||
<div class="inlineb sax-action sax-remove"><img src="~/img/action/delete16.png" alt="@(Localiser["label.remove"])" title="@(Localiser["label.remove"])" /></div>
|
||||
|
||||
@@ -8,6 +8,11 @@
|
||||
"Location": "MsSql:.\\SQLExpress2012.Saxonite_Core_Demo",
|
||||
"User": "sax-demo-user",
|
||||
"Password": "sax-demo-202105"
|
||||
},
|
||||
"Support": {
|
||||
"Location": "MsSql:.\\SQLExpress2012.Saxonite_Support_Demo",
|
||||
"User": "sax-demo-user",
|
||||
"Password": "sax-demo-202105"
|
||||
}
|
||||
},
|
||||
"Security": {
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
@@ -174,8 +174,7 @@
|
||||
//--------------------------------------------------------------
|
||||
po.getConMthCfg = function (usedMths, mth, val)
|
||||
{
|
||||
let cfg = { fnCallback: po.applyConMth, methods: po.data.contactMethods, methodsUsed: usedMths, method: mth, value: val };
|
||||
return cfg;
|
||||
return { fnCallback: po.applyConMth, methods: po.data.contactMethods, methodsUsed: usedMths, method: mth, value: val };
|
||||
}
|
||||
po.getUsedMths = function ()
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
{
|
||||
//--------------------------------------------------------------
|
||||
"use strict";
|
||||
let ps = sax.mdl.profileSports = { ajax: {}, data: {}, $pnl: {}, $dlg: {}, $frm: {} };
|
||||
let ps = sax.mdl.profileSports = { ajax: {}, data: {}, $pnl: {}, $tmpl: {}, $dlg: {}, $frm: {} };
|
||||
let $pnl = ps.$pnl, $dlg = ps.$dlg, $frm = ps.$frm;
|
||||
//--------------------------------------------------------------
|
||||
sax.refreshProfileSportsInfo = function (delay)
|
||||
@@ -78,6 +78,7 @@
|
||||
let dlg = $dlg.spt;
|
||||
$('.UserSportId,.ProfileSportExists,#ifProfileSportId,input.sax-input,textarea.sax-textarea,select.sax-select', dlg).val('');
|
||||
$('.SelectSport', dlg).show();
|
||||
$pnl.sptConTbl.empty();
|
||||
sax.clearControlErrors(dlg);
|
||||
}
|
||||
ps.updateProfileSport = function (item)
|
||||
@@ -99,6 +100,13 @@
|
||||
$('#ifProfileSportId', frm).val(item.sportId);
|
||||
$('#ifProfileSport', frm).val(item.sportName);
|
||||
$('#ifProfileSportAbout', frm).val(item.sportAbout);
|
||||
let contacts = item.contacts || [];
|
||||
for (let idx = 0; idx < contacts.length; idx++)
|
||||
{
|
||||
let contact = contacts[idx];
|
||||
$pnl.sptConTbl.append(ps.populateSportContact(ps.$tmpl.sptCon.clone(), contact));
|
||||
}
|
||||
ps.sortSptCons();
|
||||
$('#cbProfileSportParticipating', frm).val(item.sportParticipatingCode);
|
||||
$('#cbProfileSportPreparing', frm).val(item.sportPreparingCode);
|
||||
$('#cbProfileSportOfficiating', frm).val(item.sportOfficiatingCode);
|
||||
@@ -121,34 +129,60 @@
|
||||
//--------------------------------------------------------------
|
||||
ps.getSportContactCfg = function (contact)
|
||||
{
|
||||
let cfg = { fnCallback: ps.applySportContact, contactTypes: ps.data.contactTypes, titles: ps.data.titles, typesUsed: ps.getUsedContactTypes(), contact: contact};
|
||||
return cfg;
|
||||
return { fnCallback: ps.applySportContact, contactTypes: ps.data.contactTypes, titles: ps.data.titles, contactTypesUsed: !contact ? ps.getUsedContactTypes() : [], contact: contact };
|
||||
}
|
||||
ps.getUsedContactTypes = function ()
|
||||
{
|
||||
return $('input[name="Contacts.ContactTypes"]', $frm.org).map(function () { return $(this).val(); }).get();
|
||||
return $('.SportContacts input[name="Contacts.ContactType"]', $frm.org).map(function () { return $(this).val(); }).get();
|
||||
}
|
||||
ps.addSportContact = function ()
|
||||
{
|
||||
//sax.debug('addSportContact');
|
||||
ps.showSportContact(ps.getSportContactCfg());
|
||||
ps.editSportContact();
|
||||
}
|
||||
ps.editSportContact= function (contact)
|
||||
ps.editSportContact = function (contact)
|
||||
{
|
||||
//sax.debug('editSportContact');
|
||||
ps.showSportContact(ps.getSportContactCfg(contact));
|
||||
sax.mdl.sportContact.showSportContact(ps.getSportContactCfg(contact));
|
||||
}
|
||||
ps.showSportContact=function(cfg)
|
||||
ps.clearSportContact = function (contact)
|
||||
{
|
||||
sax.mdl.sportContact.showSportContact(cfg);
|
||||
$('#' + po.getSptConId(contact), $pnl.sptConTbl).remove();
|
||||
po.sortSptCons();
|
||||
}
|
||||
ps.getConId = function (contact)
|
||||
ps.getSptConId = function (contact)
|
||||
{
|
||||
return 'SptCon_' + contact.type;
|
||||
return 'SptCon_' + contact.contactType;
|
||||
}
|
||||
ps.applySportContact = function (contact)
|
||||
{
|
||||
//sax.debug('applySportContact', contact);
|
||||
let $sptCon = $('#' + ps.getSptConId(contact));
|
||||
if (!$sptCon.length) $pnl.sptConTbl.append($sptCon = ps.$tmpl.sptCon.clone());
|
||||
ps.populateSportContact($sptCon, contact);
|
||||
ps.sortSptCons();
|
||||
}
|
||||
ps.populateSportContact = function ($sptCon, contact)
|
||||
{
|
||||
$sptCon.prop('id', ps.getSptConId(contact));
|
||||
$('.sax-label', $sptCon).text(contact.contactTypeDesc);
|
||||
$('.sax-value.Name', $sptCon).text((contact.title + " " + contact.firstName + " " + contact.lastName).trim());
|
||||
$('.sax-value.Details', $sptCon).text(contact.emailAddress);
|
||||
$('input[name="Contacts.ContactType"]', $sptCon).val(contact.contactType);
|
||||
$('input[name="Contacts.Title"]', $sptCon).val(contact.title);
|
||||
$('input[name="Contacts.FirstName"]', $sptCon).val(contact.firstName);
|
||||
$('input[name="Contacts.LastName"]', $sptCon).val(contact.lastName);
|
||||
$('input[name="Contacts.EmailAddress"]', $sptCon).val(contact.emailAddress);
|
||||
$('input[name="Contacts.Phone"]', $sptCon).val(contact.phone);
|
||||
$sptCon.on('click', '.sax-action.sax-edit', function () { ps.editSportContact(contact); });
|
||||
$sptCon.on('click', '.sax-action.sax-remove', function () { ps.clearSportContact(contact); });
|
||||
return $sptCon;
|
||||
}
|
||||
ps.sortSptCons = function ()
|
||||
{
|
||||
let $rows = $pnl.sptConTbl.find('tr').detach().sort(function (a, b)
|
||||
{
|
||||
return $('.sax-label', a).text().localeCompare($('.sax-label', b).text());
|
||||
}).appendTo($pnl.sptConTbl);
|
||||
$('input[name="Contacts.Count"]', $pnl.sptCons).val($rows.length);
|
||||
}
|
||||
//--------------------------------------------------------------
|
||||
ps.storeProfileSport = function ()
|
||||
@@ -179,6 +213,9 @@
|
||||
$frm.spt.on('dblclick', '.ProfileSport.sax-input', ps.selectUserSport);
|
||||
$frm.spt.on('click', '.SelectSport.sax-button', ps.selectUserSport);
|
||||
$frm.spt.on('click', '.SportContacts .sax-action.sax-add', ps.addSportContact);
|
||||
$pnl.sptCons = $('.SportContacts', $dlg.spt);
|
||||
$pnl.sptConTbl = $('.Contacts table.sax-data', $pnl.sptCons);
|
||||
ps.$tmpl.sptCon = $('.sax-panel-item-template .Contact', $pnl.sptCons).detach();
|
||||
});
|
||||
//--------------------------------------------------------------
|
||||
}(window, window.document));
|
||||
|
||||
@@ -22,17 +22,18 @@
|
||||
{
|
||||
//sax.debug('showSportContact', cfg);
|
||||
sc.fn.cleanUp();
|
||||
cfg.contact = cfg.contact || {};
|
||||
sc.data.cfg = cfg;
|
||||
sc.populateContactTypes(cfg);
|
||||
sc.populateTitles(cfg);
|
||||
sc.fn.displaySportContact(cfg.contact || {});
|
||||
sc.fn.displaySportContact(cfg.contact);
|
||||
sax.clearControlErrors(sc.$dlg.sptCnt);
|
||||
sax.openDialog(sc.$dlg.sptCnt.dialog('option', { title: sc.data.cfg.caption || 'Sport Contact' }), sc.data.cfg.width || 640, sc.data.cfg.height || 320);
|
||||
}
|
||||
//--------------------------------------------------------------
|
||||
sc.populateContactTypes = function (cfg)
|
||||
{
|
||||
let contact = cfg.contact || {};
|
||||
let contact = cfg.contact;
|
||||
sc.$ctrl.contactType.empty();
|
||||
if (!contact.contactType)
|
||||
sc.$ctrl.contactType.append($('<option>').prop('selected', true));
|
||||
@@ -41,11 +42,10 @@
|
||||
if (typ.code && typ.code == cfg.contactType || !(cfg.contactTypesUsed || []).includes(typ.code))
|
||||
sc.$ctrl.contactType.append($('<option>').prop('value', typ.code).text(typ.desc));
|
||||
}
|
||||
//sc.$ctrl.contactType.val(contact.contactType).attr('disabled', contact.contactType && sc.$ctrl.contactType.val() == contact.contactType ? true : null);
|
||||
sc.$ctrl.contactType.val(contact.contactType).attr('disabled', contact.contactType && sc.$ctrl.contactType.val() == contact.contactType ? true : null);
|
||||
}
|
||||
sc.populateTitles = function (cfg)
|
||||
{
|
||||
let contact = cfg.contact || {};
|
||||
sc.$ctrl.title.empty();
|
||||
sc.$ctrl.title.append($('<option>').prop('selected', true));
|
||||
for (let typ of cfg.titles || [])
|
||||
@@ -56,7 +56,11 @@
|
||||
}
|
||||
sc.fn.displaySportContact = function (contact)
|
||||
{
|
||||
sc.$ctrl.emailAddress.val(contact.email);
|
||||
sc.$ctrl.contactType.val(contact.contactType);
|
||||
sc.$ctrl.emailAddress.val(contact.emailAddress);
|
||||
sc.$ctrl.title.val(contact.title);
|
||||
sc.$ctrl.firstName.val(contact.firstName);
|
||||
sc.$ctrl.lastName.val(contact.lastName);
|
||||
}
|
||||
//--------------------------------------------------------------
|
||||
sc.fn.storeSportContact = function ()
|
||||
@@ -69,7 +73,7 @@
|
||||
//sax.debug('storeSportContact handle response', response);
|
||||
sax.refreshControlValues(response.controlValues, sc.$dlg.sptCnt);
|
||||
if (!response.success || sax.hasControlErrors(sc.$dlg.sptCnt)) return;
|
||||
let contact = { contactType: sc.$ctrl.contactType.val(), email: sc.$ctrl.emailAddress.val(), title: sc.$ctrl.title.val(), firstName: sc.$ctrl.firstName.val(), lastName: sc.$ctrl.lastName.val() };
|
||||
let contact = { contactType: sc.$ctrl.contactType.val(), contactTypeDesc: $('option:selected', sc.$ctrl.contactType).text(), emailAddress: sc.$ctrl.emailAddress.val(), title: sc.$ctrl.title.val(), firstName: sc.$ctrl.firstName.val(), lastName: sc.$ctrl.lastName.val() };
|
||||
if (cfg.fnCallback) cfg.fnCallback(contact);
|
||||
sc.$dlg.sptCnt.dialog('close');
|
||||
sc.fn.cleanUp();
|
||||
|
||||
Reference in New Issue
Block a user