casa
casa copied to clipboard
Added search to new case contact datatable view
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:
- Created
CaseContactDatatableto handle server-side DataTables processing with search across creator name, creator email, case number, notes, and contact types - Added
datatable?permission inCaseContactPolicyfor admins, supervisors, and volunteers - Used ActiveRecord +
.to_sqlpattern instead of raw SQL for maintainability
Frontend:
- Updated
dashboard.jsto configure DataTables with server-side processing - Set up all 11 column renderers (icons, links, duration formatting, draft badges)
Why? 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 data
jest (48 tests):
app/javascript/__tests__/dashboard.test.js- tests for DataTable config, AJAX setup, all column renderers
# run tests
bin/rspec spec/datatables/case_contact_datatable_spec.rb
npm test -- dashboard.test.js
Thanks for triggering the review @compwron addressed final two issues and fixed tests
:)