Separate critical editor load and save errors

This commit is contained in:
2026-03-14 15:37:20 +01:00
parent 19164736ad
commit 29851ed810
2 changed files with 181 additions and 164 deletions

View File

@@ -204,7 +204,8 @@
Model="editorModel"
IsLoading="isEditorLoading"
IsSaving="isEditorSaving"
ErrorMessage="editorError"
LoadErrorMessage="editorLoadError"
SaveErrorMessage="editorSaveError"
OnClose="CloseCellEditorAsync"
OnSave="SaveCellEditorAsync" />
}
@@ -223,7 +224,8 @@
private bool isEditorOpen;
private bool isEditorLoading;
private bool isEditorSaving;
private string? editorError;
private string? editorLoadError;
private string? editorSaveError;
private int? editingResultId;
private CriticalCellEditorModel? editorModel;
@@ -321,7 +323,8 @@
return;
}
editorError = null;
editorLoadError = null;
editorSaveError = null;
editorModel = null;
editingResultId = resultId;
isEditorSaving = false;
@@ -333,7 +336,7 @@
var response = await LookupService.GetCriticalCellEditorAsync(selectedTableSlug, resultId);
if (response is null)
{
editorError = "The selected cell could not be loaded for editing.";
editorLoadError = "The selected cell could not be loaded for editing.";
editorModel = null;
return;
}
@@ -342,7 +345,7 @@
}
catch (Exception exception)
{
editorError = exception.Message;
editorLoadError = exception.Message;
editorModel = null;
}
finally
@@ -356,7 +359,8 @@
isEditorOpen = false;
isEditorLoading = false;
isEditorSaving = false;
editorError = null;
editorLoadError = null;
editorSaveError = null;
editingResultId = null;
editorModel = null;
await InvokeAsync(StateHasChanged);
@@ -370,14 +374,14 @@
}
isEditorSaving = true;
editorError = null;
editorSaveError = null;
try
{
var response = await LookupService.UpdateCriticalCellAsync(selectedTableSlug, editingResultId.Value, editorModel.ToRequest());
if (response is null)
{
editorError = "The selected cell could not be saved.";
editorSaveError = "The selected cell could not be saved.";
return;
}
@@ -386,7 +390,7 @@
}
catch (Exception exception)
{
editorError = exception.Message;
editorSaveError = exception.Message;
}
finally
{

View File

@@ -1,10 +1,10 @@
@if (Model is not null)
{
<div class="critical-editor-backdrop" @onclick="HandleBackdropClicked">
<div class="critical-editor-dialog" @onclick:stopPropagation="true">
<header class="critical-editor-header">
<div>
<span class="eyebrow">@Model.SourceDocument</span>
<div class="critical-editor-backdrop" @onclick="HandleBackdropClicked">
<div class="critical-editor-dialog" @onclick:stopPropagation="true">
<header class="critical-editor-header">
<div>
<span class="eyebrow">Manual Curation</span>
@if (Model is not null)
{
<h3 class="panel-title">Edit @Model.TableName</h3>
<p class="muted critical-editor-meta">
Roll band <strong>@Model.RollBand</strong>, column <strong>@Model.ColumnLabel</strong>
@@ -13,177 +13,187 @@
<span>, group <strong>@Model.GroupLabel</strong></span>
}
</p>
</div>
<button type="button" class="btn btn-link critical-editor-close" @onclick="OnClose">Close</button>
</header>
}
else
{
<h3 class="panel-title">Critical Cell Editor</h3>
}
</div>
<button type="button" class="btn btn-link critical-editor-close" @onclick="OnClose">Close</button>
</header>
@if (IsLoading)
{
@if (IsLoading)
{
<div class="critical-editor-body">
<p class="muted">Loading editor...</p>
</div>
}
else if (!string.IsNullOrWhiteSpace(LoadErrorMessage))
{
<div class="critical-editor-body">
<p class="error-text critical-editor-error">@LoadErrorMessage</p>
</div>
}
else if (Model is not null)
{
<EditForm Model="Model" OnSubmit="HandleSubmitAsync" class="critical-editor-form">
<div class="critical-editor-body">
<p class="muted">Loading editor...</p>
</div>
}
else
{
<EditForm Model="Model" OnSubmit="HandleSubmitAsync" class="critical-editor-form">
<div class="critical-editor-body">
@if (!string.IsNullOrWhiteSpace(ErrorMessage))
@if (!string.IsNullOrWhiteSpace(SaveErrorMessage))
{
<p class="error-text critical-editor-error">@SaveErrorMessage</p>
}
<section class="critical-editor-section">
<h4>Base Cell</h4>
<div class="field-shell">
<label>Raw Cell Text</label>
<InputTextArea class="input-shell critical-editor-textarea tall" @bind-Value="Model.RawCellText" />
</div>
<div class="field-shell">
<label>Description / Prose</label>
<InputText class="input-shell" @bind-Value="Model.DescriptionText" />
</div>
<div class="field-shell">
<label>Affix Text</label>
<InputText class="input-shell" @bind-Value="Model.RawAffixText" />
</div>
<div class="form-grid">
<div class="field-shell">
<label>Parse Status</label>
<InputText class="input-shell" @bind-Value="Model.ParseStatus" />
</div>
<div class="field-shell">
<label>Parsed Json</label>
<InputTextArea class="input-shell critical-editor-textarea json" @bind-Value="Model.ParsedJson" />
</div>
</div>
</section>
<section class="critical-editor-section">
<div class="critical-editor-section-header">
<h4>Base Effects</h4>
<button type="button" class="btn-ritual" @onclick="AddBaseEffect">Add Effect</button>
</div>
@if (Model.Effects.Count == 0)
{
<p class="error-text critical-editor-error">@ErrorMessage</p>
<p class="muted">No normalized base effects for this cell.</p>
}
<section class="critical-editor-section">
<h4>Base Cell</h4>
<div class="field-shell">
<label>Raw Cell Text</label>
<InputTextArea class="input-shell critical-editor-textarea tall" @bind-Value="Model.RawCellText" />
</div>
<div class="field-shell">
<label>Description / Prose</label>
<InputText class="input-shell" @bind-Value="Model.DescriptionText" />
</div>
<div class="field-shell">
<label>Affix Text</label>
<InputText class="input-shell" @bind-Value="Model.RawAffixText" />
</div>
<div class="form-grid">
<div class="field-shell">
<label>Parse Status</label>
<InputText class="input-shell" @bind-Value="Model.ParseStatus" />
</div>
<div class="field-shell">
<label>Parsed Json</label>
<InputTextArea class="input-shell critical-editor-textarea json" @bind-Value="Model.ParsedJson" />
</div>
</div>
</section>
<section class="critical-editor-section">
<div class="critical-editor-section-header">
<h4>Base Effects</h4>
<button type="button" class="btn-ritual" @onclick="AddBaseEffect">Add Effect</button>
</div>
@if (Model.Effects.Count == 0)
else
{
@for (var index = 0; index < Model.Effects.Count; index++)
{
<p class="muted">No normalized base effects for this cell.</p>
}
else
{
@for (var index = 0; index < Model.Effects.Count; index++)
{
var effect = Model.Effects[index];
<div class="critical-editor-card">
<div class="critical-editor-card-header">
<strong>Effect @(index + 1)</strong>
<button type="button" class="btn btn-link" @onclick="() => RemoveBaseEffect(index)">Remove</button>
</div>
@EffectFields(effect)
var effect = Model.Effects[index];
<div class="critical-editor-card">
<div class="critical-editor-card-header">
<strong>Effect @(index + 1)</strong>
<button type="button" class="btn btn-link" @onclick="() => RemoveBaseEffect(index)">Remove</button>
</div>
}
@EffectFields(effect)
</div>
}
</section>
}
</section>
<section class="critical-editor-section">
<div class="critical-editor-section-header">
<h4>Branches</h4>
<button type="button" class="btn-ritual" @onclick="AddBranch">Add Branch</button>
</div>
@if (Model.Branches.Count == 0)
<section class="critical-editor-section">
<div class="critical-editor-section-header">
<h4>Branches</h4>
<button type="button" class="btn-ritual" @onclick="AddBranch">Add Branch</button>
</div>
@if (Model.Branches.Count == 0)
{
<p class="muted">No branch records on this cell.</p>
}
else
{
@for (var index = 0; index < Model.Branches.Count; index++)
{
<p class="muted">No branch records on this cell.</p>
}
else
{
@for (var index = 0; index < Model.Branches.Count; index++)
{
var branch = Model.Branches[index];
<div class="critical-editor-card branch-card-editor">
<div class="critical-editor-card-header">
<strong>Branch @(index + 1)</strong>
<button type="button" class="btn btn-link" @onclick="() => RemoveBranch(index)">Remove</button>
</div>
<div class="form-grid">
<div class="field-shell">
<label>Branch Kind</label>
<InputText class="input-shell" @bind-Value="branch.BranchKind" />
</div>
<div class="field-shell">
<label>Condition Key</label>
<InputText class="input-shell" @bind-Value="branch.ConditionKey" />
</div>
<div class="field-shell">
<label>Sort Order</label>
<InputNumber TValue="int" class="input-shell" @bind-Value="branch.SortOrder" />
</div>
var branch = Model.Branches[index];
<div class="critical-editor-card branch-card-editor">
<div class="critical-editor-card-header">
<strong>Branch @(index + 1)</strong>
<button type="button" class="btn btn-link" @onclick="() => RemoveBranch(index)">Remove</button>
</div>
<div class="form-grid">
<div class="field-shell">
<label>Branch Kind</label>
<InputText class="input-shell" @bind-Value="branch.BranchKind" />
</div>
<div class="field-shell">
<label>Condition Text</label>
<InputText class="input-shell" @bind-Value="branch.ConditionText" />
<label>Condition Key</label>
<InputText class="input-shell" @bind-Value="branch.ConditionKey" />
</div>
<div class="field-shell">
<label>Raw Text</label>
<InputTextArea class="input-shell critical-editor-textarea" @bind-Value="branch.RawText" />
<label>Sort Order</label>
<InputNumber TValue="int" class="input-shell" @bind-Value="branch.SortOrder" />
</div>
</div>
<div class="field-shell">
<label>Condition Text</label>
<InputText class="input-shell" @bind-Value="branch.ConditionText" />
</div>
<div class="field-shell">
<label>Raw Text</label>
<InputTextArea class="input-shell critical-editor-textarea" @bind-Value="branch.RawText" />
</div>
<div class="field-shell">
<label>Description / Prose</label>
<InputText class="input-shell" @bind-Value="branch.DescriptionText" />
</div>
<div class="field-shell">
<label>Affix Text</label>
<InputText class="input-shell" @bind-Value="branch.RawAffixText" />
</div>
<div class="form-grid">
<div class="field-shell">
<label>Condition Json</label>
<InputTextArea class="input-shell critical-editor-textarea compact" @bind-Value="branch.ConditionJson" />
</div>
<div class="field-shell">
<label>Description / Prose</label>
<InputText class="input-shell" @bind-Value="branch.DescriptionText" />
</div>
<div class="field-shell">
<label>Affix Text</label>
<InputText class="input-shell" @bind-Value="branch.RawAffixText" />
</div>
<div class="form-grid">
<div class="field-shell">
<label>Condition Json</label>
<InputTextArea class="input-shell critical-editor-textarea compact" @bind-Value="branch.ConditionJson" />
</div>
<div class="field-shell">
<label>Parsed Json</label>
<InputTextArea class="input-shell critical-editor-textarea json" @bind-Value="branch.ParsedJson" />
</div>
<label>Parsed Json</label>
<InputTextArea class="input-shell critical-editor-textarea json" @bind-Value="branch.ParsedJson" />
</div>
</div>
<div class="critical-editor-subsection">
<div class="critical-editor-section-header">
<h5>Branch Effects</h5>
<button type="button" class="btn-ritual" @onclick="() => AddBranchEffect(branch)">Add Effect</button>
</div>
@if (branch.Effects.Count == 0)
<div class="critical-editor-subsection">
<div class="critical-editor-section-header">
<h5>Branch Effects</h5>
<button type="button" class="btn-ritual" @onclick="() => AddBranchEffect(branch)">Add Effect</button>
</div>
@if (branch.Effects.Count == 0)
{
<p class="muted">No normalized branch effects.</p>
}
else
{
@for (var effectIndex = 0; effectIndex < branch.Effects.Count; effectIndex++)
{
<p class="muted">No normalized branch effects.</p>
}
else
{
@for (var effectIndex = 0; effectIndex < branch.Effects.Count; effectIndex++)
{
var effect = branch.Effects[effectIndex];
<div class="critical-editor-card nested">
<div class="critical-editor-card-header">
<strong>Branch Effect @(effectIndex + 1)</strong>
<button type="button" class="btn btn-link" @onclick="() => RemoveBranchEffect(branch, effectIndex)">Remove</button>
</div>
@EffectFields(effect)
var effect = branch.Effects[effectIndex];
<div class="critical-editor-card nested">
<div class="critical-editor-card-header">
<strong>Branch Effect @(effectIndex + 1)</strong>
<button type="button" class="btn btn-link" @onclick="() => RemoveBranchEffect(branch, effectIndex)">Remove</button>
</div>
}
@EffectFields(effect)
</div>
}
</div>
}
</div>
}
</div>
}
</section>
</div>
}
</section>
</div>
<footer class="critical-editor-footer">
<button type="button" class="btn btn-link" @onclick="OnClose" disabled="@IsSaving">Cancel</button>
<button type="submit" class="btn-ritual" disabled="@IsSaving">
@(IsSaving ? "Saving..." : "Save Cell")
</button>
</footer>
</EditForm>
}
</div>
<footer class="critical-editor-footer">
<button type="button" class="btn btn-link" @onclick="OnClose" disabled="@IsSaving">Cancel</button>
<button type="submit" class="btn-ritual" disabled="@IsSaving">
@(IsSaving ? "Saving..." : "Save Cell")
</button>
</footer>
</EditForm>
}
</div>
}
</div>
@code {
[Parameter, EditorRequired]
@@ -196,7 +206,10 @@
public bool IsSaving { get; set; }
[Parameter]
public string? ErrorMessage { get; set; }
public string? LoadErrorMessage { get; set; }
[Parameter]
public string? SaveErrorMessage { get; set; }
[Parameter, EditorRequired]
public EventCallback OnClose { get; set; }