Skip to content

Commit

Permalink
feat: 支持 AddMultipleAttributes
Browse files Browse the repository at this point in the history
  • Loading branch information
ArgoZhang committed Feb 19, 2024
1 parent 0e56e40 commit 0e6d646
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public class AutoGenerateColumnAttribute : AutoGenerateBaseAttribute, ITableColu
/// <summary>
/// 获得/设置 组件自定义类型参数集合 默认为 null
/// </summary>
IEnumerable<KeyValuePair<string, object>>? IEditorItem.ComponentParameters { get; set; }
IEnumerable<KeyValuePair<string, object?>>? IEditorItem.ComponentParameters { get; set; }

/// <summary>
/// 获得/设置 显示模板
Expand Down
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/Components/EditorForm/EditorItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public class EditorItem<TValue> : ComponentBase, IEditorItem
/// 获得/设置 组件自定义类型参数集合 默认为 null
/// </summary>
[Parameter]
public IEnumerable<KeyValuePair<string, object>>? ComponentParameters { get; set; }
public IEnumerable<KeyValuePair<string, object?>>? ComponentParameters { get; set; }

/// <summary>
/// 获得/设置 placeholder 文本 默认为 null
Expand Down
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/Components/EditorForm/IEditorItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public interface IEditorItem
/// <summary>
/// 获得/设置 组件自定义类型参数集合 默认为 null
/// </summary>
IEnumerable<KeyValuePair<string, object>>? ComponentParameters { get; set; }
IEnumerable<KeyValuePair<string, object?>>? ComponentParameters { get; set; }

/// <summary>
/// 获得/设置 字典数据源 常用于外键自动转换为名称操作
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class InternalTableColumn(string fieldName, Type fieldType, string? fieldText =
/// <summary>
/// 获得/设置 组件自定义类型参数集合 默认为 null
/// </summary>
public IEnumerable<KeyValuePair<string, object>>? ComponentParameters { get; set; }
public IEnumerable<KeyValuePair<string, object?>>? ComponentParameters { get; set; }

/// <summary>
/// 获得/设置 额外数据源一般用于下拉框或者 CheckboxList 这种需要额外配置数据源组件使用
Expand Down
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/Components/Table/TableColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class TableColumn<TItem, TType> : BootstrapComponentBase, ITableColumn
/// 获得/设置 组件自定义类型参数集合 默认为 null
/// </summary>
[Parameter]
public IEnumerable<KeyValuePair<string, object>>? ComponentParameters { get; set; }
public IEnumerable<KeyValuePair<string, object?>>? ComponentParameters { get; set; }

/// <summary>
/// 获得/设置 绑定列类型
Expand Down
9 changes: 4 additions & 5 deletions src/BootstrapBlazor/Utils/Utility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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
Expand All @@ -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();
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/UnitTest/Extensions/ITableColumnExtensionsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void CopyValue_Ok()
var attr = new MockTableColumn("Name", typeof(string))
{
ComponentType = typeof(NullSwitch),
ComponentParameters = Enumerable.Empty<KeyValuePair<string, object>>(),
ComponentParameters = [],
Editable = false,
EditTemplate = new RenderFragment<object>(obj => builder => builder.AddContent(0, "test")),
Items = new List<SelectedItem>(),
Expand Down
2 changes: 1 addition & 1 deletion test/UnitTest/Misc/MockTableColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ internal class MockTableColumn : ITableColumn

public Action<TableCellArgs>? OnCellRender { get; set; }

public IEnumerable<KeyValuePair<string, object>>? ComponentParameters { get; set; }
public IEnumerable<KeyValuePair<string, object?>>? ComponentParameters { get; set; }

public string? PlaceHolder { get; set; }

Expand Down

0 comments on commit 0e6d646

Please sign in to comment.