From 8a2df7ecc1f7246e515cb7bd061d72c760c29648 Mon Sep 17 00:00:00 2001 From: Rafael Martins Date: Tue, 10 Oct 2023 18:09:54 -0300 Subject: [PATCH 01/12] feat: added dropdown to my cases and fixed the carret --- app/views/layouts/_sidebar.html.erb | 52 ++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/app/views/layouts/_sidebar.html.erb b/app/views/layouts/_sidebar.html.erb index 4c3c03ddaa..1d40b771a5 100644 --- a/app/views/layouts/_sidebar.html.erb +++ b/app/views/layouts/_sidebar.html.erb @@ -35,11 +35,32 @@ <% if current_user.casa_admin? || current_user.supervisor? %> <%= render partial: "layouts/other_duties_nav_item" %> <% end %> - <% if policy(CasaAdmin).index? %> - <% end %> -
  • <% end %> - - <% if policy(:application).see_banner_page? %> -
  • - <%= link_to banners_path, class: "#{active_class(banners_path)}" do %> - - Banners - <% end %> -
  • - <% end %>
  • From 74b8d92cf9bda2096b925102e3f849d9cd20c0b0 Mon Sep 17 00:00:00 2001 From: Rafael Martins Date: Wed, 11 Oct 2023 14:09:22 -0300 Subject: [PATCH 03/12] feat: create a partial for sidebar dropdown item --- app/helpers/sidebar_helper.rb | 4 +++ app/views/layouts/_sidebar.html.erb | 28 +++------------------ app/views/shared/_sidebar_dropdown.html.erb | 12 +++++++++ 3 files changed, 19 insertions(+), 25 deletions(-) create mode 100644 app/views/shared/_sidebar_dropdown.html.erb diff --git a/app/helpers/sidebar_helper.rb b/app/helpers/sidebar_helper.rb index e4be743388..98385042a1 100644 --- a/app/helpers/sidebar_helper.rb +++ b/app/helpers/sidebar_helper.rb @@ -15,6 +15,10 @@ def menu_item(label:, path:, visible: false) link_to label, path, class: "list-group-item #{active_class(path)}" if visible end + def get_case_contact_link(casa_case) + case_contacts_path(casa_case_id: casa_case.id) + end + private # private doesn't work in modules. It's here for semantic purposes def active_class(link_path) diff --git a/app/views/layouts/_sidebar.html.erb b/app/views/layouts/_sidebar.html.erb index 60f1926685..6ce457b895 100644 --- a/app/views/layouts/_sidebar.html.erb +++ b/app/views/layouts/_sidebar.html.erb @@ -45,7 +45,7 @@
  • <% end %> -
    <% if policy(CasaAdmin).index? %> <% end %> + + <% if !policy(Volunteer).index? %> + + <% end %> + + <% if policy(Volunteer).index? %> + + <% end %> - <% if policy(CasaAdmin).index? %> <% end %> - \ No newline at end of file + From fd2906f0a105c092d7ac3027ed7fb8c95c5994f7 Mon Sep 17 00:00:00 2001 From: Rafael Martins Date: Wed, 11 Oct 2023 16:30:18 -0300 Subject: [PATCH 05/12] test: add and fix tests for the sidebar --- spec/system/casa_cases/index_spec.rb | 21 ++++++++++++++++++++- spec/views/layouts/sidebar.html.erb_spec.rb | 2 +- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/spec/system/casa_cases/index_spec.rb b/spec/system/casa_cases/index_spec.rb index 819a55166e..be63838a05 100644 --- a/spec/system/casa_cases/index_spec.rb +++ b/spec/system/casa_cases/index_spec.rb @@ -1,11 +1,15 @@ require "rails_helper" RSpec.describe "casa_cases/index", type: :system do + let(:organization) { create(:casa_org) } + let(:volunteer) { build(:volunteer, display_name: "Bob Loblaw", casa_org: organization) } + let(:case_number) { "CINA-1" } + it "is filterable and linkable", :js do organization = build(:casa_org) admin = build(:casa_admin, casa_org: organization) volunteer = build(:volunteer, display_name: "Cool Volunteer", casa_org: organization) - cina = build(:casa_case, active: true, casa_org: organization, case_number: "CINA-1") + cina = build(:casa_case, active: true, casa_org: organization, case_number: case_number) tpr = create(:casa_case, active: true, casa_org: organization, case_number: "TPR-100") no_prefix = create(:casa_case, active: true, casa_org: organization, case_number: "123-12-123") create(:case_assignment, volunteer: volunteer, casa_case: cina) @@ -24,4 +28,19 @@ click_on "Assigned to Transition Aged Youth" click_on "Casa Case Prefix" end + + it "has a usable dropdown in sidebar" do + cina = build(:casa_case, active: true, casa_org: organization, case_number: case_number) + create(:case_assignment, volunteer: volunteer, casa_case: cina) + + sign_in volunteer + + visit root_path + click_on "My Cases" + within "#ddmenu_cases" do + click_on case_number + end + + expect(page).to have_text("Editing CINA-1") + end end diff --git a/spec/views/layouts/sidebar.html.erb_spec.rb b/spec/views/layouts/sidebar.html.erb_spec.rb index 30cdb2e5a0..be1d133174 100644 --- a/spec/views/layouts/sidebar.html.erb_spec.rb +++ b/spec/views/layouts/sidebar.html.erb_spec.rb @@ -70,7 +70,7 @@ def true_user render partial: "layouts/sidebar" - expect(rendered).to have_link("My Cases", href: "/casa_cases") + expect(rendered).to have_link("All", href: "/casa_cases") expect(rendered).to have_link("All", href: "/case_contacts") expect(rendered).to have_link("Generate Court Report", href: "/case_court_reports") expect(rendered).to_not have_link("Export Data", href: "/reports") From 88d10b4ef01f85ec25c6d43cec615cb8c3f4cd6c Mon Sep 17 00:00:00 2001 From: Rafael Martins Date: Wed, 11 Oct 2023 16:40:17 -0300 Subject: [PATCH 06/12] fix: banner postion --- app/views/layouts/_sidebar.html.erb | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/app/views/layouts/_sidebar.html.erb b/app/views/layouts/_sidebar.html.erb index 036a59b27b..648e96077b 100644 --- a/app/views/layouts/_sidebar.html.erb +++ b/app/views/layouts/_sidebar.html.erb @@ -35,15 +35,6 @@ <% if current_user.casa_admin? || current_user.supervisor? %> <%= render partial: "layouts/other_duties_nav_item" %> <% end %> - - <% if policy(:application).see_banner_page? %> - - <% end %> <% if !policy(Volunteer).index? %> + <% end %> + - <% end %> - <% if !current_user.volunteer? %> + <% else %> <% else %> From 4ad4f95cc4a54b9bb07cde473357a7e4da80f3d3 Mon Sep 17 00:00:00 2001 From: Rafael Martins Date: Mon, 16 Oct 2023 18:02:47 -0300 Subject: [PATCH 12/12] test: fix sidebar test --- spec/system/casa_cases/index_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/system/casa_cases/index_spec.rb b/spec/system/casa_cases/index_spec.rb index e12d3a6188..4b8ccd60d2 100644 --- a/spec/system/casa_cases/index_spec.rb +++ b/spec/system/casa_cases/index_spec.rb @@ -41,6 +41,7 @@ click_on case_number end - expect(page).to have_text("Editing CINA-1") + expect(page).to have_text("CASA Case Details") + expect(page).to have_text("Case number: CINA-1") end end