Improved CRM contacts autocomplete service to include state and set
What does this MR do and why?
Related to #375457 and #375467.
Currently, the contacts autocomplete endpoint returns all contacts (regardless of their state and ability to add/remove them). The data contains a limited field set that does not allow sufficient local filtering.
This MR adds the contact state and "whether it is already attached to the issue" to the results, allowing us to filter in the frontend. This will allow us to only show:
- active contacts which aren't already attached (when using the add quick action)
- currently attached contacts (when using the remove quick action)
Screenshots or screen recordings
Not really anything to show here, all changes are related to backend
How to set up and validate locally
- Enable CRM feature on a root group
- Make sure some CRM contacts are available otherwise create some
- Set some contacts as inactive (edit them and use the
Active
checkbox to change their state) - Go to an issue
- Use the
/add_contacts
quick action to add one or more contacts to that issue - Open another tab and use the
autocomplete_sources
endpoint to check the returned data.- The URL looks something like this:
http://127.0.0.1:3000/<project_path>/-/autocomplete_sources/contacts?type=Issue&type_id=<issue_id>
(e.g.http://127.0.0.1:3000/flightjs/Flight/-/autocomplete_sources/contacts?type=Issue&type_id=40
) - Change
project_path
accordingly andtype_id
to the ID of the issue
- The URL looks something like this:
- Make sure that the returned data includes the
state
field (also its value should reflect that active or inactive state of the contact) and theset
field for the CRM contacts that have been added to the issue
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Lee Tickett