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

SearchKit - Fix campaign, event & primary address dropdowns #24963

Merged
merged 4 commits into from
Nov 16, 2022

Conversation

colemanw
Copy link
Member

Overview

Fixes dev/core#3950 and dev/core#3982

Before

Multiple problems with SearchKit select lists

After

EntityRef to the rescue! 🦸

Technical Details

For fields with both an FK and an option list, prefer the FK because it's more efficient to render an autocomplete than to pre-load potentially thousands of options into a select dropdown. It also solves the bugs with Campaign lists (which has a funky set of no-prefecth options) and contact primary address dropdowns (which aren't strictly part of the contact entity so those options hadn't been loading).

@civibot
Copy link

civibot bot commented Nov 12, 2022

(Standard links)

@civibot civibot bot added the master label Nov 12, 2022
@colemanw colemanw changed the title SearchKit - Fix campaign, address dropdowns SearchKit - Fix campaign, event & primary address dropdowns Nov 12, 2022
@aydun
Copy link
Contributor

aydun commented Nov 16, 2022

Test this please

@aydun
Copy link
Contributor

aydun commented Nov 16, 2022

That fixes the problem in https://lab.civicrm.org/dev/core/-/issues/3982

But ... in the dropdown for country, the additional information shown is the id. It would be more useful to show the ISO code field.

image

The states show the country which is useful:
image

…ists

Before: option lists were preferred over FK
After: FK is preferred over option lists

Fixes dev/core#3950
Fixes dev/core#3982
@colemanw
Copy link
Member Author

Thanks @aydun I've added a customized display for Countries with your suggestion.

@aydun
Copy link
Contributor

aydun commented Nov 16, 2022

Thanks - Looks good.

More generally, is it possible to search on multiple fields in an autocomplete? For example, can it be configured to search on both name and iso so that if I type in 'gb' it would find 'United Kingdom'?

@colemanw colemanw merged commit d1df321 into civicrm:master Nov 16, 2022
@colemanw colemanw deleted the SearchKitFkFix branch November 16, 2022 19:54
@colemanw
Copy link
Member Author

@aydun yes - these Autocompletes use a special type of SearchKit display that you can configure. The search logic currently treats all fields on the top line as searchable using OR. For performance reasons I didn't include other lines in the search so if you wanted to do this on a particular form you'd need to configure an autocomplete search display for that form and use "rewrite" to place both name and iso on the top line of the autocomplete results.

@aydun
Copy link
Contributor

aydun commented Nov 16, 2022

Got it - thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants