Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(SelectTable): add SelectTable component #2775

Merged
merged 46 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
d93596d
feat: 增加 TableSelect 组件
ArgoZhang May 25, 2022
708ca36
doc: 增加 TableSelect 示例
ArgoZhang May 25, 2022
b24cff2
Merge branch 'main' into dev-table-select
ArgoZhang Aug 16, 2022
db46a28
Merge branch 'main' into dev-table-select
ArgoZhang Sep 6, 2022
d4ec1b4
Merge branch 'main' into dev-table-select
ArgoZhang Sep 23, 2022
e32f21d
Merge branch 'main' into dev-table-select
ArgoZhang Jan 9, 2024
d0745f9
refactor: 更新组件
ArgoZhang Jan 9, 2024
b1b1e70
chore: 更新路由以及映射文件
ArgoZhang Jan 9, 2024
47443f8
chore: 更新组件名
ArgoZhang Jan 9, 2024
abe29d6
doc: 增加菜单
ArgoZhang Jan 9, 2024
7ae641a
doc: 更新示例
ArgoZhang Jan 9, 2024
0ca6452
doc: 更新 Url
ArgoZhang Jan 9, 2024
b9d572f
Merge branch 'main' into dev-table-select
ArgoZhang Jan 9, 2024
67765a7
wip: 临时提交
ArgoZhang Jan 10, 2024
ed9bb8c
feat(Calendar): add OnValueChanged callback (#2780)
ArgoZhang Jan 10, 2024
8d3061d
feat(Table): support pagination on dynamic context mode (#2782)
ArgoZhang Jan 10, 2024
28367ed
Merge branch 'main' into dev-table-select
ArgoZhang Jan 11, 2024
ec53ade
Merge branch 'main' into dev-table-select
ArgoZhang Jan 11, 2024
8a7b39c
Merge branch 'main' into dev-table-select
ArgoZhang Jan 13, 2024
5999553
Merge branch 'main' into dev-table-select
ArgoZhang Jan 14, 2024
916409f
Merge branch 'main' into dev-table-select
ArgoZhang Jan 18, 2024
ce3e992
refactor: 更新样式
ArgoZhang Jan 18, 2024
1eec952
refactor: 增加 form-control 样式
ArgoZhang Jan 18, 2024
4196918
feat: 增加 IsPopover 支持
ArgoZhang Jan 18, 2024
a702195
feat: 增加 initCallback 回调方法
ArgoZhang Jan 19, 2024
d550804
feat: 增加固定表头高度自定计算功能
ArgoZhang Jan 19, 2024
5fe7f48
feat: 增加选中行关闭弹窗功能
ArgoZhang Jan 19, 2024
a481371
Merge branch 'main' into dev-table-select
ArgoZhang Jan 19, 2024
59cc4d7
Revert "refactor: 更新样式"
ArgoZhang Jan 19, 2024
5e181cb
feat: 增加 ValueTemplate 模板
ArgoZhang Jan 19, 2024
20ef086
doc: 更新 ValueTemplate 示例
ArgoZhang Jan 19, 2024
1207ade
refactor: 更改 ValueTemplate 为 Template
ArgoZhang Jan 19, 2024
60a5825
doc: 增加 Color 示例
ArgoZhang Jan 19, 2024
a929e02
feat: 增加禁用样式
ArgoZhang Jan 19, 2024
b7fd6b9
doc: 增加禁用示例
ArgoZhang Jan 19, 2024
5d6f4ca
test: 增加单元测试
ArgoZhang Jan 19, 2024
b6f65d3
refactor: 增加箭头支持主题
ArgoZhang Jan 19, 2024
b7ab3fe
test: 增加单元测试
ArgoZhang Jan 19, 2024
ec09d5c
test: 更新单元测试
ArgoZhang Jan 19, 2024
606b31e
test: 增加单元测试
ArgoZhang Jan 19, 2024
8224f22
refactor: 更新 IsRequired 方法可重写
ArgoZhang Jan 19, 2024
16fb7ac
feat: 增加验证支持
ArgoZhang Jan 19, 2024
38f0e1e
doc: 更新表单示例
ArgoZhang Jan 19, 2024
05fa845
test: 增加验证单元测试
ArgoZhang Jan 19, 2024
c6f46d4
doc: 更新资源文件
ArgoZhang Jan 19, 2024
7f5b1f6
chore: 删除 Settings 类
ArgoZhang Jan 19, 2024
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
79 changes: 79 additions & 0 deletions src/BootstrapBlazor.Server/Components/Samples/SelectTables.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
@page "/select-table"

<h3>TableSelect 表格选择器</h3>

<h4>下拉框为表格用于展示复杂类型的选择需求</h4>

<DemoBlock Title="@Localizer["NormalTitle"]" Introduction="@Localizer["NormalIntro"]" Name="Normal">
<SelectTable TItem="Foo" @bind-Value="@_foo" Items="_items" GetTextCallback="@GetTextCallback">
<TableColumns>
<TableColumn @bind-Field="@context.Name"></TableColumn>
<TableColumn @bind-Field="@context.Address"></TableColumn>
</TableColumns>
</SelectTable>
</DemoBlock>

<DemoBlock Title="@Localizer["ColorTitle"]" Introduction="@Localizer["ColorIntro"]" Name="Color">
<SelectTable TItem="Foo" @bind-Value="@_colorFoo" Items="_colorItems" GetTextCallback="@GetTextCallback" Color="Color.Danger">
<TableColumns>
<TableColumn @bind-Field="@context.Name"></TableColumn>
<TableColumn @bind-Field="@context.Address"></TableColumn>
</TableColumns>
</SelectTable>
</DemoBlock>

<DemoBlock Title="@Localizer["IsDisabledTitle"]" Introduction="@Localizer["IsDisabledIntro"]" Name="IsDisabled">
<SelectTable TItem="Foo" @bind-Value="@_disabledFoo" Items="_disabledItems" GetTextCallback="@GetTextCallback" IsDisabled="true">
<TableColumns>
<TableColumn @bind-Field="@context.Name"></TableColumn>
<TableColumn @bind-Field="@context.Address"></TableColumn>
</TableColumns>
</SelectTable>
</DemoBlock>

<DemoBlock Title="@Localizer["TemplateTitle"]" Introduction="@Localizer["TemplateIntro"]" Name="ValueTemplate">
<SelectTable TItem="Foo" @bind-Value="@_templateFoo" Items="_templateItems" ShowAppendArrow="false">
<TableColumns>
<TableColumn @bind-Field="@context.Name"></TableColumn>
<TableColumn @bind-Field="@context.Address"></TableColumn>
</TableColumns>
<Template>
<div class="dropdown-item-demo">
<div class="select-custom-header">
<div class="id">@context.Id</div>
<div class="name">@context.Name</div>
<Light Color="@(context.Complete ? Color.Success : Color.Warning)"></Light>
</div>
<Divider />
<div class="select-custom-body">
<img src="@Foo.GetAvatarUrl(context.Id)" class="bb-avatar" />
<div class="select-custom-detail">
<div class="d-flex">
<div class="flex-fill">
<div>@Foo.GetTitle(context.Id)</div>
<div class="mt-3">@context.Address</div>
</div>
<div>
<Circle Width="80" Value="@context.Count" Color="Color.Info" StrokeWidth="3" />
</div>
</div>
<BootstrapBlazor.Components.Progress Value="@context.Count"></BootstrapBlazor.Components.Progress>
</div>
</div>
</div>
</Template>
</SelectTable>
</DemoBlock>

<DemoBlock Title="@Localizer["ValidateFormTitle"]" Introduction="@Localizer["ValidateFormIntro"]" Name="ValidateForm">
<ValidateForm Model="Model">
<SelectTable TItem="Foo" @bind-Value="@_validateFormFoo" Items="_validateFormItems" GetTextCallback="@GetTextCallback" DisplayText="Test">
<TableColumns>
<TableColumn @bind-Field="@context.Name"></TableColumn>
<TableColumn @bind-Field="@context.Address"></TableColumn>
</TableColumns>
</SelectTable>
</ValidateForm>
</DemoBlock>

<AttributeTable Items="@GetAttributes()" />
135 changes: 135 additions & 0 deletions src/BootstrapBlazor.Server/Components/Samples/SelectTables.razor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/

namespace BootstrapBlazor.Server.Components.Samples;

/// <summary>
/// 可选择表格组件示例
/// </summary>
public partial class SelectTables
{
[Inject]
[NotNull]
private IStringLocalizer<Foo>? LocalizerFoo { get; set; }

[Inject]
[NotNull]
private IStringLocalizer<SelectTables>? Localizer { get; set; }

private List<Foo> _items = default!;

private List<Foo> _colorItems = default!;

private List<Foo> _templateItems = default!;

private List<Foo> _disabledItems = default!;

private List<Foo> _validateFormItems = default!;

private Foo? _foo;

private Foo? _colorFoo;

private Foo? _templateFoo;

private Foo? _disabledFoo;

private Foo? _validateFormFoo;

private Foo Model = new();

/// <summary>
///
/// </summary>
protected override void OnInitialized()
{
_items = Foo.GenerateFoo(LocalizerFoo);
_colorItems = Foo.GenerateFoo(LocalizerFoo);
_templateItems = Foo.GenerateFoo(LocalizerFoo);
_disabledItems = Foo.GenerateFoo(LocalizerFoo);
_validateFormItems = Foo.GenerateFoo(LocalizerFoo);
}

private static string? GetTextCallback(Foo? foo) => foo?.Name;

/// <summary>
/// 获得属性方法
/// </summary>
/// <returns></returns>
private AttributeItem[] GetAttributes() =>
[
new()
{
Name = "Items",
Description = Localizer["AttributeItems"],
Type = "IEnumerable<TItem>",
ValueList = " — ",
DefaultValue = " — "
},
new()
{
Name = "TableColumns",
Description = Localizer["AttributeTableColumns"],
Type = "RenderFragment<TItem>",
ValueList = " — ",
DefaultValue = " — "
},
new()
{
Name = "Color",
Description = Localizer["AttributeColor"],
Type = "Color",
ValueList = "Primary / Secondary / Success / Danger / Warning / Info / Dark",
DefaultValue = "Primary"
},
new()
{
Name = "IsDisabled",
Description = Localizer["AttributeIsDisabled"],
Type = "boolean",
ValueList = "true / false",
DefaultValue = "false"
},
new()
{
Name = "ShowAppendArrow",
Description = Localizer["AttributeShowAppendArrow"],
Type = "bool",
ValueList = "true|false",
DefaultValue = "true"
},
new()
{
Name = "GetTextCallback",
Description = Localizer["AttributeGetTextCallback"],
Type = "Func<TItem, string>",
ValueList = " — ",
DefaultValue = " — "
},
new()
{
Name = "PlaceHolder",
Description = Localizer["AttributePlaceHolder"],
Type = "string?",
ValueList = " — ",
DefaultValue = " — "
},
new()
{
Name = "Height",
Description = Localizer["AttributeHeight"],
Type = "int",
ValueList = " — ",
DefaultValue = "486"
},
new()
{
Name = "Template",
Description = Localizer["AttributeTemplate"],
Type = "RenderFragment<TItem>",
ValueList = " — ",
DefaultValue = " — "
}
];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
::deep .divider {
--bb-divider-margin: 1rem 0;
--bb-divider-bg: #c0c4cc;
}

::deep .dropdown-item-demo {
border-radius: var(--bs-border-radius);
border: var(--bs-border-width) solid var(--bs-border-color);
padding: .5rem;
flex-direction: column;
}

::deep .select-custom-header {
display: flex;
align-items: center;
margin-top: .5rem;
}

::deep .select-custom-header .id {
background-color: var(--bs-success);
padding: .25rem .5rem;
border-radius: var(--bs-border-radius);
}

::deep .select-custom-header .name {
padding: .25rem .5rem;
margin: 0 1rem;
flex: 1;
font-weight: bold;
}

::deep .select-custom-header .status {
}

::deep .select-custom-body {
display: flex;
}

::deep .select-custom-body .progress {
height: 6px;
margin-bottom: .5rem;
}

::deep .select-custom-body .bb-avatar {
width: 102px;
border: 2px solid var(--bs-info);
}

::deep .select-custom-detail {
flex: 1;
margin-left: 2rem;
}

::deep .select-custom-detail > div {
margin-bottom: .5rem;
}
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,12 @@ void AddForm(DemoMenuItem item)
Url = "select"
},
new()
{
IsNew = true,
Text = Localizer["SelectTable"],
Url = "select-table"
},
new()
{
Text = Localizer["SelectTree"],
Url = "select-tree"
Expand Down
22 changes: 22 additions & 0 deletions src/BootstrapBlazor.Server/Locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -4407,6 +4407,7 @@
"Radio": "Radio",
"Rate": "Rate",
"Select": "Select",
"SelectTable": "Select-Table",
"SelectTree": "Select-Tree",
"Slider": "Slider",
"Switch": "Switch",
Expand Down Expand Up @@ -6139,5 +6140,26 @@
"Show": "Show",
"ToolboxCardTitle": "Tools",
"Translate": "Translate"
},
"BootstrapBlazor.Server.Components.Samples.SelectTables": {
"NormalTitle": "Basic usage",
"NormalIntro": "Suitable for candidates with a relatively large amount of information, presenting information using <code>Table</code>",
"ColorTitle": "Color",
"ColorIntro": "Change component border color by setting <code>Color</code>",
"IsDisabledTitle": "Disabled",
"IsDisabledIntro": "When you set the <code>IsDisabled</code> property value to <code>true</code>, the component suppresses select",
"TemplateTitle": "Value Template",
"TemplateIntro": "Present customized display content by customizing the <code>Template</code>",
"AttributeItems": "Data source table display content set",
"AttributeTableColumns": "Table Display Column Set",
"AttributeColor": "Color",
"AttributeIsDisabled": "Is it disabled",
"AttributeShowAppendArrow": "Is the right extended small arrow displayed",
"AttributeGetTextCallback": "Get display value callback method",
"AttributePlaceHolder": "Placeholder",
"AttributeHeight": "Table height",
"AttributeTemplate": "Display Template",
"ValidateFormTitle": "ValidateForm",
"ValidateFormIntro": "Intercept data when the value is empty"
}
}
22 changes: 22 additions & 0 deletions src/BootstrapBlazor.Server/Locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -4407,6 +4407,7 @@
"Radio": "单选框 Radio",
"Rate": "评分 Rate",
"Select": "选择器 Select",
"SelectTable": "表格选择器 SelectTable",
"SelectTree": "树状选择器 SelectTree",
"Slider": "滑块 Slider",
"Switch": "开关 Switch",
Expand Down Expand Up @@ -6139,5 +6140,26 @@
"Show": "显示",
"ToolboxCardTitle": "工具栏",
"Translate": "机翻"
},
"BootstrapBlazor.Server.Components.Samples.SelectTables": {
"NormalTitle": "基本功能",
"NormalIntro": "适用于候选项信息量比较大,用 <code>Table</code> 呈现信息量",
"ColorTitle": "颜色",
"ColorIntro": "通过设置 <code>Color</code> 改变组件边框颜色",
"IsDisabledTitle": "禁用",
"IsDisabledIntro": "设置 <code>IsDisabled</code> 属性值为 <code>true</code> 时,组件禁止选择",
"TemplateTitle": "显示模板",
"TemplateIntro": "通过自定义 <code>Template</code> 模板,呈现定制化显示内容",
"AttributeItems": "数据源表格显示内容集合",
"AttributeTableColumns": "设置表格显示列集合",
"AttributeColor": "颜色",
"AttributeIsDisabled": "是否禁用",
"AttributeShowAppendArrow": "是否显示右侧扩展小箭头",
"AttributeGetTextCallback": "获得显示值回调方法",
"AttributePlaceHolder": "占位符",
"AttributeHeight": "表格高度",
"AttributeTemplate": "显示模板",
"ValidateFormTitle": "客户端验证",
"ValidateFormIntro": "下拉框未选择时,点击提交按钮时拦截。"
}
}
1 change: 1 addition & 0 deletions src/BootstrapBlazor.Server/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
"search": "Searches",
"select": "Selects",
"select-tree": "SelectTrees",
"select-table": "SelectTables",
"segmented": "Segmenteds",
"slider": "Sliders",
"slide-button": "SlideButtons",
Expand Down
Loading
Loading