elixir-cloud-aai / cloud-components

Reusable components for the ELIXIR Cloud
https://cloud-components.2.rahtiapp.fi/
Apache License 2.0
8 stars 14 forks source link

Refactor/improve mod form change events #365

Closed SalihuDickson closed 1 month ago

SalihuDickson commented 1 month ago

Description

Fixes #(issue)

Checklist

Comments

Summary by Sourcery

Refactor the form component to improve change event handling by centralizing event dispatch logic into a new method. Remove unused utility files and update the build script and documentation to reflect these deletions.

Enhancements:

Build:

Documentation:

Chores:

vercel[bot] commented 1 month ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
elixir-cloud-components 🔄 Building (Inspect) Visit Preview 💬 Add feedback Oct 12, 2024 6:49pm
changeset-bot[bot] commented 1 month ago

⚠️ No Changeset found

Latest commit: 6e9dfd5c2651a76ccd9a5858ec29edae8cf58b07

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

sourcery-ai[bot] commented 1 month ago

Reviewer's Guide by Sourcery

This pull request refactors and improves the form change events in the EccUtilsDesignForm component. It introduces a new method for dispatching change events, removes redundant code, and updates the handling of various form field types. Additionally, it removes utilities-related files and references.

Sequence diagram for form field change event handling

sequenceDiagram
    participant User
    participant Form as EccUtilsDesignForm
    participant Event as CustomEvent

    User->>Form: Change form field
    Form->>Form: alertFieldChange(key, value)
    Form->>Event: Dispatch "ecc-utils-change" event
    Event-->>Form: Event bubbles up
    Event-->>User: Notify change event

Updated class diagram for EccUtilsDesignForm

classDiagram
    class EccUtilsDesignForm {
        +alertFieldChange(key: string, value: any)
        +renderSwitchTemplate(field: Field, path: string): TemplateResult
        +requestUpdate()
        -form: any
    }
    note for EccUtilsDesignForm "Refactored to use alertFieldChange for event dispatching"

File-Level Changes

Change Details Files
Introduced a new method for dispatching form change events
  • Added a new private method 'alertFieldChange' to handle event dispatching
  • Updated existing change handlers to use the new 'alertFieldChange' method
  • Removed redundant event dispatching code from various form field handlers
packages/ecc-utils-design/src/components/form/form.ts
Improved handling of select field changes
  • Updated the select field change handler to trim the selected option's text content
  • Changed the value passed to the change event from the select element's value to the trimmed label
packages/ecc-utils-design/src/components/form/form.ts
Removed utilities-related files and references
  • Removed 'utilities' entry from the design documentation meta file
  • Removed import and export of utilities from the main index file
  • Removed utilities from the build script
  • Deleted utilities.mdx documentation file
  • Deleted utilities-related TypeScript files
apps/documentation/pages/design/_meta.json
packages/ecc-utils-design/src/index.ts
scripts/build.js
apps/documentation/pages/design/utilities.mdx
packages/ecc-utils-design/src/utilities/general.ts
packages/ecc-utils-design/src/utilities/index.ts

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](https://app.sourcery.ai) 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 - [Contact our support team](mailto:support@sourcery.ai) for questions or feedback. - Visit our [documentation](https://docs.sourcery.ai) for detailed guides and information. - Keep in touch with the Sourcery team by following us on [X/Twitter](https://x.com/SourceryAI), [LinkedIn](https://www.linkedin.com/company/sourcery-ai/) or [GitHub](https://github.com/sourcery-ai).