Separate UX diagnostics from curation
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
@using System
|
||||
@using System.Collections.Generic
|
||||
@using System.Linq
|
||||
@using System.Text.Json
|
||||
@using Microsoft.JSInterop
|
||||
@using RolemasterDb.App.Domain
|
||||
@using RolemasterDb.App.Features
|
||||
@@ -206,11 +205,11 @@
|
||||
}
|
||||
</section>
|
||||
|
||||
<section class="critical-editor-section critical-editor-diagnostics-section">
|
||||
<section class="critical-editor-section">
|
||||
<details class="critical-editor-advanced">
|
||||
<summary class="critical-editor-advanced-summary">
|
||||
<span>Advanced Review & Diagnostics</span>
|
||||
<span class="critical-editor-advanced-meta">@GetAdvancedSummary(Model, ComparisonBaseline)</span>
|
||||
<span>Advanced Review</span>
|
||||
<span class="critical-editor-advanced-meta">@GetReviewSummary(Model, ComparisonBaseline)</span>
|
||||
</summary>
|
||||
|
||||
<div class="critical-editor-advanced-body">
|
||||
@@ -257,87 +256,6 @@
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="critical-editor-card nested">
|
||||
<div class="critical-editor-card-header">
|
||||
<div>
|
||||
<strong>Parser Metadata</strong>
|
||||
<p class="muted critical-editor-inline-copy">Last loaded or re-parsed parser result.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<dl class="critical-editor-diagnostic-grid">
|
||||
<div>
|
||||
<dt>OCR Source</dt>
|
||||
<dd>@(string.IsNullOrWhiteSpace(Model.RawCellText) ? "—" : Model.RawCellText)</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>Parse Status</dt>
|
||||
<dd>@Model.ParseStatus</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>Raw Affix Text</dt>
|
||||
<dd>@(string.IsNullOrWhiteSpace(Model.RawAffixText) ? "—" : Model.RawAffixText)</dd>
|
||||
</div>
|
||||
</dl>
|
||||
|
||||
@if (Model.ValidationMessages.Count > 0)
|
||||
{
|
||||
<div class="critical-editor-validation-list">
|
||||
@foreach (var message in Model.ValidationMessages)
|
||||
{
|
||||
<p class="critical-editor-validation-item">@message</p>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="field-shell">
|
||||
<label>Parsed Effects JSON</label>
|
||||
<pre class="critical-editor-diagnostic-block">@FormatJson(Model.ParsedJson)</pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@{
|
||||
var effectMetadata = GetEffectMetadataRows(Model);
|
||||
}
|
||||
|
||||
@if (effectMetadata.Count > 0)
|
||||
{
|
||||
<div class="critical-editor-card nested">
|
||||
<div class="critical-editor-card-header">
|
||||
<div>
|
||||
<strong>Effect Source Metadata</strong>
|
||||
<p class="muted critical-editor-inline-copy">Stored source markers and labels for the current effect list.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="critical-editor-diagnostic-list">
|
||||
@foreach (var entry in effectMetadata)
|
||||
{
|
||||
<div class="critical-editor-diagnostic-item">
|
||||
<div>
|
||||
<strong>@entry.Scope</strong>
|
||||
<p class="muted critical-editor-inline-copy">@entry.EffectLabel</p>
|
||||
</div>
|
||||
<div class="critical-editor-diagnostic-values">
|
||||
<span><strong>Type:</strong> @entry.SourceType</span>
|
||||
<span><strong>Text:</strong> @(string.IsNullOrWhiteSpace(entry.SourceText) ? "—" : entry.SourceText)</span>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="critical-editor-card nested">
|
||||
<div class="critical-editor-card-header">
|
||||
<div>
|
||||
<strong>Current Save Payload</strong>
|
||||
<p class="muted critical-editor-inline-copy">Request built from the visible editor state, including generated branch internals.</p>
|
||||
</div>
|
||||
</div>
|
||||
<pre class="critical-editor-diagnostic-block">@BuildCurrentSavePayloadJson(Model)</pre>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
@@ -388,10 +306,6 @@
|
||||
[Parameter, EditorRequired]
|
||||
public EventCallback OnSave { get; set; }
|
||||
|
||||
private static readonly JsonSerializerOptions DiagnosticJsonOptions = new()
|
||||
{
|
||||
WriteIndented = true
|
||||
};
|
||||
private static readonly IReadOnlyList<(string Token, IReadOnlyList<CriticalEffectLookupResponse> Effects)> QuickParseLegendEntries =
|
||||
[
|
||||
("+15", [CreateQuickLegendEffect(CriticalEffectCodes.DirectHits, valueInteger: 15)]),
|
||||
@@ -631,7 +545,7 @@
|
||||
effect.IsOverridden = true;
|
||||
}
|
||||
|
||||
private static string GetAdvancedSummary(CriticalCellEditorModel model, CriticalCellEditorModel? comparisonBaseline)
|
||||
private static string GetReviewSummary(CriticalCellEditorModel model, CriticalCellEditorModel? comparisonBaseline)
|
||||
{
|
||||
var differenceCount = GetComparisonDifferenceCount(model, comparisonBaseline);
|
||||
var noteCount = model.ValidationMessages.Count;
|
||||
@@ -647,13 +561,13 @@
|
||||
segments.Add($"{noteCount} parser note{(noteCount == 1 ? string.Empty : "s")}");
|
||||
}
|
||||
|
||||
return segments.Count == 0 ? "Generated compare and diagnostics" : string.Join(" · ", segments);
|
||||
return segments.Count == 0 ? "Generated compare" : string.Join(" · ", segments);
|
||||
}
|
||||
|
||||
private static string GetParserNoteSummary(int noteCount) =>
|
||||
noteCount == 1
|
||||
? "1 parser note is available under Advanced Review & Diagnostics."
|
||||
: $"{noteCount} parser notes are available under Advanced Review & Diagnostics.";
|
||||
? "1 parser note is available under Advanced Review."
|
||||
: $"{noteCount} parser notes are available under Advanced Review.";
|
||||
|
||||
private static CriticalEffectLookupResponse CreateQuickLegendEffect(
|
||||
string effectCode,
|
||||
@@ -675,27 +589,6 @@
|
||||
"legend",
|
||||
null);
|
||||
|
||||
private static string FormatJson(string json)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(json))
|
||||
{
|
||||
return "{}";
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
using var document = JsonDocument.Parse(json);
|
||||
return JsonSerializer.Serialize(document.RootElement, DiagnosticJsonOptions);
|
||||
}
|
||||
catch (JsonException)
|
||||
{
|
||||
return json.Trim();
|
||||
}
|
||||
}
|
||||
|
||||
private static string BuildCurrentSavePayloadJson(CriticalCellEditorModel model) =>
|
||||
JsonSerializer.Serialize(model.ToRequest(), DiagnosticJsonOptions);
|
||||
|
||||
private static IReadOnlyList<string> GetComparisonSummaryItems(CriticalCellEditorModel model, CriticalCellEditorModel? comparisonBaseline)
|
||||
{
|
||||
if (model.GeneratedState is null)
|
||||
@@ -775,37 +668,6 @@
|
||||
.Select(CreatePreviewBranch)
|
||||
.ToList();
|
||||
|
||||
private static List<(string Scope, string EffectLabel, string SourceType, string? SourceText)> GetEffectMetadataRows(CriticalCellEditorModel model)
|
||||
{
|
||||
var rows = new List<(string Scope, string EffectLabel, string SourceType, string? SourceText)>();
|
||||
|
||||
foreach (var effect in model.Effects)
|
||||
{
|
||||
if (ShouldIncludeEffectMetadata(effect))
|
||||
{
|
||||
rows.Add(("Base Result", GetEffectLabel(effect), effect.SourceType, effect.SourceText));
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var branch in model.Branches.OrderBy(item => item.SortOrder))
|
||||
{
|
||||
var scope = string.IsNullOrWhiteSpace(branch.ConditionText) ? "Condition" : branch.ConditionText.Trim();
|
||||
foreach (var effect in branch.Effects)
|
||||
{
|
||||
if (ShouldIncludeEffectMetadata(effect))
|
||||
{
|
||||
rows.Add((scope, GetEffectLabel(effect), effect.SourceType, effect.SourceText));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rows;
|
||||
}
|
||||
|
||||
private static bool ShouldIncludeEffectMetadata(CriticalEffectEditorModel effect) =>
|
||||
!string.IsNullOrWhiteSpace(effect.SourceText) ||
|
||||
!string.IsNullOrWhiteSpace(effect.SourceType);
|
||||
|
||||
private static IReadOnlyList<CriticalEffectLookupResponse> BuildSingleBadgeEffect(CriticalEffectEditorModel effect) =>
|
||||
[CreateBadgeEffect(effect)];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user