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(); /// /// True when this composition node is inherited — its underlying /// TemplateComposition row belongs to an ancestor of the template it is /// rendered under, not to that template itself (followup #9). Inherited nodes are /// badged read-only and their context menu suppresses Rename/Delete (those edit the /// base). Always false for folders and templates. /// public bool IsInherited { get; init; } /// /// Explicit, path-qualified key override. The same inherited composition row can /// surface under several derived members (e.g. LeakTest under both LeftReactorSide /// and RightReactorSide), so a plain c:{Id} key would collide and break the /// TreeView's selection/expansion tracking. Composition nodes set this to a /// parent-path-qualified value; folders/templates leave it null and use the default. /// public string? KeyOverride { get; init; } /// Stable key for TreeView selection / expansion tracking. public string Key => KeyOverride ?? Kind switch { TemplateTreeNodeKind.Folder => $"f:{Id}", TemplateTreeNodeKind.Template => $"t:{Id}", TemplateTreeNodeKind.Composition => $"c:{Id}", _ => $"x:{Id}", }; }