From 26245c0db99d4c75fed5a7af57b28fcd143a0dc4 Mon Sep 17 00:00:00 2001 From: Argo Date: Tue, 18 Jan 2022 13:32:01 +0000 Subject: [PATCH] =?UTF-8?q?!2328=20doc(#I4RCRW):=20update=20sample=20code?= =?UTF-8?q?=20for=20Dialog=20ShowEdit/Search/SaveDialog=20*=20doc:=20?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BC=B9=E7=AA=97=E7=A4=BA=E4=BE=8B=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=20*=20feat:=20=E5=A2=9E=E5=8A=A0=20DialogSaveDetail?= =?UTF-8?q?=20=E7=BB=84=E4=BB=B6=20*=20refactor:=20=E5=BE=AE=E8=B0=83=20Po?= =?UTF-8?q?pover=20=E8=84=9A=E6=9C=AC=E4=BB=A3=E7=A0=81=20*=20revert:=20?= =?UTF-8?q?=E6=81=A2=E5=A4=8D=E9=85=8D=E7=BD=AE=20*=20doc:=20=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/DialogSaveDetail.razor | 17 ++++++++ .../Samples/Dialogs.razor | 37 ++++++++++++---- .../Samples/Dialogs.razor.cs | 43 +++++++++++++++++++ 3 files changed, 89 insertions(+), 8 deletions(-) create mode 100644 src/BootstrapBlazor.Shared/Components/DialogSaveDetail.razor diff --git a/src/BootstrapBlazor.Shared/Components/DialogSaveDetail.razor b/src/BootstrapBlazor.Shared/Components/DialogSaveDetail.razor new file mode 100644 index 000000000..3d4f373a5 --- /dev/null +++ b/src/BootstrapBlazor.Shared/Components/DialogSaveDetail.razor @@ -0,0 +1,17 @@ +
+
+ +
+
+ +
+
+ +@code { + /// + /// + /// + [Parameter] + [NotNull] + public Foo? Value { get; set; } +} diff --git a/src/BootstrapBlazor.Shared/Samples/Dialogs.razor b/src/BootstrapBlazor.Shared/Samples/Dialogs.razor index ff8f6c17a..bbbd7c356 100644 --- a/src/BootstrapBlazor.Shared/Samples/Dialogs.razor +++ b/src/BootstrapBlazor.Shared/Samples/Dialogs.razor @@ -4,14 +4,6 @@

通过注入服务调用 Show 方法弹出窗口进行人机交互

- -

- 本组件使用注入服务的形式提供功能,使用时用户体验效果非常舒适,随时随地的调用,需要在使用本组件的页面中内置 Dialog 组件,或者在 MainLayout 主布局组件中内置,示例代码如下: -

-
- -
<Dialog />
-

通过设置 DialogOption IsKeyboard 参数,开启弹窗是否支持 ESC,请点击后面按钮设置后再点击 弹窗 按钮测试效果

@@ -100,6 +92,35 @@ + +

功能介绍

+
    +
  • 点击按钮弹出编辑弹窗
  • +
  • 通过 EditDialogOption 参数对弹窗进行设置
  • +
  • 设计出发点通过给定 Model 或者 Items 自动生成带客户端验证的表单窗口
  • +
+ +
+ + +

功能介绍

+
    +
  • 点击按钮弹出搜索弹窗
  • +
  • 通过 SearchDialogOption 参数对弹窗进行设置
  • +
  • 设计出发点通过给定 Model 或者 Items 自动生成搜索窗口
  • +
+ +
+ + +

功能介绍

+
    +
  • 点击按钮弹出保存弹窗
  • +
  • 设计出发点通过给定 TComponent 自动生成保存窗口,通过设置 saveCallback 在保存回调方法中进行数据处理,TComponent 泛型组件所需要参数可以通过 parameters 进行传递
  • +
+ +
+ diff --git a/src/BootstrapBlazor.Shared/Samples/Dialogs.razor.cs b/src/BootstrapBlazor.Shared/Samples/Dialogs.razor.cs index 373fc65b0..a5e2de209 100644 --- a/src/BootstrapBlazor.Shared/Samples/Dialogs.razor.cs +++ b/src/BootstrapBlazor.Shared/Samples/Dialogs.razor.cs @@ -7,6 +7,7 @@ using BootstrapBlazor.Shared.Common; using BootstrapBlazor.Shared.Components; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Web; +using Microsoft.Extensions.Localization; using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -29,6 +30,10 @@ public sealed partial class Dialogs [NotNull] private DialogService? DialogService { get; set; } + [Inject] + [NotNull] + private IStringLocalizer? Localizer { get; set; } + private bool IsKeyboard { get; set; } private void OnClickKeyboard() @@ -224,6 +229,44 @@ public sealed partial class Dialogs }); } + private async Task OnEditDialogClick() + { + var option = new EditDialogOption() + { + Title = "编辑弹窗", + Model = new Foo(), + RowType = RowType.Inline, + ItemsPerRow = 2, + ItemChangedType = ItemChangedType.Update + }; + await DialogService.ShowEditDialog(option); + } + + private async Task OnSearchDialogClick() + { + var option = new SearchDialogOption() + { + Title = "搜索弹窗", + Model = new Foo(), + RowType = RowType.Inline, + ItemsPerRow = 2, + }; + await DialogService.ShowSearchDialog(option); + } + + private async Task OnSaveDialogClick() + { + var foo = Foo.Generate(Localizer); + await DialogService.ShowSaveDialog("保存", () => + { + // 此处可以访问 foo 实例进行入库操作等 + return Task.FromResult(true); + }, new Dictionary + { + ["Value"] = foo + }); + } + /// /// 获得属性方法 ///