feat(cv): qualify templates and reliable local import processing
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace JobTrackerApi.Models;
|
||||
|
||||
@@ -6,6 +7,10 @@ namespace JobTrackerApi.Models;
|
||||
public sealed class CoverLetterDocumentSettings
|
||||
{
|
||||
public int SchemaVersion { get; set; } = 1;
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public int? DesignVersion { get; set; }
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? HeadingFont { get; set; }
|
||||
public string Language { get; set; } = "en";
|
||||
public string SenderName { get; set; } = "";
|
||||
public string SenderTitle { get; set; } = "";
|
||||
@@ -38,16 +43,18 @@ public static class CoverLetterDocumentSettingsJson
|
||||
public static CoverLetterDocumentSettings Normalize(CoverLetterDocumentSettings? value)
|
||||
{
|
||||
value ??= new();
|
||||
var theme = CvThemeCatalog.Resolve(value.ThemeId);
|
||||
var theme = CvThemeCatalog.Resolve(value.ThemeId, value.DesignVersion);
|
||||
var style = CvVariantSettingsJson.Normalize(new()
|
||||
{
|
||||
AccentColor = value.AccentColor, BodyFont = value.BodyFont,
|
||||
AccentColor = value.AccentColor, BodyFont = value.BodyFont, HeadingFont = value.HeadingFont,
|
||||
BaseFontSizePt = value.BaseFontSizePt, LineHeight = value.LineHeight, PageMarginMm = value.PageMarginMm,
|
||||
});
|
||||
static string Text(string? text, int limit) => (text ?? "")[..Math.Min(text?.Length ?? 0, limit)];
|
||||
return new()
|
||||
{
|
||||
SchemaVersion = 1, ThemeId = theme.Id,
|
||||
DesignVersion = value.DesignVersion is 1 or 2 ? value.DesignVersion : null,
|
||||
HeadingFont = value.DesignVersion == 2 ? style.HeadingFont ?? theme.HeadingFont : null,
|
||||
Language = value.Language?.Trim().ToLowerInvariant() is "nb" or "nb-no" ? "nb-NO" : "en",
|
||||
SenderName = Text(value.SenderName, 300), SenderTitle = Text(value.SenderTitle, 300),
|
||||
SenderEmail = Text(value.SenderEmail, 300), SenderPhone = Text(value.SenderPhone, 100), SenderLocation = Text(value.SenderLocation, 300),
|
||||
|
||||
Reference in New Issue
Block a user