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: useVxeTable returns formApi instance #4582

Merged
merged 1 commit into from
Oct 7, 2024
Merged

feat: useVxeTable returns formApi instance #4582

merged 1 commit into from
Oct 7, 2024

Conversation

anncwb
Copy link
Collaborator

@anncwb anncwb commented Oct 7, 2024

Description

resolve #4581

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Checklist

ℹ️ Check all checkboxes - this will indicate that you have done everything in accordance with the rules in CONTRIBUTING.

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs:dev command.
  • Run the tests with pnpm test.
  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Summary by CodeRabbit

  • New Features

    • Introduced ExtendedFormApi type for enhanced form API management.
    • Updated grid mounting process to include form API integration.
  • Bug Fixes

    • Added warning for deprecated formConfig in grid options, promoting the use of formOptions.
  • Chores

    • Updated several package versions to ensure current dependencies and improve overall stability.

@anncwb anncwb added the enhancement New feature or request label Oct 7, 2024
Copy link

changeset-bot bot commented Oct 7, 2024

⚠️ No Changeset found

Latest commit: 4f4ad99

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented Oct 7, 2024

Walkthrough

The changes in this pull request introduce enhancements to the form and grid interaction within the application. Key modifications include the addition of the ExtendedFormApi type export, updates to the VxeGridApi class for improved form API integration, and adjustments to the use-vxe-grid.vue component to reflect these changes. Additionally, several package versions have been updated in the pnpm-workspace.yaml file to maintain current dependencies.

Changes

File Path Change Summary
packages/@core/ui-kit/form-ui/src/index.ts Added export for ExtendedFormApi type.
packages/effects/plugins/src/vxe-table/api.ts Introduced formApi property and modified mount method to accept formApi as a parameter.
packages/effects/plugins/src/vxe-table/use-vxe-grid.vue Updated mount method call to include formApi and added a warning for deprecated formConfig.
pnpm-workspace.yaml Updated package versions for several dependencies and made minor whitespace adjustments.

Assessment against linked issues

