Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/BootstrapBlazor/Components/Table/Table.razor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,14 @@
.btn-gear .dropdown-menu .dropdown-item {
padding: 6px 12px;
display: table-cell;
color: #504d4d;

&:not(.disabled) {
color: #504d4d;
}

&.disabled {
pointer-events: auto;
}
}

.btn-gear .dropdown-menu .dropdown-item:not(:first-child) {
Expand Down
59 changes: 32 additions & 27 deletions src/BootstrapBlazor/Components/Table/TableToolbar.razor
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
<div class="@ToolbarClassString">
@foreach (var button in _buttons)
{
@if (button is TableToolbarButton<TItem> b && b.IsShow)
@if (button is TableToolbarButton<TItem> { IsShow: true } b)
{
<Button AdditionalAttributes="b.AdditionalAttributes" Size="b.Size"
Color="@b.Color" Icon="@b.Icon" Text="@b.Text" IsAsync="@b.IsAsync"
OnClickWithoutRender="() => OnToolbarButtonClick(b)"
TooltipText="@b.TooltipText" TooltipPlacement="@b.TooltipPlacement" TooltipTrigger="@b.TooltipTrigger"
IsDisabled="GetDisabled(b)"></Button>
}
else if (button is TableToolbarPopConfirmButton<TItem> pb && pb.IsShow)
else if (button is TableToolbarPopConfirmButton<TItem> { IsShow: true } pb)
{
<PopConfirmButton AdditionalAttributes="pb.AdditionalAttributes" CustomClass="@pb.CustomClass"
Color="@pb.Color" Icon="@pb.Icon" Text="@pb.Text" Size="pb.Size" ShowShadow="@pb.ShowShadow"
Expand All @@ -31,7 +31,7 @@
CloseButtonText="@pb.CloseButtonText" Content="@pb.Content">
</PopConfirmButton>
}
else if (button is TableToolbarComponent<TItem> cb && cb.IsShow)
else if (button is TableToolbarComponent<TItem> { IsShow: true } cb)
{
<CascadingValue Value="OnGetSelectedRows" IsFixed="true">
@cb.ChildContent
Expand All @@ -48,31 +48,36 @@
<div class="dropdown-menu">
@foreach (var button in _buttons)
{
@if (button is TableToolbarButton<TItem> { IsShow: true } b)
@switch (button)
{
<div class="dropdown-item" @onclick="e => OnToolbarButtonClick(b)">
@if (string.IsNullOrEmpty(b.Icon))
{
<span>@b.Text</span>
}
else
{
<i class="@b.Icon"></i>
}
</div>
}
else if (button is TableToolbarPopConfirmButton<TItem> { IsShow: true } pb)
{
<div class="dropdown-item" @onclick="pb.OnConfirm">
@if (string.IsNullOrEmpty(pb.Icon))
{
<span>@pb.Text</span>
}
else
{
<i class="@pb.Icon"></i>
}
</div>
case TableToolbarButton<TItem> { IsShow: true } b:
{
<DynamicElement class="@GetItemClass(b)" TriggerClick="!GetDisabled(b)" OnClick="() => OnToolbarButtonClick(b)">
@if (string.IsNullOrEmpty(b.Icon))
{
<span>@b.Text</span>
}
else
{
<i class="@b.Icon"></i>
}
</DynamicElement>
break;
}
case TableToolbarPopConfirmButton<TItem> { IsShow: true } pb:
{
<DynamicElement class="@GetItemClass(pb)" TriggerClick="!GetDisabled(pb)" OnClick="pb.OnConfirm">
@if (string.IsNullOrEmpty(pb.Icon))
{
<span>@pb.Text</span>
}
else
{
<i class="@pb.Icon"></i>
}
</DynamicElement>
break;
}
}
}
</div>
Expand Down
4 changes: 4 additions & 0 deletions src/BootstrapBlazor/Components/Table/TableToolbar.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ public partial class TableToolbar<TItem> : ComponentBase
.AddClass("d-none d-sm-inline-flex", IsAutoCollapsedToolbarButton)
.Build();

private string? GetItemClass(ButtonBase button) => CssBuilder.Default("dropdown-item")
.AddClass("disabled", GetDisabled(button))
.Build();

private async Task OnToolbarButtonClick(TableToolbarButton<TItem> button)
{
_asyncButtonStateCache.TryGetValue(button, out var disabled);
Expand Down