Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
41 changes: 27 additions & 14 deletions src/BootstrapBlazor/Attributes/AutoGenerateBaseAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,74 +1,87 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License
// See the LICENSE file in the project root for more information.
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone

namespace BootstrapBlazor.Components;

/// <summary>
/// Base class for AutoGenerateColumn attribute, used to mark auto-generated columns in <see cref="Table{TItem}"/>
/// <para lang="zh">AutoGenerateColumn 属性基类,用于标记 <see cref="Table{TItem}"/> 中的自动生成列</para>
/// <para lang="en">Base class for AutoGenerateColumn attribute, used to mark auto-generated columns in <see cref="Table{TItem}"/></para>
/// </summary>
public abstract class AutoGenerateBaseAttribute : Attribute
{
/// <summary>
/// Gets or sets whether the current column is editable. Default is true. When set to false, the auto-generated edit UI will not generate this column.
/// <para lang="zh">获得/设置 当前列是否可编辑。默认为 true。当设置为 false 时,自动编辑 UI 不会生成此列。</para>
/// <para lang="en">Gets or sets whether the current column is editable. Default is true. When set to false, the auto-generated edit UI will not generate this column.</para>
/// </summary>
[Obsolete("Deprecated. If it is editable, use the Readonly parameter. If it is visible, use the Ignore parameter.")]
[ExcludeFromCodeCoverage]
public bool Editable { get; set; } = true;

/// <summary>
/// Gets or sets whether the current column is rendered. Default is false. When set to true, the UI will not generate this column.
/// <para lang="zh">获得/设置 当前列是否渲染。默认为 false。当设置为 true 时,UI 不会生成此列。</para>
/// <para lang="en">Gets or sets whether the current column is rendered. Default is false. When set to true, the UI will not generate this column.</para>
/// </summary>
public bool Ignore { get; set; }

/// <summary>
/// Gets or sets whether the current edit item is read-only. Default is false.
/// <para lang="zh">获得/设置 当前编辑项是否只读。默认为 false。</para>
/// <para lang="en">Gets or sets whether the current edit item is read-only. Default is false.</para>
/// </summary>
public bool Readonly { get; set; }

/// <summary>
/// Gets or sets whether the current edit item is visible. Default is true.
/// <para lang="zh">获得/设置 当前编辑项是否可见。默认为 true。</para>
/// <para lang="en">Gets or sets whether the current edit item is visible. Default is true.</para>
/// </summary>
public bool Visible { get; set; } = true;

/// <summary>
/// Gets or sets whether sorting is allowed. Default is false.
/// <para lang="zh">获得/设置 是否允许排序。默认为 false。</para>
/// <para lang="en">Gets or sets whether sorting is allowed. Default is false.</para>
/// </summary>
public bool Sortable { get; set; }

/// <summary>
/// Gets or sets whether data filtering is allowed. Default is false.
/// <para lang="zh">获得/设置 是否允许数据筛选。默认为 false。</para>
/// <para lang="en">Gets or sets whether data filtering is allowed. Default is false.</para>
/// </summary>
public bool Filterable { get; set; }

/// <summary>
/// Gets or sets whether the column participates in search. Default is false.
/// <para lang="zh">获得/设置 此列是否参与搜索。默认为 false。</para>
/// <para lang="en">Gets or sets whether the column participates in search. Default is false.</para>
/// </summary>
public bool Searchable { get; set; }

/// <summary>
/// Gets or sets whether text wrapping is allowed in this column. Default is false.
/// <para lang="zh">获得/设置 此列是否允许文本换行。默认为 false。</para>
/// <para lang="en">Gets or sets whether text wrapping is allowed in this column. Default is false.</para>
/// </summary>
public bool TextWrap { get; set; }

/// <summary>
/// Gets or sets whether text overflow is ellipsis in this column. Default is false.
/// <para lang="zh">获得/设置 此列文本溢出时是否显示省略号。默认为 false。</para>
/// <para lang="en">Gets or sets whether text overflow is ellipsis in this column. Default is false.</para>
/// </summary>
public bool TextEllipsis { get; set; }

/// <summary>
/// Gets or sets the text alignment. Default is Alignment.None.
/// <para lang="zh">获得/设置 文本对齐方式。默认为 Alignment.None。</para>
/// <para lang="en">Gets or sets the text alignment. Default is Alignment.None.</para>
/// </summary>
public Alignment Align { get; set; }

/// <summary>
/// Gets or sets whether to show tooltips on mouse hover. Default is false.
/// <para lang="zh">获得/设置 鼠标悬停时是否显示提示信息。默认为 false。</para>
/// <para lang="en">Gets or sets whether to show tooltips on mouse hover. Default is false.</para>
/// </summary>
public bool ShowTips { get; set; }

/// <summary>
/// Gets or sets whether the column can be copied. Default is false.
/// <para lang="zh">获得/设置 列是否可以被复制。默认为 false。</para>
/// <para lang="en">Gets or sets whether the column can be copied. Default is false.</para>
/// </summary>
public bool ShowCopyColumn { get; set; }
}
5 changes: 3 additions & 2 deletions src/BootstrapBlazor/Attributes/AutoGenerateClassAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License
// See the LICENSE file in the project root for more information.
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone

