CRM: Fix Contact List Rendering in Local Dev Environment#47437
CRM: Fix Contact List Rendering in Local Dev Environment#47437
Conversation
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
There was a problem hiding this comment.
Pull request overview
Fixes a JavaScript syntax error in Jetpack CRM list view output that breaks rendering in local dev (Studio/symlinked setups), ensuring Contacts/Transactions/Invoices lists can load correctly.
Changes:
- Consolidates a PHP-generated JS string (
zbsObjectEmailLinkPrefix) into a single-line assignment to avoid invalid JS. - Applies stricter comparisons (
===) in several conditionals (mostly formatting/lint-driven). - Adds a CRM changelog entry for the patch fix.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
projects/plugins/crm/includes/ZeroBSCRM.List.php |
Fixes the broken JS string output and includes several lint/formatting updates in list view rendering logic. |
projects/plugins/crm/changelog/fix-crm-error-in-local-dev |
Adds a patch-level changelog note describing the list rendering fix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| $currentColumns = $customViews[ $this->objType ]; | ||
| } | ||
| if ( $currentColumns == false ) { | ||
| if ( $currentColumns === false ) { |
There was a problem hiding this comment.
Switching this fallback check to a strict === false changes behavior when $customViews[$this->objType] is an empty array. The AJAX column-save paths can persist an empty array when the user saves with no columns selected, and with this change the list view would keep [] instead of falling back to $defaultColumns, potentially rendering an empty/broken table. Consider treating an empty array the same as false here (e.g., fall back when empty($currentColumns) or when it’s not a non-empty array).
| if ( $currentColumns === false ) { | |
| // Fall back to default columns when no valid, non-empty column configuration is available. | |
| if ( ! is_array( $currentColumns ) || empty( $currentColumns ) ) { |
| foreach ( $tags as $t ) { | ||
| $simple_tags[] = array( | ||
| 'id' => $t['id'], | ||
| 'name' => $t['name'], | ||
| 'slug' => $t['slug'], | ||
| ); |
There was a problem hiding this comment.
The indentation in this if ( is_array( $tags ) ... ) block looks off (the foreach and its body aren’t indented under the if). Even though it still parses, it makes the PHP/JS mixed block harder to read and increases the risk of misreading brace scope during future edits. Please re-indent this block to reflect the actual nesting.
| foreach ( $tags as $t ) { | |
| $simple_tags[] = array( | |
| 'id' => $t['id'], | |
| 'name' => $t['name'], | |
| 'slug' => $t['slug'], | |
| ); | |
| foreach ( $tags as $t ) { | |
| $simple_tags[] = array( | |
| 'id' => $t['id'], | |
| 'name' => $t['name'], | |
| 'slug' => $t['slug'], | |
| ); |
| if ( is_array( $zbsCustomerFields['status'][3] ) ) { | ||
| echo wp_json_encode( $zbsCustomerFields['status'][3] ); | ||
| echo wp_json_encode( $zbsCustomerFields['status'][3] ); | ||
| } else { | ||
| echo '[]'; | ||
| echo '[]'; | ||
| } |
There was a problem hiding this comment.
These echo statements inside the if/else are no longer indented under their control flow, which makes it easy to miss which branch they belong to in this mixed PHP/JS section. Please re-indent the echo wp_json_encode(...) / echo '[]' lines to match the surrounding block structure.
Code Coverage SummaryCoverage changed in 1 file.
|
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Thanks! I ran into this as well and it looks like it was caused by #46809. |
tbradsha
left a comment
There was a problem hiding this comment.
Looks like the LLM went haywire; I'd recommend removing all edits but the actual fix (highlighted inline).
| // this assumes is contact for now, just sends to prefill - perhaps later add mailto: optional (wh wants lol) | ||
| var zbsObjectEmailLinkPrefix = '<?php echo jpcrm_esc_link( 'email', -1, 'zerobs_customer', true ); ?>'; |
Fixes JETCRM-1405 on Linear
Proposed changes:
It fixes a broken string by consolidating it into a single line to prevent JS errors that prevent Contacts, Transactions, and Invoices from being properly listed.
The linter also changed some stuff with the formatting in the file.
Other information:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions:
To test, build CRM and run locally from Studio by symlinking, i.e.:
ln -s /jetpack/projects/plugins/crm zero-bs-crmActivate Jetpack CRM and go to the contact list. Observe that it doesn't render properly:
Apply the PR and see that the list renders properly:
Changelog