mirror of
https://gitee.com/LongbowEnterprise/BootstrapBlazor.git
synced 2024-12-05 05:29:47 +08:00
!3563 feat(#I638ZX): add binding Value support switch month/year
* feat: 增加 Value 双向绑定支持 * refactor: 格式化代码 * test: 增加 SwalOption Class 参数单元测试 * refactor: 增加可为空标记消除警告信息
This commit is contained in:
parent
bd93106ec0
commit
6335e168c9
@ -8,19 +8,19 @@
|
||||
<div class="calendar-title">@GetTitle()</div>
|
||||
<div class="calendar-button-group">
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-sm" @onclick="e => OnChangeYear(-1)">
|
||||
<button type="button" class="btn btn-sm" @onclick="() => OnChangeYear(-1)">
|
||||
<span>@PreviousYear</span>
|
||||
</button>
|
||||
<button type="button" class="btn btn-sm" @onclick="e => OnChangeMonth(-1)">
|
||||
<button type="button" class="btn btn-sm" @onclick="() => OnChangeMonth(-1)">
|
||||
<span>@PreviousMonth</span>
|
||||
</button>
|
||||
<button type="button" class="btn btn-sm" @onclick="e => OnChangeMonth(0)">
|
||||
<button type="button" class="btn btn-sm" @onclick="() => OnChangeMonth(0)">
|
||||
<span>@Today</span>
|
||||
</button>
|
||||
<button type="button" class="btn btn-sm" @onclick="e => OnChangeMonth(1)">
|
||||
<button type="button" class="btn btn-sm" @onclick="() => OnChangeMonth(1)">
|
||||
<span>@NextMonth</span>
|
||||
</button>
|
||||
<button type="button" class="btn btn-sm" @onclick="e => OnChangeYear(1)">
|
||||
<button type="button" class="btn btn-sm" @onclick="() => OnChangeYear(1)">
|
||||
<span>@NextYear</span>
|
||||
</button>
|
||||
</div>
|
||||
@ -64,13 +64,13 @@
|
||||
<div class="calendar-title"><span class="d-none d-sm-inline-block">@GetTitle()</span> <span>@WeekNumberText</span></div>
|
||||
<div class="calendar-button-group">
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-sm" @onclick="e => OnChangeWeek(-7)">
|
||||
<button type="button" class="btn btn-sm" @onclick="() => OnChangeWeek(-7)">
|
||||
<span>@PreviousWeek</span>
|
||||
</button>
|
||||
<button type="button" class="btn btn-sm" @onclick="e => OnChangeWeek(0)">
|
||||
<button type="button" class="btn btn-sm" @onclick="() => OnChangeWeek(0)">
|
||||
<span>@WeekText</span>
|
||||
</button>
|
||||
<button type="button" class="btn btn-sm" @onclick="e => OnChangeWeek(7)">
|
||||
<button type="button" class="btn btn-sm" @onclick="() => OnChangeWeek(7)">
|
||||
<span>@NextWeek</span>
|
||||
</button>
|
||||
</div>
|
||||
|
@ -179,24 +179,30 @@ public partial class Calendar
|
||||
{
|
||||
await ValueChanged.InvokeAsync(Value);
|
||||
}
|
||||
|
||||
StateHasChanged();
|
||||
else
|
||||
{
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 右侧快捷切换年按钮回调此方法
|
||||
/// </summary>
|
||||
/// <param name="offset"></param>
|
||||
protected void OnChangeYear(int offset)
|
||||
protected async Task OnChangeYear(int offset)
|
||||
{
|
||||
Value = Value.AddYears(offset);
|
||||
if (ValueChanged.HasDelegate)
|
||||
{
|
||||
await ValueChanged.InvokeAsync(Value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 右侧快捷切换月按钮回调此方法
|
||||
/// </summary>
|
||||
/// <param name="offset"></param>
|
||||
protected void OnChangeMonth(int offset)
|
||||
protected async Task OnChangeMonth(int offset)
|
||||
{
|
||||
if (offset == 0)
|
||||
{
|
||||
@ -206,13 +212,17 @@ public partial class Calendar
|
||||
{
|
||||
Value = Value.AddMonths(offset);
|
||||
}
|
||||
if (ValueChanged.HasDelegate)
|
||||
{
|
||||
await ValueChanged.InvokeAsync(Value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 右侧快捷切换周按钮回调此方法
|
||||
/// </summary>
|
||||
/// <param name="offset"></param>
|
||||
protected void OnChangeWeek(int offset)
|
||||
protected async Task OnChangeWeek(int offset)
|
||||
{
|
||||
if (offset == 0)
|
||||
{
|
||||
@ -223,6 +233,10 @@ public partial class Calendar
|
||||
Value = Value.AddDays(offset);
|
||||
}
|
||||
WeekNumberText = Localizer[nameof(WeekNumberText), GetWeekCount()];
|
||||
if (ValueChanged.HasDelegate)
|
||||
{
|
||||
await ValueChanged.InvokeAsync(Value);
|
||||
}
|
||||
}
|
||||
|
||||
private CalendarCellValue CreateCellValue(DateTime cellValue)
|
||||
|
@ -127,7 +127,7 @@ public partial class Table<TItem> : ITable where TItem : class, new()
|
||||
|
||||
private int PageStartIndex => Rows.Any() ? (PageIndex - 1) * PageItems + 1 : 0;
|
||||
|
||||
private string PageInfoLabelString => Localizer[nameof(PageInfoText), PageStartIndex, (PageIndex - 1) * PageItems + Rows.Count, TotalCount];
|
||||
private string? PageInfoLabelString => Localizer[nameof(PageInfoText), PageStartIndex, (PageIndex - 1) * PageItems + Rows.Count, TotalCount];
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 列拷贝 Tooltip 文字
|
||||
|
@ -24,7 +24,8 @@ public class SwalTest : SwalTestBase
|
||||
ShowFooter = true,
|
||||
ShowClose = true,
|
||||
CloseButtonIcon = "test-close-icon",
|
||||
CloseButtonText = "test-button-text-Cancel"
|
||||
CloseButtonText = "test-button-text-Cancel",
|
||||
Class = "dialog-swal-test"
|
||||
}));
|
||||
|
||||
// 代码覆盖模板单元测试
|
||||
@ -33,6 +34,7 @@ public class SwalTest : SwalTestBase
|
||||
Assert.Contains("Test-ButtonTemplate", cut.Markup);
|
||||
Assert.Contains("test-close-icon", cut.Markup);
|
||||
Assert.Contains("test-button-text-Cancel", cut.Markup);
|
||||
Assert.Contains("dialog-swal-test", cut.Markup);
|
||||
|
||||
// 测试关闭逻辑
|
||||
var modals = cut.FindComponents<Modal>();
|
||||
|
Loading…
Reference in New Issue
Block a user