feat(NumberFilter): support nullable data type (#4261)

* feat: 支持可为空数据类型

* chore: bump version 8.9.2-beta06

* test: 更新单元测试
This commit is contained in:
Argo Zhang 2024-09-10 17:13:49 +08:00 committed by GitHub
parent 6f02ab0fe7
commit 9425792f61
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 16 deletions

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<Version>8.9.2-beta05</Version>
<Version>8.9.2-beta06</Version>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">

View File

@ -60,22 +60,22 @@ else
<DateTimeFilter Count="_count" />
break;
case nameof(Int16):
<NumberFilter TType="Int16" Count="@_count" Step="@_step" />
<NumberFilter TType="Int16?" Count="@_count" Step="@_step" />
break;
case nameof(Int32):
<NumberFilter TType="Int32" Count="@_count" Step="@_step" />
<NumberFilter TType="Int32?" Count="@_count" Step="@_step" />
break;
case nameof(Int64):
<NumberFilter TType="Int64" Count="@_count" Step="@_step" />
<NumberFilter TType="Int64?" Count="@_count" Step="@_step" />
break;
case nameof(Single):
<NumberFilter TType="Single" Count="@_count" Step="@_step" />
<NumberFilter TType="Single?" Count="@_count" Step="@_step" />
break;
case nameof(Double):
<NumberFilter TType="Double" Count="@_count" Step="@_step" />
<NumberFilter TType="Double?" Count="@_count" Step="@_step" />
break;
case nameof(Decimal):
<NumberFilter TType="Decimal" Count="@_count" Step="@_step" />
<NumberFilter TType="Decimal?" Count="@_count" Step="@_step" />
break;
case nameof(String):
<StringFilter Count="_count" />

View File

@ -73,7 +73,7 @@ public class TableNumberFilterTest : BootstrapBlazorTestBase
}
[Fact]
public void Misc_Ok()
public async Task Misc_Ok()
{
var cut = Context.RenderComponent<BootstrapBlazorRoot>(pb =>
{
@ -93,17 +93,17 @@ public class TableNumberFilterTest : BootstrapBlazorTestBase
}));
});
});
var filter = cut.FindComponent<NumberFilter<int>>();
var input = filter.FindComponent<BootstrapInputNumber<int>>();
var filter = cut.FindComponent<NumberFilter<int?>>();
var input = filter.FindComponent<BootstrapInputNumber<int?>>();
// Click ToDay Cell
cut.InvokeAsync(() =>
await cut.InvokeAsync(() =>
{
input.Instance.SetValue(10);
});
var filterButton = cut.FindComponent<FilterButton<FilterAction>>();
cut.InvokeAsync(() =>
await cut.InvokeAsync(() =>
{
// OnFilterValueChanged
var logics = filterButton.FindAll(".dropdown-item");
@ -118,15 +118,13 @@ public class TableNumberFilterTest : BootstrapBlazorTestBase
Assert.Equal(FilterAction.LessThanOrEqual, conditions.Filters[0].FilterAction);
// OnClearFilter
cut.InvokeAsync(() =>
await cut.InvokeAsync(() =>
{
filterButton.Find(".fa-ban").Click();
});
conditions = filter.Instance.GetFilterConditions();
Assert.NotNull(conditions.Filters);
Assert.Single(conditions.Filters);
Assert.Equal(0, conditions.Filters[0].FieldValue);
Assert.Equal(FilterAction.GreaterThanOrEqual, conditions.Filters[0].FilterAction);
Assert.Empty(conditions.Filters);
}
[Fact]