-
Notifications
You must be signed in to change notification settings - Fork 306
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
support IEnumerable data lookup #4859
base: main
Are you sure you want to change the base?
Conversation
Thanks for your PR, @tiansfather. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
Reviewer's Guide by SourceryThis PR enhances the table column functionality by adding support for IEnumerable data lookup. The implementation modifies the RenderValue method to handle IEnumerable types, converting them to a List and implementing proper lookup value matching for collection types. Sequence diagram for RenderValue method with IEnumerablesequenceDiagram
participant ITableColumnExtensions
participant ITableColumn
participant Builder
participant IEnumerable
participant List
ITableColumnExtensions->>ITableColumn: GetItemValue(item)
alt Lookup is not null and val is IEnumerable
ITableColumnExtensions->>IEnumerable: GetEnumerator()
IEnumerable->>List: Add(Current)
ITableColumnExtensions->>ITableColumn: Lookup matching
alt Lookup matches found
ITableColumnExtensions->>Builder: RenderTooltip(matched Text)
else No matches
ITableColumnExtensions->>Builder: RenderTooltip(enumeratorDatas)
end
else Lookup is not null and val is not IEnumerable
ITableColumnExtensions->>ITableColumn: Lookup matching
alt Lookup match found
ITableColumnExtensions->>Builder: RenderTooltip(matched Text)
end
end
Class diagram for ITableColumnExtensions changesclassDiagram
class ITableColumnExtensions {
+List<IFilterAction> ToSearches(IEnumerable<ITableColumn> columns)
+RenderFragment RenderValue<TItem>(ITableColumn col, TItem item)
}
ITableColumnExtensions : RenderValue<TItem> --> GetEnumeratorDatas
class GetEnumeratorDatas {
+List<object> GetEnumeratorDatas(IEnumerable enumerableObj)
}
class ITableColumn {
+object GetItemValue(TItem item)
+RenderFragment RenderTooltip(string text, TItem item)
+Type PropertyType
+IEnumerable<LookupItem> Lookup
+StringComparison LookupStringComparison
}
class LookupItem {
+string Value
+string Text
}
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey @tiansfather - I've reviewed your changes - here's some feedback:
Overall Comments:
- Please fill out the PR template completely, including summary, bug number, and risk assessment. This helps with tracking and reviewing changes.
- Consider using LINQ methods (like .ToList()) instead of manual enumeration in GetEnumeratorDatas. This would be more efficient and idiomatic C#.
Here's what I looked at during the review
- 🟡 General issues: 2 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
// 转化 Lookup 数据源 | ||
var lookupVal = col.Lookup.FirstOrDefault(l => l.Value.Equals(val.ToString(), col.LookupStringComparison)); | ||
if (lookupVal != null) | ||
if ((Nullable.GetUnderlyingType(col.PropertyType) ?? col.PropertyType).IsGenericType && val is IEnumerable v) |
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.
suggestion: Repeated type checking logic could be simplified
Extract the type checking expression into a local variable to avoid repetition and improve readability.
// 转化 Lookup 数据源 | |
var lookupVal = col.Lookup.FirstOrDefault(l => l.Value.Equals(val.ToString(), col.LookupStringComparison)); | |
if (lookupVal != null) | |
if ((Nullable.GetUnderlyingType(col.PropertyType) ?? col.PropertyType).IsGenericType && val is IEnumerable v) | |
// 转化 Lookup 数据源 | |
var isNullableGenericEnumerable = (Nullable.GetUnderlyingType(col.PropertyType) ?? col.PropertyType).IsGenericType; | |
if (isNullableGenericEnumerable && val is IEnumerable v) |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4859 +/- ##
===========================================
- Coverage 100.00% 99.98% -0.02%
===========================================
Files 623 623
Lines 27832 27875 +43
Branches 3982 3983 +1
===========================================
+ Hits 27832 27871 +39
- Misses 0 4 +4 ☔ View full report in Codecov by Sentry. |
{PR title}
Summary of the changes (Less than 80 chars)
Description
fixes #{bug number} (in this specific format)
Regression?
[If yes, specify the version the behavior has regressed from]
[是否影响老版本]
Risk
[Justify the selection above]
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Add support for IEnumerable data lookup in table columns by converting IEnumerable types to List for lookup matching, and enhance the RenderValue method to handle these types effectively.
New Features:
Enhancements: