From f43ffed262eb1ec07e58d99ed97d2a71d74e8f66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=89=E0=A4=A4=E0=A5=8D=E0=A4=95=E0=A4=B0=E0=A5=8D?= =?UTF-8?q?=E0=A4=B7=20=E0=A5=A5=20Utkarsh?= Date: Tue, 27 Jan 2026 14:49:21 +0530 Subject: [PATCH 1/6] work done for issue number - #6563 --- app/controllers/case_contacts_controller.rb | 13 ++++++++++++- app/views/case_contacts/_case_contact.html.erb | 12 ++++++++++-- config/routes.rb | 1 + 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/app/controllers/case_contacts_controller.rb b/app/controllers/case_contacts_controller.rb index 5f4275ea82..d47a98e397 100644 --- a/app/controllers/case_contacts_controller.rb +++ b/app/controllers/case_contacts_controller.rb @@ -6,7 +6,8 @@ class CaseContactsController < ApplicationController before_action :set_case_contact, only: %i[edit destroy] before_action :set_contact_types, only: %i[new edit create] before_action :require_organization! - after_action :verify_authorized, except: %i[leave] + before_action :set_volunteer, only: %i[impersonate_and_edit] + after_action :verify_authorized, except: %i[leave, impersonate_and_edit] def index load_case_contacts @@ -61,6 +62,12 @@ def leave redirect_back_to_referer(fallback_location: case_contacts_path) end + + def impersonate_and_edit + impersonate_user(@volunteer) + redirect_to casa_case_path(params[:casa_case_id]) + end + private def update_or_create_additional_expense(all_ae_params, cc) @@ -98,4 +105,8 @@ def build_draft_case_ids(params, casa_cases) [] end + + def set_volunteer + @volunteer = Volunteer.find(params[:creator_id]) + end end diff --git a/app/views/case_contacts/_case_contact.html.erb b/app/views/case_contacts/_case_contact.html.erb index c3324c52a4..0260d51f0d 100644 --- a/app/views/case_contacts/_case_contact.html.erb +++ b/app/views/case_contacts/_case_contact.html.erb @@ -38,8 +38,16 @@ <% if Pundit.policy(current_user, contact).update? %> <%= render "case_contacts/followup", contact: contact, followup: contact.requested_followup %>
- <%= link_to edit_case_contact_path(contact), class: "text-danger", data: { turbo: false } do %> - Edit + <%# debugger %> + <%# this is the place where i have to make UI change - utkarsh %> + <% if current_user.casa_admin? || current_user.supervisor? %> + <%= link_to case_contacts_impersonate_and_edit_path(creator_id: contact.creator.id, casa_case_id: @casa_case), class: "text-danger", data: { turbo: false } do %> + View/Edit + <% end %> + <% else %> + <%= link_to edit_case_contact_path(contact), class: "text-danger", data: { turbo: false } do %> + Edit + <% end %> <% end %>
<% end %> diff --git a/config/routes.rb b/config/routes.rb index d3d77105b7..c34d217e9d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -85,6 +85,7 @@ # Feature flag for new case contact table design get "case_contacts/new_design", to: "case_contacts/case_contacts_new_design#index" post "case_contacts/new_design/datatable", to: "case_contacts/case_contacts_new_design#datatable", as: "datatable_case_contacts_new_design" + get "case_contacts/impersonate_and_edit", to: "case_contacts#impersonate_and_edit" resources :case_contacts, except: %i[create update show], concerns: %i[with_datatable] do member do post :restore From 8c6442ad5c7bf3448e8d0953bce73f142c15dcce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=89=E0=A4=A4=E0=A5=8D=E0=A4=95=E0=A4=B0=E0=A5=8D?= =?UTF-8?q?=E0=A4=B7=20=E0=A5=A5=20Utkarsh?= Date: Tue, 27 Jan 2026 15:12:31 +0530 Subject: [PATCH 2/6] debugger removed --- app/views/case_contacts/_case_contact.html.erb | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/views/case_contacts/_case_contact.html.erb b/app/views/case_contacts/_case_contact.html.erb index 0260d51f0d..5e6d494ce1 100644 --- a/app/views/case_contacts/_case_contact.html.erb +++ b/app/views/case_contacts/_case_contact.html.erb @@ -38,8 +38,6 @@ <% if Pundit.policy(current_user, contact).update? %> <%= render "case_contacts/followup", contact: contact, followup: contact.requested_followup %>
- <%# debugger %> - <%# this is the place where i have to make UI change - utkarsh %> <% if current_user.casa_admin? || current_user.supervisor? %> <%= link_to case_contacts_impersonate_and_edit_path(creator_id: contact.creator.id, casa_case_id: @casa_case), class: "text-danger", data: { turbo: false } do %> View/Edit From 4178a8f144f4fadb71ed5246cb8c5ab645f849fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=89=E0=A4=A4=E0=A5=8D=E0=A4=95=E0=A4=B0=E0=A5=8D?= =?UTF-8?q?=E0=A4=B7=20=E0=A5=A5=20Utkarsh?= Date: Tue, 27 Jan 2026 15:22:26 +0530 Subject: [PATCH 3/6] linting error resolved --- app/controllers/case_contacts_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/case_contacts_controller.rb b/app/controllers/case_contacts_controller.rb index d47a98e397..3780e15d7d 100644 --- a/app/controllers/case_contacts_controller.rb +++ b/app/controllers/case_contacts_controller.rb @@ -7,7 +7,7 @@ class CaseContactsController < ApplicationController before_action :set_contact_types, only: %i[new edit create] before_action :require_organization! before_action :set_volunteer, only: %i[impersonate_and_edit] - after_action :verify_authorized, except: %i[leave, impersonate_and_edit] + after_action :verify_authorized, except: %i[leave impersonate_and_edit] def index load_case_contacts @@ -62,9 +62,9 @@ def leave redirect_back_to_referer(fallback_location: case_contacts_path) end - def impersonate_and_edit impersonate_user(@volunteer) + redirect_to casa_case_path(params[:casa_case_id]) end From 70668121507fd047999b523afc96c2a97e173d35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=89=E0=A4=A4=E0=A5=8D=E0=A4=95=E0=A4=B0=E0=A5=8D?= =?UTF-8?q?=E0=A4=B7=20=E0=A5=A5=20Utkarsh?= Date: Tue, 27 Jan 2026 16:09:02 +0530 Subject: [PATCH 4/6] failing tests were corrected to align with new feature --- spec/views/case_contacts/case_contact.html.erb_spec.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spec/views/case_contacts/case_contact.html.erb_spec.rb b/spec/views/case_contacts/case_contact.html.erb_spec.rb index 924ad29a09..d62210f8c7 100644 --- a/spec/views/case_contacts/case_contact.html.erb_spec.rb +++ b/spec/views/case_contacts/case_contact.html.erb_spec.rb @@ -73,17 +73,16 @@ enable_pundit(view, admin) allow(view).to receive(:current_user).and_return(admin) end - context "occurred_at is before the last day of the month in the quarter that the case contact was created" do let(:case_contact) { build_stubbed(:case_contact, creator: volunteer) } let(:case_contact2) { build_stubbed(:case_contact, deleted_at: Time.current, creator: volunteer) } - it "shows edit button" do + it "shows view/edit button" do assign :case_contact, case_contact assign :casa_cases, [case_contact.casa_case] render(partial: "case_contacts/case_contact", locals: {contact: case_contact}) - expect(rendered).to have_link(nil, href: "/case_contacts/#{case_contact.id}/edit") + expect(rendered).to have_link(nil, href: "/case_contacts/impersonate_and_edit?creator_id=#{case_contact.creator.id}") end it "shows make reminder button" do From 9201608418f307dcf6e580f27eb38ee5c2f2178c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=89=E0=A4=A4=E0=A5=8D=E0=A4=95=E0=A4=B0=E0=A5=8D?= =?UTF-8?q?=E0=A4=B7=20=E0=A5=A5=20Utkarsh?= Date: Tue, 27 Jan 2026 17:45:42 +0530 Subject: [PATCH 5/6] if supervisor adds a case details, he should see view/edit button not just edit --- app/views/case_contacts/_case_contact.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/case_contacts/_case_contact.html.erb b/app/views/case_contacts/_case_contact.html.erb index 5e6d494ce1..df19ed4fd1 100644 --- a/app/views/case_contacts/_case_contact.html.erb +++ b/app/views/case_contacts/_case_contact.html.erb @@ -38,7 +38,7 @@ <% if Pundit.policy(current_user, contact).update? %> <%= render "case_contacts/followup", contact: contact, followup: contact.requested_followup %>
- <% if current_user.casa_admin? || current_user.supervisor? %> + <% if (current_user.casa_admin? || current_user.supervisor?) && contact.creator != current_user %> <%= link_to case_contacts_impersonate_and_edit_path(creator_id: contact.creator.id, casa_case_id: @casa_case), class: "text-danger", data: { turbo: false } do %> View/Edit <% end %> From fd1d7750b3876133232899e11c37724e4153e5ad Mon Sep 17 00:00:00 2001 From: compwron Date: Tue, 27 Jan 2026 19:19:25 -0800 Subject: [PATCH 6/6] Update app/views/case_contacts/_case_contact.html.erb Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- app/views/case_contacts/_case_contact.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/case_contacts/_case_contact.html.erb b/app/views/case_contacts/_case_contact.html.erb index df19ed4fd1..baf8203b67 100644 --- a/app/views/case_contacts/_case_contact.html.erb +++ b/app/views/case_contacts/_case_contact.html.erb @@ -38,7 +38,7 @@ <% if Pundit.policy(current_user, contact).update? %> <%= render "case_contacts/followup", contact: contact, followup: contact.requested_followup %>
- <% if (current_user.casa_admin? || current_user.supervisor?) && contact.creator != current_user %> + <% if (current_user.casa_admin? || current_user.supervisor?) && contact.creator&.volunteer? && contact.creator != current_user %> <%= link_to case_contacts_impersonate_and_edit_path(creator_id: contact.creator.id, casa_case_id: @casa_case), class: "text-danger", data: { turbo: false } do %> View/Edit <% end %>