From 645f2462c2a60ecc12770b3b9b67767307fdd903 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Fri, 21 Feb 2025 11:45:10 +0800 Subject: [PATCH 1/7] =?UTF-8?q?refactor:=20=E6=94=AF=E6=8C=81=20Required?= =?UTF-8?q?=20=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Attributes/AutoGenerateColumnAttribute.cs | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/BootstrapBlazor/Attributes/AutoGenerateColumnAttribute.cs b/src/BootstrapBlazor/Attributes/AutoGenerateColumnAttribute.cs index 0b806a71dc4..6f81018d8b7 100644 --- a/src/BootstrapBlazor/Attributes/AutoGenerateColumnAttribute.cs +++ b/src/BootstrapBlazor/Attributes/AutoGenerateColumnAttribute.cs @@ -84,17 +84,35 @@ public class AutoGenerateColumnAttribute : AutoGenerateBaseAttribute, ITableColu /// /// /// - public bool? Required { get; set; } + public bool Required { get; set; } + + bool? IEditorItem.Required + { + get => Required; + set => Required = value ?? false; + } /// /// /// - public bool? IsRequiredWhenAdd { get; set; } + public bool IsRequiredWhenAdd { get; set; } + + bool? ITableColumn.IsRequiredWhenAdd + { + get => IsRequiredWhenAdd; + set => IsRequiredWhenAdd = value ?? false; + } /// /// /// - public bool? IsRequiredWhenEdit { get; set; } + public bool IsRequiredWhenEdit { get; set; } + + bool? ITableColumn.IsRequiredWhenEdit + { + get => IsRequiredWhenEdit; + set => IsRequiredWhenEdit = value ?? false; + } /// /// From 319907e9a554de2fcd1c7b735bbe81cb7e55ff72 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Fri, 21 Feb 2025 11:45:46 +0800 Subject: [PATCH 2/7] =?UTF-8?q?test:=20=E6=9B=B4=E6=96=B0=E5=8D=95?= =?UTF-8?q?=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/UnitTest/Attributes/AutoGenerateClassTest.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/UnitTest/Attributes/AutoGenerateClassTest.cs b/test/UnitTest/Attributes/AutoGenerateClassTest.cs index f77ed200a4d..eb83d7bc47e 100644 --- a/test/UnitTest/Attributes/AutoGenerateClassTest.cs +++ b/test/UnitTest/Attributes/AutoGenerateClassTest.cs @@ -201,6 +201,11 @@ public void AutoGenerateColumn_Ok() attrInterface.ToolboxTemplate = col => builder => builder.AddContent(0, "test"); Assert.NotNull(attrInterface.ToolboxTemplate); + attrInterface.IsRequiredWhenAdd = true; + Assert.True(attrInterface.IsRequiredWhenAdd); + attrInterface.IsRequiredWhenEdit = true; + Assert.True(attrInterface.IsRequiredWhenEdit); + var attrEditor = (IEditorItem)attr; attrEditor.Items = null; Assert.Null(attrEditor.Items); @@ -226,13 +231,13 @@ public void AutoGenerateColumn_Ok() attrEditor.LookupService = new LookupService(); Assert.NotNull(attrEditor.LookupService); + attrEditor.Required = true; + Assert.True(attrEditor.Required); + // 增加 GetDisplay 单元覆盖率 attr.Text = null; Assert.Equal(string.Empty, attr.GetDisplayName()); - Assert.True(attr.Required); - Assert.True(attr.IsRequiredWhenEdit); - Assert.True(attr.IsRequiredWhenAdd); Assert.Equal("test", attr.RequiredErrorMessage); } From eb8ab3dbf6fddcf096630c1d4c53a067f349d2d5 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Fri, 21 Feb 2025 12:37:50 +0800 Subject: [PATCH 3/7] =?UTF-8?q?refactor:=20=E4=BB=A3=E7=A0=81=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor.Server/Data/Foo.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/BootstrapBlazor.Server/Data/Foo.cs b/src/BootstrapBlazor.Server/Data/Foo.cs index 8b0988cc851..92ecc5f1c06 100644 --- a/src/BootstrapBlazor.Server/Data/Foo.cs +++ b/src/BootstrapBlazor.Server/Data/Foo.cs @@ -109,7 +109,7 @@ public class Foo /// Generate Foo class, random data /// /// 返回一个Foo类的List,Return a List of Foo class - public static List GenerateFoo(IStringLocalizer localizer, int count = 80) => Enumerable.Range(1, count).Select(i => new Foo() + public static List GenerateFoo(IStringLocalizer localizer, int count = 80) => [.. Enumerable.Range(1, count).Select(i => new Foo() { Id = i, Name = localizer["Foo.Name", $"{i:d4}"], @@ -119,7 +119,7 @@ public class Foo Complete = Random.Shared.Next(1, 100) > 50, Education = Random.Shared.Next(1, 100) > 50 ? EnumEducation.Primary : EnumEducation.Middle, ReadonlyColumn = Random.Shared.Next(10, 50) - }).ToList(); + })]; /// /// 生成 Foo 类 Hobbies 数据 From 38f52415db2c51f5cfd9c62e8c9eb3abf3fdf01e Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Fri, 21 Feb 2025 12:38:01 +0800 Subject: [PATCH 4/7] =?UTF-8?q?refactor:=20=E9=87=8D=E6=9E=84=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Attributes/AutoGenerateColumnAttribute.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BootstrapBlazor/Attributes/AutoGenerateColumnAttribute.cs b/src/BootstrapBlazor/Attributes/AutoGenerateColumnAttribute.cs index 6f81018d8b7..f320a05ca04 100644 --- a/src/BootstrapBlazor/Attributes/AutoGenerateColumnAttribute.cs +++ b/src/BootstrapBlazor/Attributes/AutoGenerateColumnAttribute.cs @@ -127,7 +127,7 @@ public class AutoGenerateColumnAttribute : AutoGenerateBaseAttribute, ITableColu bool? IEditorItem.ShowLabelTooltip { get => ShowLabelTooltip; - set => ShowLabelTooltip = value.HasValue && value.Value; + set => ShowLabelTooltip = value ?? false; } /// From 18d41c31c6e34c3013f230063aa7244b884d3baf Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Fri, 21 Feb 2025 13:11:54 +0800 Subject: [PATCH 5/7] =?UTF-8?q?refactor:=20=E5=B1=8F=E8=94=BD=20IsRequired?= =?UTF-8?q?WhenAdd/IsRequiredWhenEdit=20=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Attributes/AutoGenerateColumnAttribute.cs | 32 ++----------------- 1 file changed, 3 insertions(+), 29 deletions(-) diff --git a/src/BootstrapBlazor/Attributes/AutoGenerateColumnAttribute.cs b/src/BootstrapBlazor/Attributes/AutoGenerateColumnAttribute.cs index f320a05ca04..52914a76498 100644 --- a/src/BootstrapBlazor/Attributes/AutoGenerateColumnAttribute.cs +++ b/src/BootstrapBlazor/Attributes/AutoGenerateColumnAttribute.cs @@ -81,38 +81,12 @@ public class AutoGenerateColumnAttribute : AutoGenerateBaseAttribute, ITableColu set => IsVisibleWhenEdit = value ?? true; } - /// - /// - /// - public bool Required { get; set; } + bool? IEditorItem.Required { get; set; } - bool? IEditorItem.Required - { - get => Required; - set => Required = value ?? false; - } - /// - /// - /// - public bool IsRequiredWhenAdd { get; set; } + bool? ITableColumn.IsRequiredWhenAdd { get; set; } - bool? ITableColumn.IsRequiredWhenAdd - { - get => IsRequiredWhenAdd; - set => IsRequiredWhenAdd = value ?? false; - } - - /// - /// - /// - public bool IsRequiredWhenEdit { get; set; } - - bool? ITableColumn.IsRequiredWhenEdit - { - get => IsRequiredWhenEdit; - set => IsRequiredWhenEdit = value ?? false; - } + bool? ITableColumn.IsRequiredWhenEdit { get; set; } /// /// From 1f6eb137106f43366ec373aa9b80794ae9391258 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Fri, 21 Feb 2025 13:27:11 +0800 Subject: [PATCH 6/7] =?UTF-8?q?test:=20=E6=9B=B4=E6=96=B0=E5=8D=95?= =?UTF-8?q?=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/UnitTest/Attributes/AutoGenerateClassTest.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/test/UnitTest/Attributes/AutoGenerateClassTest.cs b/test/UnitTest/Attributes/AutoGenerateClassTest.cs index eb83d7bc47e..a9ac8571a79 100644 --- a/test/UnitTest/Attributes/AutoGenerateClassTest.cs +++ b/test/UnitTest/Attributes/AutoGenerateClassTest.cs @@ -70,10 +70,7 @@ public void AutoGenerateColumn_Ok() HeaderTextWrap = true, IsMarkupString = true, - Required = true, - RequiredErrorMessage = "test", - IsRequiredWhenAdd = true, - IsRequiredWhenEdit = true + RequiredErrorMessage = "test" }; Assert.Equal(1, attr.Order); Assert.True(attr.Ignore); From 4f71273f762f9c92200b7fd6a8d95a1315cc60e6 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Fri, 21 Feb 2025 13:33:45 +0800 Subject: [PATCH 7/7] chore: bump version 9.3.1-beta27 Co-Authored-By: cqths <145242365+cqths@users.noreply.github.com> --- src/BootstrapBlazor/BootstrapBlazor.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BootstrapBlazor/BootstrapBlazor.csproj b/src/BootstrapBlazor/BootstrapBlazor.csproj index 7185b9c967b..7b193de50b5 100644 --- a/src/BootstrapBlazor/BootstrapBlazor.csproj +++ b/src/BootstrapBlazor/BootstrapBlazor.csproj @@ -1,7 +1,7 @@ - 9.3.1-beta26 + 9.3.1-beta27