Skip to content

Commit c416c5a

Browse files
Merge branch 'main' into 3689-check-double-clicks-on-submit
2 parents 6dcf836 + bff9bdd commit c416c5a

File tree

110 files changed

+1730
-560
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+1730
-560
lines changed

.github/workflows/ruby_lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ jobs:
2727
- name: lint
2828
run: bundle exec rubocop
2929
- name: lint erb files
30-
run: bundle exec erblint --lint-all
30+
run: bundle exec erb_lint --lint-all

Gemfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ gem 'bootsnap', require: false
108108
gem "nokogiri", ">= 1.10.4"
109109
gem "sprockets", "~> 4.2.2"
110110
gem "prawn", "~> 2.4.0"
111+
gem "matrix" # Used by prawn
111112
gem "ttfunk", "~>1.7.0"
112113

113114
group :production, :staging do
@@ -155,7 +156,7 @@ group :development, :test do
155156
# More concise test ("should") matchers
156157
gem "shoulda-matchers", "~> 6.5"
157158
# Default rules for Rubocop.
158-
gem "standard", "~> 1.40"
159+
gem "standard", "~> 1.50"
159160
gem "standard-rails"
160161
gem "standard-performance"
161162
# Erb linter.

Gemfile.lock

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -76,27 +76,30 @@ GEM
7676
addressable (2.8.7)
7777
public_suffix (>= 2.0.2, < 7.0)
7878
afm (0.2.2)
79-
annotaterb (4.14.0)
79+
annotaterb (4.16.0)
80+
activerecord (>= 6.0.0)
81+
activesupport (>= 6.0.0)
8082
ast (2.4.3)
8183
autoprefixer-rails (10.4.13.0)
8284
execjs (~> 2)
8385
awesome_print (1.9.2)
84-
aws-eventstream (1.3.1)
85-
aws-partitions (1.1050.0)
86-
aws-sdk-core (3.218.1)
86+
aws-eventstream (1.4.0)
87+
aws-partitions (1.1123.0)
88+
aws-sdk-core (3.226.1)
8789
aws-eventstream (~> 1, >= 1.3.0)
8890
aws-partitions (~> 1, >= 1.992.0)
8991
aws-sigv4 (~> 1.9)
9092
base64
9193
jmespath (~> 1, >= 1.6.1)
92-
aws-sdk-kms (1.98.0)
93-
aws-sdk-core (~> 3, >= 3.216.0)
94+
logger
95+
aws-sdk-kms (1.106.0)
96+
aws-sdk-core (~> 3, >= 3.225.0)
9497
aws-sigv4 (~> 1.5)
95-
aws-sdk-s3 (1.181.0)
96-
aws-sdk-core (~> 3, >= 3.216.0)
98+
aws-sdk-s3 (1.191.0)
99+
aws-sdk-core (~> 3, >= 3.225.0)
97100
aws-sdk-kms (~> 1)
98101
aws-sigv4 (~> 1.5)
99-
aws-sigv4 (1.11.0)
102+
aws-sigv4 (1.12.1)
100103
aws-eventstream (~> 1, >= 1.0.2)
101104
azure-storage-blob (2.0.3)
102105
azure-storage-common (~> 2.0)
@@ -120,7 +123,7 @@ GEM
120123
erubi (~> 1.4)
121124
parser (>= 2.4)
122125
smart_properties
123-
bigdecimal (3.2.1)
126+
bigdecimal (3.2.2)
124127
bindex (0.8.1)
125128
binding_of_caller (1.0.1)
126129
debug_inspector (>= 1.2.0)
@@ -135,7 +138,7 @@ GEM
135138
bugsnag (6.27.1)
136139
concurrent-ruby (~> 1.0)
137140
builder (3.3.0)
138-
bullet (8.0.5)
141+
bullet (8.0.8)
139142
activesupport (>= 3.0.0)
140143
uniform_notifier (~> 1.11)
141144
capybara (3.40.0)
@@ -235,11 +238,11 @@ GEM
235238
smart_properties
236239
erubi (1.13.1)
237240
execjs (2.10.0)
238-
factory_bot (6.5.0)
239-
activesupport (>= 5.0.0)
240-
factory_bot_rails (6.4.4)
241+
factory_bot (6.5.4)
242+
activesupport (>= 6.1.0)
243+
factory_bot_rails (6.5.0)
241244
factory_bot (~> 6.5)
242-
railties (>= 5.0.0)
245+
railties (>= 6.1.0)
243246
faker (3.5.1)
244247
i18n (>= 1.8.11, < 2)
245248
faraday (1.10.4)
@@ -277,11 +280,11 @@ GEM
277280
ffi (1.17.2-x86_64-darwin)
278281
ffi (1.17.2-x86_64-linux-gnu)
279282
filterrific (5.2.7)
280-
flipper (1.3.4)
283+
flipper (1.3.5)
281284
concurrent-ruby (< 2)
282-
flipper-active_record (1.3.4)
285+
flipper-active_record (1.3.5)
283286
activerecord (>= 4.2, < 9)
284-
flipper (~> 1.3.4)
287+
flipper (~> 1.3.5)
285288
flipper-ui (1.3.4)
286289
erubi (>= 1.0.0, < 2.0.0)
287290
flipper (~> 1.3.4)
@@ -333,8 +336,8 @@ GEM
333336
actionview (>= 5.0.0)
334337
activesupport (>= 5.0.0)
335338
jmespath (1.6.2)
336-
json (2.11.3)
337-
jwt (2.10.1)
339+
json (2.12.2)
340+
jwt (3.1.2)
338341
base64
339342
kaminari (1.2.2)
340343
activesupport (>= 4.1.0)
@@ -350,7 +353,7 @@ GEM
350353
kaminari-core (1.2.2)
351354
knapsack_pro (8.3.0)
352355
rake
353-
language_server-protocol (3.17.0.4)
356+
language_server-protocol (3.17.0.5)
354357
launchy (3.0.0)
355358
addressable (~> 2.8)
356359
childprocess (~> 5.0)
@@ -509,8 +512,8 @@ GEM
509512
puma (6.6.0)
510513
nio4r (~> 2.0)
511514
racc (1.8.1)
512-
rack (3.1.15)
513-
rack-mini-profiler (3.3.1)
515+
rack (3.1.16)
516+
rack-mini-profiler (4.0.0)
514517
rack (>= 1.2.0)
515518
rack-protection (4.1.1)
516519
base64 (>= 0.1.0)
@@ -566,7 +569,7 @@ GEM
566569
rb-fsevent (0.11.2)
567570
rb-inotify (0.10.1)
568571
ffi (~> 1.0)
569-
rdoc (6.14.0)
572+
rdoc (6.14.1)
570573
erb
571574
psych (>= 4.0.0)
572575
recaptcha (5.19.0)
@@ -602,7 +605,7 @@ GEM
602605
rspec-mocks (~> 3.13)
603606
rspec-support (~> 3.13)
604607
rspec-support (3.13.4)
605-
rubocop (1.75.4)
608+
rubocop (1.75.8)
606609
json (~> 2.3)
607610
language_server-protocol (~> 3.17.0.2)
608611
lint_roller (~> 1.1.0)
@@ -613,7 +616,7 @@ GEM
613616
rubocop-ast (>= 1.44.0, < 2.0)
614617
ruby-progressbar (~> 1.7)
615618
unicode-display_width (>= 2.4.0, < 4.0)
616-
rubocop-ast (1.44.1)
619+
rubocop-ast (1.45.1)
617620
parser (>= 3.3.7.2)
618621
prism (~> 1.4)
619622
rubocop-performance (1.25.0)
@@ -681,10 +684,10 @@ GEM
681684
activesupport (>= 5.2)
682685
sprockets (>= 3.0.0)
683686
stackprof (0.2.27)
684-
standard (1.49.0)
687+
standard (1.50.0)
685688
language_server-protocol (~> 3.17.0.2)
686689
lint_roller (~> 1.0)
687-
rubocop (~> 1.75.2)
690+
rubocop (~> 1.75.5)
688691
standard-custom (~> 1.0.0)
689692
standard-performance (~> 1.8)
690693
standard-custom (1.0.2)
@@ -707,15 +710,15 @@ GEM
707710
tilt (2.2.0)
708711
timeout (0.4.3)
709712
ttfunk (1.7.0)
710-
turbo-rails (2.0.13)
713+
turbo-rails (2.0.16)
711714
actionpack (>= 7.1.0)
712715
railties (>= 7.1.0)
713716
tzinfo (2.0.6)
714717
concurrent-ruby (~> 1.0)
715718
unicode-display_width (3.1.4)
716719
unicode-emoji (~> 4.0, >= 4.0.4)
717720
unicode-emoji (4.0.4)
718-
uniform_notifier (1.16.0)
721+
uniform_notifier (1.17.0)
719722
uri (1.0.3)
720723
useragent (0.16.11)
721724
version_gem (1.1.8)
@@ -792,6 +795,7 @@ DEPENDENCIES
792795
listen (~> 3.9.0)
793796
lograge
794797
magic_test
798+
matrix
795799
memory_profiler
796800
money-rails
797801
newrelic_rpm
@@ -827,7 +831,7 @@ DEPENDENCIES
827831
solid_cache (~> 1.0)
828832
sprockets (~> 4.2.2)
829833
stackprof
830-
standard (~> 1.40)
834+
standard (~> 1.50)
831835
standard-performance
832836
standard-rails
833837
stimulus-rails

