Skip to content

Commit

Permalink
Merge branch 'main' into issue-6187-admin-new-case-contacts
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-yi37 committed Feb 6, 2025
2 parents c8aeb63 + a2e7577 commit 6f6e544
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 24 deletions.
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ gem "net-pop" # needed for ruby upgrade to 3.1.0 https://www.ruby-lang.org/en/ne
gem "net-smtp", require: false # needed for ruby upgrade to 3.1.0 for some dang reason
gem "noticed" # Notifications
gem "oj" # faster JSON parsing 🍊
gem "pagy" # pagination
gem "paranoia" # For soft-deleting database objects
gem "pdf-forms" # filling in fund request PDFs with user input
gem "pg" # Use postgresql as the database for Active Record
gem "pretender"
gem "puma", "6.5.0" # 6.2.2 fails to install on m1 # Use Puma as the app server
gem "puma", "6.6.0" # 6.2.2 fails to install on m1 # Use Puma as the app server
gem "pundit" # for authorization management - based on user.role field
gem "rack-attack" # for blocking & throttling abusive requests
gem "rack-cors" # for allowing cross-origin resource sharing
Expand Down
26 changes: 14 additions & 12 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ GEM
dotenv-rails (3.1.7)
dotenv (= 3.1.7)
railties (>= 6.1)
draper (4.0.2)
draper (4.0.4)
actionpack (>= 5.0)
activemodel (>= 5.0)
activemodel-serializers-xml (>= 1.0)
Expand Down Expand Up @@ -335,7 +335,7 @@ GEM
net-protocol
net-protocol (0.2.2)
timeout
net-smtp (0.5.0)
net-smtp (0.5.1)
net-protocol
nio4r (2.7.4)
nokogiri (1.18.2)
Expand All @@ -354,6 +354,7 @@ GEM
ostruct (>= 0.2)
orm_adapter (0.5.0)
ostruct (0.6.1)
pagy (9.3.3)
parallel (1.26.3)
parallel_tests (4.9.0)
parallel
Expand Down Expand Up @@ -386,12 +387,12 @@ GEM
date
stringio
public_suffix (6.0.1)
puma (6.5.0)
puma (6.6.0)
nio4r (~> 2.0)
pundit (2.4.0)
activesupport (>= 3.0.0)
racc (1.8.1)
rack (3.1.8)
rack (3.1.9)
rack-attack (6.7.0)
rack (>= 1.0, < 4)
rack-cors (2.0.2)
Expand Down Expand Up @@ -442,7 +443,7 @@ GEM
zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.2.1)
rdoc (6.11.0)
rdoc (6.12.0)
psych (>= 4.0.0)
regexp_parser (2.10.0)
reline (0.6.0)
Expand All @@ -453,15 +454,15 @@ GEM
actionpack (>= 5.2)
railties (>= 5.2)
rexml (3.4.0)
rspec-core (3.13.2)
rspec-core (3.13.3)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-rails (7.1.0)
rspec-rails (7.1.1)
actionpack (>= 7.0)
activesupport (>= 7.0)
railties (>= 7.0)
Expand Down Expand Up @@ -571,16 +572,16 @@ GEM
stimulus-rails (1.3.4)
railties (>= 6.0.0)
stringio (3.1.2)
strong_migrations (2.1.0)
activerecord (>= 6.1)
strong_migrations (2.2.0)
activerecord (>= 7)
thor (1.3.2)
timeout (0.4.3)
traceroute (0.8.1)
rails (>= 3.0.0)
turbo-rails (2.0.11)
actionpack (>= 6.0.0)
railties (>= 6.0.0)
twilio-ruby (7.4.2)
twilio-ruby (7.4.3)
benchmark
faraday (>= 0.9, < 3.0)
jwt (>= 1.5, < 3.0)
Expand All @@ -604,7 +605,7 @@ GEM
activemodel (>= 6.0.0)
bindex (>= 0.4.0)
railties (>= 6.0.0)
webmock (3.24.0)
webmock (3.25.0)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
Expand Down Expand Up @@ -672,6 +673,7 @@ DEPENDENCIES
net-smtp
noticed
oj
pagy
parallel_tests
paranoia
pdf-forms
Expand All @@ -681,7 +683,7 @@ DEPENDENCIES
pretender
pry
pry-byebug
puma (= 6.5.0)
puma (= 6.6.0)
pundit
rack-attack
rack-cors
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![erb lint](https://github.com/rubyforgood/casa/actions/workflows/erb_lint.yml/badge.svg)](https://github.com/rubyforgood/casa/actions/workflows/erb_lint.yml)
[![standardrb lint](https://github.com/rubyforgood/casa/actions/workflows/ruby_lint.yml/badge.svg)](https://github.com/rubyforgood/casa/actions/workflows/ruby_lint.yml)
[![brakeman](https://github.com/rubyforgood/casa/workflows/brakeman/badge.svg)](https://github.com/rubyforgood/casa/actions/workflows/security.yml)
[![yarn lint](https://github.com/rubyforgood/casa/actions/workflows/yarn_lint_and_test.yml/badge.svg)](https://github.com/rubyforgood/casa/actions/workflows/yarn_lint_and_test.yml)
[![npm lint](https://github.com/rubyforgood/casa/actions/workflows/npm_lint_and_test.yml/badge.svg)](https://github.com/rubyforgood/casa/actions/workflows/npm_lint_and_test.yml)

[![Maintainability](https://api.codeclimate.com/v1/badges/24f3bb10db6afac417e2/maintainability)](https://codeclimate.com/github/rubyforgood/casa/trends/technical_debt)
[![Test Coverage](https://api.codeclimate.com/v1/badges/24f3bb10db6afac417e2/test_coverage)](https://codeclimate.com/github/rubyforgood/casa/trends/test_coverage_total)
Expand Down
1 change: 1 addition & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class ApplicationController < ActionController::Base
include Pundit::Authorization
include Pagy::Backend
include Organizational
include Users::TimeZone

Expand Down
11 changes: 6 additions & 5 deletions app/controllers/case_contacts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ def index
}
) || return

case_contacts = CaseContact.case_hash_from_cases(@filterrific.find)
@pagy, @filtered_case_contacts = pagy(@filterrific.find)
case_contacts = CaseContact.case_hash_from_cases(@filtered_case_contacts)
case_contacts = case_contacts.select { |k, _v| k == params[:casa_case_id].to_i } if params[:casa_case_id].present?

@presenter = CaseContactPresenter.new(case_contacts)
Expand Down Expand Up @@ -103,12 +104,12 @@ def current_organization_groups
end

def all_case_contacts
policy_scope(current_organization.case_contacts).includes(
policy_scope(current_organization.case_contacts).preload(
:creator,
:followups,
:contact_types,
contact_topic_answers: [:contact_topic],
casa_case: [:volunteers]
contact_types: :contact_type_group,
contact_topic_answers: :contact_topic,
casa_case: :volunteers
)
end

Expand Down
2 changes: 2 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
module ApplicationHelper
include Pagy::Frontend

def body_class
qualified_controller_name = controller.controller_path.tr("/", "-")
"#{qualified_controller_name} #{qualified_controller_name}-#{controller.action_name}"
Expand Down
2 changes: 2 additions & 0 deletions app/views/case_contacts/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
</div>
</div>
<% end %>

<%= turbo_frame_tag :case_contacts do %>
<% @presenter.case_contacts.each do |casa_case_id, data| %>
<div class="card-style-1 mb-5">
Expand Down Expand Up @@ -156,4 +157,5 @@
</div>
<% end %>
<% end %>
<%== pagy_bootstrap_nav(@pagy) %>
<% end %>
5 changes: 5 additions & 0 deletions config/initializers/pagy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require "pagy/extras/bootstrap"
require "pagy/extras/size"

Pagy::DEFAULT[:size] = [1, 3, 3, 1]
Pagy::DEFAULT[:nav_class] = "pagy-bootstrap-nav"
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"select2-bootstrap-5-theme": "^1.3.0",
"strftime": "^0.10.3",
"sweetalert2": "^11.3.5",
"tom-select": "^2.4.1",
"tom-select": "^2.4.2",
"trix": "^2.1.12"
},
"version": "0.1.0",
Expand Down
2 changes: 2 additions & 0 deletions spec/views/case_contacts/index.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
RSpec.describe "case_contacts/index", type: :view do
let(:user) { build_stubbed(:volunteer) }
let(:case_contacts) { CaseContact.all }
let(:pagy) { Pagy.new(count: 0) }

let(:filterrific_param_set) do
param_set = Filterrific::ParamSet.new(case_contacts, {})
Expand Down Expand Up @@ -30,6 +31,7 @@
assign(:current_organization_groups, groups)
assign(:filterrific, filterrific_param_set)
assign(:presenter, CaseContactPresenter.new(case_contacts))
assign(:pagy, pagy)

render template: "case_contacts/index"
end
Expand Down

0 comments on commit 6f6e544

Please sign in to comment.