mirror of
https://gitee.com/LongbowEnterprise/BootstrapBlazor.git
synced 2024-12-05 05:29:47 +08:00
!3556 feat(#I62RUU): set the parameter default value for DialogCloseButton/DialogSaveButton
* feat: ModalDialog 增加对 DialogClose/SaveButton 支持 * feat: DialogSaveButton 增加默认属性 * feat: DialogCloseButton 增加默认属性
This commit is contained in:
parent
0bc43b2635
commit
79e3a752d8
@ -3,6 +3,7 @@
|
||||
// Website: https://www.blazor.zone or https://argozhang.github.io/
|
||||
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace BootstrapBlazor.Components;
|
||||
|
||||
@ -11,9 +12,19 @@ namespace BootstrapBlazor.Components;
|
||||
/// </summary>
|
||||
public partial class DialogCloseButton : Button
|
||||
{
|
||||
/// <summary>
|
||||
/// 获得/设置 按钮颜色
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public override Color Color { get; set; } = Color.Secondary;
|
||||
|
||||
[CascadingParameter]
|
||||
private Func<Task>? OnCloseAsync { get; set; }
|
||||
|
||||
[Inject]
|
||||
[NotNull]
|
||||
private IStringLocalizer<ModalDialog>? Localizer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// <inheritdoc/>
|
||||
/// </summary>
|
||||
@ -26,4 +37,15 @@ public partial class DialogCloseButton : Button
|
||||
OnClickWithoutRender = OnCloseAsync;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <inheritdoc/>
|
||||
/// </summary>
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
base.OnParametersSet();
|
||||
|
||||
ButtonIcon ??= "fa-solid fa-fw fa-xmark";
|
||||
Text ??= Localizer[nameof(ModalDialog.CloseButtonText)];
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
// Website: https://www.blazor.zone or https://argozhang.github.io/
|
||||
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace BootstrapBlazor.Components;
|
||||
|
||||
@ -11,6 +12,10 @@ namespace BootstrapBlazor.Components;
|
||||
/// </summary>
|
||||
public partial class DialogSaveButton : Button
|
||||
{
|
||||
[Inject]
|
||||
[NotNull]
|
||||
private IStringLocalizer<ModalDialog>? Localizer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// <inheritdoc/>
|
||||
/// </summary>
|
||||
@ -20,4 +25,15 @@ public partial class DialogSaveButton : Button
|
||||
|
||||
ButtonType = ButtonType.Submit;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <inheritdoc/>
|
||||
/// </summary>
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
base.OnParametersSet();
|
||||
|
||||
ButtonIcon ??= "fa-solid fa-floppy-disk";
|
||||
Text ??= Localizer[nameof(ModalDialog.SaveButtonText)];
|
||||
}
|
||||
}
|
||||
|
@ -35,9 +35,11 @@
|
||||
</div>
|
||||
}
|
||||
<CascadingValue Name="BodyContext" Value="@BodyContext" IsFixed="true">
|
||||
<div class="modal-body">
|
||||
@RenderBodyTemplate()
|
||||
</div>
|
||||
<CascadingValue Value="OnClickClose" IsFixed="true">
|
||||
<div class="modal-body">
|
||||
@RenderBodyTemplate()
|
||||
</div>
|
||||
</CascadingValue>
|
||||
@if (ShowFooter)
|
||||
{
|
||||
<div class="modal-footer">
|
||||
@ -53,7 +55,12 @@
|
||||
{
|
||||
<Button Color="Color.Primary" Text="@SaveButtonText" Icon="fa-solid fa-fw fa-floppy-disk" OnClickWithoutRender="OnClickSave" />
|
||||
}
|
||||
@FooterTemplate
|
||||
@if (FooterTemplate != null)
|
||||
{
|
||||
<CascadingValue Value="OnClickClose" IsFixed>
|
||||
@FooterTemplate
|
||||
</CascadingValue>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</CascadingValue>
|
||||
|
Loading…
Reference in New Issue
Block a user