app/controllers/item_categories_controller.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,17 @@ def update
3333
end
3434
end
3535

36+
def destroy
37+
@item_category = current_organization.item_categories.find_by(id: params[:id])
38+
if @item_category.items.exists?
39+
flash[:alert] = "Cannot delete item category because it has associated items."
40+
else
41+
@item_category.destroy
42+
flash[:notice] = "#{@item_category.name} has been deleted."
43+
end
44+
redirect_to items_path
45+
end
46+
3647
private
3748

3849
def item_category_params

app/javascript/utils/donations.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,14 @@ $(function() {
108108
)
109109

110110
const large_donation_boundary = 100000;
111-
$(document).on("submit", "form#new_donation", (e, _) =>
111+
$(document).on("click", "form#new_donation button[type='submit']", (e, _) =>
112112
$(".quantity").each(function(_, q) {
113113
const quantity = parseInt(q.value, 10);
114114
if (quantity > large_donation_boundary) {
115-
confirm(
115+
const answer_confirm = confirm(
116116
`${quantity} items is a large donation! Are you sure you want to submit?`
117-
);
117+
)
118+
answer_confirm === false && e.preventDefault();
118119
}
119120
})
120121
);

app/models/item.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
# active :boolean default(TRUE)
77
# additional_info :text
88
# barcode_count :integer
9-
# category :string
109
# distribution_quantity :integer
1110
# name :string
1211
# on_hand_minimum_quantity :integer default(0), not null

app/models/item_category.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,16 @@ class ItemCategory < ApplicationRecord
1616

1717
belongs_to :organization
1818
has_many :items, -> { order(name: :asc) }, inverse_of: :item_category, dependent: :nullify
19-
has_many :partner_groups, dependent: :nullify
19+
has_and_belongs_to_many :partner_groups, dependent: :nullify
20+
21+
before_destroy :ensure_no_associated_partner_groups
22+
23+
private
24+
25+
def ensure_no_associated_partner_groups
26+
if partner_groups.exists?
27+
errors.add(:base, "Cannot delete item category with associated partner groups")
28+
throw(:abort)
29+
end
30+
end
2031
end

app/models/partner.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def families_served_count
146146
end
147147

148148
def children_served_count
149-
children.count
149+
children.count { |child| !child.archived? }
150150
end
151151

152152
def family_zipcodes_count

app/pdfs/distribution_pdf.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ def compute_and_render
8888
font_size 10
8989
end
9090

91+
move_down 10
92+
text "Distribution ID:", style: :bold
93+
font_size 12
94+
text @distribution.id.to_s
95+
9196
move_down 10
9297
text "Comments:", style: :bold
9398
font_size 12

app/pdfs/picklists_pdf.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,16 @@ def compute_and_render
7676
font_size 10
7777
end
7878

79+
# Add quota information only if quota is set and greater than 0
80+
quota = request.partner.quota
81+
if quota && quota > 0
82+
move_down 5
83+
text "Quota:", style: :bold, align: :right
84+
font_size 12
85+
text quota.to_s, align: :right
86+
font_size 10
87+
end
88+
7989
move_down 10
8090
text "Comments:", style: :bold
8191
font_size 12

0 commit comments

Comments
 (0)