Separate critical editor load and save errors
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
@if (Model is not null)
|
||||
{
|
||||
<div class="critical-editor-backdrop" @onclick="HandleBackdropClicked">
|
||||
<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>
|
||||
<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,6 +13,11 @@
|
||||
<span>, group <strong>@Model.GroupLabel</strong></span>
|
||||
}
|
||||
</p>
|
||||
}
|
||||
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>
|
||||
@@ -23,13 +28,19 @@
|
||||
<p class="muted">Loading editor...</p>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
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">
|
||||
@if (!string.IsNullOrWhiteSpace(ErrorMessage))
|
||||
@if (!string.IsNullOrWhiteSpace(SaveErrorMessage))
|
||||
{
|
||||
<p class="error-text critical-editor-error">@ErrorMessage</p>
|
||||
<p class="error-text critical-editor-error">@SaveErrorMessage</p>
|
||||
}
|
||||
|
||||
<section class="critical-editor-section">
|
||||
@@ -182,8 +193,7 @@
|
||||
</EditForm>
|
||||
}
|
||||
</div>
|
||||
</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; }
|
||||
|
||||
Reference in New Issue
Block a user