using PlotLine.Models; namespace PlotLine.Services; // One vocabulary for the directory legend, indicators and assignment menus. public sealed record CharacterQuickValue(string Value,string Label,string Icon,string Tone="secondary"); public sealed record CharacterQuickGroup(string Id,string Label,IReadOnlyList Values); public static class CharacterQuickAttributes { public static IReadOnlyList Definitions(IEnumerable sex) => [ new("importance","Story importance",[new("10","Major","attribute-star","warning"),new("6","Supporting","characters","info"),new("2","Minor","attribute-person"),new("","Unclassified","help")]), new("life","Life status",[new("0","Living","attribute-heart","success"),new("1","Deceased","attribute-flower","data-5"),new("","Unrecorded","help")]), new("sex","Sex",new[]{new CharacterQuickValue("","Not set","help")}.Concat(sex.Select(s=>new CharacterQuickValue(s.CharacterSexValueID.ToString(),s.SexName,"attribute-person"))).ToArray()), new("quickAdd","Quick Add Bar",[new("1","Included","attribute-pin","primary"),new("0","Excluded","attribute-unpin")]) ]; public static object Snapshot(Character c)=>new {id=c.CharacterID,name=c.CharacterName,version=c.UpdatedDate.ToString("O"),values=new Dictionary{["importance"]=c.CharacterImportance?.ToString()??"",["life"]=c.IsDeceased.HasValue?(c.IsDeceased.Value?"1":"0"):"",["sex"]=c.SexValueID?.ToString()??(string.IsNullOrWhiteSpace(c.Sex)?"":"legacy:"+c.Sex),["quickAdd"]=c.ShowInQuickAddBar?"1":"0"}}; } public sealed record CharacterQuickChange(int Id,string? Value,string Version); public sealed record CharacterQuickAssignment(int ProjectId,string Attribute,CharacterQuickChange[] Changes);