namespace BootstrapBlazor.Components;

/// <summary>
/// AutoGenerateColumn attribute class, used to mark auto-generated columns in <see cref="Table{TItem}"/>
/// <para lang="zh">AutoGenerateColumn 属性类,用于在 <see cref="Table{TItem}"/> 中标记自动生成的列</para>
/// <para lang="en">AutoGenerateColumn attribute class, used to mark auto-generated columns in <see cref="Table{TItem}"/></para>
/// </summary>
[AttributeUsage(AttributeTargets.Class)]
public class AutoGenerateClassAttribute : AutoGenerateBaseAttribute
Expand Down
50 changes: 31 additions & 19 deletions src/BootstrapBlazor/Attributes/AutoGenerateColumnAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License
// See the LICENSE file in the project root for more information.
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone

namespace BootstrapBlazor.Components;

/// <summary>
/// AutoGenerateColumn attribute class, used to mark auto-generated columns in <see cref="Table{TItem}"/>
/// <para lang="zh">AutoGenerateColumn 属性类,用于在 <see cref="Table{TItem}"/> 中标记自动生成的列</para>
/// <para lang="en">AutoGenerateColumn attribute class, used to mark auto-generated columns in <see cref="Table{TItem}"/></para>
/// </summary>
[AttributeUsage(AttributeTargets.Property)]
public class AutoGenerateColumnAttribute : AutoGenerateBaseAttribute, ITableColumn
{
/// <summary>
/// Gets or sets the display order. The rules are as follows:
/// <para></para>
/// &gt;0 for the front, 1,2,3...
/// <para></para>
/// =0 for the middle (default)
/// <para></para>
/// &lt;0 for the back, ...-3,-2,-1
/// <para lang="zh">获得/设置 显示顺序。规则如下:</para>
/// <para lang="en">Gets or sets the display order. The rules are as follows:</para>
/// <para lang="zh">&gt;0 正序排列,1,2,3...</para>
/// <para lang="en">&gt;0 for the front, 1,2,3...</para>
/// <para lang="zh">=0 保持默认</para>
/// <para lang="en">=0 for the middle (default)</para>
/// <para lang="zh">&lt;0 倒序排列,...-3,-2,-1</para>
/// <para lang="en">&lt;0 for the back, ...-3,-2,-1</para>
/// </summary>
public int Order { get; set; }

Expand All @@ -33,7 +35,8 @@ public class AutoGenerateColumnAttribute : AutoGenerateBaseAttribute, ITableColu
public bool SkipValidate { get; set; }

/// <summary>
/// Gets or sets whether the column is read-only when adding a new item. Default is null, using the <see cref="IEditorItem.Readonly"/> value.
/// <para lang="zh">获得/设置 新建时此列是否只读。默认值为 null,使用 <see cref="IEditorItem.Readonly"/> 值。</para>
/// <para lang="en">Gets or sets whether the column is read-only when adding a new item. Default is null, using the <see cref="IEditorItem.Readonly"/> value.</para>
/// </summary>
public bool IsReadonlyWhenAdd { get; set; }

Expand All @@ -44,7 +47,8 @@ public class AutoGenerateColumnAttribute : AutoGenerateBaseAttribute, ITableColu
}

/// <summary>
/// Gets or sets whether the column is read-only when editing an item. Default is null, using the <see cref="IEditorItem.Readonly"/> value.
/// <para lang="zh">获得/设置 编辑时此列是否只读。默认值为 null,使用 <see cref="IEditorItem.Readonly"/> 值。</para>
/// <para lang="en">Gets or sets whether the column is read-only when editing an item. Default is null, using the <see cref="IEditorItem.Readonly"/> value.</para>
/// </summary>
public bool IsReadonlyWhenEdit { get; set; }

