From a965d4a5bd9112e96b1eeb96256217640b0af13b Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Tue, 12 May 2026 08:57:42 -0400 Subject: [PATCH] =?UTF-8?q?feat(templates/ui):=20phase=209=20=E2=80=94=20s?= =?UTF-8?q?ingle-parent=20editor=20context?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Derive-on-compose guarantees at most one slot owner per template, so the Parent.* context in the Monaco editor resolves directly via OwnerCompositionId without a picker. Base templates suppress Parent.* assistance entirely (empty context). Removed the multi-parent - @foreach (var (parent, idx) in _editorParents.Select((p, i) => (p, i))) - { - - } - - (this template is composed by @_editorParents.Count parents; pick one for Parent.* assistance) - - } > BuildParentContextsAsync(int templateId) { - var parents = await TemplateEngineRepository.GetTemplatesComposingAsync(templateId); - return parents - .Select(p => BuildCompositionContext(p.Name, p)) - .ToList(); + // Post derive-on-compose: only derived templates have a parent context, + // and exactly one — the template that owns their composition slot. + // Base templates suppress Parent.* assistance. + if (_selectedTemplate?.IsDerived != true || _ownerTemplate == null) + return new List(); + + // Resolve the owner with eager-loaded members so the context has shapes. + var owner = await TemplateEngineRepository.GetTemplateByIdAsync(_ownerTemplate.Id); + if (owner == null) + return new List(); + + return new List + { + BuildCompositionContext(owner.Name, owner) + }; } private static ScadaLink.CentralUI.ScriptAnalysis.CompositionContext BuildCompositionContext( @@ -1331,12 +1321,6 @@ return new ScadaLink.CentralUI.ScriptAnalysis.CompositionContext(label, attrs, scripts); } - private void OnParentContextChanged(ChangeEventArgs e) - { - if (int.TryParse(e.Value?.ToString(), out var idx) && idx >= 0 && idx < _editorParents.Count) - _selectedParentIndex = idx; - } - private static string MapDataType(ScadaLink.Commons.Types.Enums.DataType dt) => dt switch { ScadaLink.Commons.Types.Enums.DataType.Boolean => "Boolean",