Phase 12K: Warning UI Refinement.

This commit is contained in:
Nick Beckley 2026-06-15 10:08:29 +01:00
parent ecc8d3c76a
commit 1783ab88ee
3 changed files with 220 additions and 189 deletions

View File

@ -4052,6 +4052,7 @@ public sealed class ContinuityValidationService(
ShowAcknowledgedWarnings = showAcknowledgedWarnings,
Warnings = rows,
ProjectWarnings = dashboardWarnings,
WarningGroups = BuildWarningSeverityGroups(dashboardWarnings),
BookOptions = projectBooks.Select(x => new SelectListItem($"Book {x.BookNumber}: {x.BookTitle}", x.BookID.ToString(), x.BookID == bookId)).ToList(),
ChapterOptions = projectChapters.Select(x => new SelectListItem($"Ch {x.ChapterNumber:g}: {x.ChapterTitle}", x.ChapterID.ToString(), x.ChapterID == chapterId)).ToList(),
WarningTypeOptions = lookupData.WarningTypes.Select(x => new SelectListItem(x.TypeName, x.WarningTypeID.ToString(), x.WarningTypeID == warningTypeId)).ToList(),
@ -4297,6 +4298,33 @@ public sealed class ContinuityValidationService(
warning.InvestigationSceneId = warning.CurrentSceneId ?? warning.ReferencedSceneId ?? warning.SceneID;
}
private static IReadOnlyList<WarningSeverityGroupViewModel> BuildWarningSeverityGroups(IReadOnlyList<ProjectWarningViewModel> warnings)
{
var groups = warnings
.GroupBy(x => WarningSeverityGroupLabel(x.Severity))
.ToDictionary(x => x.Key, x => x.ToList(), StringComparer.OrdinalIgnoreCase);
return new[] { "Critical", "Warning", "Information" }
.Where(groups.ContainsKey)
.Select(severity => new WarningSeverityGroupViewModel
{
Severity = severity,
IsExpanded = severity is "Critical" or "Warning",
Warnings = groups[severity]
})
.ToList();
}
private static string WarningSeverityGroupLabel(string severity)
{
return severity switch
{
"Critical" or "Error" => "Critical",
"Warning" => "Warning",
_ => "Information"
};
}
private static string WarningCategoryForPersisted(ContinuityWarning warning)
{
return warning.EntityType switch

View File

@ -1671,6 +1671,7 @@ public sealed class WarningDashboardViewModel
public bool ShowAcknowledgedWarnings { get; set; }
public IReadOnlyList<ContinuityWarning> Warnings { get; set; } = [];
public IReadOnlyList<ProjectWarningViewModel> ProjectWarnings { get; set; } = [];
public IReadOnlyList<WarningSeverityGroupViewModel> WarningGroups { get; set; } = [];
public IReadOnlyList<SelectListItem> BookOptions { get; set; } = [];
public IReadOnlyList<SelectListItem> ChapterOptions { get; set; } = [];
public IReadOnlyList<SelectListItem> WarningTypeOptions { get; set; } = [];
@ -1683,6 +1684,13 @@ public sealed class WarningDashboardViewModel
public bool HasAnyWarnings { get; set; }
}
public sealed class WarningSeverityGroupViewModel
{
public string Severity { get; set; } = string.Empty;
public bool IsExpanded { get; set; }
public IReadOnlyList<ProjectWarningViewModel> Warnings { get; set; } = [];
}
public sealed class ProjectWarningViewModel
{
public string Source { get; set; } = "Persisted";

View File

@ -7,7 +7,7 @@
@functions {
private static string SeverityBadgeClass(string severity) => severity switch
{
"Critical" => "bg-danger",
"Critical" or "Error" => "bg-danger",
"Warning" => "bg-warning text-dark",
_ => "bg-info text-dark"
};
@ -143,194 +143,189 @@
}
else
{
<div class="table-responsive">
<table class="table table-sm align-middle">
<thead>
<tr>
<th>Severity</th>
<th>Category</th>
<th>Warning Type</th>
<th>Message</th>
<th>Book</th>
<th>Chapter</th>
<th>Scene</th>
<th>Status</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach (var warning in Model.ProjectWarnings)
{
<tr>
<td><span class="badge @SeverityBadgeClass(warning.Severity)">@warning.Severity</span></td>
<td>@warning.Category</td>
<td>@warning.WarningTypeDisplayName</td>
<td>
<div>@warning.Message</div>
@if (!string.IsNullOrWhiteSpace(warning.Details))
{
<small class="text-muted d-block">@warning.Details</small>
}
@if (!string.IsNullOrWhiteSpace(warning.KnowledgeTitle))
{
<small class="text-muted d-block">Knowledge: @warning.KnowledgeTitle</small>
}
@if (!string.IsNullOrWhiteSpace(warning.PreviousKnowledgeState) && !string.IsNullOrWhiteSpace(warning.CurrentKnowledgeState))
{
<small class="text-muted d-block">State: @warning.PreviousKnowledgeState &rarr; @warning.CurrentKnowledgeState</small>
}
@if (warning.PreviousSceneId.HasValue)
{
<small class="text-muted d-block">
Previous:
<a asp-controller="Timeline" asp-action="Index" asp-route-projectId="@Model.Project.ProjectID" asp-route-selectedSceneId="@warning.PreviousSceneId">@warning.PreviousContextSceneDisplayName</a>
</small>
}
@if (warning.CurrentSceneId.HasValue)
{
<small class="text-muted d-block">
Current:
<a asp-controller="Timeline" asp-action="Index" asp-route-projectId="@Model.Project.ProjectID" asp-route-selectedSceneId="@warning.CurrentSceneId">@warning.CurrentContextSceneDisplayName</a>
</small>
}
@if (warning.EstablishedSceneId.HasValue)
{
<small class="text-muted d-block">
Established:
<a asp-controller="Timeline" asp-action="Index" asp-route-projectId="@Model.Project.ProjectID" asp-route-selectedSceneId="@warning.EstablishedSceneId">@(string.IsNullOrWhiteSpace(warning.EstablishedContextSceneDisplayName) ? warning.EstablishedSceneDisplayName : warning.EstablishedContextSceneDisplayName)</a>
</small>
}
@if (warning.ReferencedSceneId.HasValue)
{
<small class="text-muted d-block">
Earlier reference:
<a asp-controller="Timeline" asp-action="Index" asp-route-projectId="@Model.Project.ProjectID" asp-route-selectedSceneId="@warning.ReferencedSceneId">@(string.IsNullOrWhiteSpace(warning.ReferencedContextSceneDisplayName) ? warning.ReferencedSceneDisplayName : warning.ReferencedContextSceneDisplayName)</a>
</small>
}
@if (warning.IsAcknowledged && !string.IsNullOrWhiteSpace(warning.AcknowledgementNotes))
{
<small class="text-muted d-block">Note: @warning.AcknowledgementNotes</small>
}
</td>
<td>@(string.IsNullOrWhiteSpace(warning.BookDisplayName) ? "Project" : warning.BookDisplayName)</td>
<td>@(string.IsNullOrWhiteSpace(warning.ChapterDisplayName) ? "-" : warning.ChapterDisplayName)</td>
<td>
@if (warning.SceneID.HasValue)
{
<a asp-controller="Timeline" asp-action="Index" asp-route-projectId="@Model.Project.ProjectID" asp-route-selectedSceneId="@warning.SceneID">@warning.ContextSceneDisplayName</a>
}
else
{
<span class="muted">Project-wide</span>
}
</td>
<td>
@if (warning.IsDismissed)
{
<span class="badge bg-secondary">Dismissed</span>
}
else if (warning.IsIntentional || warning.IsAcknowledged)
{
<span class="badge bg-secondary">Acknowledged</span>
}
else
{
<span class="badge bg-warning text-dark">Active</span>
}
</td>
<td>
@if (warning.CanInvestigate)
{
<a class="btn btn-outline-primary btn-sm"
asp-controller="ContinuityExplorer"
asp-action="Index"
asp-route-projectId="@Model.Project.ProjectID"
asp-route-mode="@warning.InvestigationDisplayMode"
asp-route-characterId="@warning.CharacterID"
asp-route-assetId="@warning.AssetID"
asp-route-sceneId="@warning.InvestigationSceneId">Investigate</a>
}
@if (warning.Source == "Persisted" && warning.ContinuityWarningID.HasValue)
{
@if (warning.IsDismissed || warning.IsIntentional)
{
<form asp-action="Restore" method="post" class="d-inline">
<input type="hidden" name="id" value="@warning.ContinuityWarningID" />
<input type="hidden" name="projectId" value="@Model.Project.ProjectID" />
<input type="hidden" name="bookId" value="@Model.BookID" />
<input type="hidden" name="sceneId" value="@Model.SceneID" />
<button class="btn btn-outline-secondary btn-sm" type="submit">Restore</button>
</form>
}
else
{
<form asp-action="Dismiss" method="post" class="d-inline">
<input type="hidden" name="id" value="@warning.ContinuityWarningID" />
<input type="hidden" name="projectId" value="@Model.Project.ProjectID" />
<input type="hidden" name="bookId" value="@Model.BookID" />
<input type="hidden" name="sceneId" value="@Model.SceneID" />
<button class="btn btn-outline-secondary btn-sm" type="submit">Dismiss</button>
</form>
<form asp-action="MarkIntentional" method="post" class="d-inline">
<input type="hidden" name="id" value="@warning.ContinuityWarningID" />
<input type="hidden" name="projectId" value="@Model.Project.ProjectID" />
<input type="hidden" name="bookId" value="@Model.BookID" />
<input type="hidden" name="sceneId" value="@Model.SceneID" />
<button class="btn btn-outline-secondary btn-sm" type="submit">Intentional</button>
</form>
}
}
else
{
@if (warning.IsAcknowledged)
{
<form asp-action="RestoreGeneratedWarning" method="post" class="d-inline">
<input type="hidden" name="WarningType" value="@warning.WarningType" />
<input type="hidden" name="SceneID" value="@warning.SceneID" />
<input type="hidden" name="CharacterID" value="@warning.CharacterID" />
<input type="hidden" name="AssetID" value="@warning.AssetID" />
<input type="hidden" name="ReturnFilter.ProjectID" value="@Model.Project.ProjectID" />
<input type="hidden" name="ReturnFilter.BookID" value="@Model.BookID" />
<input type="hidden" name="ReturnFilter.ChapterID" value="@Model.ChapterID" />
<input type="hidden" name="ReturnFilter.SceneID" value="@Model.SceneID" />
<input type="hidden" name="ReturnFilter.WarningTypeID" value="@Model.WarningTypeID" />
<input type="hidden" name="ReturnFilter.WarningSeverityID" value="@Model.WarningSeverityID" />
<input type="hidden" name="ReturnFilter.EntityType" value="@Model.EntityType" />
<input type="hidden" name="ReturnFilter.Category" value="@Model.Category" />
<input type="hidden" name="ReturnFilter.IncludeDismissed" value="@Model.IncludeDismissed" />
<input type="hidden" name="ReturnFilter.IncludeIntentional" value="@Model.IncludeIntentional" />
<input type="hidden" name="ReturnFilter.ShowAcknowledgedWarnings" value="@Model.ShowAcknowledgedWarnings" />
<button class="btn btn-outline-secondary btn-sm" type="submit">Restore</button>
</form>
}
else
{
<form asp-action="AcknowledgeGeneratedWarning" method="post" class="d-flex gap-1 align-items-center">
<input type="hidden" name="WarningType" value="@warning.WarningType" />
<input type="hidden" name="SceneID" value="@warning.SceneID" />
<input type="hidden" name="CharacterID" value="@warning.CharacterID" />
<input type="hidden" name="AssetID" value="@warning.AssetID" />
<input type="hidden" name="ReturnFilter.ProjectID" value="@Model.Project.ProjectID" />
<input type="hidden" name="ReturnFilter.BookID" value="@Model.BookID" />
<input type="hidden" name="ReturnFilter.ChapterID" value="@Model.ChapterID" />
<input type="hidden" name="ReturnFilter.SceneID" value="@Model.SceneID" />
<input type="hidden" name="ReturnFilter.WarningTypeID" value="@Model.WarningTypeID" />
<input type="hidden" name="ReturnFilter.WarningSeverityID" value="@Model.WarningSeverityID" />
<input type="hidden" name="ReturnFilter.EntityType" value="@Model.EntityType" />
<input type="hidden" name="ReturnFilter.Category" value="@Model.Category" />
<input type="hidden" name="ReturnFilter.IncludeDismissed" value="@Model.IncludeDismissed" />
<input type="hidden" name="ReturnFilter.IncludeIntentional" value="@Model.IncludeIntentional" />
<input type="hidden" name="ReturnFilter.ShowAcknowledgedWarnings" value="@Model.ShowAcknowledgedWarnings" />
<input class="form-control form-control-sm" type="text" name="Notes" maxlength="500" placeholder="Optional note" />
<button class="btn btn-outline-primary btn-sm" type="submit">Acknowledge</button>
</form>
}
}
</td>
</tr>
}
</tbody>
</table>
<div class="accordion" id="warning-severity-groups">
@foreach (var group in Model.WarningGroups)
{
var groupId = $"warning-group-{group.Severity.ToLowerInvariant().Replace(" ", "-")}";
<div class="accordion-item">
<h3 class="accordion-header" id="@($"{groupId}-heading")">
<button class="accordion-button @(group.IsExpanded ? "" : "collapsed")" type="button" data-bs-toggle="collapse" data-bs-target="#@groupId" aria-expanded="@group.IsExpanded.ToString().ToLowerInvariant()" aria-controls="@groupId">
@group.Severity (@group.Warnings.Count)
</button>
</h3>
<div id="@groupId" class="accordion-collapse collapse @(group.IsExpanded ? "show" : "")" aria-labelledby="@($"{groupId}-heading")">
<div class="accordion-body p-0">
<div class="table-responsive">
<table class="table table-sm align-middle mb-0">
<thead>
<tr>
<th>Severity</th>
<th>Category</th>
<th>Warning Type</th>
<th>Message</th>
<th>Scene</th>
<th>Status</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach (var warning in group.Warnings)
{
<tr>
<td><span class="badge @SeverityBadgeClass(warning.Severity)">@warning.Severity</span></td>
<td>@warning.Category</td>
<td>@warning.WarningTypeDisplayName</td>
<td>
<div>@warning.Message</div>
@if (!string.IsNullOrWhiteSpace(warning.Details))
{
<small class="text-muted d-block">@warning.Details</small>
}
@if (!string.IsNullOrWhiteSpace(warning.PreviousKnowledgeState) && !string.IsNullOrWhiteSpace(warning.CurrentKnowledgeState))
{
<small class="text-muted d-block">@warning.PreviousKnowledgeState &rarr; @warning.CurrentKnowledgeState</small>
}
@if (warning.IsAcknowledged && !string.IsNullOrWhiteSpace(warning.AcknowledgementNotes))
{
<small class="text-muted d-block">Note: @warning.AcknowledgementNotes</small>
}
</td>
<td>
@if (warning.PreviousSceneId.HasValue || warning.CurrentSceneId.HasValue)
{
@if (warning.PreviousSceneId.HasValue)
{
<small class="text-muted d-block">Previous</small>
<a class="d-block mb-2" asp-controller="Timeline" asp-action="Index" asp-route-projectId="@Model.Project.ProjectID" asp-route-selectedSceneId="@warning.PreviousSceneId">@warning.PreviousContextSceneDisplayName</a>
}
@if (warning.CurrentSceneId.HasValue)
{
<small class="text-muted d-block">Current</small>
<a class="d-block" asp-controller="Timeline" asp-action="Index" asp-route-projectId="@Model.Project.ProjectID" asp-route-selectedSceneId="@warning.CurrentSceneId">@warning.CurrentContextSceneDisplayName</a>
}
}
else if (warning.SceneID.HasValue)
{
<a asp-controller="Timeline" asp-action="Index" asp-route-projectId="@Model.Project.ProjectID" asp-route-selectedSceneId="@warning.SceneID">@warning.ContextSceneDisplayName</a>
}
else
{
<span class="muted">Project-wide</span>
}
</td>
<td>
@if (warning.IsDismissed)
{
<span class="badge bg-secondary">Dismissed</span>
}
else if (warning.IsIntentional || warning.IsAcknowledged)
{
<span class="badge bg-secondary">Acknowledged</span>
}
else
{
<span class="badge bg-warning text-dark">Active</span>
}
</td>
<td>
<div class="d-grid gap-2" style="min-width: 150px;">
@if (warning.CanInvestigate)
{
<a class="btn btn-outline-primary btn-sm w-100"
asp-controller="ContinuityExplorer"
asp-action="Index"
asp-route-projectId="@Model.Project.ProjectID"
asp-route-mode="@warning.InvestigationDisplayMode"
asp-route-characterId="@warning.CharacterID"
asp-route-assetId="@warning.AssetID"
asp-route-sceneId="@warning.InvestigationSceneId">Investigate</a>
}
@if (warning.Source == "Persisted" && warning.ContinuityWarningID.HasValue)
{
@if (warning.IsDismissed || warning.IsIntentional)
{
<form asp-action="Restore" method="post" class="d-grid">
<input type="hidden" name="id" value="@warning.ContinuityWarningID" />
<input type="hidden" name="projectId" value="@Model.Project.ProjectID" />
<input type="hidden" name="bookId" value="@Model.BookID" />
<input type="hidden" name="sceneId" value="@Model.SceneID" />
<button class="btn btn-outline-secondary btn-sm w-100" type="submit">Restore</button>
</form>
}
else
{
<form asp-action="Dismiss" method="post" class="d-grid">
<input type="hidden" name="id" value="@warning.ContinuityWarningID" />
<input type="hidden" name="projectId" value="@Model.Project.ProjectID" />
<input type="hidden" name="bookId" value="@Model.BookID" />
<input type="hidden" name="sceneId" value="@Model.SceneID" />
<button class="btn btn-outline-secondary btn-sm w-100" type="submit">Dismiss</button>
</form>
<form asp-action="MarkIntentional" method="post" class="d-grid">
<input type="hidden" name="id" value="@warning.ContinuityWarningID" />
<input type="hidden" name="projectId" value="@Model.Project.ProjectID" />
<input type="hidden" name="bookId" value="@Model.BookID" />
<input type="hidden" name="sceneId" value="@Model.SceneID" />
<button class="btn btn-outline-secondary btn-sm w-100" type="submit">Intentional</button>
</form>
}
}
else if (warning.IsAcknowledged)
{
<span class="badge bg-secondary justify-self-stretch">Acknowledged</span>
<form asp-action="RestoreGeneratedWarning" method="post" class="d-grid">
<input type="hidden" name="WarningType" value="@warning.WarningType" />
<input type="hidden" name="SceneID" value="@warning.SceneID" />
<input type="hidden" name="CharacterID" value="@warning.CharacterID" />
<input type="hidden" name="AssetID" value="@warning.AssetID" />
<input type="hidden" name="ReturnFilter.ProjectID" value="@Model.Project.ProjectID" />
<input type="hidden" name="ReturnFilter.BookID" value="@Model.BookID" />
<input type="hidden" name="ReturnFilter.ChapterID" value="@Model.ChapterID" />
<input type="hidden" name="ReturnFilter.SceneID" value="@Model.SceneID" />
<input type="hidden" name="ReturnFilter.WarningTypeID" value="@Model.WarningTypeID" />
<input type="hidden" name="ReturnFilter.WarningSeverityID" value="@Model.WarningSeverityID" />
<input type="hidden" name="ReturnFilter.EntityType" value="@Model.EntityType" />
<input type="hidden" name="ReturnFilter.Category" value="@Model.Category" />
<input type="hidden" name="ReturnFilter.IncludeDismissed" value="@Model.IncludeDismissed" />
<input type="hidden" name="ReturnFilter.IncludeIntentional" value="@Model.IncludeIntentional" />
<input type="hidden" name="ReturnFilter.ShowAcknowledgedWarnings" value="@Model.ShowAcknowledgedWarnings" />
<button class="btn btn-outline-secondary btn-sm w-100" type="submit">Restore</button>
</form>
}
else
{
<form asp-action="AcknowledgeGeneratedWarning" method="post" class="d-grid gap-2">
<input type="hidden" name="WarningType" value="@warning.WarningType" />
<input type="hidden" name="SceneID" value="@warning.SceneID" />
<input type="hidden" name="CharacterID" value="@warning.CharacterID" />
<input type="hidden" name="AssetID" value="@warning.AssetID" />
<input type="hidden" name="ReturnFilter.ProjectID" value="@Model.Project.ProjectID" />
<input type="hidden" name="ReturnFilter.BookID" value="@Model.BookID" />
<input type="hidden" name="ReturnFilter.ChapterID" value="@Model.ChapterID" />
<input type="hidden" name="ReturnFilter.SceneID" value="@Model.SceneID" />
<input type="hidden" name="ReturnFilter.WarningTypeID" value="@Model.WarningTypeID" />
<input type="hidden" name="ReturnFilter.WarningSeverityID" value="@Model.WarningSeverityID" />
<input type="hidden" name="ReturnFilter.EntityType" value="@Model.EntityType" />
<input type="hidden" name="ReturnFilter.Category" value="@Model.Category" />
<input type="hidden" name="ReturnFilter.IncludeDismissed" value="@Model.IncludeDismissed" />
<input type="hidden" name="ReturnFilter.IncludeIntentional" value="@Model.IncludeIntentional" />
<input type="hidden" name="ReturnFilter.ShowAcknowledgedWarnings" value="@Model.ShowAcknowledgedWarnings" />
<label class="form-label mb-0 small">Reason (optional)</label>
<input class="form-control form-control-sm" type="text" name="Notes" maxlength="500" />
<button class="btn btn-outline-success btn-sm w-100" type="submit">Acknowledge</button>
</form>
}
</div>
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
</div>
</div>
}
</div>
}
</section>