This commit is contained in:
2021-07-02 09:28:37 +01:00
parent 03873bbdf4
commit 03ea1058be
64 changed files with 3038 additions and 250 deletions
@@ -33,9 +33,9 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
// Sport.
public long SportId { get; set; }
public String SportName { get; set; }
// Region.
public long RegionId { get; set; }
public String RegionName { get; set; }
// Region - country.
public long RegionIdCountry { get; set; }
public String RegionNameCountry { get; set; }
// Common properties.
public String StatusCode { get; set; }
public String StatusDesc { get; set; }
@@ -57,9 +57,9 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
using (SaxSport sport = ReferenceMgr.GetSportById(organisation.SportIdPrimary))
data.SportName = sport?.Name ?? "";
// Region.
data.RegionId = SysId.ToLong(organisation.RegionIdPrimary);
data.RegionIdCountry = SysId.ToLong(organisation.RegionIdPrimary);
using (SaxRegion region = ReferenceMgr.GetRegionById(organisation.RegionIdPrimary))
data.RegionName = region?.Name ?? "";
data.RegionNameCountry = region?.Name ?? "";
// Common properties.
data.StatusCode = organisation.StatusCode;
data.StatusDesc = organisation.StatusDesc;
@@ -154,8 +154,8 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
MemberCount = StringUtil.ToLong(values.GetString(colMemberCount.DataName)),
SportId = values.GetLong(colSportId.DataName),
SportName = values.GetString(colSportName.DataName),
RegionId = values.GetLong(colRegionId.DataName),
RegionName = values.GetString(colRegionName.DataName),
RegionIdCountry = values.GetLong(colRegionId.DataName),
RegionNameCountry = values.GetString(colRegionName.DataName),
StatusCode = values.GetString(colStatus.DataName),
StatusDesc = SacsSystem.GetStatusDescForCode(values.GetString(colStatus.DataName))
};
@@ -257,8 +257,8 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
organisation.OrganisationCategory = model.OrganisationCategory;
if (model.OrganisationSportId != null)
organisation.SportIdPrimary = model.OrganisationSportId.ToSysId();
if (model.OrganisationRegionId != null)
organisation.RegionIdPrimary = model.OrganisationRegionId.ToSysId();
if (model.OrganisationRegionIdCountry != null)
organisation.RegionIdPrimary = model.OrganisationRegionIdCountry.ToSysId();
// Common properties.
if (model.OrganisationStatusCode != null)
organisation.Status = model.OrganisationStatus;
@@ -53,12 +53,20 @@ namespace Saxonite.Net.Core.Web.Admin.Models
public String OrganisationCategoryValue { get; set; }
public Sax.OrganisationCategory OrganisationCategory { get { return (Sax.OrganisationCategory)OrganisationCategoryCodes.GetTypeForCode(OrganisationCategoryValue); } }
public String OrganisationSportId { get; set; }
public String OrganisationRegionId { get; set; }
public String OrganisationRegionIdCountry { get; set; }
// Common properties.
public String OrganisationNotes { get; set; }
public String OrganisationStatusCode { get; set; }
public SaStatus OrganisationStatus { get { return SacsSystem.GetStatusForCode(OrganisationStatusCode); } }
// Utilities.
public bool IsSportMandatory()
{
if (OrganisationCategory == Sax.OrganisationCategory.Club) return true;
if (OrganisationCategory == Sax.OrganisationCategory.Association) return true;
return false;
}
//-------------------------------------------------------------------
// Validation.
//-------------------------------------------------------------------
@@ -89,6 +97,44 @@ namespace Saxonite.Net.Core.Web.Admin.Models
responseData.SetControlError(nameof(OrganisationCategoryValue), Localiser["msg.validation.mandatory.value"]);
}
// Organisation sport.
if (OrganisationSportId != null)
{
if (SysId.IsValid(OrganisationSportId.ToSysId()) || IsSportMandatory())
{
using (SaxSport sport = ReferenceMgr.GetSportById(OrganisationSportId.ToSysId()))
{
if (sport == null)
responseData.SetControlError(nameof(OrganisationSportId), Localiser["msg.validation.invalid.value"]);
}
}
}
// Organisation country.
if (OrganisationRegionIdCountry != null)
{
using (SaxRegion region = ReferenceMgr.GetRegionById(OrganisationRegionIdCountry.ToSysId()))
{
if (region == null)
responseData.SetControlError(nameof(OrganisationRegionIdCountry), Localiser["msg.validation.invalid.value"]);
else if (region.RegionType != Sax.RegionType.Country)
responseData.SetControlError(nameof(OrganisationRegionIdCountry), "Organisation region must be a country");
}
if (!StringUtil.IsEmpty(OrganisationName))
{
// Name must be unqiue within region.
SaxOrganisation.Params prmOrganisation = new SaxOrganisation.Params();
if (SysId.IsValid(OrganisationId.ToSysId()))
prmOrganisation.IdsExcluded.Add(OrganisationId.ToSysId());
prmOrganisation.NameFull = OrganisationName;
prmOrganisation.RegionIdsIncluded.Add(OrganisationRegionIdCountry.ToSysId());
prmOrganisation.StatusCat = SaxOrganisation.StatusCat.Any;
if (AccountMgr.GetOrganisationCount(prmOrganisation) > 0)
responseData.SetControlError(nameof(OrganisationName), Localiser["msg.validation.duplicate.value"]);
}
}
// Organisation status.
if (OrganisationStatusCode != null)
{
@@ -90,8 +90,6 @@ namespace Saxonite.Net.Core.Web.Admin.Models
// User title.
if (UserTitle != null)
{
if (StringUtil.IsEmpty(UserTitle))
responseData.SetControlError(nameof(UserTitle), Localiser["msg.validation.mandatory.value"]);
}
// User first name.
@@ -165,6 +165,12 @@
<data name="label.columns" xml:space="preserve">
<value>Columns</value>
</data>
<data name="label.country" xml:space="preserve">
<value>Country</value>
</data>
<data name="label.county" xml:space="preserve">
<value>County</value>
</data>
<data name="label.create" xml:space="preserve">
<value>Create</value>
</data>
@@ -231,6 +237,9 @@
<data name="label.no" xml:space="preserve">
<value>No</value>
</data>
<data name="label.not.specified" xml:space="preserve">
<value>Not specified</value>
</data>
<data name="label.ok" xml:space="preserve">
<value>OK</value>
</data>
@@ -252,6 +261,9 @@
<data name="label.previous" xml:space="preserve">
<value>Previous</value>
</data>
<data name="label.province" xml:space="preserve">
<value>Province</value>
</data>
<data name="label.reference" xml:space="preserve">
<value>Reference</value>
</data>
@@ -56,7 +56,7 @@
@* Organisation sport *@
<div class="sax-form-control OrganisationSportId">
<div class="sax-label">
<label for="ifOrganisationSportId"><span><span class="required">*</span> @Localiser["label.sport"]</span></label>
<label for="ifOrganisationSportCaption"><span><span class="required">*</span> @Localiser["label.sport"]</span></label>
</div>
<div class="sax-control row">
@Html.HiddenFor(model => model.OrganisationSportId, new { @id = "ifOrganisationSportId", @class = "OrganisationSportId" })
@@ -67,13 +67,13 @@
</div>
@* Organisation region *@
<div class="sax-form-control OrganisationRegionId">
<div class="sax-form-control OrganisationRegionIdCountry">
<div class="sax-label">
<label for="ifOrganisationRegionId"><span><span class="required">*</span> @Localiser["label.region"]</span></label>
<label for="ifOrganisationRegionCaptionCountry"><span><span class="required">*</span> @Localiser["label.country"]</span></label>
</div>
<div class="sax-control row">
@Html.HiddenFor(model => model.OrganisationRegionId, new { @id = "ifOrganisationRegionId", @class = "OrganisationRegionId" })
<div class="col"><input type="text" id="ifOrganisationRegionCaption" class="OrganisationRegionCaption sax-input" readonly="readonly" ondblclick="sax.selectRegion()" /> </div>
@Html.HiddenFor(model => model.OrganisationRegionIdCountry, new { @id = "ifOrganisationRegionIdCountry", @class = "OrganisationRegionIdCountry" })
<div class="col"><input type="text" id="ifOrganisationRegionCaptionCountry" class="OrganisationRegionCaptionCountry sax-input" readonly="readonly" ondblclick="sax.selectRegion()" /> </div>
<div class="fixed"><button id="pbSelectRegion" class="sax-button" style="min-width:auto;margin-left:4px;padding:4px 6px" onclick="sax.selectRegion()">@Localiser["label.select"]</button></div>
</div>
<div class="sax-message"></div>
@@ -36,7 +36,7 @@
<label for="cbUserTitle"><span><span class="required"></span> @Localiser["label.title"]</span></label>
</div>
<div class="sax-control">
@Html.DropDownListFor(model => model.UserTitle, Model.TitlesForSelect, Localiser["label.select"], new { @id = "cbUserTitle", @class = "UserTitle sax-select" })
@Html.DropDownListFor(model => model.UserTitle, Model.TitlesForSelect, Localiser["label.not.specified"], new { @id = "cbUserTitle", @class = "UserTitle sax-select" })
</div>
<div class="sax-message"></div>
</div>
@@ -89,6 +89,7 @@
let $frm = sax.$frm.organisation;
$('.OrganisationSportId', $frm).val(rgn.id);
$('.OrganisationSportCaption', $frm).val(rgn.name);
sax.clearControlError($('.OrganisationSportCaption', $frm));
}
//--------------------------------------------------------------
@@ -115,15 +116,16 @@
{
//sax.debug('onRegionSelected', rgn);
let $frm = sax.$frm.organisation;
$('.OrganisationRegionId', $frm).val(rgn.id);
$('.OrganisationRegionCaption', $frm).val(rgn.name);
$('.OrganisationRegionIdCountry', $frm).val(rgn.id);
$('.OrganisationRegionCaptionCountry', $frm).val(rgn.name);
sax.clearControlError($('.OrganisationRegionCaptionCountry', $frm));
}
//--------------------------------------------------------------
sax.createItem = function ()
{
let $frm = sax.$frm.organisation;
$('.OrganisationId,.OrganisationSportId,.OrganisationRegionId,input[type="text"],textarea,select', $frm).val('');
$('.OrganisationId,.OrganisationSportId,.OrganisationRegionIdCountry,input[type="text"],textarea,select', $frm).val('');
$('.OrganisationStatus', $frm).val(sax.data.defaultStatusCode);
sax.clearControlErrors();
sax.$dlg.organisation.dialog('option', 'title', sax.dlg.title.createOrganisation);
@@ -154,8 +156,8 @@
$('.OrganisationCategory', $frm).val(item.categoryCode);
$('.OrganisationSportId', $frm).val(item.sportId);
$('.OrganisationSportCaption', $frm).val(item.sportName);
$('.OrganisationRegionId', $frm).val(item.regionId);
$('.OrganisationRegionCaption', $frm).val(item.regionName);
$('.OrganisationRegionIdCountry', $frm).val(item.regionIdCountry);
$('.OrganisationRegionCaptionCountry', $frm).val(item.regionNameCountry);
$('.OrganisationStatus', $frm).val(item.statusCode);
sax.clearControlErrors();
sax.$dlg.organisation.dialog('option', 'title', sax.dlg.title.updateOrganisation);
@@ -206,6 +208,7 @@
$('.sax-panel-filter .sax-action.sax-item-create').on('click', function () { sax.createItem(); });
$('.sax-panel-filter .sax-action.sax-results-refresh').on('click', function () { sax.refreshResults(); });
$('.sax-input').on('input', function () { sax.clearControlError(this); });
$('.sax-select').on('change', function () { sax.clearControlError(this); });
sax.$frm.filter = $('#frmOrganisationFilter');
$('.FilterOrganisation', sax.$frm.filter).on('input', function () { sax.refreshResults(250); });