Skip to content

Conversation

@gweesin
Copy link
Contributor

@gweesin gweesin commented Mar 3, 2025

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: #1601

What is the new behavior?

support using getTreeExpandeds to get all expanded records.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • New Features

    • Introduced an API method to retrieve expanded row data, enhancing grid functionality.
    • Added new interactive components that display hierarchical (tree) data with expand/collapse capabilities and modal feedback.
    • Provided a demo showcasing the usage of the new functionality.
  • Tests

    • Implemented an automated test to verify that tree node expansion updates the displayed count of expanded rows as expected.

@coderabbitai
Copy link

coderabbitai bot commented Mar 3, 2025

Walkthrough

This pull request introduces a new API method getTreeExpandeds to retrieve expanded row data in grid components. The addition appears in both the API definition and internal grid methods. New Vue components have been created to demonstrate tree grid functionality using this method, alongside a corresponding demo entry and a Playwright test verifying proper tree expansion behavior. The changes enhance how expanded rows are managed and displayed in both PC and mobile-first environments.

Changes

Files Change Summary
examples/.../apis/grid.js, packages/.../methods.ts Added new API method getTreeExpandeds that returns an array of expanded row objects with associated metadata.
examples/.../tree-table-tree-grid-expand-composition-api.vue, examples/.../tree-table-tree-grid-expand.vue Introduced new Vue components utilizing TinyGrid to implement a tree table, which call getTreeExpandeds on tree expansion events and display the count via TinyModal.
examples/.../tree-table-tree-grid-expand.spec.js Added Playwright test to verify tree node expansion and validate the count of expanded rows.
examples/.../grid-tree-table.js Added a new demo entry showcasing how to use the getTreeExpandeds method to retrieve expanded row data.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant G as Grid Component
    participant M as TinyModal

    U->>G: Toggle tree node expansion
    G->>G: Call getTreeExpandeds()
    G->>M: Display count of expanded rows
    M-->>U: Show updated modal message
Loading

Possibly related PRs

Suggested reviewers

  • zzcr
  • gimmyhehe

Poem

I'm a hopping rabbit, full of cheer,
New grid methods make our code so clear.
Expanded rows now jump into view,
TinyModal shows what they can do,
With every bound, our grids persevere!
🐇🌟

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

examples/sites/demos/pc/app/grid/webdoc/grid-tree-table.js

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-vue".

(The package "eslint-plugin-vue" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-vue@latest --save-dev

The plugin "eslint-plugin-vue" was referenced from the config file in ".eslintrc.js » @antfu/eslint-config » @antfu/eslint-config-vue".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6508533 and cea7f23.

📒 Files selected for processing (1)
  • examples/sites/demos/pc/app/grid/webdoc/grid-tree-table.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • examples/sites/demos/pc/app/grid/webdoc/grid-tree-table.js
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: PR E2E Test (pnpm test:e2e3)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the enhancement New feature or request (功能增强) label Mar 3, 2025
@petercat-assistant
Copy link

Walkthrough

This pull request introduces a new feature to the grid component by exposing the getTreeExpandeds function. This function allows users to retrieve all expanded records in a tree grid structure, enhancing the grid's functionality for handling hierarchical data.

Changes

File Summary
examples/sites/demos/apis/grid.js Added getTreeExpandeds function documentation.
examples/sites/demos/pc/app/grid/tree-table/tree-table-tree-grid-expand-composition-api.vue Added a new Vue component demonstrating the getTreeExpandeds function.
examples/sites/demos/pc/app/grid/tree-table/tree-table-tree-grid-expand.spec.js Added a test case to verify the expanded row count functionality.
examples/sites/demos/pc/app/grid/tree-table/tree-table-tree-grid-expand.vue Added a new Vue component demonstrating the getTreeExpandeds function.
examples/sites/demos/pc/app/grid/webdoc/grid-tree-table.js Updated documentation to include getTreeExpandeds method details.
packages/vue/src/grid/src/tree/src/methods.ts Implemented the getTreeExpandeds method to return expanded rows.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (4)
examples/sites/demos/pc/app/grid/tree-table/tree-table-tree-grid-expand.spec.js (1)

7-8: Consider adding more test cases for more complex tree structures.

The current test verifies a single expansion scenario. For more thorough testing, consider adding test cases that:

  1. Expand multiple nodes
  2. Collapse nodes
  3. Test nested tree structures with multiple levels
examples/sites/demos/pc/app/grid/tree-table/tree-table-tree-grid-expand.vue (3)

7-7: Consider improving the method naming.

The event handler name handTreeExpand should be handleTreeExpand to follow common naming conventions in JavaScript/Vue.

-      @toggle-tree-change="handTreeExpand"
+      @toggle-tree-change="handleTreeExpand"

148-155: Good implementation of the getTreeExpandeds function.

This handler demonstrates the newly exposed getTreeExpandeds() function, which is the primary purpose of this PR. The function retrieves an array of expanded rows and displays their count using a modal.

Two suggestions for improvement:

  1. Consider adding error handling in case the grid reference is not available.
  2. Method naming should match the event handler binding in the template.
-    handTreeExpand() {
+    handleTreeExpand() {
       let treeExpandeds = this.$refs.treeGrid.getTreeExpandeds()

       TinyModal.message({
         message: `展开行数:${treeExpandeds.length}`,
         status: 'info'
       })
     }

1-158: Consider adding i18n for UI strings.

The demo currently uses Chinese text for column titles and the modal message. For international users, consider adding support for internationalization or providing English translations in comments.

Also, adding some comments at the top of the file explaining the purpose of this demo (showcasing the getTreeExpandeds function) would improve documentation.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 67b9c48 and 6508533.

📒 Files selected for processing (6)
  • examples/sites/demos/apis/grid.js (1 hunks)
  • examples/sites/demos/pc/app/grid/tree-table/tree-table-tree-grid-expand-composition-api.vue (1 hunks)
  • examples/sites/demos/pc/app/grid/tree-table/tree-table-tree-grid-expand.spec.js (1 hunks)
  • examples/sites/demos/pc/app/grid/tree-table/tree-table-tree-grid-expand.vue (1 hunks)
  • examples/sites/demos/pc/app/grid/webdoc/grid-tree-table.js (1 hunks)
  • packages/vue/src/grid/src/tree/src/methods.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: PR E2E Test (pnpm test:e2e3)
🔇 Additional comments (12)
packages/vue/src/grid/src/tree/src/methods.ts (1)

125-127: New API method to retrieve expanded tree nodes added successfully.

This implementation looks good as it provides a simple accessor method to retrieve all expanded tree nodes from the current grid state. This aligns with the PR objective to expose this functionality to users.

examples/sites/demos/pc/app/grid/tree-table/tree-table-tree-grid-expand.spec.js (1)

1-9: Test for tree expansion functionality looks good.

The test effectively validates that:

  1. The tree node can be expanded by clicking the expansion icon
  2. The correct number of expanded rows is displayed after expansion

This provides good coverage for the new getTreeExpandeds functionality.

examples/sites/demos/pc/app/grid/webdoc/grid-tree-table.js (1)

99-109: Demo entry for the new functionality added correctly.

The demo entry is properly structured with appropriate ID, name, and description in both Chinese and English.

examples/sites/demos/apis/grid.js (1)

1695-1708: **Well-structured API addition for retrieving expanded tree data. **

The new getTreeExpandeds method is properly documented with correct type signature, stability version, descriptions in both Chinese and English, and appropriate mode support. This is a useful addition that allows users to programmatically access the expanded rows in a tree grid, which is essential for scenarios where you need to track or manipulate the expanded state.

examples/sites/demos/pc/app/grid/tree-table/tree-table-tree-grid-expand-composition-api.vue (4)

1-15: **Well-structured grid component implementation. **

The template is cleanly organized with appropriate props. The tree structure is correctly configured with the tree-config property and the tree-node attribute on the index column, which follows best practices for TinyVue grid tree tables.


17-20: **Proper imports with appropriate component granularity. **

The imports are correctly structured, importing only the necessary components from the @opentiny/vue package. Using the composition API setup script is a modern approach that aligns with Vue 3 best practices.


21-138: **Well-structured hierarchical data for tree grid demonstration. **

The data structure correctly models a hierarchical organization with companies and their subsidiaries, using the children property for nesting. Using a ref for the table data allows for reactivity if needed.


139-148: **Good demonstration of the new getTreeExpandeds API. **

This event handler effectively showcases the usage of the new getTreeExpandeds method. The feedback via a modal message provides clear visual confirmation of the method's functionality. This makes the example both practical and instructional.

One suggestion for enhancement would be to add basic error handling around the method call, though it's reasonable to omit it in a demo context.

examples/sites/demos/pc/app/grid/tree-table/tree-table-tree-grid-expand.vue (4)

1-15: Well-structured template implementing tree grid functionality.

The template effectively sets up a TinyGrid component with tree functionality. The reference (ref="treeGrid") is properly defined to access the grid instance in methods, and the tree-config is correctly configured to use the "children" property for hierarchical data. The tree-node attribute is appropriately applied to the index column.


18-18: Import statement looks good.

Proper imports from the @opentiny/vue package for the required components.


25-145: Well-structured hierarchical test data.

The test data effectively demonstrates a complex tree structure with multiple levels of nesting, which is ideal for showcasing the tree expansion functionality. The structure with id/pid relationships and nested children arrays provides a realistic demonstration case.


149-149: Effectively demonstrates the new getTreeExpandeds API.

The line properly showcases the new API being exposed by this PR, allowing retrieval of all expanded records in the tree grid. This implementation aligns perfectly with the PR objective to expose this functionality.

@zzcr zzcr merged commit 10f537f into opentiny:dev Mar 4, 2025
10 checks passed
@gweesin gweesin deleted the feat/tree-grid-fn branch March 4, 2025 03:56
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.

2 participants