Skip to content
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

feat(Select): add LookupService parameter #4898

Merged
merged 7 commits into from
Dec 20, 2024
Merged

feat(Select): add LookupService parameter #4898

merged 7 commits into from
Dec 20, 2024

Conversation

ArgoZhang
Copy link
Collaborator

@ArgoZhang ArgoZhang commented Dec 20, 2024

add LookupService parameter

Summary of the changes (Less than 80 chars)

简单描述你更改了什么, 不超过80个字符;如果有关联 Issue 请在下方填写相关编号

Description

fixes #4897

Regression?

  • Yes
  • No

[If yes, specify the version the behavior has regressed from]

[是否影响老版本]

Risk

  • High
  • Medium
  • Low

[Justify the selection above]

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Add a LookupService parameter to the Select component to allow it to fetch data from a lookup service.

New Features:

  • Allow the Select component to use a lookup service to populate its options.

Tests:

  • Add tests for the lookup service key.

Copy link

sourcery-ai bot commented Dec 20, 2024

Reviewer's Guide by Sourcery

This pull request introduces a new LookupService parameter to the Select component, allowing developers to use a lookup service to populate the select options. This change simplifies the process of binding select options to data from external sources. The Utility.cs file was updated to handle the new parameter, and the EditorForm and Table components were modified to use the new functionality. Additionally, the IEditorItemExtensions class was extended with a new method to determine if an item is of lookup type.

Sequence diagram for Select component data loading with LookupService

sequenceDiagram
    participant Select as Select Component
    participant LS as LookupService
    Note over Select: OnParametersSetAsync
    alt LookupService is provided
        Select->>LS: GetItemsByKeyAsync(LookupServiceKey, LookupServiceData)
        LS-->>Select: Returns SelectedItems[]
    else No LookupService
        Note over Select: Returns empty array
    end
    Note over Select: Update Items collection
Loading

File-Level Changes

Change Details Files
Added LookupService parameter to Select component.
  • Added LookupService, LookupServiceKey, and LookupServiceData parameters to the SelectBase component.
  • Modified the Select component to use the provided LookupService or the default one if available.
  • Updated Utility.cs to support the new LookupService parameter in the CreateComponentByFieldType method.
  • Modified EditorForm and Table components to utilize the new lookup service functionality.
  • Added IsLookup extension method to IEditorItemExtensions.
  • Removed loading spinner from EditorForm.razor as lookup data is now fetched asynchronously.
  • Added test cases for the new lookup service functionality in EditorFormTest.cs.
src/BootstrapBlazor/Components/Select/SelectBase.cs
src/BootstrapBlazor/Components/Select/Select.razor.cs
src/BootstrapBlazor/Utils/Utility.cs
src/BootstrapBlazor/Components/EditorForm/EditorForm.razor.cs
src/BootstrapBlazor/Components/Table/Table.razor.cs
src/BootstrapBlazor/Components/EditorForm/EditorForm.razor
src/BootstrapBlazor/Extensions/IEditorItemExtensions.cs
test/UnitTest/Components/EditorFormTest.cs
Refactored item generation logic.
  • Simplified the GenerateComponentType method in Utility.cs to determine the component type based on the IEditorItem.
  • Moved the logic for generating items from OnAfterRenderAsync to OnParametersSetAsync in the Select component and updated the GetItemsAsync method to fetch items using the lookup service if available.
src/BootstrapBlazor/Utils/Utility.cs
src/BootstrapBlazor/Components/Select/Select.razor.cs
Improved handling of nullable boolean select components.
  • Updated the condition for rendering nullable boolean select components to consider the IsLookup status of the item.
src/BootstrapBlazor/Utils/Utility.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#4897 Add LookupService parameter to Select component

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@bb-auto bb-auto bot added the enhancement New feature or request label Dec 20, 2024
@bb-auto bb-auto bot added this to the v9.0.0 milestone Dec 20, 2024
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @ArgoZhang - I've reviewed your changes - here's some feedback:

Overall Comments:

  • The loading spinner markup is still present but its visibility control was removed. This could cause the spinner to be permanently visible - consider either implementing proper visibility control or removing the spinner markup entirely.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟡 Testing: 1 issue found
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

test/UnitTest/Components/EditorFormTest.cs Show resolved Hide resolved
Copy link

codecov bot commented Dec 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (c4901f2) to head (ee1f5f5).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #4898   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          624       624           
  Lines        27872     27870    -2     
  Branches      4003      4001    -2     
=========================================
- Hits         27872     27870    -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ArgoZhang ArgoZhang merged commit efb2508 into main Dec 20, 2024
5 checks passed
@ArgoZhang ArgoZhang deleted the refactor-look branch December 20, 2024 03:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(Select): add LookupService parameter
1 participant