-
-
Notifications
You must be signed in to change notification settings - Fork 382
feat(IEditorItem): add EditorItem generic type #7642
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
caaf9db
feat: 增加 EditorItem 类
ArgoZhang d1a1b5b
Merge branch 'main' into feat-editor-item
ArgoZhang 539c46a
feat: 增加 HasParameterAttribute 扩展方法
ArgoZhang 8bef84a
feat: 增加 RenderEditTemplate 方法
ArgoZhang 6a84000
refactor: 移除参数标签
ArgoZhang 2e4c8f9
test: 增加单元测试
ArgoZhang 475e456
test: 增加单元测试
ArgoZhang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,191 @@ | ||
| // 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> | ||
| /// <para lang="zh">EditorItem 表单渲染项实体类</para> | ||
| /// <para lang="en">EditorItem form field class</para> | ||
| /// </summary> | ||
| /// <param name="fieldName"></param> | ||
| /// <param name="fieldType"></param> | ||
| /// <param name="fieldText"></param> | ||
| public class EditorItem<TModel>(string fieldName, Type fieldType, string? fieldText = null) : IEditorItem | ||
| { | ||
| private string FieldName { get; } = fieldName; | ||
|
|
||
| /// <summary> | ||
| /// <inheritdoc cref="IEditorItem.SkipValidate"/> | ||
| /// </summary> | ||
| public bool SkipValidate { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// <inheritdoc cref="IEditorItem.Ignore"/> | ||
| /// </summary> | ||
| public bool? Ignore { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// <inheritdoc cref="IEditorItem.Readonly"/> | ||
| /// </summary> | ||
| public bool? Readonly { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// <inheritdoc cref="IEditorItem.Required"/> | ||
| /// </summary> | ||
| public bool? Required { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// <inheritdoc cref="IEditorItem.RequiredErrorMessage"/> | ||
| /// </summary> | ||
| public string? RequiredErrorMessage { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// <inheritdoc cref="IEditorItem.ShowLabelTooltip"/> | ||
| /// </summary> | ||
| public bool? ShowLabelTooltip { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// <inheritdoc cref="IEditorItem.PlaceHolder"/> | ||
| /// </summary> | ||
| public string? PlaceHolder { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// <inheritdoc cref="IEditorItem.PropertyType"/> | ||
| /// </summary> | ||
| public Type PropertyType { get; } = fieldType; | ||
|
|
||
| [Obsolete("已弃用,请删除;Deprecated, please delete")] | ||
| [ExcludeFromCodeCoverage] | ||
| bool IEditorItem.Editable { get; set; } = true; | ||
|
|
||
| /// <summary> | ||
| /// <inheritdoc cref="IEditorItem.Step"/> | ||
| /// </summary> | ||
| public string? Step { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// <inheritdoc cref="IEditorItem.Rows"/> | ||
| /// </summary> | ||
| public int Rows { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// <inheritdoc cref="IEditorItem.Cols"/> | ||
| /// </summary> | ||
| public int Cols { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// <inheritdoc cref="IEditorItem.Text"/> | ||
| /// </summary> | ||
| [NotNull] | ||
| public string? Text { get; set; } = fieldText; | ||
|
|
||
| /// <summary> | ||
| /// <inheritdoc cref="IEditorItem.EditTemplate"/> | ||
| /// </summary> | ||
| public RenderFragment<TModel>? EditTemplate { get; set; } | ||
|
|
||
| RenderFragment<object>? IEditorItem.EditTemplate | ||
| { | ||
ArgoZhang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| get | ||
| { | ||
| return EditTemplate == null ? null : new RenderFragment<object>(item => builder => | ||
| { | ||
| builder.AddContent(0, EditTemplate((TModel)item)); | ||
| }); | ||
| } | ||
| set | ||
| { | ||
| } | ||
ArgoZhang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| /// <summary> | ||
| /// <inheritdoc cref="IEditorItem.ComponentType"/> | ||
| /// </summary> | ||
| public Type? ComponentType { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// <inheritdoc cref="IEditorItem.ComponentParameters"/> | ||
| /// </summary> | ||
| public IEnumerable<KeyValuePair<string, object>>? ComponentParameters { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// <inheritdoc cref="IEditorItem.Items"/> | ||
| /// </summary> | ||
| public IEnumerable<SelectedItem>? Items { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// <inheritdoc cref="IEditorItem.Order"/> | ||
| /// </summary> | ||
| public int Order { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// <inheritdoc cref="ILookup.Lookup"/> | ||
| /// </summary> | ||
| public IEnumerable<SelectedItem>? Lookup { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// <inheritdoc cref="IEditorItem.ShowSearchWhenSelect"/> | ||
| /// </summary> | ||
| public bool ShowSearchWhenSelect { get; set; } | ||
|
|
||
| [Obsolete("已弃用,请删除;Deprecated, please delete")] | ||
| [ExcludeFromCodeCoverage] | ||
| bool IEditorItem.IsFixedSearchWhenSelect { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// <inheritdoc cref="IEditorItem.IsPopover"/> | ||
| /// </summary> | ||
| public bool IsPopover { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// <inheritdoc cref="ILookup.LookupStringComparison"/> | ||
| /// </summary> | ||
| public StringComparison LookupStringComparison { get; set; } = StringComparison.OrdinalIgnoreCase; | ||
|
|
||
| /// <summary> | ||
| /// <inheritdoc cref="ILookup.LookupServiceKey"/> | ||
| /// </summary> | ||
| public string? LookupServiceKey { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// <inheritdoc cref="ILookup.LookupServiceData"/> | ||
| /// </summary> | ||
| public object? LookupServiceData { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// <inheritdoc cref="ILookup.LookupService"/> | ||
| /// </summary> | ||
| public ILookupService? LookupService { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// <inheritdoc cref="ITableColumn.OnCellRender"/> | ||
| /// </summary> | ||
| public Action<TableCellArgs>? OnCellRender { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// <inheritdoc cref="IEditorItem.ValidateRules"/> | ||
| /// </summary> | ||
| public List<IValidator>? ValidateRules { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// <inheritdoc cref="IEditorItem.GroupName"/> | ||
| /// </summary> | ||
| public string? GroupName { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// <inheritdoc cref="IEditorItem.GroupOrder"/> | ||
| /// </summary> | ||
| public int GroupOrder { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// <inheritdoc cref="IEditorItem.GetDisplayName"/> | ||
| /// </summary> | ||
| public string GetDisplayName() => Text; | ||
ArgoZhang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /// <summary> | ||
| /// <inheritdoc cref="IEditorItem.GetFieldName"/> | ||
| /// </summary> | ||
| public string GetFieldName() => FieldName; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.