From 89429a2e904e1df8b9335f4966c7350e0275c5ee Mon Sep 17 00:00:00 2001 From: Rhian Moraes Date: Tue, 20 Jul 2021 14:34:37 -0300 Subject: [PATCH 1/2] Display archived contacts in a different color --- .../case_contacts/_case_contact.html.erb | 18 +++++--- config/locales/views.en.yml | 2 + spec/system/case_contacts/index_spec.rb | 43 +++++++++++++++++++ 3 files changed, 56 insertions(+), 7 deletions(-) diff --git a/app/views/case_contacts/_case_contact.html.erb b/app/views/case_contacts/_case_contact.html.erb index 29feb97730..04929751b5 100644 --- a/app/views/case_contacts/_case_contact.html.erb +++ b/app/views/case_contacts/_case_contact.html.erb @@ -3,15 +3,21 @@
- + <% header_color_class = contact.quarter_editable? ? "text-primary" : "text-secondary" %> + +
- - <%= t('.deleted_text') if policy(contact).restore? && contact.deleted? %> - <%= contact.contact_groups_with_types.keys.join(', ') %> + + <%= t(".deleted_text") if policy(contact).restore? && contact.deleted? %> + <%= contact.contact_groups_with_types.keys.join(", ") %> + <%= t("case_contacts.archived") unless contact.quarter_editable? %> <%= 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? %> + + <% end %>
<%= contact.decorate.contact_types %> @@ -40,12 +46,10 @@ <% if contact.quarter_editable? %> <%= render "case_contacts/followup", contact: contact, followup: contact.requested_followup %>
- <%= 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 %> <%= t("button.edit") %> <% end %>
- <% else %> - <% end %> <% end %>
diff --git a/config/locales/views.en.yml b/config/locales/views.en.yml index 690a014f20..a07e18cb03 100644 --- a/config/locales/views.en.yml +++ b/config/locales/views.en.yml @@ -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 diff --git a/spec/system/case_contacts/index_spec.rb b/spec/system/case_contacts/index_spec.rb index f235a71c0c..0b9327f204 100644 --- a/spec/system/case_contacts/index_spec.rb +++ b/spec/system/case_contacts/index_spec.rb @@ -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 From 818b6adfc6e0dc396419f249916ac2f9570d4c10 Mon Sep 17 00:00:00 2001 From: Rhian Moraes Date: Tue, 20 Jul 2021 14:48:33 -0300 Subject: [PATCH 2/2] Fix linter issues --- app/views/case_contacts/_case_contact.html.erb | 6 +++++- spec/system/case_contacts/index_spec.rb | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/views/case_contacts/_case_contact.html.erb b/app/views/case_contacts/_case_contact.html.erb index 04929751b5..c823daff0d 100644 --- a/app/views/case_contacts/_case_contact.html.erb +++ b/app/views/case_contacts/_case_contact.html.erb @@ -16,7 +16,11 @@ <%= 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? %> - + <% end %>
diff --git a/spec/system/case_contacts/index_spec.rb b/spec/system/case_contacts/index_spec.rb index 0b9327f204..0b9ed1e5c5 100644 --- a/spec/system/case_contacts/index_spec.rb +++ b/spec/system/case_contacts/index_spec.rb @@ -95,7 +95,7 @@ end it "displays an information tooltip about the archived contacts" do - tooltip = find('.fa-question-circle') + 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.")