Skip to content

Commit

Permalink
feat(ITableColumn): update parameter to Nullable data type (#3802)
Browse files Browse the repository at this point in the history
* refactor: searchable 更改为可为空类型

* fix: 修复使用 AutoGenerateColumnAttribute 值时继承 AutoGenerateClassAttribute 问题

* feat: Filterable 更改为可为空类型

* refactor: 更改 Sortable 为可为空类型

* refactor: 更改可折行配置为可为空类型

* refactor: Ignore/Readonly/Visible 更改为可为空数据类型

* refactor: ShowTips/ShowCopyColumn/Align 更改为可为空数据类型

* refactor: 增加继承 Class 标签值逻辑

* refactor: 优化继承 Class 标签中设置的参数值逻辑

* Revert "refactor: 优化继承 Class 标签中设置的参数值逻辑"

This reverts commit 68d0055.

* test: 更新单元测试

* test: 更新单元测试

* test: 更新单元测试

* fix: 修复注释

* refactor: 更正单词拼写

* chore: bump version 8.7.1

* refactor: 更新 Ignore 逻辑

* refactor: 动态数据移除忽略条件

* refactor: 更改数据类型提高性能

---------

Co-authored-by: Alex chow <zhouchuanglin@gmail.com>
  • Loading branch information
ArgoZhang and densen2014 authored Jul 7, 2024
1 parent bb50e0b commit 8bd79c7
Show file tree
Hide file tree
Showing 25 changed files with 247 additions and 130 deletions.
14 changes: 7 additions & 7 deletions src/BootstrapBlazor.Server/Locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -1270,7 +1270,7 @@
"P17": "3. Add stylesheet file",
"P18": "Add a theme style sheet to the host file",
"P19": "Need to reference BootstrapBlazor.FontAwesome package",
"P20": "4. Add the Javascript file",
"P20": "4. Add the JavaScript file",
"P21": "add code",
"P22": "5. Register the BootstrapBlazor service",
"P23": "6. Add namespace reference",
Expand Down Expand Up @@ -2526,7 +2526,7 @@
"BootstrapBlazor.Server.Components.Samples.Editors": {
"EditorsTitle": "Editor",
"EditorsDescription": "Convert the entered text into <code>html</code> code snippets",
"EditorsTips": "The <code>Editor</code> component is a secondary package of <a href='https://summernote.org/' target='_blank'><code>Summernote component</code></a>, such as If you need to use the localization function, please download the corresponding language pack from the official website and quote it by yourself. <code>zh-CN</code> <code>en-US</code> has been built inthe required <code>css</code> <code>javascript</code> dynamically loaded on demand. If you edit too much content, <code>signalR</code> communication interruption may be triggered. Please adjust the <code>HubOptions</code> configuration.",
"EditorsTips": "The <code>Editor</code> component is a secondary package of <a href='https://summernote.org/' target='_blank'><code>Summernote component</code></a>, such as If you need to use the localization function, please download the corresponding language pack from the official website and quote it by yourself. <code>zh-CN</code> <code>en-US</code> has been built in the required <code>css</code> <code>JavaScript</code> dynamically loaded on demand. If you edit too much content, <code>signalR</code> communication interruption may be triggered. Please adjust the <code>HubOptions</code> configuration.",
"EditorNormalTitle": "Basic usage",
"EditorNormalIntro": "The default rendering is <code>div</code> and it becomes a rich text edit box when clicked",
"EditorNormalDescription": "Set the <code>IsEditor</code> attribute value to control whether the component defaults to <code>div</code> or <code>editor</code>",
Expand Down Expand Up @@ -2817,7 +2817,7 @@
"MarkdownsCss": "CSS file",
"MarkdownsCssText": "dynamic import css",
"MarkdownsJs": "JS file",
"MarkdownsJsText": "dynamic import javascript",
"MarkdownsJsText": "dynamic import JavaScript",
"MarkdownsLocalizationTipsTitle": "Localization",
"MarkdownsLocalizationTips": "The component has a built-in Chinese to switch between current cultural information for Chinese",
"MarkdownsNormalTitle": "Common usage",
Expand Down Expand Up @@ -5558,7 +5558,7 @@
"Features": "Features of Components",
"P6": "The Bootstrap Blazor UI component library provides everything from basic <code>Button</code> components to advanced web-level <code>SmartPage</code> components",
"Advantage": "Advantage",
"AdvantageLi1": "No need to write <code>Javascript</code> to use components",
"AdvantageLi1": "No need to write <code>JavaScript</code> to use components",
"AdvantageLi2": "The component supports all <code>html</code> features",
"AdvantageLi3": "The component supports two-way data binding",
"AdvantageLi4": "Components support automatic client verification",
Expand Down Expand Up @@ -5969,7 +5969,7 @@
"BootstrapBlazor.Server.Components.Samples.DockViews.Index": {
"DockViewTitle": "DockView",
"DockViewDescription": "A multi window layout manager for webapps",
"DockViewIntro": "<p><code>DockView</code> component is wrapped <a href=\"https://github.com/golden-layout/golden-layout?wt.mc_id=DT-MVP-5004174\" target=\"_blank\">Golden Layout</a> lib,it is a <code>Javascript</code> layout manager which enables you to layout components in a web page and re-arrange them with drag and drop. Its features include: </p><ul class=\"ul-demo\"><li>Native popup windows</li><li>Touch support</li><li>Support for application frameworks such as <code>Angular</code> and <code>Vue</code></li><li>Virtual components</li><li>Comprehensive API</li><li>Load and save layouts</li><li>Focus components</li><li>Completely themeable</li><li>Works in modern browsers (<code>Firefox</code>, <code>Chrome</code>)</li><li>Responsive design</li></ul>"
"DockViewIntro": "<p><code>DockView</code> component is wrapped <a href=\"https://github.com/golden-layout/golden-layout?wt.mc_id=DT-MVP-5004174\" target=\"_blank\">Golden Layout</a> lib,it is a <code>JavaScript</code> layout manager which enables you to layout components in a web page and re-arrange them with drag and drop. Its features include: </p><ul class=\"ul-demo\"><li>Native popup windows</li><li>Touch support</li><li>Support for application frameworks such as <code>Angular</code> and <code>Vue</code></li><li>Virtual components</li><li>Comprehensive API</li><li>Load and save layouts</li><li>Focus components</li><li>Completely themeable</li><li>Works in modern browsers (<code>Firefox</code>, <code>Chrome</code>)</li><li>Responsive design</li></ul>"
},
"BootstrapBlazor.Server.Components.Samples.DockViews.DockViewCol": {
"DockViewColTitle": "DockView - Column",
Expand Down Expand Up @@ -6006,7 +6006,7 @@
"BootstrapBlazor.Server.Components.Samples.DockViews2.Index": {
"DockView2Title": "DockViewV2",
"DockView2Description": "A multi window layout manager for webapps",
"DockView2Intro": "<p><code>DockView</code> component is wrapped <a href=\"https://github.com/mathuo/dockview?wt.mc_id=DT-MVP-5004174\" target=\"_blank\">Golden Layout</a> lib,it is a <code>Javascript</code> layout manager which enables you to layout components in a web page and re-arrange them with drag and drop. Its features include: </p><ul class=\"ul-demo\"><li>Native popup windows</li><li>Touch support</li><li>Support for application frameworks such as <code>Angular</code> and <code>Vue</code></li><li>Virtual components</li><li>Comprehensive API</li><li>Load and save layouts</li><li>Focus components</li><li>Completely themeable</li><li>Works in modern browsers (<code>Firefox</code>, <code>Chrome</code>)</li><li>Responsive design</li></ul>"
"DockView2Intro": "<p><code>DockView</code> component is wrapped <a href=\"https://github.com/mathuo/dockview?wt.mc_id=DT-MVP-5004174\" target=\"_blank\">Golden Layout</a> lib,it is a <code>JavaScript</code> layout manager which enables you to layout components in a web page and re-arrange them with drag and drop. Its features include: </p><ul class=\"ul-demo\"><li>Native popup windows</li><li>Touch support</li><li>Support for application frameworks such as <code>Angular</code> and <code>Vue</code></li><li>Virtual components</li><li>Comprehensive API</li><li>Load and save layouts</li><li>Focus components</li><li>Completely themeable</li><li>Works in modern browsers (<code>Firefox</code>, <code>Chrome</code>)</li><li>Responsive design</li></ul>"
},
"BootstrapBlazor.Server.Components.Samples.DockViews2.DockViewCol": {
"DockViewColTitle": "DockViewV2 - Column",
Expand Down Expand Up @@ -6303,7 +6303,7 @@
"BasicIntro": "Basic Use",
"Value": "Gets or sets the value of the input",
"Theme": "Theme of the editor",
"Language": "Language used by the editor: csharp, javascript, ...",
"Language": "Language used by the editor: csharp, JavaScript, ...",
"ValueChanged": "Gets or sets a callback that updates the bound value"
},
"BootstrapBlazor.Server.Components.Samples.JSRuntimeExtensions": {
Expand Down
14 changes: 7 additions & 7 deletions src/BootstrapBlazor.Server/Locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1206,7 +1206,7 @@
"P22": "添加样式表文件",
"P23": "在宿主文件中增加主题样式表",
"P24": "需引用 BootstrapBlazor.FontAwesome 包",
"P25": "添加 Javascript 文件",
"P25": "添加 JavaScript 文件",
"P26": "增加代码",
"P27": "注册 BootstrapBlazor 服务",
"P28": "增加命名空间引用",
Expand Down Expand Up @@ -1270,7 +1270,7 @@
"P17": "3. 添加样式表文件",
"P18": "在宿主文件中增加主题样式表",
"P19": "需引用 BootstrapBlazor.FontAwesome 包",
"P20": "4. 添加 Javascript 文件",
"P20": "4. 添加 JavaScript 文件",
"P21": "增加代码",
"P22": "5. 注册 BootstrapBlazor 服务",
"P23": "6. 增加命名空间引用",
Expand Down Expand Up @@ -2526,7 +2526,7 @@
"BootstrapBlazor.Server.Components.Samples.Editors": {
"EditorsTitle": "Editor 富文本框",
"EditorsDescription": "将输入的文字转化为 <code>html</code> 代码片段",
"EditorsTips": "<code>Editor</code> 组件是对 <a href='https://summernote.org/' target='_blank'><code>Summernote 组件</code></a> 的二次封装,如需使用本地化功能请自行官网下载相对应语言包,自行引用即可,<code>zh-CN</code> <code>en-US</code> 已内置;组件所需 <code>css</code> <code>javascript</code> 均按需动态加载,使用者无需设置。由于 <code>summernote</code> 组件依赖 <b>jQuery</b>,所以需要自行引用 <code>jQuery</code> 脚本包。如果编辑内容过多,可能会触发 <code>signalR</code> 通讯中断问题,请自行调整 <code>HubOptions</code> 配置即可。",
"EditorsTips": "<code>Editor</code> 组件是对 <a href='https://summernote.org/' target='_blank'><code>Summernote 组件</code></a> 的二次封装,如需使用本地化功能请自行官网下载相对应语言包,自行引用即可,<code>zh-CN</code> <code>en-US</code> 已内置;组件所需 <code>css</code> <code>JavaScript</code> 均按需动态加载,使用者无需设置。由于 <code>summernote</code> 组件依赖 <b>jQuery</b>,所以需要自行引用 <code>jQuery</code> 脚本包。如果编辑内容过多,可能会触发 <code>signalR</code> 通讯中断问题,请自行调整 <code>HubOptions</code> 配置即可。",
"EditorNormalTitle": "基础用法",
"EditorNormalIntro": "默认呈现为 <code>div</code> 点击后变为富文本编辑框",
"EditorNormalDescription": "通过设置 <code>IsEditor</code> 属性值来控制组件默认是 <code>div</code> 还是 <code>editor</code>",
Expand Down Expand Up @@ -5558,7 +5558,7 @@
"Features": "组件特色",
"P6": "Bootstrap Blazor UI 组件库提供了从基本的 <code>Button</code> 组件到高级的网页级 <code>SmartPage</code> 组件",
"Advantage": "优势",
"AdvantageLi1": "使用组件无需编写 <code>Javascript</code>",
"AdvantageLi1": "使用组件无需编写 <code>JavaScript</code>",
"AdvantageLi2": "组件支持所有 <code>html</code> 特性",
"AdvantageLi3": "组件支持数据双向绑定",
"AdvantageLi4": "组件支持自动客户端验证",
Expand Down Expand Up @@ -5969,7 +5969,7 @@
"BootstrapBlazor.Server.Components.Samples.DockViews.Index": {
"DockViewTitle": "DockView 可停靠视图",
"DockViewDescription": "多标签停靠布局管理器",
"DockViewIntro": "<p><code>DockView</code> 组件是封装的 <a href=\"https://github.com/golden-layout/golden-layout?wt.mc_id=DT-MVP-5004174\" target=\"_blank\">Golden Layout</a> 库,它是一个 <code>Javascript</code> 布局管理器,它使您能够在网页中布局组件并通过拖放重新排列它们。其特点包括:</p><ul class=\"ul-demo\"><li>原生弹出窗口</li><li>触摸支持</li><li>支持 <code>Angular</code>、<code>Vue</code> 等应用框架</li><li>虚拟组件</li><li>全面的API</li><li>加载和保存布局</li><li>焦点组件</li><li>完全主题化</li><li>适用于现代浏览器(<code>Firefox</code>、<code>Chrome</code>)</li><li>响应式设计</li></ul>"
"DockViewIntro": "<p><code>DockView</code> 组件是封装的 <a href=\"https://github.com/golden-layout/golden-layout?wt.mc_id=DT-MVP-5004174\" target=\"_blank\">Golden Layout</a> 库,它是一个 <code>JavaScript</code> 布局管理器,它使您能够在网页中布局组件并通过拖放重新排列它们。其特点包括:</p><ul class=\"ul-demo\"><li>原生弹出窗口</li><li>触摸支持</li><li>支持 <code>Angular</code>、<code>Vue</code> 等应用框架</li><li>虚拟组件</li><li>全面的API</li><li>加载和保存布局</li><li>焦点组件</li><li>完全主题化</li><li>适用于现代浏览器(<code>Firefox</code>、<code>Chrome</code>)</li><li>响应式设计</li></ul>"
},
"BootstrapBlazor.Server.Components.Samples.DockViews.DockViewCol": {
"DockViewColTitle": "DockView 列布局",
Expand Down Expand Up @@ -6006,7 +6006,7 @@
"BootstrapBlazor.Server.Components.Samples.DockViews2.Index": {
"DockView2Title": "DockViewV2 可停靠视图",
"DockView2Description": "多标签停靠布局管理器",
"DockView2Intro": "<p><code>DockView</code> 组件是封装的 <a href=\"https://github.com/mathuo/dockview?wt.mc_id=DT-MVP-5004174\" target=\"_blank\">DockView</a> 库,它是一个 <code>Javascript</code> 布局管理器,它使您能够在网页中布局组件并通过拖放重新排列它们。其特点包括:</p><ul class=\"ul-demo\"><li>原生弹出窗口</li><li>触摸支持</li><li>支持 <code>Angular</code>、<code>Vue</code> 等应用框架</li><li>虚拟组件</li><li>全面的API</li><li>加载和保存布局</li><li>焦点组件</li><li>完全主题化</li><li>适用于现代浏览器(<code>Firefox</code>、<code>Chrome</code>)</li><li>响应式设计</li></ul>"
"DockView2Intro": "<p><code>DockView</code> 组件是封装的 <a href=\"https://github.com/mathuo/dockview?wt.mc_id=DT-MVP-5004174\" target=\"_blank\">DockView</a> 库,它是一个 <code>JavaScript</code> 布局管理器,它使您能够在网页中布局组件并通过拖放重新排列它们。其特点包括:</p><ul class=\"ul-demo\"><li>原生弹出窗口</li><li>触摸支持</li><li>支持 <code>Angular</code>、<code>Vue</code> 等应用框架</li><li>虚拟组件</li><li>全面的API</li><li>加载和保存布局</li><li>焦点组件</li><li>完全主题化</li><li>适用于现代浏览器(<code>Firefox</code>、<code>Chrome</code>)</li><li>响应式设计</li></ul>"
},
"BootstrapBlazor.Server.Components.Samples.DockViews2.DockViewCol": {
"DockViewColTitle": "DockViewV2 列布局",
Expand Down Expand Up @@ -6303,7 +6303,7 @@
"BasicIntro": "基础用法",
"Value": "获得或设置 Value",
"Theme": "编辑器的主题",
"Language": "编辑器使用的语言:csharp,javascript,...",
"Language": "编辑器使用的语言:csharp,JavaScript,...",
"ValueChanged": "获取或设置更新绑定值的回调"
},
"BootstrapBlazor.Server.Components.Samples.JSRuntimeExtensions": {
Expand Down
57 changes: 56 additions & 1 deletion src/BootstrapBlazor/Attributes/AutoGenerateColumnAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,68 @@ public class AutoGenerateColumnAttribute : AutoGenerateBaseAttribute, ITableColu
/// </summary>
Func<object?, Task<string?>>? ITableColumn.GetTooltipTextCallback { get; set; }

/// <summary>
/// <inheritdoc/>
/// </summary>
bool? ITableColumn.Searchable { get => Searchable; set => Searchable = value ?? false; }

/// <summary>
/// <inheritdoc/>
/// </summary>
bool? ITableColumn.Filterable { get => Filterable; set => Filterable = value ?? false; }

/// <summary>
/// <inheritdoc/>
/// </summary>
bool? ITableColumn.Sortable { get => Sortable; set => Sortable = value ?? false; }

/// <summary>
/// <inheritdoc/>
/// </summary>
bool? ITableColumn.TextWrap { get => TextWrap; set => TextWrap = value ?? false; }

/// <summary>
/// <inheritdoc/>
/// </summary>
bool? ITableColumn.TextEllipsis { get => TextEllipsis; set => TextEllipsis = value ?? false; }

/// <summary>
/// <inheritdoc/>
/// </summary>
bool? IEditorItem.Ignore { get => Ignore; set => Ignore = value ?? false; }

/// <summary>
/// <inheritdoc/>
/// </summary>
bool? IEditorItem.Readonly { get => Readonly; set => Readonly = value ?? false; }

/// <summary>
/// <inheritdoc/>
/// </summary>
bool? ITableColumn.Visible { get => Visible; set => Visible = value ?? true; }

/// <summary>
/// <inheritdoc/>
/// </summary>
bool? ITableColumn.ShowTips { get => ShowTips; set => ShowTips = value ?? false; }

/// <summary>
/// <inheritdoc/>
/// </summary>
bool? ITableColumn.ShowCopyColumn { get => ShowCopyColumn; set => ShowCopyColumn = value ?? false; }

/// <summary>
/// <inheritdoc/>
/// </summary>
Alignment? ITableColumn.Align { get => Align; set => Align = value ?? Alignment.None; }

/// <summary>
/// <inheritdoc/>
/// </summary>
public string? Step { get; set; }

/// <summary>
/// 获得/设置 Textarea 行数
/// 获得/设置 行数
/// </summary>
public int Rows { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/BootstrapBlazor.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<Version>8.7.1-beta08</Version>
<Version>8.7.1</Version>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
Expand Down
6 changes: 3 additions & 3 deletions src/BootstrapBlazor/Components/EditorForm/EditorForm.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ private void ResetItems()
_formItems = [];
if (Items != null)
{
_formItems.AddRange(Items.Where(i => !i.Ignore));
_formItems.AddRange(Items.Where(i => !i.GetIgnore()));
}
else
{
Expand All @@ -268,7 +268,7 @@ private void ResetItems()
if (item != null)
{
// 过滤掉不编辑与不可见的列
if (el.Ignore || !el.IsVisible(ItemChangedType, IsSearch.Value))
if (el.GetIgnore() || !el.IsVisible(ItemChangedType, IsSearch.Value))
{
items.Remove(item);
}
Expand All @@ -283,7 +283,7 @@ private void ResetItems()
}
else
{
_formItems.AddRange(_editorItems.Where(i => !i.Ignore && i.IsVisible(ItemChangedType, IsSearch.Value)));
_formItems.AddRange(_editorItems.Where(i => !i.GetIgnore() && i.IsVisible(ItemChangedType, IsSearch.Value)));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/BootstrapBlazor/Components/EditorForm/EditorItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ public class EditorItem<TValue> : ComponentBase, IEditorItem
/// <inheritdoc/>>
/// </summary>
[Parameter]
public bool Ignore { get; set; }
public bool? Ignore { get; set; }

/// <summary>
/// <inheritdoc/>>
/// </summary>
[Parameter]
public bool Readonly { get; set; }
public bool? Readonly { get; set; }

/// <summary>
/// 获得/设置 是否不进行验证 默认为 false
Expand Down
4 changes: 2 additions & 2 deletions src/BootstrapBlazor/Components/EditorForm/IEditorItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ public interface IEditorItem
/// <summary>
/// 获得/设置 当前编辑项是否只读 默认为 false
/// </summary>
bool Readonly { get; set; }
bool? Readonly { get; set; }

/// <summary>
/// 获得/设置 当前编辑项是否忽略 默认为 false 当设置为 true 时 UI 不生成此列
/// </summary>
bool Ignore { get; set; }
bool? Ignore { get; set; }

/// <summary>
/// 获得/设置 是否不进行验证 默认为 false
Expand Down
Loading

0 comments on commit 8bd79c7

Please sign in to comment.