Share critical cell parsing across app and importer
This commit is contained in:
@@ -207,10 +207,13 @@
|
||||
<CriticalCellEditorDialog
|
||||
Model="editorModel"
|
||||
IsLoading="isEditorLoading"
|
||||
IsReparsing="isEditorReparsing"
|
||||
IsSaving="isEditorSaving"
|
||||
LoadErrorMessage="@editorLoadError"
|
||||
ReparseErrorMessage="@editorReparseError"
|
||||
SaveErrorMessage="@editorSaveError"
|
||||
OnClose="CloseCellEditorAsync"
|
||||
OnReparse="ReparseCellEditorAsync"
|
||||
OnSave="SaveCellEditorAsync" />
|
||||
}
|
||||
|
||||
@@ -227,8 +230,10 @@
|
||||
private bool IsTableSelectionDisabled => isReferenceDataLoading || (referenceData?.CriticalTables.Count ?? 0) == 0;
|
||||
private bool isEditorOpen;
|
||||
private bool isEditorLoading;
|
||||
private bool isEditorReparsing;
|
||||
private bool isEditorSaving;
|
||||
private string? editorLoadError;
|
||||
private string? editorReparseError;
|
||||
private string? editorSaveError;
|
||||
private int? editingResultId;
|
||||
private CriticalCellEditorModel? editorModel;
|
||||
@@ -328,9 +333,11 @@
|
||||
}
|
||||
|
||||
editorLoadError = null;
|
||||
editorReparseError = null;
|
||||
editorSaveError = null;
|
||||
editorModel = null;
|
||||
editingResultId = resultId;
|
||||
isEditorReparsing = false;
|
||||
isEditorSaving = false;
|
||||
isEditorLoading = true;
|
||||
isEditorOpen = true;
|
||||
@@ -362,14 +369,47 @@
|
||||
{
|
||||
isEditorOpen = false;
|
||||
isEditorLoading = false;
|
||||
isEditorReparsing = false;
|
||||
isEditorSaving = false;
|
||||
editorLoadError = null;
|
||||
editorReparseError = null;
|
||||
editorSaveError = null;
|
||||
editingResultId = null;
|
||||
editorModel = null;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
private async Task ReparseCellEditorAsync()
|
||||
{
|
||||
if (editorModel is null || string.IsNullOrWhiteSpace(selectedTableSlug) || editingResultId is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
isEditorReparsing = true;
|
||||
editorReparseError = null;
|
||||
|
||||
try
|
||||
{
|
||||
var response = await LookupService.ReparseCriticalCellAsync(selectedTableSlug, editingResultId.Value, editorModel.RawCellText);
|
||||
if (response is null)
|
||||
{
|
||||
editorReparseError = "The selected cell could not be re-parsed.";
|
||||
return;
|
||||
}
|
||||
|
||||
editorModel = CriticalCellEditorModel.FromResponse(response);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
editorReparseError = exception.Message;
|
||||
}
|
||||
finally
|
||||
{
|
||||
isEditorReparsing = false;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SaveCellEditorAsync()
|
||||
{
|
||||
if (editorModel is null || string.IsNullOrWhiteSpace(selectedTableSlug) || editingResultId is null)
|
||||
|
||||
Reference in New Issue
Block a user