Skip to content

Commit 6d55ed2

Browse files
committed
refactor: 精简代码
1 parent 80ef17d commit 6d55ed2

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

src/BootstrapBlazor/Components/Filters/BoolFilter.razor.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,6 @@ public override async Task SetFilterConditionsAsync(FilterKeyValueAction filter)
7171
{
7272
_value = value ? "true" : "false";
7373
}
74-
else if (first.FieldValue is null)
75-
{
76-
_value = "";
77-
}
7874
await base.SetFilterConditionsAsync(filter);
7975
}
8076
}

src/BootstrapBlazor/Components/Filters/FilterBase.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public abstract class FilterBase : BootstrapModuleComponentBase, IFilterAction
5858
/// <summary>
5959
/// 获得/设置 是否为 HeaderRow 模式 默认 false
6060
/// </summary>
61-
protected bool IsHeaderRow => TableFilter?.IsHeaderRow ?? false;
61+
protected bool IsHeaderRow => TableFilter.IsHeaderRow;
6262

6363
/// <summary>
6464
/// <inheritdoc/>
@@ -119,8 +119,8 @@ protected async Task OnClickConfirm()
119119
var table = TableFilter.Table;
120120
if (table != null)
121121
{
122-
var f = TableFilter.FilterAction.GetFilterConditions();
123-
if (f.Filters != null && f.Filters.Count > 0)
122+
var f = GetFilterConditions();
123+
if (f.Filters is { Count: > 0 })
124124
{
125125
table.Filters[FieldKey] = TableFilter.FilterAction;
126126
}
@@ -141,11 +141,8 @@ protected async Task OnClickConfirm()
141141
/// <returns></returns>
142142
protected async Task OnFilterValueChanged()
143143
{
144-
if (TableFilter != null)
145-
{
146-
await TableFilter.OnFilterAsync();
147-
StateHasChanged();
148-
}
144+
await TableFilter.OnFilterAsync();
145+
StateHasChanged();
149146
}
150147

151148
/// <summary>

src/BootstrapBlazor/Extensions/TableFilterExtensions.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,16 @@
55

66
namespace BootstrapBlazor.Components;
77

8-
internal static class TableFilterExtensions
8+
/// <summary>
9+
/// TableFilter extensions methods
10+
/// </summary>
11+
public static class TableFilterExtensions
912
{
13+
/// <summary>
14+
/// <see cref="TableFilter"/> Whether has filter
15+
/// </summary>
16+
/// <param name="filter"></param>
17+
/// <returns></returns>
1018
public static bool HasFilter(this TableFilter? filter)
1119
{
1220
if (filter == null)

0 commit comments

Comments
 (0)