-
-
Notifications
You must be signed in to change notification settings - Fork 523
New Case Contacts Table: row actions menu #6834
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
Merged
compwron
merged 23 commits into
rubyforgood:main
from
cliftonmcintosh:feature/6500-case-contacts-new-design-row-actions-menu
Apr 15, 2026
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
a4e1f1c
Add per-row permission flags and action metadata to CaseContactDatatable
cliftonmcintosh 4ece46c
Add ellipsis action menu to new case contacts table
cliftonmcintosh 0d1a603
Require confirmation before deleting a case contact
cliftonmcintosh b60ee3a
Disable unauthorized menu items instead of hiding them
cliftonmcintosh 484f603
Add system specs for action menu visibility
cliftonmcintosh 6ca3198
Add system spec for Edit action
cliftonmcintosh ec25d2e
Add system specs for Delete action
cliftonmcintosh d1a3a48
Add system specs for Set Reminder and Resolve Reminder actions
cliftonmcintosh 781fcc2
Add system specs for permission states on action menu items
cliftonmcintosh 68043f4
use single quotes
cliftonmcintosh 44f22e2
Extract fireSwalFollowupAlert from case_contact.js into dashboard.js
cliftonmcintosh 7b719f0
Extract clickActionButton helper in dashboard click handler tests
cliftonmcintosh c4370f3
Fix flaky permission state specs with unique occurred_at dates
cliftonmcintosh 3c48462
Merge branch 'main' into feature/6500-case-contacts-new-design-row-ac…
compwron 7c5dfc1
Merge branch 'rubyforgood:main' into feature/6500-case-contacts-new-d…
cliftonmcintosh 5fe23db
fix: add missing comma and simplify has_followup in CaseContactDatatable
cliftonmcintosh fd16040
fix: remove dataType 'json' from Delete and Resolve Reminder AJAX calls
cliftonmcintosh a43e4e4
fix: include CSRF token in Set Reminder AJAX request
cliftonmcintosh 709890f
fix: preserve pagination position when reloading DataTable after row …
cliftonmcintosh f6223a3
fix: send Accept: application/json header and add respond_to to follo…
cliftonmcintosh dd273b1
fix: preload casa_org associations to eliminate N+1 queries in CaseCo…
cliftonmcintosh b4758d1
refactor: replace Capybara.reset_sessions! with shared_context for ad…
cliftonmcintosh db661da
Merge branch 'main' into feature/6500-case-contacts-new-design-row-ac…
cliftonmcintosh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,10 +8,20 @@ class CaseContactDatatable < ApplicationDatatable | |
| duration_minutes | ||
| ].freeze | ||
|
|
||
| def initialize(base_relation, params, current_user) | ||
| super(base_relation, params) | ||
| @current_user = current_user | ||
| end | ||
|
|
||
| private | ||
|
|
||
| attr_reader :current_user | ||
|
|
||
| def data | ||
| records.map do |case_contact| | ||
| policy = CaseContactPolicy.new(current_user, case_contact) | ||
| requested_followup = case_contact.followups.find(&:requested?) | ||
|
|
||
| { | ||
| id: case_contact.id, | ||
| occurred_at: I18n.l(case_contact.occurred_at, format: :full, default: nil), | ||
|
|
@@ -35,7 +45,11 @@ def data | |
| .map { |a| {question: a.contact_topic&.question, value: a.value} }, | ||
| notes: case_contact.notes.presence, | ||
| is_draft: !case_contact.active?, | ||
| has_followup: case_contact.followups.any?(&:requested?) | ||
| has_followup: requested_followup.present?, | ||
| can_edit: policy.update?, | ||
| can_destroy: policy.destroy?, | ||
| edit_path: Rails.application.routes.url_helpers.edit_case_contact_path(case_contact), | ||
| followup_id: requested_followup&.id | ||
| } | ||
| end | ||
| end | ||
|
|
@@ -49,6 +63,7 @@ def raw_records | |
| .joins("INNER JOIN users creators ON creators.id = case_contacts.creator_id") | ||
| .left_joins(:casa_case) | ||
| .includes(:casa_case, :contact_types, :contact_topics, :followups, :creator, contact_topic_answers: :contact_topic) | ||
| .preload(:casa_org, :creator_casa_org) | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To handle an N+1 warning 21:01:42 web.1 | N+1 queries detected:
21:01:42 web.1 | SELECT "casa_orgs".* FROM "casa_orgs" INNER JOIN "casa_cases" ON "casa_orgs"."id" = "casa_cases"."casa_org_id" WHERE "casa_cases"."id" = $1 LIMIT $2
21:01:42 web.1 | SELECT "casa_orgs".* FROM "casa_orgs" INNER JOIN "casa_cases" ON "casa_orgs"."id" = "casa_cases"."casa_org_id" WHERE "casa_cases"."id" = $1 LIMIT $2
21:01:42 web.1 | SELECT "casa_orgs".* FROM "casa_orgs" INNER JOIN "casa_cases" ON "casa_orgs"."id" = "casa_cases"."casa_org_id" WHERE "casa_cases"."id" = $1 LIMIT $2
21:01:42 web.1 | SELECT "casa_orgs".* FROM "casa_orgs" INNER JOIN "casa_cases" ON "casa_orgs"."id" = "casa_cases"."casa_org_id" WHERE "casa_cases"."id" = $1 LIMIT $2
21:01:42 web.1 | SELECT "casa_orgs".* FROM "casa_orgs" INNER JOIN "casa_cases" ON "casa_orgs"."id" = "casa_cases"."casa_org_id" WHERE "casa_cases"."id" = $1 LIMIT $2
21:01:42 web.1 | SELECT "casa_orgs".* FROM "casa_orgs" INNER JOIN "casa_cases" ON "casa_orgs"."id" = "casa_cases"."casa_org_id" WHERE "casa_cases"."id" = $1 LIMIT $2
21:01:42 web.1 | Call stack:
21:01:42 web.1 | app/policies/case_contact_policy.rb:57:in 'CaseContactPolicy#same_org?'
21:01:42 web.1 | app/policies/application_policy.rb:72:in 'ApplicationPolicy#is_supervisor_same_org?'
21:01:42 web.1 | app/policies/application_policy.rb:89:in 'ApplicationPolicy#admin_or_supervisor_same_org?'
21:01:42 web.1 | app/policies/case_contact_policy.rb:45:in 'CaseContactPolicy#creator_or_supervisor_or_admin?'
21:01:42 web.1 | app/policies/case_contact_policy.rb:11:in 'CaseContactPolicy#update?'
21:01:42 web.1 | app/datatables/case_contact_datatable.rb:49:in 'block in CaseContactDatatable#data'
21:01:42 web.1 | app/datatables/case_contact_datatable.rb:21:in 'Enumerable#map'
21:01:42 web.1 | app/datatables/case_contact_datatable.rb:21:in 'CaseContactDatatable#data'
21:01:42 web.1 | app/datatables/application_datatable.rb:15:in 'ApplicationDatatable#as_json'
21:01:42 web.1 | app/controllers/case_contacts/case_contacts_new_design_controller.rb:15:in 'CaseContacts::CaseContactsNewDesignController#datatable' |
||
| .order(order_clause) | ||
| .order(:id) | ||
| end | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
case_contact.followups.find(&:requested?)forces loading the full followups association for each case contact and then scans it in Ruby. With.includes(:followups)this can pull a lot of rows into memory even though only the requested followup (if any) is needed. Consider fetching only requested followups (e.g., via a scoped query keyed by the page of case_contact IDs) and then looking up the ID per row, to reduce memory and object allocations.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.
has_followupwas re-scanning the already-loaded followups collection withany?(&:requested?)whenrequested_followupwas already computed on the line above. Simplified torequested_followup.present?.Regarding the suggestion to scope the followups query to only load requested followups: the current
includes(:followups)does load all followups per record, but in practice each case contact is unlikely to accumulate enough followups for this to be significant. I left this as-is for now but it's a reasonable future improvement if it becomes a concern.