Expand All @@ -55,7 +59,8 @@ public class AutoGenerateColumnAttribute : AutoGenerateBaseAttribute, ITableColu
}

/// <summary>
/// Gets or sets whether the column is visible when adding a new item. Default is null, using the <see cref="AutoGenerateBaseAttribute.Visible"/> value.
/// <para lang="zh">获得/设置 新建时此列是否可见。默认值为 null,使用 <see cref="AutoGenerateBaseAttribute.Visible"/> 值。</para>
/// <para lang="en">Gets or sets whether the column is visible when adding a new item. Default is null, using the <see cref="AutoGenerateBaseAttribute.Visible"/> value.</para>
/// </summary>
public bool IsVisibleWhenAdd { get; set; } = true;

Expand All @@ -66,7 +71,8 @@ public class AutoGenerateColumnAttribute : AutoGenerateBaseAttribute, ITableColu
}

/// <summary>
/// Gets or sets whether the column is visible when editing an item. Default is null, using the <see cref="AutoGenerateBaseAttribute.Visible"/> value.
/// <para lang="zh">获得/设置 编辑时此列是否可见。默认值为 null,使用 <see cref="AutoGenerateBaseAttribute.Visible"/> 值。</para>
/// <para lang="en">Gets or sets whether the column is visible when editing an item. Default is null, using the <see cref="AutoGenerateBaseAttribute.Visible"/> value.</para>
/// </summary>
public bool IsVisibleWhenEdit { get; set; } = true;

Expand All @@ -90,7 +96,8 @@ public class AutoGenerateColumnAttribute : AutoGenerateBaseAttribute, ITableColu
public string? RequiredErrorMessage { get; set; }

/// <summary>
/// Gets or sets whether to show label tooltip. Mostly used when the label text is too long and gets truncated. Default is false.
/// <para lang="zh">获得/设置 是否显示标签工具提示。通常用于标签文本过长被截断时。默认为 false。</para>
/// <para lang="en">Gets or sets whether to show label tooltip. Mostly used when the label text is too long and gets truncated. Default is false.</para>
/// </summary>
public bool ShowLabelTooltip { get; set; }

Expand All @@ -101,14 +108,16 @@ public class AutoGenerateColumnAttribute : AutoGenerateBaseAttribute, ITableColu
}

/// <summary>
/// Gets or sets the default sort order. Default is SortOrder.Unset.
/// <para lang="zh">获得/设置 默认排序顺序。默认为 SortOrder.Unset。</para>
/// <para lang="en">Gets or sets the default sort order. Default is SortOrder.Unset.</para>
/// </summary>
public SortOrder DefaultSortOrder { get; set; }

IEnumerable<SelectedItem>? IEditorItem.Items { get; set; }

/// <summary>
/// Gets or sets the column width.
/// <para lang="zh">获得/设置 列宽。</para>
/// <para lang="en">Gets or sets the column width.</para>
/// </summary>
public int Width { get; set; }

Expand Down Expand Up @@ -230,6 +239,9 @@ public class AutoGenerateColumnAttribute : AutoGenerateBaseAttribute, ITableColu
/// </summary>
public bool ShowSearchWhenSelect { get; set; }

/// <summary>
/// <inheritdoc/>
/// </summary>
/// <summary>
/// <inheritdoc/>
/// </summary>
Expand All @@ -253,17 +265,17 @@ public class AutoGenerateColumnAttribute : AutoGenerateBaseAttribute, ITableColu
ILookupService? ILookup.LookupService { get; set; }

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

/// <summary>
/// <inheritdoc/>>
/// <inheritdoc/>
/// </summary>
public object? LookupServiceData { get; set; }

/// <summary>
/// <inheritdoc/>>
/// <inheritdoc/>
/// </summary>
public StringComparison LookupStringComparison { get; set; } = StringComparison.OrdinalIgnoreCase;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License
// See the LICENSE file in the project root for more information.
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone

namespace BootstrapBlazor.Components;

/// <summary>
/// Constructor
/// <para lang="zh">构造函数</para>
/// <para lang="en">Constructor</para>
/// </summary>
/// <param name="path"></param>
class BootstrapModuleAutoLoaderAttribute(string? path = null) : JSModuleAutoLoaderAttribute(path)
{
/// <summary>
/// Gets or sets the module name. Automatically uses scripts from the modules folder.
/// <para lang="zh">获得/设置 模块名称。自动使用 modules 文件夹中的脚本。</para>
/// <para lang="en">Gets or sets the module name. Automatically uses scripts from the modules folder.</para>
/// </summary>
public string? ModuleName { get; set; }
}
14 changes: 9 additions & 5 deletions src/BootstrapBlazor/Attributes/FileValidationAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License
// See the LICENSE file in the project root for more information.
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone
Expand All @@ -9,25 +9,29 @@
namespace BootstrapBlazor.Components;

