namespace WordVersioning.Api.Models; /// นิยาม field หนึ่งตัวของ template (FR-9) — Key = content control (SDT) tag ที่ detect ตอน upload public class TemplateField { public Guid Id { get; set; } public Guid TemplateId { get; set; } public Template? Template { get; set; } /// = SDT tag — unique ต่อ template ใช้ค่าเดียวกันทั้ง generate/extract/sync public string Key { get; set; } = string.Empty; /// ชื่อที่แสดงในฟอร์ม (default = Key จนกว่า admin จะตั้ง) public string Label { get; set; } = string.Empty; /// text | number | date public string Type { get; set; } = "text"; /// รูปแบบช่องกรอกในฟอร์มสร้างเอกสาร (FR-14): textbox|textarea สำหรับ text · number · date /// — presentation metadata เท่านั้น ไม่กระทบ validation ของค่า (ยึด Type) · null = default ของ Type public string? Editor { get; set; } public bool IsRequired { get; set; } /// ลำดับตอนแสดงฟอร์ม (default = ลำดับที่ปรากฏในไฟล์ตอน detect) public int SortOrder { get; set; } public static readonly string[] ValidTypes = ["text", "number", "date"]; /// editor ที่เลือกได้ต่อ type (FR-14) — ตัวแรกของแต่ละรายการคือ default public static readonly Dictionary EditorsByType = new() { ["text"] = ["textbox", "textarea"], ["number"] = ["number"], ["date"] = ["date"], }; public static string DefaultEditor(string type) => EditorsByType.TryGetValue(type, out var editors) ? editors[0] : "textbox"; }