Skip to content

Commit 028aa2a

Browse files
committed
Merge branch 'main' into feat-region
2 parents 34dc8f8 + a9981ed commit 028aa2a

File tree

15 files changed

+65
-27
lines changed

15 files changed

+65
-27
lines changed

src/BootstrapBlazor/BootstrapBlazor.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
4-
<Version>9.11.2-beta04</Version>
4+
<Version>9.11.2-beta07</Version>
55
</PropertyGroup>
66

77
<ItemGroup>

src/BootstrapBlazor/Components/Filters/FilterButton.razor

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
@typeparam TValue
33
@inherits Dropdown<TValue>
44

5-
<button type="button" class="btn btn-filter dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
6-
<i class="@FilterIcon" />
7-
</button>
8-
<div class="dropdown-menu shadow">
9-
@foreach (var item in Items)
10-
{
11-
<div class="@ActiveItem(item)" @onclick="e => OnItemClick(item)">@item.Text</div>
12-
}
5+
<div id="@Id" class="bb-filter-btn-group">
6+
<button type="button" class="btn btn-filter dropdown-toggle" data-bs-toggle="bb.dropdown" aria-expanded="false">
7+
<i class="@FilterIcon" />
8+
</button>
9+
<div class="dropdown-menu shadow">
10+
@foreach (var item in Items)
11+
{
12+
<div class="@ActiveItem(item)" @onclick="e => OnItemClick(item)">@item.Text</div>
13+
}
14+
</div>
15+
<Button Icon="@ClearIcon" Color="Color.None" class="btn-ban text-danger" OnClickWithoutRender="ClearFilter" />
1316
</div>
14-
<Button Icon="@ClearIcon" Color="Color.None" class="btn-ban text-danger" OnClickWithoutRender="ClearFilter" />
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import Data from "../../modules/data.js"
2+
import Popover from "../../modules/base-popover.js"
3+
4+
export function init(id) {
5+
const el = document.getElementById(id)
6+
if (el == null) {
7+
return
8+
}
9+
const popover = Popover.init(el);
10+
11+
const dropdown = { popover }
12+
Data.set(id, dropdown)
13+
}
14+
15+
export function dispose(id) {
16+
const dropdown = Data.get(id)
17+
Data.remove(id)
18+
19+
if (dropdown) {
20+
Popover.dispose(dropdown.popover)
21+
}
22+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.bb-filter-btn-group {
2+
display: flex;
3+
flex-wrap: nowrap;
4+
}

src/BootstrapBlazor/Components/Filters/StringFilter.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
@if (IsHeaderRow)
55
{
66
<div class="@FilterRowClassString">
7-
<BootstrapInput @bind-Value="@_value1" ShowLabel="false" SkipValidate="true"></BootstrapInput>
7+
<BootstrapInput Value="@_value1" OnValueChanged="OnValueChanged" ShowLabel="false" SkipValidate="true"></BootstrapInput>
88
<FilterButton Items="Items" @bind-Value="_action1" OnSelectedItemChanged="_ => OnFilterAsync()" OnClearFilter="OnClearFilter" />
99
</div>
1010
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,10 @@ public override async Task SetFilterConditionsAsync(FilterKeyValueAction filter)
128128
}
129129
await base.SetFilterConditionsAsync(filter);
130130
}
131+
132+
private async Task OnValueChanged(string? val)
133+
{
134+
_value1 = val;
135+
await OnFilterAsync();
136+
}
131137
}

src/BootstrapBlazor/Components/Table/Table.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
<span class="caret"></span>
108108
</button>
109109
<div class="dropdown-menu dropdown-menu-end shadow">
110-
@foreach (var item in VisibleColumns)
110+
@foreach (var item in _visibleColumns)
111111
{
112112
<div class="dropdown-item">
113113
<Checkbox ShowAfterLabel="true" DisplayText="@item.DisplayName" IsDisabled="@GetColumnsListState(item)"

src/BootstrapBlazor/Components/Table/Table.razor.Toolbar.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ public Func<TItem, bool>? ShowDeleteButtonCallback
466466
/// <summary>
467467
/// 获得/设置 各列是否显示状态集合
468468
/// </summary>
469-
private List<ColumnVisibleItem> VisibleColumns { get; } = [];
469+
private readonly List<ColumnVisibleItem> _visibleColumns = [];
470470

471471
/// <summary>
472472
/// 获得当前可见列集合
@@ -475,11 +475,15 @@ public Func<TItem, bool>? ShowDeleteButtonCallback
475475
public IEnumerable<ITableColumn> GetVisibleColumns()
476476
{
477477
// 不可见列
478-
var items = VisibleColumns.Where(i => i.Visible);
479-
return Columns.Where(i => !i.GetIgnore() && items.Any(v => v.Name == i.GetFieldName()) && ScreenSize >= i.ShownWithBreakPoint);
478+
var items = _visibleColumns.Where(i => i.Visible).Select(a => a.Name).ToHashSet();
479+
return Columns.Where(i => !i.GetIgnore() && items.Contains(i.GetFieldName()) && ScreenSize >= i.ShownWithBreakPoint);
480480
}
481481

482-
private bool GetColumnsListState(ColumnVisibleItem item) => VisibleColumns.Find(i => i.Name == item.Name) is { Visible: true } && VisibleColumns.Where(i => i.Visible).DistinctBy(i => i.Name).Count(i => i.Visible) == 1;
482+
private bool GetColumnsListState(ColumnVisibleItem item)
483+
{
484+
var items = _visibleColumns.Where(i => i.Visible).Select(a => a.Name).Distinct().ToHashSet();
485+
return items.Contains(item.Name) && items.Count == 1;
486+
}
483487

484488
private bool ShowAddForm { get; set; }
485489

src/BootstrapBlazor/Components/Table/Table.razor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,8 +1276,8 @@ private void InternalResetVisibleColumns(List<ITableColumn> columns, IEnumerable
12761276
}
12771277
}
12781278
}
1279-
VisibleColumns.Clear();
1280-
VisibleColumns.AddRange(cols);
1279+
_visibleColumns.Clear();
1280+
_visibleColumns.AddRange(cols);
12811281
}
12821282

12831283
/// <summary>

src/BootstrapBlazor/Components/Table/Table.razor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ const autoFitColumnWidth = async (table, col) => {
747747
const span = th.querySelector('.table-cell');
748748
const thStyle = getComputedStyle(th);
749749
const margin = parseFloat(thStyle.getPropertyValue('padding-left')) + parseFloat(thStyle.getPropertyValue('padding-right'))
750-
maxWidth = Math.max(maxWidth, calcCellWidth(span)) + margin;
750+
maxWidth = Math.max(maxWidth, calcCellWidth(span) + margin);
751751
}
752752

753753
if (table.options.autoFitColumnWidthCallback !== null) {

0 commit comments

Comments
 (0)