/// <summary>
/// 上传文件扩展名验证标签类
/// <para lang="zh">上传文件扩展名验证标签类</para>
/// <para lang="en">Upload file extension validation attribute class</para>
/// </summary>
[AttributeUsage(AttributeTargets.Property)]
public class FileValidationAttribute : ValidationAttribute
{
private IStringLocalizer? Localizer { get; set; }

/// <summary>
/// 获得/设置 允许的扩展名
/// <para lang="zh">获得/设置 允许的扩展名</para>
/// <para lang="en">Gets or sets allowed extensions</para>
/// </summary>
public string[] Extensions { get; set; } = [];

/// <summary>
/// 获得/设置 文件大小 默认为 0 未限制
/// <para lang="zh">获得/设置 文件大小 默认为 0 未限制</para>
/// <para lang="en">Gets or sets file size. Default is 0 (no limit)</para>
/// </summary>
public long FileSize { get; set; }

/// <summary>
/// 是否合规判断方法
/// <para lang="zh">是否合规判断方法</para>
/// <para lang="en">Is valid method</para>
/// </summary>
/// <param name="value"></param>
/// <param name="validationContext"></param>
Expand Down
19 changes: 12 additions & 7 deletions src/BootstrapBlazor/Attributes/JSModuleAutoLoaderAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,34 +1,39 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License
// See the LICENSE file in the project root for more information.
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone

namespace BootstrapBlazor.Components;

/// <summary>
/// JSModuleAutoLoaderAttribute class
/// <para lang="zh">JSModuleAutoLoaderAttribute 类</para>
/// <para lang="en">JSModuleAutoLoaderAttribute class</para>
/// </summary>
/// <param name="path">The path to the JavaScript module</param>
/// <param name="path"><para lang="zh">JavaScript 模块的路径</para><para lang="en">The path to the JavaScript module</para></param>
[AttributeUsage(AttributeTargets.Class)]
public class JSModuleAutoLoaderAttribute(string? path = null) : Attribute
{
/// <summary>
/// Gets the path property
/// <para lang="zh">获得 路径属性</para>
/// <para lang="en">Gets the path property</para>
/// </summary>
public string? Path { get; } = path;

/// <summary>
/// Represents a reference to a JavaScript object. Default value is false.
/// <para lang="zh">表示对 JavaScript 对象的引用。默认值为 false。</para>
/// <para lang="en">Represents a reference to a JavaScript object. Default value is false.</para>
/// </summary>
public bool JSObjectReference { get; set; }

/// <summary>
/// Gets or sets whether to automatically invoke init. Default is true.
/// <para lang="zh">获得/设置 是否自动调用 init。默认值为 true。</para>
/// <para lang="en">Gets or sets whether to automatically invoke init. Default is true.</para>
/// </summary>
public bool AutoInvokeInit { get; set; } = true;

/// <summary>
/// Gets or sets whether to automatically invoke dispose. Default is true.
/// <para lang="zh">获得/设置 是否自动调用 dispose。默认值为 true。</para>
/// <para lang="en">Gets or sets whether to automatically invoke dispose. Default is true.</para>
/// </summary>
public bool AutoInvokeDispose { get; set; } = true;
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License
// See the LICENSE file in the project root for more information.
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone

namespace BootstrapBlazor.Components;

/// <summary>
/// JSModuleNotInheritedAttribute <see cref="JSModuleAutoLoaderAttribute"/>
/// <para lang="zh">JSModuleNotInheritedAttribute <see cref="JSModuleAutoLoaderAttribute"/></para>
/// <para lang="en">JSModuleNotInheritedAttribute <see cref="JSModuleAutoLoaderAttribute"/></para>
/// </summary>
[AttributeUsage(AttributeTargets.Class)]
public sealed class JSModuleNotInheritedAttribute : Attribute
{
// 增加 sealed 关键字防止二开写派生类导致 type.GetCustomAttribute<JSModuleNotInheritedAttribute>() 报错
// BootstrapModuleComponentBase 类 OnLoadJSModule 方法

}
Loading