diff --git a/SaxoniteCoreWeb/Base/App/SaxLocaliser.cs b/SaxoniteCoreWeb/Base/App/SaxLocaliser.cs index 3c6b2f5..b8cc30d 100644 --- a/SaxoniteCoreWeb/Base/App/SaxLocaliser.cs +++ b/SaxoniteCoreWeb/Base/App/SaxLocaliser.cs @@ -41,30 +41,39 @@ namespace Saxonite.Net.Core.Web.Base.App /// Retrieve localised text. public LocalizedString GetText(string key) { - return GetText(key, new object[] { }); + return GetText(key, null); } + /// Retrieve localised text. + public LocalizedString GetText(string key, bool logMissingKey = true) + { + return GetText(key, null, logMissingKey); + } + /// Retrieve localised text. public LocalizedString GetText(string key, object param) { return GetText(key, new object[] { param }); } + /// Retrieve localised text. public LocalizedString GetText(string key, object param1, object param2) { return GetText(key, new object[] { param1, param2 }); } - public LocalizedString GetText(string key, object[] parameters) + /// Retrieve localised text. + public LocalizedString GetText(string key, object[] parameters, bool logMissingKey = true) { - LocalizedString text = MainProperties.GetString(key, parameters); + LocalizedString text = parameters == null || parameters.IsEmpty() ? MainProperties.GetString(key) : MainProperties.GetString(key, parameters); if (text.ResourceNotFound) { - SaLogger.Debug(GetType().Name + ".GetText Key not found: " + key); // Look up key in alternative property files. foreach (IStringLocalizer properties in AlternativeProperties ?? new List()) { - text = properties.GetString(key, parameters); + text = parameters == null || parameters.IsEmpty() ? properties.GetString(key) : properties.GetString(key, parameters); if (!text.ResourceNotFound) break; } } + if (text.ResourceNotFound && logMissingKey) + SaLogger.Debug(GetType().Name + ".GetText Key not found: " + key); return text; } @@ -135,19 +144,21 @@ namespace Saxonite.Net.Core.Web.Base.App //------------------------------------------------------------------- // Specific phrase translation. //------------------------------------------------------------------- - private class CodeCache + private class CodesCache { - public List genderCodes; - public List sportParticipationCodes; - public List sportOfficiatingCodes; - public List regionTypeCodes; - public List userRoleCodes; - public List organisationTypeCodes; - public List organisationCategoryCodes; - public List organisationRoleCodes; - public List opportunityTypeCodes; + private Dictionary> codeTypeCache { get; } = new Dictionary>(); + public List GetCodesOfType(Sax.CodeType codeType) + { + List codes = codeTypeCache.GetValue(codeType, null); + if (codes == null) + { + codes = SaxSystem.GetCodesOfType(codeType); + codeTypeCache.Add(codeType, codes); + } + return codes; + } } - private CodeCache codes = new CodeCache(); + private CodesCache codesCache = new CodesCache(); // Status. public String GetStatusCaption(SaStatus status) @@ -156,94 +167,100 @@ namespace Saxonite.Net.Core.Web.Base.App return SacsSystem.GetStatusDesc(status); } + // Generic code type. + private String GetCodeTypeCaption(Sax.CodeType codeType, T type) where T : struct, IConvertible + { + if (!(type is Enum)) + throw new ArgumentException(GetType().Name + ".GetCodeTypeCaption Type parameter must be an enumerated type. Type supplied: " + type.GetType().Name); + return GetCodeTypeCaption(codeType, (int)(type as IConvertible), type.ToString()); + } + private String GetCodeTypeCaption(Sax.CodeType codeType, int type, String typeName) + { + if (type < 1) return ""; + List codes = this.codesCache.GetCodesOfType(codeType); + TypeCodeDesc code = codes.GetEntryForType(type); + if (code != null) + { + // Code Type localisation. + String codeTypeKey = "codeType." + codeType.ToString() + "." + typeName; + String typeDesc = GetText(codeTypeKey, false); + if (typeDesc.EqualsCI(codeTypeKey)) + typeDesc = ""; + return StringUtil.OnEmpty(typeDesc, code.Desc); + } + return ""; + } + + // Yes/No. + public String GetYesNoCaption(Sax.YesNo yesNo) + { + return GetCodeTypeCaption(Sax.CodeType.YesNo, yesNo); + } + + // Data item type. + public String GetItemDataTypeCaption(Sax.DataItemType itemType) + { + return GetCodeTypeCaption(Sax.CodeType.DataItemType, itemType); + } + // Gender. public String GetGenderCaption(Sax.Gender gender) { - if ((int)gender < 1) return ""; - if (codes.genderCodes == null) - codes.genderCodes = SaxSystem.GetCodesOfType(Sax.CodeType.Gender); - // ToDo Opportunity Type localisation. - return codes.genderCodes.GetDescForType(gender); + return GetCodeTypeCaption(Sax.CodeType.Gender, gender); + } + + // Sport Speciality label. + public String GetSportSpecialityLabelCaption(Sax.SportSpecialityLabel specialityLabel) + { + return GetCodeTypeCaption(Sax.CodeType.SportSpecialityLabel, specialityLabel); } // Sport Participation. - public String GetSportParticipationTypeCaption(Sax.SportParticipation participation) + public String GetSportParticipationCaption(Sax.SportParticipation participation) { - if ((int)participation < 1) return ""; - if (codes.sportParticipationCodes == null) - codes.sportParticipationCodes = SaxSystem.GetCodesOfType(Sax.CodeType.SportParticipation); - // ToDo Sport Participation localisation. - return codes.sportParticipationCodes.GetDescForType(participation); + return GetCodeTypeCaption(Sax.CodeType.SportParticipation, participation); } // Sport Officiating. - public String GetSportOfficiatingTypeCaption(Sax.SportOfficiating participation) + public String GetSportOfficiatingCaption(Sax.SportOfficiating participation) { - if ((int)participation < 1) return ""; - if (codes.sportOfficiatingCodes == null) - codes.sportOfficiatingCodes = SaxSystem.GetCodesOfType(Sax.CodeType.SportOfficiating); - // ToDo Sport Officiating localisation. - return codes.sportOfficiatingCodes.GetDescForType(participation); + return GetCodeTypeCaption(Sax.CodeType.SportOfficiating, participation); } // Region type. public String GetRegionTypeCaption(Sax.RegionType regionType) { - if ((int)regionType < 1) return ""; - if (codes.regionTypeCodes == null) - codes.regionTypeCodes = SaxSystem.GetCodesOfType(Sax.CodeType.RegionType); - // ToDo Region type localisation. - return codes.regionTypeCodes.GetDescForType(regionType); + return GetCodeTypeCaption(Sax.CodeType.RegionType, regionType); } // User role. public String GetUserRoleCaption(Sax.UserRole userRole) { - if ((int)userRole < 1) return ""; - if (codes.userRoleCodes == null) - codes.userRoleCodes = SaxSystem.GetCodesOfType(Sax.CodeType.UserRole); - // ToDo User Role localisation. - return codes.userRoleCodes.GetDescForType(userRole); + return GetCodeTypeCaption(Sax.CodeType.UserRole, userRole); } // Organisation type. public String GetOrganisationTypeCaption(Sax.OrganisationType organisationType) { - if ((int)organisationType < 1) return ""; - if (codes.organisationTypeCodes == null) - codes.organisationTypeCodes = SaxSystem.GetCodesOfType(Sax.CodeType.OrganisationType); - // ToDo Organisation Type localisation. - return codes.organisationTypeCodes.GetDescForType(organisationType); + return GetCodeTypeCaption(Sax.CodeType.OrganisationType, organisationType); } // Organisation category. public String GetOrganisationCategoryCaption(Sax.OrganisationCategory organisationCategory) { - if ((int)organisationCategory < 1) return ""; - if (codes.organisationCategoryCodes == null) - codes.organisationCategoryCodes = SaxSystem.GetCodesOfType(Sax.CodeType.OrganisationCategory); - // ToDo Organisation Category localisation. - return codes.organisationCategoryCodes.GetDescForType(organisationCategory); + return GetCodeTypeCaption(Sax.CodeType.OrganisationCategory, organisationCategory); } // Organisation role. public String GetOrganisationRoleCaption(Sax.OrganisationRole organisationRole) { - if ((int)organisationRole < 1) return ""; - if (codes.organisationRoleCodes == null) - codes.organisationRoleCodes = SaxSystem.GetCodesOfType(Sax.CodeType.OrganisationRole); - // ToDo Organisation Role localisation. - return codes.organisationRoleCodes.GetDescForType(organisationRole); + return GetCodeTypeCaption(Sax.CodeType.OrganisationRole, organisationRole); } // Opportunity type. public String GetOpportunityTypeCaption(Sax.OpportunityType opportunityType) { - if ((int)opportunityType < 1) return ""; - if (codes.opportunityTypeCodes == null) - codes.opportunityTypeCodes = SaxSystem.GetCodesOfType(Sax.CodeType.OpportunityType); - // ToDo Opportunity Type localisation. - return codes.opportunityTypeCodes.GetDescForType(opportunityType); + return GetCodeTypeCaption(Sax.CodeType.OpportunityType, opportunityType); } //------------------------------------------------------------------- diff --git a/SaxoniteCoreWeb/Base/Models/SaxModel_Base.cs b/SaxoniteCoreWeb/Base/Models/SaxModel_Base.cs index ee260f5..65d76d4 100644 --- a/SaxoniteCoreWeb/Base/Models/SaxModel_Base.cs +++ b/SaxoniteCoreWeb/Base/Models/SaxModel_Base.cs @@ -288,8 +288,8 @@ namespace Saxonite.Net.Core.Web.Base.Models get { List values = new List(); - foreach (TypeCodeDesc yesNo in SaxSystem.GetCodesOfType(Sax.CodeType.YesNo)) - values.Add(new SelectListItem(yesNo.Code, GetYesNoCaption((Sax.YesNo)yesNo.Type))); + foreach (TypeCodeDesc yesNo in YesNoCodes) + values.Add(new SelectListItem(yesNo.Code, Localiser.GetYesNoCaption((Sax.YesNo)yesNo.Type))); return values; } } @@ -299,29 +299,48 @@ namespace Saxonite.Net.Core.Web.Base.Models { get { - List codes = new List(); - codes.Add(new SelectListItem("Default", "")); - codes.AddRange(new SelectList(SportSpecialityLabelCodes, "Code", "Desc")); - return codes; + List values = new List(); + values.Add(new SelectListItem("Default", "")); + foreach (TypeCodeDesc sportSpecialityLabel in SportSpecialityLabelCodes) + values.Add(new SelectListItem(sportSpecialityLabel.Code, Localiser.GetSportSpecialityLabelCaption((Sax.SportSpecialityLabel)sportSpecialityLabel.Type))); + return values; } } /// List of Sport Participation options for dropdown. public IEnumerable SportParticipationCodesForSelect { - get { return new SelectList(SportParticipationCodes, "Code", "Desc"); } + get + { + List values = new List(); + foreach (TypeCodeDesc sportParticipation in SportParticipationCodes) + values.Add(new SelectListItem(sportParticipation.Code, Localiser.GetSportParticipationCaption((Sax.SportParticipation)sportParticipation.Type))); + return values; + } } /// List of Sport Officiating options for dropdown. public IEnumerable SportOfficiatingCodesForSelect { - get { return new SelectList(SportOfficiatingCodes, "Code", "Desc"); } + get + { + List values = new List(); + foreach (TypeCodeDesc sportOfficiating in SportOfficiatingCodes) + values.Add(new SelectListItem(sportOfficiating.Code, Localiser.GetSportOfficiatingCaption((Sax.SportOfficiating)sportOfficiating.Type))); + return values; + } } /// List of Region Types for dropdown. public IEnumerable RegionTypesForSelect { - get { return new SelectList(RegionTypeCodes.FindAll(item => item.Type != (int)Sax.RegionType.Universe && item.Type != (int)Sax.RegionType.Galaxy), "Code", "Desc"); } + get + { + List values = new List(); + foreach (TypeCodeDesc organisationType in RegionTypeCodes.FindAll(item => item.Type != (int)Sax.RegionType.Universe && item.Type != (int)Sax.RegionType.Galaxy)) + values.Add(new SelectListItem(organisationType.Code, Localiser.GetRegionTypeCaption((Sax.RegionType)organisationType.Type))); + return values; + } } /// List of titles for dropdown. @@ -333,27 +352,25 @@ namespace Saxonite.Net.Core.Web.Base.Models /// List of Organisation Types for dropdown. public IEnumerable OrganisationTypesForSelect { - get { return new SelectList(OrganisationTypeCodes, "Code", "Desc"); } + get + { + List values = new List(); + foreach (TypeCodeDesc organisationType in OrganisationTypeCodes) + values.Add(new SelectListItem(organisationType.Code, Localiser.GetOrganisationTypeCaption((Sax.OrganisationType)organisationType.Type))); + return values; + } } /// List of Organisation Categories for dropdown. public IEnumerable OrganisationCategoriesForSelect { - get { return new SelectList(OrganisationCategoryCodes, "Code", "Desc"); } - } - - //------------------------------------------------------------------- - // Localisation. - //------------------------------------------------------------------- - public String GetItemDataTypeCaption(Sax.DataItemType itemType) - { - // Default - return code description. - return DataItemTypeCodes.GetDescForType(itemType); - } - public String GetYesNoCaption(Sax.YesNo yesNo) - { - // Default - return code description. - return YesNoCodes.GetDescForType(yesNo); + get + { + List values = new List(); + foreach (TypeCodeDesc organisationCategory in OrganisationCategoryCodes) + values.Add(new SelectListItem(organisationCategory.Code, Localiser.GetOrganisationCategoryCaption((Sax.OrganisationCategory)organisationCategory.Type))); + return values; + } } //------------------------------------------------------------------- diff --git a/SaxoniteCoreWebAdmin/wwwroot/css/sax-data.css b/SaxoniteCoreWebAdmin/wwwroot/css/sax-data.css index 7ccb301..d30bc60 100644 --- a/SaxoniteCoreWebAdmin/wwwroot/css/sax-data.css +++ b/SaxoniteCoreWebAdmin/wwwroot/css/sax-data.css @@ -135,8 +135,6 @@ margin: 6px auto; border: solid 1px #979797; border-radius: 6px; - -webkit-border-radius: 6px; - -moz-border-radius: 6px; overflow: hidden; } diff --git a/SaxoniteCoreWebAdmin/wwwroot/css/sax-form.css b/SaxoniteCoreWebAdmin/wwwroot/css/sax-form.css index 263f196..e863bd0 100644 --- a/SaxoniteCoreWebAdmin/wwwroot/css/sax-form.css +++ b/SaxoniteCoreWebAdmin/wwwroot/css/sax-form.css @@ -13,8 +13,6 @@ border: solid 1px #979797; border-color: var(--color-primary); border-radius: 4px; - -webkit-border-radius: 4px; - -moz-border-radius: 4px; overflow: hidden; } @@ -161,8 +159,6 @@ background-color: #fff; border: 1px solid #595959; border-radius: 2px; - -webkit-border-radius: 2px; - -moz-border-radius: 2px; outline: none; } diff --git a/SaxoniteCoreWebOnline/Localisation/SaxOnlineProperties.resx b/SaxoniteCoreWebOnline/Localisation/SaxOnlineProperties.resx index f4ed53b..3cc1f19 100644 --- a/SaxoniteCoreWebOnline/Localisation/SaxOnlineProperties.resx +++ b/SaxoniteCoreWebOnline/Localisation/SaxOnlineProperties.resx @@ -252,6 +252,9 @@ 1 character + + Clear + Close @@ -309,6 +312,9 @@ Experience + + First + First name @@ -336,6 +342,9 @@ Remember Me + + Last + Last name @@ -357,6 +366,9 @@ Name + + Next + No @@ -414,6 +426,9 @@ Postal code + + Previous + Province diff --git a/SaxoniteCoreWebOnline/Online/Controllers/AccountController-Ajax-Sports.cs b/SaxoniteCoreWebOnline/Online/Controllers/AccountController-Ajax-Sports.cs index d5f8433..e111e7f 100644 --- a/SaxoniteCoreWebOnline/Online/Controllers/AccountController-Ajax-Sports.cs +++ b/SaxoniteCoreWebOnline/Online/Controllers/AccountController-Ajax-Sports.cs @@ -47,9 +47,9 @@ namespace Saxonite.Net.Core.Web.Online.Controllers data.SportSpecialityLabel = model.GetSportSpecialityLabel(userSport.SportId); data.SportAbout = userSport.About; data.SportParticipationCode = SportParticipationCodes.GetCodeForType(userSport.Participation); - data.SportParticipation = Localiser.GetSportParticipationTypeCaption(userSport.Participation); + data.SportParticipation = Localiser.GetSportParticipationCaption(userSport.Participation); data.SportOfficiatingCode = SportOfficiatingCodes.GetCodeForType(userSport.Officiating); - data.SportOfficiating = Localiser.GetSportOfficiatingTypeCaption(userSport.Officiating); + data.SportOfficiating = Localiser.GetSportOfficiatingCaption(userSport.Officiating); data.CreatedOnFmt = DateUtil.Format(userSport.CreateStamp.On, "d-MMM-yyyy"); data.StatusCode = userSport.StatusCode; data.StatusDesc = userSport.StatusDesc; @@ -117,8 +117,8 @@ namespace Saxonite.Net.Core.Web.Online.Controllers SportId = model.GetEncryptedSportId(sportId), SportName = values.GetString(colSportName.DataName), SportSpecialityLabel = model.GetSportSpecialityLabel(sportId), - SportParticipation = Localiser.GetSportParticipationTypeCaption((Sax.SportParticipation)values.GetLong(colParticipation.DataName)), - SportOfficiating = Localiser.GetSportOfficiatingTypeCaption((Sax.SportOfficiating)values.GetLong(colOfficiating.DataName)), + SportParticipation = Localiser.GetSportParticipationCaption((Sax.SportParticipation)values.GetLong(colParticipation.DataName)), + SportOfficiating = Localiser.GetSportOfficiatingCaption((Sax.SportOfficiating)values.GetLong(colOfficiating.DataName)), StatusCode = values.GetString(colStatus.DataName), StatusDesc = SacsSystem.GetStatusDescForCode(values.GetString(colStatus.DataName)) }; diff --git a/SaxoniteCoreWebOnline/Online/Controllers/SearchController-Ajax-Organisations.cs b/SaxoniteCoreWebOnline/Online/Controllers/SearchController-Ajax-Organisations.cs index 0059e69..39936fe 100644 --- a/SaxoniteCoreWebOnline/Online/Controllers/SearchController-Ajax-Organisations.cs +++ b/SaxoniteCoreWebOnline/Online/Controllers/SearchController-Ajax-Organisations.cs @@ -14,6 +14,7 @@ using Sarand.Net.Standard.Base.Bus; using Sarand.Net.Standard.Base.Utils; using Sarand.Net.Standard.Base.Core; using Sarand.Net.Standard.Base.Dbas; +using Saxonite.Net.Standard.Base.App; namespace Saxonite.Net.Core.Web.Online.Controllers { @@ -29,10 +30,12 @@ namespace Saxonite.Net.Core.Web.Online.Controllers { public String Id { get; set; } public String Name { get; set; } + public String CategoryDesc { get; set; } public String SportId { get; set; } public String SportName { get; set; } public String RegionId { get; set; } public String RegionName { get; set; } + public String Location { get; set; } } private class AjaxResponse_Search_Organisations : AjaxResponse_Data { @@ -75,13 +78,14 @@ namespace Saxonite.Net.Core.Web.Online.Controllers // Item columns. ColumnDfn colId = AccountMgr.GetOrganisationColumnDfn(SaxOrganisation.Column.Id); ColumnDfn colName = AccountMgr.GetOrganisationColumnDfn(SaxOrganisation.Column.Name); + ColumnDfn colCategory = AccountMgr.GetOrganisationColumnDfn(SaxOrganisation.Column.OrganisationCategory_Desc); 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 columns = new List() { - colId, colName, + colId, colName, colCategory, colSportId, colSportName, colRegionId, colRegionName, }; @@ -96,14 +100,16 @@ namespace Saxonite.Net.Core.Web.Online.Controllers while (resultSet != null && resultSet.HasRows && resultSet.NextRecord()) { NamedValue.Map values = resultSet.GetRecordValues(); + Sax.OrganisationCategory category = (Sax.OrganisationCategory)OrganisationCategoryCodes.GetTypeForCode(values.GetString(colCategory.DataName)); 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))), + CategoryDesc = Localiser.GetOrganisationCategoryCaption(category), + //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), + //RegionId = model.GetEncryptedRegionId(new SysId(values.GetLong(colRegionId.DataName))), + Location = values.GetString(colRegionName.DataName), }; responseData.Organisations.Add(organisationData); } @@ -123,10 +129,12 @@ namespace Saxonite.Net.Core.Web.Online.Controllers { 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; } + public String Category { get; set; } + public String Sport { get; set; } + public String Location { get; set; } + public String Address { get; set; } + public String PostalCode { get; set; } + public String Phone { get; set; } } private class AjaxResponse_Search_Organisation : AjaxResponse_Data { @@ -143,7 +151,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers { String fn = GetType().Name + ".GetProfileOrganisation"; AjaxResponse_Search_Organisation responseData = new AjaxResponse_Search_Organisation(model); - String messageTitle = Localiser["label.organisations"]; + String messageTitle = Localiser["label.organisation"]; // Validate session and referrer. if (!ValidReferer) return Forbid(); @@ -175,13 +183,21 @@ namespace Saxonite.Net.Core.Web.Online.Controllers { 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), + Category = Localiser.GetOrganisationCategoryCaption(organisation.OrganisationCategory), + Sport = model.GetSportCaption(organisation.SportIdPrimary), + Location = model.GetRegionCaption(organisation.RegionIdPrimary), }; responseData.Organisation = organisationData; + // Organisation address. + SaxItemAddress address = ItemDataMgr.GetFirstItemAddressByItemAndType(organisation.GetItemId()); + if (address != null) + { + String addressLines = (new List() { address.Line1, address.Line2, address.Line3 }).Concat(", ", "", "", true, true); + String addressTownProvince = (new List() { address.Town, address.Province }).Concat(", ", "", "", true, true); + organisationData.Address = (new List() { addressLines, addressTownProvince }).Concat("\n", "", "", true, true); + organisationData.PostalCode = address.PostalCode; + } } // Complete response. diff --git a/SaxoniteCoreWebOnline/Views/Search/Organisations.cshtml b/SaxoniteCoreWebOnline/Views/Search/Organisations.cshtml index 0dd3153..b945c86 100644 --- a/SaxoniteCoreWebOnline/Views/Search/Organisations.cshtml +++ b/SaxoniteCoreWebOnline/Views/Search/Organisations.cshtml @@ -4,7 +4,7 @@ ViewData["Title"] = "Search Organisations"; } -
+