diff --git a/backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs b/backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs index c40403ba9..862807ad1 100644 --- a/backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs +++ b/backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs @@ -195,7 +195,11 @@ await Cache.DoUsingNewOrCurrentUOW("Update WritingSystem", "Revert WritingSystem", async () => { - var updateProxy = new UpdateWritingSystemProxy(lcmWritingSystem, this) { Type = type }; // TODO: Doesn't compile, wants Font to be set. Also wants a GUID Id which we don't have... + var updateProxy = new UpdateWritingSystemProxy(lcmWritingSystem, this) + { + Id = Guid.Empty, + Type = type, + }; update.Apply(updateProxy); updateProxy.CommitUpdate(Cache); }); diff --git a/backend/FwLite/FwDataMiniLcmBridge/Api/UpdateProxy/UpdateWritingSystemProxy.cs b/backend/FwLite/FwDataMiniLcmBridge/Api/UpdateProxy/UpdateWritingSystemProxy.cs index ee67bcf43..eaf849fcb 100644 --- a/backend/FwLite/FwDataMiniLcmBridge/Api/UpdateProxy/UpdateWritingSystemProxy.cs +++ b/backend/FwLite/FwDataMiniLcmBridge/Api/UpdateProxy/UpdateWritingSystemProxy.cs @@ -1,7 +1,9 @@ +using System.Diagnostics.CodeAnalysis; using MiniLcm.Models; using SIL.LCModel; using SIL.LCModel.Core.WritingSystems; using SIL.LCModel.DomainServices; +using SIL.WritingSystems; namespace FwDataMiniLcmBridge.Api.UpdateProxy; @@ -11,10 +13,14 @@ public record UpdateWritingSystemProxy : WritingSystem private readonly CoreWritingSystemDefinition _workingLcmWritingSystem; private readonly FwDataMiniLcmApi _lexboxLcmApi; + [SetsRequiredMembers] public UpdateWritingSystemProxy(CoreWritingSystemDefinition lcmWritingSystem, FwDataMiniLcmApi lexboxLcmApi) { _origLcmWritingSystem = lcmWritingSystem; _workingLcmWritingSystem = new CoreWritingSystemDefinition(lcmWritingSystem, cloneId: true); + base.Abbreviation = Abbreviation = _origLcmWritingSystem.Abbreviation ?? ""; + base.Name = Name = _origLcmWritingSystem.LanguageName ?? ""; + base.Font = Font = _origLcmWritingSystem.DefaultFontName ?? ""; _lexboxLcmApi = lexboxLcmApi; } @@ -49,10 +55,15 @@ public override required string Abbreviation set => _workingLcmWritingSystem.Abbreviation = value; } - // TODO: Change WritingSystem Font property to be a list of strings instead of a single string, then do something like this - // public override required List Fonts - // { - // get => _workingLcmWritingSystem.Fonts.Select(f => f.Name).ToList(); - // set => throw new NotImplementedException(); - // } + public override required string Font + { + get => _workingLcmWritingSystem.DefaultFontName; + set + { + if (value != _workingLcmWritingSystem.DefaultFontName) + { + _workingLcmWritingSystem.DefaultFont = new FontDefinition(value); + } + } + } } diff --git a/backend/FwLite/MiniLcm/Models/WritingSystem.cs b/backend/FwLite/MiniLcm/Models/WritingSystem.cs index 253f2dc28..e23627cd7 100644 --- a/backend/FwLite/MiniLcm/Models/WritingSystem.cs +++ b/backend/FwLite/MiniLcm/Models/WritingSystem.cs @@ -6,7 +6,6 @@ public record WritingSystem: IObjectWithId public virtual required WritingSystemId WsId { get; set; } public virtual required string Name { get; set; } public virtual required string Abbreviation { get; set; } - // TODO: Font will need to become Fonts, a list or array of strings, to better match the LCM model public virtual required string Font { get; set; } public DateTimeOffset? DeletedAt { get; set; }