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: form progress bar #334

Merged
merged 4 commits into from
Mar 18, 2024
Merged

feat: form progress bar #334

merged 4 commits into from
Mar 18, 2024

Conversation

madassdev
Copy link
Collaborator

@madassdev madassdev commented Mar 4, 2024

Summary by CodeRabbit

  • New Features
    • Enhanced form user experience with a dynamic progress bar to show completion status of required fields.
    • Added a new customization option in the form for toggling the display of the progress bar.
    • Short summary

@madassdev madassdev requested a review from JhumanJ March 4, 2024 08:06
Copy link
Contributor

coderabbitai bot commented Mar 4, 2024

Walkthrough

The update introduces a dynamic progress bar to enhance user experience in the OpenForm.vue component, visually indicating the completion status of required fields within the form. This real-time feedback mechanism encourages form completion by showing users their progress.

Changes

File(s) Summary
app/Http/Requests/UserFormRequest.php Updated with a new validation rule for the 'show_progress_bar' functionality.
app/Models/Forms/Form.php
client/components/open/forms/components/form-components/FormCustomization.vue
Added attribute and component support for 'show_progress_bar'.
client/components/open/forms/OpenForm.vue Updated to display a progress bar based on completed required fields.
database/migrations/2024_03_12_173732_show_progress_bar.php Added migration for the show_progress_bar column in the forms table.

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>.
    • Generate unit-tests 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 tests 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

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.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 30587fb and e7bb91f.
Files selected for processing (1)
  • client/components/open/forms/OpenForm.vue (2 hunks)
Additional comments: 1
client/components/open/forms/OpenForm.vue (1)
  • 168-176: The formProgress computed property efficiently calculates the completion progress of required fields in the form. It filters required fields, checks for completed fields, and calculates the progress percentage. This logic is clear and concise. However, ensure that this.dataFormValue[field.nf_id] accurately reflects the current state of the form inputs, especially for complex input types (e.g., checkboxes, radio buttons) that might not directly map to a simple string value. If there are custom input components or complex data structures, additional handling might be necessary to accurately determine if a field is "completed."

Copy link
Owner

@JhumanJ JhumanJ left a comment

Choose a reason for hiding this comment

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

@madassdev we don't have an option to set form.show_progress_bar to true... And the form Model doesn't have the property. Please make sure to:

  • add the property do the DB model
  • add the property to the model
  • Add validation to userFormRequest
  • add the front-end toggle in form editor to enable and disable this

Copy link
Owner

@JhumanJ JhumanJ left a comment

Choose a reason for hiding this comment

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

@madassdev we don't have an option to set form.show_progress_bar to true... And the form Model doesn't have the property. Please make sure to:

  • add the property do the DB model
  • add the property to the model
  • Add validation to userFormRequest
  • add the front-end toggle in form editor to enable and disable this

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.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between e7bb91f and eb230f0.
Files selected for processing (5)
  • app/Http/Requests/UserFormRequest.php (1 hunks)
  • app/Models/Forms/Form.php (1 hunks)
  • client/components/open/forms/OpenForm.vue (2 hunks)
  • client/components/open/forms/components/form-components/FormCustomization.vue (1 hunks)
  • database/migrations/2024_03_12_173732_show_progress_bar.php (1 hunks)
Additional comments: 4
database/migrations/2024_03_12_173732_show_progress_bar.php (1)
  • 1-32: The migration file for adding the show_progress_bar column to the forms table is correctly implemented, following Laravel's best practices. The choice of a boolean type with a default value enhances data integrity, and the inclusion of a down method to reverse the migration is commendable.
client/components/open/forms/components/form-components/FormCustomization.vue (1)
  • 62-64: The addition of the toggle-switch-input component for enabling the "Show progress bar" feature in form customization is well-implemented. It follows the established pattern of using reusable components for form customization options, ensuring a consistent user experience.
app/Http/Requests/UserFormRequest.php (1)
  • 75-75: The addition of the validation rule for show_progress_bar as a boolean is correctly implemented. It ensures data integrity and proper handling of the attribute in form submissions, following Laravel's validation conventions.
