From 0e6d6463b01c25b78621d0ab4387c017aaf74e61 Mon Sep 17 00:00:00 2001 From: Argo-AscioTech Date: Mon, 19 Feb 2024 15:37:04 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=20AddMultipleAttribu?= =?UTF-8?q?tes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Attributes/AutoGenerateColumnAttribute.cs | 2 +- src/BootstrapBlazor/Components/EditorForm/EditorItem.cs | 2 +- src/BootstrapBlazor/Components/EditorForm/IEditorItem.cs | 2 +- .../Components/Table/InternalTableColumn.cs | 2 +- src/BootstrapBlazor/Components/Table/TableColumn.cs | 2 +- src/BootstrapBlazor/Utils/Utility.cs | 9 ++++----- test/UnitTest/Extensions/ITableColumnExtensionsTest.cs | 2 +- test/UnitTest/Misc/MockTableColumn.cs | 2 +- 8 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/BootstrapBlazor/Attributes/AutoGenerateColumnAttribute.cs b/src/BootstrapBlazor/Attributes/AutoGenerateColumnAttribute.cs index 9bd5513976a..7115098c6cc 100644 --- a/src/BootstrapBlazor/Attributes/AutoGenerateColumnAttribute.cs +++ b/src/BootstrapBlazor/Attributes/AutoGenerateColumnAttribute.cs @@ -128,7 +128,7 @@ public class AutoGenerateColumnAttribute : AutoGenerateBaseAttribute, ITableColu /// /// 获得/设置 组件自定义类型参数集合 默认为 null /// - IEnumerable>? IEditorItem.ComponentParameters { get; set; } + IEnumerable>? IEditorItem.ComponentParameters { get; set; } /// /// 获得/设置 显示模板 diff --git a/src/BootstrapBlazor/Components/EditorForm/EditorItem.cs b/src/BootstrapBlazor/Components/EditorForm/EditorItem.cs index 3592b1bf06a..29380a42833 100644 --- a/src/BootstrapBlazor/Components/EditorForm/EditorItem.cs +++ b/src/BootstrapBlazor/Components/EditorForm/EditorItem.cs @@ -128,7 +128,7 @@ public class EditorItem : ComponentBase, IEditorItem /// 获得/设置 组件自定义类型参数集合 默认为 null /// [Parameter] - public IEnumerable>? ComponentParameters { get; set; } + public IEnumerable>? ComponentParameters { get; set; } /// /// 获得/设置 placeholder 文本 默认为 null diff --git a/src/BootstrapBlazor/Components/EditorForm/IEditorItem.cs b/src/BootstrapBlazor/Components/EditorForm/IEditorItem.cs index 99162177bbd..acb5840b148 100644 --- a/src/BootstrapBlazor/Components/EditorForm/IEditorItem.cs +++ b/src/BootstrapBlazor/Components/EditorForm/IEditorItem.cs @@ -83,7 +83,7 @@ public interface IEditorItem /// /// 获得/设置 组件自定义类型参数集合 默认为 null /// - IEnumerable>? ComponentParameters { get; set; } + IEnumerable>? ComponentParameters { get; set; } /// /// 获得/设置 字典数据源 常用于外键自动转换为名称操作 diff --git a/src/BootstrapBlazor/Components/Table/InternalTableColumn.cs b/src/BootstrapBlazor/Components/Table/InternalTableColumn.cs index a2e27450534..74e0502b87a 100644 --- a/src/BootstrapBlazor/Components/Table/InternalTableColumn.cs +++ b/src/BootstrapBlazor/Components/Table/InternalTableColumn.cs @@ -107,7 +107,7 @@ class InternalTableColumn(string fieldName, Type fieldType, string? fieldText = /// /// 获得/设置 组件自定义类型参数集合 默认为 null /// - public IEnumerable>? ComponentParameters { get; set; } + public IEnumerable>? ComponentParameters { get; set; } /// /// 获得/设置 额外数据源一般用于下拉框或者 CheckboxList 这种需要额外配置数据源组件使用 diff --git a/src/BootstrapBlazor/Components/Table/TableColumn.cs b/src/BootstrapBlazor/Components/Table/TableColumn.cs index d4962f722c5..6d5c83006e1 100644 --- a/src/BootstrapBlazor/Components/Table/TableColumn.cs +++ b/src/BootstrapBlazor/Components/Table/TableColumn.cs @@ -36,7 +36,7 @@ public class TableColumn : BootstrapComponentBase, ITableColumn /// 获得/设置 组件自定义类型参数集合 默认为 null /// [Parameter] - public IEnumerable>? ComponentParameters { get; set; } + public IEnumerable>? ComponentParameters { get; set; } /// /// 获得/设置 绑定列类型 diff --git a/src/BootstrapBlazor/Utils/Utility.cs b/src/BootstrapBlazor/Utils/Utility.cs index 1b4fbb54e8d..402391e4c4b 100644 --- a/src/BootstrapBlazor/Utils/Utility.cs +++ b/src/BootstrapBlazor/Utils/Utility.cs @@ -384,6 +384,7 @@ public static void CreateDisplayByFieldType(this RenderTreeBuilder builder, IEdi { builder.AddAttribute(5, "class", col.CssClass); } + builder.AddMultipleAttributes(6, item.ComponentParameters); builder.CloseComponent(); } else if (item.ComponentType == typeof(Textarea)) @@ -399,12 +400,9 @@ public static void CreateDisplayByFieldType(this RenderTreeBuilder builder, IEdi } if (item is ITableColumn col) { - if (col.ComponentParameters != null) - { - builder.AddMultipleAttributes(6, col.ComponentParameters); - } - builder.AddAttribute(7, "class", col.CssClass); + builder.AddAttribute(6, "class", col.CssClass); } + builder.AddMultipleAttributes(7, item.ComponentParameters); builder.CloseComponent(); } else @@ -426,6 +424,7 @@ public static void CreateDisplayByFieldType(this RenderTreeBuilder builder, IEdi } builder.AddAttribute(6, "class", col.CssClass); } + builder.AddMultipleAttributes(7, item.ComponentParameters); builder.CloseComponent(); } } diff --git a/test/UnitTest/Extensions/ITableColumnExtensionsTest.cs b/test/UnitTest/Extensions/ITableColumnExtensionsTest.cs index bc7cdbb2804..07e080f767e 100644 --- a/test/UnitTest/Extensions/ITableColumnExtensionsTest.cs +++ b/test/UnitTest/Extensions/ITableColumnExtensionsTest.cs @@ -43,7 +43,7 @@ public void CopyValue_Ok() var attr = new MockTableColumn("Name", typeof(string)) { ComponentType = typeof(NullSwitch), - ComponentParameters = Enumerable.Empty>(), + ComponentParameters = [], Editable = false, EditTemplate = new RenderFragment(obj => builder => builder.AddContent(0, "test")), Items = new List(), diff --git a/test/UnitTest/Misc/MockTableColumn.cs b/test/UnitTest/Misc/MockTableColumn.cs index c9b86987b84..96eacb62807 100644 --- a/test/UnitTest/Misc/MockTableColumn.cs +++ b/test/UnitTest/Misc/MockTableColumn.cs @@ -86,7 +86,7 @@ internal class MockTableColumn : ITableColumn public Action? OnCellRender { get; set; } - public IEnumerable>? ComponentParameters { get; set; } + public IEnumerable>? ComponentParameters { get; set; } public string? PlaceHolder { get; set; }