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