namespace ZB.MOM.WW.ScadaBridge.CentralUI.Components.Shared;
public enum TemplateTreeNodeKind
{
Folder,
Template,
///
/// Composition slot under a parent Template — produced only by callers that
/// supply TemplateFolderTree.ExtraTemplateChildren. The Transport
/// Export wizard intentionally never emits this kind (compositions aren't
/// independently exportable); the Templates page uses it to surface slots.
///
Composition,
}
///
/// Adapter node used by TemplateFolderTree to model the template-folder
/// hierarchy in a TreeView. Folder nodes carry sub-folders + their templates as
/// children; template nodes are leaves unless the caller injects extras via
/// TemplateFolderTree.ExtraTemplateChildren (e.g. composition slots).
///
public sealed class TemplateTreeNode
{
/// Discriminator indicating whether this node represents a folder, template, or composition slot.
public required TemplateTreeNodeKind Kind { get; init; }
/// Database id of the underlying folder, template, or composition record.
public required int Id { get; init; }
/// Display name of the node.
public required string Name { get; init; }
/// Child nodes (sub-folders, templates, or composition slots).
public List Children { get; } = new();
/// Stable key for TreeView selection / expansion tracking.
public string Key => Kind switch
{
TemplateTreeNodeKind.Folder => $"f:{Id}",
TemplateTreeNodeKind.Template => $"t:{Id}",
TemplateTreeNodeKind.Composition => $"c:{Id}",
_ => $"x:{Id}",
};
}