From de6710aef84cc73bbb5328b4ab95e4c6d3574c34 Mon Sep 17 00:00:00 2001 From: Argo-AsicoTech Date: Wed, 11 Dec 2024 08:48:10 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20EditForm/InCell?= =?UTF-8?q?=20=E6=A8=A1=E5=BC=8F=E4=B8=8B=E6=9C=AA=E8=A7=A6=E5=8F=91=20OnA?= =?UTF-8?q?fterCancelSaveAsync=20=E5=9B=9E=E8=B0=83=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Table/Table.razor.Toolbar.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/BootstrapBlazor/Components/Table/Table.razor.Toolbar.cs b/src/BootstrapBlazor/Components/Table/Table.razor.Toolbar.cs index 94b729568f6..0a9c9ce9ad6 100644 --- a/src/BootstrapBlazor/Components/Table/Table.razor.Toolbar.cs +++ b/src/BootstrapBlazor/Components/Table/Table.razor.Toolbar.cs @@ -622,7 +622,7 @@ private async Task ShowDeleteToastAsync(string title, string content, ToastCateg /// 取消保存方法 /// /// - protected void CancelSave() + protected async Task CancelSave() { if (EditMode == EditMode.EditForm) { @@ -635,6 +635,11 @@ protected void CancelSave() AddInCell = false; EditInCell = false; } + + if (OnAfterCancelSaveAsync != null) + { + await OnAfterCancelSaveAsync(); + } } /// From d91647670094f8d6105fbbfb83f07296ccad6af2 Mon Sep 17 00:00:00 2001 From: Argo-AsicoTech Date: Wed, 11 Dec 2024 08:48:24 +0800 Subject: [PATCH 2/3] chore: bump version 9.1.3-beta03 --- src/BootstrapBlazor/BootstrapBlazor.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BootstrapBlazor/BootstrapBlazor.csproj b/src/BootstrapBlazor/BootstrapBlazor.csproj index 99d0077a1cd..22686dd7d98 100644 --- a/src/BootstrapBlazor/BootstrapBlazor.csproj +++ b/src/BootstrapBlazor/BootstrapBlazor.csproj @@ -1,7 +1,7 @@ - 9.1.3-beta02 + 9.1.3-beta03 From 21321448bd1b3a2970c4295bf9e305a19d009d0c Mon Sep 17 00:00:00 2001 From: Argo-AsicoTech Date: Wed, 11 Dec 2024 08:48:31 +0800 Subject: [PATCH 3/3] =?UTF-8?q?test:=20=E6=9B=B4=E6=96=B0=E5=8D=95?= =?UTF-8?q?=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/UnitTest/Components/TableTest.cs | 82 +++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/test/UnitTest/Components/TableTest.cs b/test/UnitTest/Components/TableTest.cs index 936168feafb..b7d68df963d 100644 --- a/test/UnitTest/Components/TableTest.cs +++ b/test/UnitTest/Components/TableTest.cs @@ -5507,6 +5507,88 @@ public async Task OnSaveAsync_Ok() Assert.True(afterModify); } + [Fact] + public async Task OnAfterCancelSaveAsync_EditForm() + { + var localizer = Context.Services.GetRequiredService>(); + var items = Foo.GenerateFoo(localizer, 2); + var afterCancelSave = false; + var cut = Context.RenderComponent(pb => + { + pb.AddChildContent>(pb => + { + pb.Add(a => a.RenderMode, TableRenderMode.Table); + pb.Add(a => a.Items, items); + pb.Add(a => a.IsMultipleSelect, true); + pb.Add(a => a.ShowToolbar, true); + pb.Add(a => a.ShowExtendButtons, true); + pb.Add(a => a.EditMode, EditMode.EditForm); + pb.Add(a => a.OnAfterCancelSaveAsync, () => + { + afterCancelSave = true; + return Task.CompletedTask; + }); + pb.Add(a => a.TableColumns, foo => builder => + { + builder.OpenComponent>(0); + builder.AddAttribute(1, "Field", "Name"); + builder.AddAttribute(2, "FieldExpression", Utility.GenerateValueExpression(foo, "Name", typeof(string))); + builder.CloseComponent(); + }); + }); + }); + + // test edit button + var button = cut.FindAll("tbody tr button"); + await cut.InvokeAsync(() => button[0].Click()); + + // 取消按钮 + var cancelButton = cut.Find(".form-footer .btn-secondary"); + await cut.InvokeAsync(() => cancelButton.Click()); + Assert.True(afterCancelSave); + } + + [Fact] + public async Task OnAfterCancelSaveAsync_InCell() + { + var localizer = Context.Services.GetRequiredService>(); + var items = Foo.GenerateFoo(localizer, 2); + var afterCancelSave = false; + var cut = Context.RenderComponent(pb => + { + pb.AddChildContent>(pb => + { + pb.Add(a => a.RenderMode, TableRenderMode.Table); + pb.Add(a => a.Items, items); + pb.Add(a => a.IsMultipleSelect, true); + pb.Add(a => a.ShowToolbar, true); + pb.Add(a => a.ShowExtendButtons, true); + pb.Add(a => a.EditMode, EditMode.EditForm); + pb.Add(a => a.OnAfterCancelSaveAsync, () => + { + afterCancelSave = true; + return Task.CompletedTask; + }); + pb.Add(a => a.TableColumns, foo => builder => + { + builder.OpenComponent>(0); + builder.AddAttribute(1, "Field", "Name"); + builder.AddAttribute(2, "FieldExpression", Utility.GenerateValueExpression(foo, "Name", typeof(string))); + builder.CloseComponent(); + }); + }); + }); + + // test edit button + var button = cut.FindAll("tbody tr button"); + await cut.InvokeAsync(() => button[0].Click()); + + // 取消按钮 + button = cut.FindAll("tbody tr button"); + await cut.InvokeAsync(() => button[1].Click()); + Assert.True(afterCancelSave); + } + [Fact] public async Task OnAfterCancelSaveAsync_Popup() {