Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 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
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
<div style="height: 600px;">
<Table TItem="Foo"
IsPagination="true" PageItemsSource="new int[] {10, 20}"
IsStriped="true" IsBordered="true"
ShowToolbar="true" ShowSearch="true" IsMultipleSelect="true" ShowExtendButtons="true"
IsStriped="true" IsBordered="true" ShowMoreButton="true"
ShowToolbar="true" ShowSearch="true" ShowCardView="true" IsMultipleSelect="true" ShowExtendButtons="true"
AddModalTitle="@Localizer["AddModelTitle"]" EditModalTitle="@Localizer["EditModelTitle"]"
SearchModel="@SearchModel" SearchMode="SearchMode.Top" ShowEmpty="true"
OnQueryAsync="@OnSearchModelQueryAsync" OnResetSearchAsync="@OnResetSearchAsync"
Expand All @@ -49,6 +49,11 @@
</div>
</GroupBox>
</SearchTemplate>
<MoreButtonDropdownTemplate>
<DropdownItem Text="Copy" Icon="fa-solid fa-copy" OnClick="@(() => OnAction(context, "Copy"))"></DropdownItem>
<DropdownDivider></DropdownDivider>
<DropdownItem Text="Paste" Icon="fa-solid fa-paste" OnClick="@(() => OnAction(context, "Paste"))"></DropdownItem>
</MoreButtonDropdownTemplate>
</Table>
</div>
</DemoBlock>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ private Task<QueryData<Foo>> OnSearchModelQueryAsync(QueryPageOptions options)
Items = items,
TotalCount = total,
IsSorted = true,
IsFiltered = options.Filters.Any(),
IsSearch = options.Searches.Any(),
IsAdvanceSearch = options.AdvanceSearches.Any()
IsFiltered = options.Filters.Count != 0,
IsSearch = options.Searches.Count != 0,
IsAdvanceSearch = options.AdvanceSearches.Count != 0
});
}

Expand Down Expand Up @@ -183,4 +183,9 @@ private Task<QueryData<Foo>> OnQueryAsync(QueryPageOptions options)
IsAdvanceSearch = options.CustomerSearches.Count > 0 && string.IsNullOrEmpty(options.SearchText),
});
}

[Inject, NotNull]
private ToastService? ToastService { get; set; }

private Task OnAction(Foo foo, string actionName) => ToastService.Information("MoreButtonTemplate Action", $"Trigger {actionName}");
}
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/Components/Dropdown/Dropdown.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@namespace BootstrapBlazor.Components
@namespace BootstrapBlazor.Components

Check failure on line 1 in src/BootstrapBlazor/Components/Dropdown/Dropdown.razor

View workflow job for this annotation

GitHub Actions / run test

The 'namespace' directive must appear at the start of the line.
@typeparam TValue
@inherits PopoverSelectBase<TValue>
@attribute [BootstrapModuleAutoLoader("Dropdown/Dropdown.razor.js", JSObjectReference = true)]
Expand Down
19 changes: 19 additions & 0 deletions src/BootstrapBlazor/Components/Table/Table.razor
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,10 @@
@RowButtonTemplate.Invoke(item)
</TableExtensionButton>
}
@if (ShowMoreButton)
{
@RenderMoreButton(item)
}
</div>
</div>;

Expand Down Expand Up @@ -942,10 +946,25 @@
@RowButtonTemplate?.Invoke(item)
</TableExtensionButton>
}
@if (ShowMoreButton)
{
@RenderMoreButton(item)
}
</div>
</div>
</td>;

RenderFragment<TItem> RenderMoreButton => item =>
@<Dropdown TValue="string" Color="Color.Secondary" IsFixedButtonText="true" FixedButtonText="更多"
Size="Size.ExtraSmall" IsPopover="true" Icon="@MoreButtonIcon">
<ItemsTemplate>
@if (MoreButtonDropdownTemplate != null)
{
@MoreButtonDropdownTemplate(item)
}
</ItemsTemplate>
</Dropdown>;

RenderFragment RenderSearch =>
@<Card IsCollapsible="true" HeaderText="@SearchModalTitle" Collapsed="CollapsedTopSearch">
<HeaderTemplate>
Expand Down
14 changes: 13 additions & 1 deletion src/BootstrapBlazor/Components/Table/Table.razor.Edit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,18 @@ public partial class Table<TItem>
[Parameter]
public RenderFragment<TItem>? RowButtonTemplate { get; set; }

/// <summary>
/// 获得/设置 是否显示 行内更多按钮 默认 false 不显示
/// </summary>
[Parameter]
public bool ShowMoreButton { get; set; }

/// <summary>
/// 获得/设置 行内更多按钮下拉框模板 默认 null
/// </summary>
[Parameter]
public RenderFragment<TItem>? MoreButtonDropdownTemplate { get; set; }

