-
-
Notifications
You must be signed in to change notification settings - Fork 364
feat(Table): skip validate on Excel model #6017
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -470,7 +470,8 @@ public static void CreateDisplayByFieldType(this RenderTreeBuilder builder, IEdi | |||||||||
| /// <param name="changedType"></param> | ||||||||||
| /// <param name="isSearch"></param> | ||||||||||
| /// <param name="lookupService"></param> | ||||||||||
| public static void CreateComponentByFieldType(this RenderTreeBuilder builder, ComponentBase component, IEditorItem item, object model, ItemChangedType changedType = ItemChangedType.Update, bool isSearch = false, ILookupService? lookupService = null) | ||||||||||
| /// <param name="skipValidate"></param> | ||||||||||
| public static void CreateComponentByFieldType(this RenderTreeBuilder builder, ComponentBase component, IEditorItem item, object model, ItemChangedType changedType = ItemChangedType.Update, bool isSearch = false, ILookupService? lookupService = null, bool? skipValidate = null) | ||||||||||
| { | ||||||||||
| var fieldType = item.PropertyType; | ||||||||||
| var fieldName = item.GetFieldName(); | ||||||||||
|
|
@@ -488,7 +489,7 @@ public static void CreateComponentByFieldType(this RenderTreeBuilder builder, Co | |||||||||
| builder.AddAttribute(30, nameof(ValidateBase<string>.ValueChanged), fieldValueChanged); | ||||||||||
| builder.AddAttribute(40, nameof(ValidateBase<string>.ValueExpression), valueExpression); | ||||||||||
| builder.AddAttribute(41, nameof(ValidateBase<string>.ShowRequired), GetRequired(item, changedType)); | ||||||||||
| builder.AddAttribute(41, nameof(ValidateBase<string>.RequiredErrorMessage), item.RequiredErrorMessage); | ||||||||||
| builder.AddAttribute(42, nameof(ValidateBase<string>.RequiredErrorMessage), item.RequiredErrorMessage); | ||||||||||
|
|
||||||||||
| if (!item.CanWrite(model.GetType(), changedType, isSearch)) | ||||||||||
| { | ||||||||||
|
|
@@ -504,6 +505,11 @@ public static void CreateComponentByFieldType(this RenderTreeBuilder builder, Co | |||||||||
| { | ||||||||||
| builder.AddAttribute(70, nameof(ValidateBase<string>.ShowLabelTooltip), item.ShowLabelTooltip); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| if (skipValidate is true) | ||||||||||
| { | ||||||||||
| builder.AddAttribute(71, nameof(ValidateBase<string>.SkipValidate), true); | ||||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| if (componentType == typeof(NullSwitch) && TryGetProperty(model.GetType(), fieldName, out var propertyInfo)) | ||||||||||
|
|
@@ -547,7 +553,7 @@ public static void CreateComponentByFieldType(this RenderTreeBuilder builder, Co | |||||||||
| } | ||||||||||
|
|
||||||||||
| // 设置 SkipValidate 参数 | ||||||||||
|
||||||||||
| // 设置 SkipValidate 参数 | |
| // 设置 SkipValidate 参数 | |
| // Add the SkipValidate attribute only if skipValidate is false and the component type is valid. | |
| // This ensures that validation is skipped only when explicitly allowed by the conditions. |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -254,7 +254,7 @@ public void CreateDisplayByFieldType_Formatter() | |||||||||
| public void CreateComponentByFieldType_Ok() | ||||||||||
| { | ||||||||||
| var editor = new MockNullDisplayNameColumn("Name", typeof(string)) { Readonly = true }; | ||||||||||
| var fragment = new RenderFragment(builder => builder.CreateComponentByFieldType(new BootstrapBlazorRoot(), editor, new Foo() { Name = "Test-Component" })); | ||||||||||
| var fragment = new RenderFragment(builder => builder.CreateComponentByFieldType(new BootstrapBlazorRoot(), editor, new Foo() { Name = "Test-Component" }, skipValidate: true)); | ||||||||||
| var cut = Context.Render(builder => builder.AddContent(0, fragment)); | ||||||||||
| Assert.Contains("value=\"Test-Component\"", cut.Markup); | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (testing): Enhance assertion to verify Update the assertion to verify the rendered markup includes the SkipValidate attribute or that the component instance’s skipValidate parameter is true.
Suggested change
|
||||||||||
| } | ||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Document that a null value for skipValidate is treated as false to ensure API consumers understand the default behavior.