Objective Addressed Explanation
Provide API to operate on forms in useVbenVxeGrid (#4581)

Possibly related PRs

Suggested labels

feature

Suggested reviewers

  • vince292007

🐇 In the meadow, hopping with glee,
A new form API, as bright as can be!
With grids and forms, a dance so fine,
Together they flourish, in perfect line.
Hooray for the changes, let’s all cheer,
For smoother interactions, we hold dear! 🌼


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 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.

Copy link
Contributor

@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: 0

🧹 Outside diff range and nitpick comments (3)
packages/effects/plugins/src/vxe-table/api.ts (2)

29-31: LGTM with suggestion: New stateHandler and formApi properties

The addition of the private stateHandler property and the public formApi property aligns well with the PR objectives. However, consider initializing formApi as null or undefined instead of an empty object to avoid potential runtime errors if methods are called before proper initialization.

- public formApi = {} as ExtendedFormApi;
+ public formApi: ExtendedFormApi | null = null;

This change would make it clearer when formApi is not yet initialized and allow for safer usage throughout the class.


58-64: LGTM with suggestion: Updated mount method

The update to the mount method, including the new formApi parameter, aligns well with the PR objectives. The assignment of formApi to the class property is correct, and the use of the isMounted flag prevents multiple mounting.

For improved type safety, consider updating the method signature to reflect that formApi is required:

- mount(instance: null | VxeGridInstance, formApi: ExtendedFormApi) {
+ mount(instance: VxeGridInstance, formApi: ExtendedFormApi) {

This change ensures that instance is always provided and not null, which seems to be the intended usage based on the method body.

packages/effects/plugins/src/vxe-table/use-vxe-grid.vue (1)

Line range hint 1-290: Consider updating documentation for enhanced form capabilities

The existing implementation in this file already includes robust form-handling capabilities, such as:

  1. The useTableForm hook for initializing the form API.
  2. The vbenFormOptions computed property that sets up form behavior, including handleSubmit and handleReset methods.
  3. Form-related slots and bindings in the template.

These features, combined with the recent change to pass formApi to the mount method, provide a comprehensive solution for form operations within the grid component. This aligns well with the PR objectives and addresses the issues raised in #4581.

To ensure developers are aware of these capabilities:

Consider updating the component's documentation to highlight:

  1. The availability of formApi for manual form operations.
  2. The built-in methods for form submission and reset.
  3. How to leverage these features to address scenarios like clearing form values and reloading the grid with current form values.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 60c615c and 4f4ad99.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (4)
  • packages/@core/ui-kit/form-ui/src/index.ts (1 hunks)
  • packages/effects/plugins/src/vxe-table/api.ts (3 hunks)
  • packages/effects/plugins/src/vxe-table/use-vxe-grid.vue (1 hunks)
  • pnpm-workspace.yaml (3 hunks)
🧰 Additional context used
🔇 Additional comments (10)
packages/@core/ui-kit/form-ui/src/index.ts (1)

3-8: LGTM: Addition of ExtendedFormApi export aligns with PR objectives.

The addition of ExtendedFormApi to the exported types is consistent with the PR's goal of providing an API to operate on forms. This change makes the new form API type available to consumers of this module, which is a necessary step in implementing the enhanced form functionality described in the PR objectives.

A few points to consider:

  1. The naming convention (ExtendedFormApi) suggests that this type extends an existing form API. This aligns well with the PR's intention to provide additional form operations.
  2. By exporting this type, you're making it part of the public API. Ensure that the type is well-documented and that you're committed to maintaining its interface in future versions.
  3. The change is minimal and non-breaking, which is in line with the PR author's assertion that there are no breaking changes.

To ensure that the ExtendedFormApi type is properly defined and exported, let's verify its implementation:

packages/effects/plugins/src/vxe-table/api.ts (3)

1-1: LGTM: Import statement for ExtendedFormApi

The import of ExtendedFormApi from '@vben-core/form-ui' is appropriate and aligns with the PR objectives to provide an API for form operations.


27-28: LGTM: Addition of private isMounted property

The addition of the private isMounted property is a good practice. It helps prevent multiple mounting of the grid API and improves the overall robustness of the class.


Line range hint 1-124: Overall assessment: Well-implemented feature with minor suggestions

The changes in this file successfully implement the form API functionality as outlined in the PR objectives. The code maintains good practices such as proper encapsulation and clear method signatures. The suggestions provided are minor and aimed at improving type safety and preventing potential runtime errors.

Key points:

  1. The addition of the ExtendedFormApi import and formApi property aligns with the PR goals.
  2. The isMounted flag improves the robustness of the class.
  3. The updated mount method correctly integrates the form API.

Consider implementing the suggested improvements to further enhance the code quality and type safety.

pnpm-workspace.yaml (5)

28-28: LGTM: Minor version update for '@intlify/core-base'

The update from '^10.0.3' to '^10.0.4' for '@intlify/core-base' is a minor version bump, which typically includes backwards-compatible bug fixes. This change is in line with good practices for keeping dependencies up-to-date.


77-77: LGTM: Patch version update for 'cz-git'

The update from '^1.10.0' to '^1.10.1' for 'cz-git' is a patch version bump, which typically includes backwards-compatible bug fixes. This change is in line with good practices for keeping dependencies up-to-date.


78-78: LGTM: Consistent patch version update for 'czg'

The update from '^1.10.0' to '^1.10.1' for 'czg' is a patch version bump, consistent with the 'cz-git' update. This change maintains version consistency between related packages and follows good practices for keeping dependencies up-to-date.


Line range hint 1-179: Summary: Package version updates are appropriate and consistent

The changes in this file consist of minor and patch version updates for several packages. These updates are in line with good practices for keeping dependencies up-to-date and maintaining consistency across related packages. No issues were found that would prevent merging these changes.

However, please ensure that the updates for 'vue-i18n' and 'vxe-pc-ui' mentioned in the AI summary are verified and correctly implemented in the file.


173-173: Verify additional package updates mentioned in the summary

The AI-generated summary mentions two additional package updates that are not highlighted in the annotated code:

  1. 'vue-i18n' updated from '^10.0.3' to '^10.0.4' (line 173)
  2. 'vxe-pc-ui' updated from '^4.2.14' to '^4.2.15' (line 176)

These updates follow the same pattern of minor version bumps as the other changes in this file. While they appear to be in line with good practices, please verify that these changes are intentional and correctly implemented in the file.

To confirm these changes, you can run the following command:

Also applies to: 176-176

✅ Verification successful

Package updates correctly implemented

The 'vue-i18n' package has been updated to ^10.0.4 (line 173) and 'vxe-pc-ui' has been updated to ^4.2.15 (line 176) as mentioned in the summary. These minor version updates are correctly implemented.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify the additional package updates
grep -n "vue-i18n\|vxe-pc-ui" pnpm-workspace.yaml

Length of output: 142

packages/effects/plugins/src/vxe-table/use-vxe-grid.vue (1)

220-220: LGTM: Enhanced grid-form integration

The addition of formApi as a second argument to the mount method call is a positive change. This modification aligns well with the PR objectives, specifically addressing the need for an API to operate on forms within the useVbenVxeGrid functionality. It enhances the integration between the grid and form components, potentially resolving the issue of clearing form values when overriding the default reset behavior.

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.

FEATURE: useVbenVxeGrid提供操作表单的api
1 participant