Skip to content

Make conditional logic dropdown options label/value update with field options#1601

Merged
Crabcyborg merged 26 commits into
masterfrom
issue-2911-fix_conditional_logic_option
Aug 7, 2024
Merged

Make conditional logic dropdown options label/value update with field options#1601
Crabcyborg merged 26 commits into
masterfrom
issue-2911-fix_conditional_logic_option

Conversation

@AbdiTolesa
Copy link
Copy Markdown
Contributor

@AbdiTolesa AbdiTolesa commented Apr 1, 2024

Fix https://github.com/Strategy11/formidable-pro/issues/2911
Requires https://github.com/Strategy11/formidable-pro/pull/4940

Test steps

  1. Create a new form with a radio button field. Check 'Use separate values'.
  2. Add a conditional field based off of the radio.
  3. Update the the radio options to something else, including the option used in the conditional logic in (2).
  4. The conditional logic value options should be updated to reflect the change.
  5. Confirm that the field labels and values are mapped to the conditional logic dropdown correctly

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 1, 2024

Walkthrough

The recent update significantly enhances the management of choice values and labels in a JavaScript file by introducing new helper functions for improved data manipulation. These changes streamline the retrieval of old and new values or labels and include a function to fetch conditional logic options based on field IDs. Overall, these enhancements improve the usability and functionality of the form management interface.

Changes

File Change Summary
js/formidable_admin.js Enhanced onOptionTextBlur for better handling of choice values and labels with new helper functions (getChoiceOldAndNewValues, getChoiceOldValueAndLabel, getChoiceNewValueAndLabel). Introduced getNewConditionalLogicOption for fetching conditional logic options by field IDs. Modified prependValueSelectWithOptionMatch to accept new parameters for dynamic option management.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Form as Form Management
    participant Helper as Helper Functions

    User->>Form: Modify option text
    Form->>Helper: Call getChoiceOldAndNewValues
    Helper-->>Form: Return old/new values
    Form->>Helper: Call getChoiceOldValueAndLabel
    Helper-->>Form: Return old label
    Form->>Helper: Call getChoiceNewValueAndLabel
    Helper-->>Form: Return new label
    Form->>Form: Update option if necessary
    Form->>User: Reflect changes in UI
Loading

Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ceddb1f and 6971564.

Files selected for processing (1)
  • js/formidable_admin.js (10 hunks)
Files skipped from review as they are similar to previous changes (1)
  • js/formidable_admin.js

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

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

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.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 29.60%. Comparing base (7034b2b) to head (7baad48).
Report is 111 commits behind head on master.

❗ Current head 7baad48 differs from pull request most recent head 96bef34. Consider uploading reports for the commit 96bef34 to get more accurate results

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1601      +/-   ##
============================================
+ Coverage     29.55%   29.60%   +0.05%     
- Complexity     7821     7860      +39     
============================================
  Files           119      121       +2     
  Lines         25762    25952     +190     
============================================
+ Hits           7613     7683      +70     
- Misses        18149    18269     +120     

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

@Strategy11 Strategy11 deleted a comment from coderabbitai Bot Apr 1, 2024
@AbdiTolesa AbdiTolesa changed the title Make conditional logic dropdown in sync with options Make conditional logic dropdown options label/value update with field options Apr 1, 2024
@AbdiTolesa AbdiTolesa requested a review from garretlaxton April 1, 2024 13:52
Copy link
Copy Markdown

@garretlaxton garretlaxton left a comment

Choose a reason for hiding this comment

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

This works great! The conditional logic dropdowns show the updated field values.

@Crabcyborg Crabcyborg requested a review from truongwp April 2, 2024 13:00
Comment thread js/formidable_admin.js Outdated
Comment thread js/formidable_admin.js Outdated
@AbdiTolesa AbdiTolesa requested a review from truongwp April 3, 2024 08:44
@truongwp
Copy link
Copy Markdown
Contributor

truongwp commented Apr 3, 2024

@AbdiTolesa I got 2 problems:

  1. When adding a new option, I change the label, but it isn't updated in the conditional logic.
  2. When deleting an option, it isn't removed in the conditional logic.

Please see my screen recording:

Screen.Recording.2024-04-03.at.20.14.12.mov

@AbdiTolesa
Copy link
Copy Markdown
Contributor Author

AbdiTolesa commented Apr 3, 2024

@AbdiTolesa I got 2 problems:

  1. When adding a new option, I change the label, but it isn't updated in the conditional logic.
  2. When deleting an option, it isn't removed in the conditional logic.

@truongwp Thanks for catching those issues! They are both fixed now if you can check again.
UPDATE: I just found one issue and working on it, so please hold from checking this again for now.

@truongwp I have updated this code to handle some edge cases and I believe it could use your review now. Thank you in adavance!

Comment thread js/formidable_admin.js Outdated
Comment thread js/formidable_admin.js Outdated
Comment thread js/formidable_admin.js
Comment thread js/formidable_admin.js
@AbdiTolesa
Copy link
Copy Markdown
Contributor Author

@AbdiTolesa I think we'll need to update this PR now.

Your other PR (#1894) also updates this code.

I just merged that other PR.

When you have the chance, can you work on fixing the merge conflict here?

Thank you!

@Crabcyborg I have fixed the merge conflict now.

Copy link
Copy Markdown
Contributor

@Crabcyborg Crabcyborg left a comment

Choose a reason for hiding this comment

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

Thanks @AbdiTolesa @truongwp and @garretlaxton for working on this!

I think this is good to merge now.

🚀

@Crabcyborg Crabcyborg merged commit 0adce64 into master Aug 7, 2024
@Crabcyborg Crabcyborg deleted the issue-2911-fix_conditional_logic_option branch August 7, 2024 17:39
@coderabbitai coderabbitai Bot mentioned this pull request Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants