Skip to content

Commit

Permalink
Merge pull request #2298 from rhian-cs/2286-highlight-archived-case-c…
Browse files Browse the repository at this point in the history
…ontacts

[#2286] Display archived contacts differently in order to highlight them
  • Loading branch information
compwron authored Jul 22, 2021
2 parents aa0ff8d + 818b6ad commit 14b8403
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 7 deletions.
22 changes: 15 additions & 7 deletions app/views/case_contacts/_case_contact.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,25 @@
<div class="row d-flex justify-content-between no-gutters">
<div class="col-8">
<div class="media">
<i class="mt-1 mr-3 text-primary <%= contact.decorate.medium_icon_classes %>"></i>
<% header_color_class = contact.quarter_editable? ? "text-primary" : "text-secondary" %>

<i class="mt-1 mr-3 <%= header_color_class %> <%= contact.decorate.medium_icon_classes %>"></i>
<div class="media-body">
<h5 class="mt-0 card-title">
<strong class="text-primary">
<%= t('.deleted_text') if policy(contact).restore? && contact.deleted? %>
<%= contact.contact_groups_with_types.keys.join(', ') %>
<strong class="<%= header_color_class %>">
<%= t(".deleted_text") if policy(contact).restore? && contact.deleted? %>
<%= contact.contact_groups_with_types.keys.join(", ") %>
<%= t("case_contacts.archived") unless contact.quarter_editable? %>
</strong>
<%= link_to(t("button.undelete"), restore_case_contact_path(contact.id), method: :post,
class: "btn btn-info") if policy(contact).restore? && contact.deleted? %>
<% unless contact.quarter_editable? %>
<i
class="fa fa-question-circle"
aria-hidden="true"
data-toggle="tooltip"
title="<%= t("case_contacts.quarter_not_editable") %>"></i>
<% end %>
</h5>
<h6 class="card-subtitle mb-2 text-muted">
<%= contact.decorate.contact_types %>
Expand Down Expand Up @@ -40,12 +50,10 @@
<% if contact.quarter_editable? %>
<%= render "case_contacts/followup", contact: contact, followup: contact.requested_followup %>
<div class="col-sm-5">
<%= link_to edit_case_contact_path(contact), class: 'btn btn-outline-primary' do %>
<%= link_to edit_case_contact_path(contact), class: "btn btn-outline-primary" do %>
<strong><%= t("button.edit") %></strong>
<% end %>
</div>
<% else %>
<i class="fa fa-question-circle" aria-hidden="true" data-toggle="tooltip" title="This case contact was created in a previous quarter and is therefore no longer editable."></i>
<% end %>
<% end %>
</div>
Expand Down
2 changes: 2 additions & 0 deletions config/locales/views.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ en:
header: Confirm Note Content
body: Please double check your notes to ensure they don't contain any identifying details about your youth or anyone else.
note: Note
quarter_not_editable: Archived contacts can't be edited. Case contacts are archived after the end of each quarter.
archived: (Archived)
casa_cases:
show:
title: CASA Case Details
Expand Down
43 changes: 43 additions & 0 deletions spec/system/case_contacts/index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,49 @@
end
end
end

describe "case contacts text color" do
let(:contact_group_text) { case_contact.contact_groups_with_types.keys.first }

context "with active case contact" do
let!(:case_contact) { create(:case_contact, creator: volunteer, casa_case: casa_case, occurred_at: Time.zone.yesterday) }

before do
sign_in volunteer
visit case_contacts_path
end

it "displays correct color for contact" do
within ".card-title" do
title = find("strong.text-primary")
expect(title).to have_content(contact_group_text)
end
end
end

context "with archived case contact", js: true do
let!(:case_contact) { create(:case_contact, creator: volunteer, casa_case: casa_case, occurred_at: 1.year.ago) }

before do
sign_in volunteer
visit case_contacts_path
end

it "displays correct color for contact" do
within ".card-title" do
title = find("strong.text-secondary")
expect(title).to have_content("#{contact_group_text} (Archived)")
end
end

it "displays an information tooltip about the archived contacts" do
tooltip = find(".fa-question-circle")
page.driver.browser.action.move_to(tooltip.native).perform

expect(page).to have_content("Archived contacts can't be edited. Case contacts are archived after the end of each quarter.")
end
end
end
end

context "without case contacts" do
Expand Down

0 comments on commit 14b8403

Please sign in to comment.