feat(templateengine): ResolvedAttribute.DefaultDataSourceReference — pre-binding default for the Configure page; excluded from the revision hash (pinned)

This commit is contained in:
Joseph Doherty
2026-08-20 15:53:05 -04:00
parent 4cfd9337a3
commit 3acb79d97e
3 changed files with 103 additions and 1 deletions
@@ -78,6 +78,17 @@ public sealed record ResolvedAttribute
/// </summary>
public string? DataSourceReference { get; init; }
/// <summary>
/// The data-source reference as resolved from the template chain BEFORE any
/// per-instance <c>InstanceConnectionBinding.DataSourceReferenceOverride</c> was
/// applied — i.e. the template/composed default the Configure page shows as the
/// placeholder. Equals <see cref="DataSourceReference"/> when no override is set;
/// null for attributes that are not data-sourced.
/// Central-side presentation data only: deliberately excluded from the revision
/// hash (<c>RevisionHashService</c> projects through <c>HashableAttribute</c>).
/// </summary>
public string? DefaultDataSourceReference { get; init; }
/// <summary>
/// If data-sourced: the resolved connection ID from the instance binding.
/// </summary>
@@ -369,6 +369,15 @@ public class FlatteningService
Dictionary<string, ResolvedAttribute> attributes,
IReadOnlyDictionary<int, DataConnection> dataConnections)
{
// Capture the pre-binding default for EVERY data-sourced attribute (bound or
// not) so the Configure page can show the template default as a placeholder.
foreach (var key in attributes.Keys.ToList())
{
var attr = attributes[key];
if (attr.DataSourceReference is not null && attr.DefaultDataSourceReference is null)
attributes[key] = attr with { DefaultDataSourceReference = attr.DataSourceReference };
}
foreach (var binding in bindings)
{
if (!attributes.TryGetValue(binding.AttributeName, out var existing))
@@ -385,7 +394,8 @@ public class FlatteningService
BoundDataConnectionId = connection.Id,
BoundDataConnectionName = connection.Name,
BoundDataConnectionProtocol = connection.Protocol,
DataSourceReference = binding.DataSourceReferenceOverride ?? existing.DataSourceReference
DataSourceReference = binding.DataSourceReferenceOverride ?? existing.DataSourceReference,
DefaultDataSourceReference = existing.DefaultDataSourceReference ?? existing.DataSourceReference
};
}
}