/// <summary>
/// 获得/设置 行内功能按钮列头文本 默认为 操作
/// </summary>
Expand Down Expand Up @@ -302,7 +314,7 @@ private async Task InternalOnAddAsync()

private TItem CreateTItem() => CreateItemCallback?.Invoke() ?? CreateInstance();

private readonly string ErrorMessage = $"{typeof(TItem)} create instrance failed. Please provide {nameof(CreateItemCallback)} create the {typeof(TItem)} instance. {typeof(TItem)} 自动创建实例失败,请通过 {nameof(CreateItemCallback)} 回调方法手动创建实例";
private readonly string ErrorMessage = $"{typeof(TItem)} create instance failed. Please provide {nameof(CreateItemCallback)} create the {typeof(TItem)} instance. {typeof(TItem)} 自动创建实例失败,请通过 {nameof(CreateItemCallback)} 回调方法手动创建实例";

private TItem CreateInstance()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ public partial class Table<TItem>
[Parameter]
public string? EditButtonIcon { get; set; }

/// <summary>
/// 获得/设置 更多按钮图标
/// </summary>
[Parameter]
public string? MoreButtonIcon { get; set; }

/// <summary>
/// 获得/设置 更新按钮文本
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions src/BootstrapBlazor/Components/Table/Table.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,7 @@ private void OnInitParameters()
AddButtonIcon ??= IconTheme.GetIconByKey(ComponentIcons.TableAddButtonIcon);
EditButtonIcon ??= IconTheme.GetIconByKey(ComponentIcons.TableEditButtonIcon);
DeleteButtonIcon ??= IconTheme.GetIconByKey(ComponentIcons.TableDeleteButtonIcon);
MoreButtonIcon ??= IconTheme.GetIconByKey(ComponentIcons.TableMoreButtonIcon);
RefreshButtonIcon ??= IconTheme.GetIconByKey(ComponentIcons.TableRefreshButtonIcon);
CardViewButtonIcon ??= IconTheme.GetIconByKey(ComponentIcons.TableCardViewButtonIcon);
ColumnListButtonIcon ??= IconTheme.GetIconByKey(ComponentIcons.TableColumnListButtonIcon);
Expand Down
5 changes: 5 additions & 0 deletions src/BootstrapBlazor/Enums/ComponentIcons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,11 @@ public enum ComponentIcons
/// </summary>
TableEditButtonIcon,

/// <summary>
/// Table 组件 MoreButtonIcon 属性图标
/// </summary>
TableMoreButtonIcon,

/// <summary>
/// Table 组件 DeleteButtonIcon 属性图标
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions src/BootstrapBlazor/Icons/BootstrapIcons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ internal static class BootstrapIcons

{ ComponentIcons.TableAddButtonIcon, "bi bi-plus" },
{ ComponentIcons.TableEditButtonIcon, "bi bi-check2-square" },
{ ComponentIcons.TableMoreButtonIcon, "bi bi-three-dots" },
{ ComponentIcons.TableDeleteButtonIcon, "bi bi-x" },
{ ComponentIcons.TableRefreshButtonIcon, "bi bi-arrow-clockwise" },
{ ComponentIcons.TableCardViewButtonIcon, "bi bi-list" },
Expand Down
1 change: 1 addition & 0 deletions src/BootstrapBlazor/Icons/FontAwesomeIcons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ internal static class FontAwesomeIcons

{ ComponentIcons.TableAddButtonIcon, "fa-solid fa-plus" },
{ ComponentIcons.TableEditButtonIcon, "fa-regular fa-pen-to-square" },
{ ComponentIcons.TableMoreButtonIcon, "fa-solid fa-ellipsis" },
{ ComponentIcons.TableDeleteButtonIcon, "fa-solid fa-xmark" },
{ ComponentIcons.TableRefreshButtonIcon, "fa-solid fa-arrows-rotate" },
{ ComponentIcons.TableCardViewButtonIcon, "fa-solid fa-bars" },
Expand Down
1 change: 1 addition & 0 deletions src/BootstrapBlazor/Icons/MaterialDesignIcons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ internal static class MaterialDesignIcons

{ ComponentIcons.TableAddButtonIcon, "mdi mdi-plus" },
{ ComponentIcons.TableEditButtonIcon, "mdi mdi-file-edit-outline" },
{ ComponentIcons.TableMoreButtonIcon, "mdi mdi-dots-horizontal" },
{ ComponentIcons.TableDeleteButtonIcon, "mdi mdi-close" },
{ ComponentIcons.TableRefreshButtonIcon, "mdi mdi-refresh" },
{ ComponentIcons.TableCardViewButtonIcon, "mdi mdi-menu" },
Expand Down
Loading