using ScadaLink.Commons.Types.Enums;

namespace ScadaLink.Commons.Entities.Templates;

public class TemplateAttribute
{
    public int Id { get; set; }
    public int TemplateId { get; set; }
    public string Name { get; set; }
    public string? Value { get; set; }
    public DataType DataType { get; set; }
    public bool IsLocked { get; set; }
    public string? Description { get; set; }
    public string? DataSourceReference { get; set; }

    /// <summary>
    /// True when this row was copied from the base template and has not been
    /// overridden on the derived template. Changes to the base flow downward
    /// for inherited rows; an explicit override flips this to false.
    /// Always false on base (non-derived) templates.
    /// </summary>
    public bool IsInherited { get; set; }

    /// <summary>
    /// Set on a base attribute. When true, derived templates may not override
    /// the value — the row is rendered readonly with a 🔒 in the derived UI,
    /// and any attempt to update it through the API is rejected.
    /// </summary>
    public bool LockedInDerived { get; set; }

    public TemplateAttribute(string name)
    {
        Name = name ?? throw new ArgumentNullException(nameof(name));
    }
}
