From 3dde2789550921fde2a8f5eb8f2bffb8c77b978c Mon Sep 17 00:00:00 2001 From: Leon Hoppe Date: Thu, 16 Jan 2025 16:22:25 +0100 Subject: [PATCH] Added creation/modification confirmation --- src/HopFrame.Web/Components/Dialogs/HopFrameEditor.razor | 7 ++++++- src/HopFrame.Web/Models/RelationPickerDialogData.cs | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/HopFrame.Web/Components/Dialogs/HopFrameEditor.razor b/src/HopFrame.Web/Components/Dialogs/HopFrameEditor.razor index b2a334f..bd16751 100644 --- a/src/HopFrame.Web/Components/Dialogs/HopFrameEditor.razor +++ b/src/HopFrame.Web/Components/Dialogs/HopFrameEditor.razor @@ -256,9 +256,14 @@ } StateHasChanged(); - return _validationErrors + var valid = _validationErrors .Select(err => err.Value.Count) .All(c => c == 0); + + if (!valid) return false; + var dialog = await Dialogs.ShowConfirmationAsync($"Do you really want to {(_currentlyEditing ? "edit" : "create")} this entry?"); + var result = await dialog.Result; + return !result.Cancelled; } private enum InputType { diff --git a/src/HopFrame.Web/Models/RelationPickerDialogData.cs b/src/HopFrame.Web/Models/RelationPickerDialogData.cs index 90d5a79..3d48bf1 100644 --- a/src/HopFrame.Web/Models/RelationPickerDialogData.cs +++ b/src/HopFrame.Web/Models/RelationPickerDialogData.cs @@ -2,7 +2,7 @@ namespace HopFrame.Web.Models; -public class RelationPickerDialogData(TableConfig sourceTable, object? current) { +public sealed class RelationPickerDialogData(TableConfig sourceTable, object? current) { public object? Object { get; set; } = current; public TableConfig SourceTable { get; init; } = sourceTable; } \ No newline at end of file