mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-02 03:57:38 +08:00
feat(module: confirm): add AutoFocusButton
options for the open method in confirm service (#2398)
* fix decimal conversion * Fix Culture Decimal Separator * feat(ConfirmService) Allow choose AutoFocusButton * Update components/modal/confirmDialog/ConfirmService.cs Co-authored-by: James Yeung <shunjiey@hotmail.com> * Fix after add Nullable to ConfirmAutoFocusButton * Fix format in code Co-authored-by: James Yeung <shunjiey@hotmail.com>
This commit is contained in:
parent
5e85c7c649
commit
a97828e673
@ -87,7 +87,7 @@ namespace AntDesign
|
||||
throw new FormatException();
|
||||
}
|
||||
|
||||
_value = int.Parse(value.Substring(0, index), CultureInfo.InvariantCulture);
|
||||
_value = decimal.Parse(value.Substring(0, index), CultureInfo.InvariantCulture);
|
||||
|
||||
if (index == value.Length)
|
||||
{
|
||||
|
@ -34,15 +34,16 @@ namespace AntDesign
|
||||
set
|
||||
{
|
||||
_step = value;
|
||||
NumberFormatInfo nfi = CultureInfo.NumberFormat;
|
||||
var stepStr = _step.ToString();
|
||||
if (string.IsNullOrEmpty(_format))
|
||||
{
|
||||
_format = string.Join('.', stepStr.Split('.').Select(n => new string('0', n.Length)));
|
||||
_format = string.Join('.', stepStr.Split(nfi.NumberDecimalSeparator).Select(n => new string('0', n.Length)));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (stepStr.IndexOf('.') > 0)
|
||||
_decimalPlaces = stepStr.Length - stepStr.IndexOf('.') - 1;
|
||||
if (stepStr.IndexOf(nfi.NumberDecimalSeparator) > 0)
|
||||
_decimalPlaces = stepStr.Length - stepStr.IndexOf(nfi.NumberDecimalSeparator) - 1;
|
||||
else
|
||||
_decimalPlaces = 0;
|
||||
}
|
||||
|
@ -22,13 +22,15 @@ namespace AntDesign
|
||||
/// <param name="confirmButtons">the buttons of dialog</param>
|
||||
/// <param name="confirmIcon">the icon of dialog</param>
|
||||
/// <param name="options">the configuration options for dialog</param>
|
||||
/// <param name="autoFocusButton">the autofocus button</param>
|
||||
/// <returns></returns>
|
||||
public async Task<ConfirmResult> Show(
|
||||
OneOf<string, RenderFragment> content,
|
||||
OneOf<string, RenderFragment> title,
|
||||
ConfirmButtons confirmButtons,
|
||||
ConfirmIcon confirmIcon,
|
||||
ConfirmButtonOptions options)
|
||||
ConfirmButtonOptions options,
|
||||
ConfirmAutoFocusButton? autoFocusButton = ConfirmAutoFocusButton.Ok)
|
||||
{
|
||||
if (options == null) throw new ArgumentNullException(nameof(options));
|
||||
ConfirmOptions confirmOptions = new ConfirmOptions()
|
||||
@ -37,6 +39,10 @@ namespace AntDesign
|
||||
ConfirmButtons = confirmButtons,
|
||||
ConfirmIcon = confirmIcon,
|
||||
};
|
||||
|
||||
if (autoFocusButton != null)
|
||||
confirmOptions.AutoFocusButton = (ConfirmAutoFocusButton)autoFocusButton;
|
||||
|
||||
if (title.IsT0)
|
||||
{
|
||||
confirmOptions.Title = title.AsT0;
|
||||
|
Loading…
Reference in New Issue
Block a user