app/Models/Forms/Form.php (1)
  • 95-95: The addition of the show_progress_bar attribute to the $fillable array in the Form model is correctly implemented. It enables mass assignment for this attribute, following Laravel's best practices for model security and data handling.

Comment on lines +8 to +24
<template v-if='form.show_progress_bar'>
<div v-if='isIframe' class='mb-4 p-2'>
<div class='w-full h-2 bg-gray-200 dark:bg-gray-600 relative border rounded-full overflow-hidden'>
<div class='h-full transition-all duration-300 rounded-r-full'
:class="{ 'w-0': formProgress === 0 }"
:style="{ width: formProgress + '%', background: form.color }"
/>
</div>
</div>
<div v-else class='fixed top-0 left-0 right-0 z-50'>
<div class='w-full h-[0.2rem] bg-gray-200 dark:bg-gray-600 relative overflow-hidden'>
<div class='h-full transition-all duration-300'
:class="{ 'w-0': formProgress === 0 }"
:style="{ width: formProgress + '%', background: form.color }"
/>
</div>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

The implementation of the dynamic progress bar in OpenForm.vue is well-executed, with conditional rendering based on form.show_progress_bar and isIframe. The formProgress computed property correctly calculates the progress percentage, enhancing the user experience by providing visual feedback on form completion status.

However, to improve accessibility for users relying on screen readers, consider adding accessibility attributes such as role="progressbar" and aria-valuenow, aria-valuemin, aria-valuemax to the progress bar elements.

+ <div role="progressbar" aria-valuenow="formProgress" aria-valuemin="0" aria-valuemax="100" class='h-full transition-all duration-300 rounded-r-full'
+      :class="{ 'w-0': formProgress === 0 }"
+      :style="{ width: formProgress + '%', background: form.color }">

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
<template v-if='form.show_progress_bar'>
<div v-if='isIframe' class='mb-4 p-2'>
<div class='w-full h-2 bg-gray-200 dark:bg-gray-600 relative border rounded-full overflow-hidden'>
<div class='h-full transition-all duration-300 rounded-r-full'
:class="{ 'w-0': formProgress === 0 }"
:style="{ width: formProgress + '%', background: form.color }"
/>
</div>
</div>
<div v-else class='fixed top-0 left-0 right-0 z-50'>
<div class='w-full h-[0.2rem] bg-gray-200 dark:bg-gray-600 relative overflow-hidden'>
<div class='h-full transition-all duration-300'
:class="{ 'w-0': formProgress === 0 }"
:style="{ width: formProgress + '%', background: form.color }"
/>
</div>
</div>
<template v-if='form.show_progress_bar'>
<div v-if='isIframe' class='mb-4 p-2'>
<div class='w-full h-2 bg-gray-200 dark:bg-gray-600 relative border rounded-full overflow-hidden'>
<div role="progressbar" aria-valuenow="formProgress" aria-valuemin="0" aria-valuemax="100" class='h-full transition-all duration-300 rounded-r-full'
:class="{ 'w-0': formProgress === 0 }"
:style="{ width: formProgress + '%', background: form.color }">
</div>
</div>
</div>
<div v-else class='fixed top-0 left-0 right-0 z-50'>
<div class='w-full h-[0.2rem] bg-gray-200 dark:bg-gray-600 relative overflow-hidden'>
<div role="progressbar" aria-valuenow="formProgress" aria-valuemin="0" aria-valuemax="100" class='h-full transition-all duration-300'
:class="{ 'w-0': formProgress === 0 }"
:style="{ width: formProgress + '%', background: form.color }">
</div>
</div>
</div>

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between eb230f0 and b9ad20b.
Files selected for processing (1)
  • database/migrations/2024_03_12_173732_show_progress_bar.php (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • database/migrations/2024_03_12_173732_show_progress_bar.php

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between b9ad20b and 02746ab.
Files selected for processing (1)
  • app/Http/Requests/UserFormRequest.php (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • app/Http/Requests/UserFormRequest.php

@JhumanJ JhumanJ merged commit 2420012 into main Mar 18, 2024
5 checks passed
@JhumanJ JhumanJ deleted the 4ce61-progress-bar- branch March 18, 2024 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants