-
-
Notifications
You must be signed in to change notification settings - Fork 513
Added search to new case contact datatable view #6627
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
Added search to new case contact datatable view #6627
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements server-side DataTables functionality for the new case contacts table to improve performance with large datasets. The implementation includes backend processing via a CaseContactDatatable class, policy updates to authorize access, and comprehensive frontend column renderers.
Key Changes:
- Server-side DataTables processing with search across creator name, email, case number, notes, and contact types
- Authorization via
CaseContactPolicy#datatable?for admins, supervisors, and volunteers - 11 column renderers handling icons, links, duration formatting, and draft badges
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| app/datatables/case_contact_datatable.rb | New datatable class implementing server-side search, ordering, and pagination with ActiveRecord queries |
| app/policies/case_contact_policy.rb | Added datatable? permission aliased to existing authorization method |
| app/controllers/case_contacts/case_contacts_new_design_controller.rb | Added datatable action to return JSON response |
| config/routes.rb | Added POST route for datatable endpoint |
| app/views/case_contacts/case_contacts_new_design/index.html.erb | Updated data-source attribute to point to new datatable endpoint |
| app/javascript/src/dashboard.js | Configured DataTables with server-side processing, AJAX setup, and 11 column renderers |
| app/javascript/tests/dashboard.test.js | Comprehensive Jest tests for DataTable configuration and column renderers |
| spec/datatables/case_contact_datatable_spec.rb | RSpec tests for data structure, search, ordering, pagination, and edge cases |
| spec/policies/case_contact_policy_spec.rb | Tests for datatable permission authorization |
| spec/requests/case_contacts/case_contacts_new_design_spec.rb | Integration tests for datatable endpoint authorization and scoped data |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Thanks for triggering the review @compwron addressed final two issues and fixed tests |
|
:) |
What github issue is this PR for, if any?
Resolves #6504
What changed, and why?
Added server-side search to the new case contacts table for better performance with large datasets.
Backend:
CaseContactDatatableto handle server-side DataTables processing with search across creator name, creator email, case number, notes, and contact typesdatatable?permission inCaseContactPolicyfor admins, supervisors, and volunteers.to_sqlpattern instead of raw SQL for maintainabilityFrontend:
dashboard.jsto configure DataTables with server-side processingWhy?
Loading all case contacts client-side would get slow with lots of data. Server-side processing lets the database handle filtering and pagination, only returning one page at a time.
How is this tested?
rspec (46 tests):
spec/datatables/case_contact_datatable_spec.rb- 35 tests for data structure, search, ordering, pagination, sanitizationspec/policies/case_contact_policy_spec.rb- 3 tests for permissionsspec/requests/case_contacts/case_contacts_new_design_spec.rb- 8 tests for endpoint authorization and scoped datajest (48 tests):
app/javascript/__tests__/dashboard.test.js- tests for DataTable config, AJAX setup, all column renderers