Skip to content

Commit

Permalink
Merge branch 'main' into 4217-kit-various-refactors
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyli97 committed Dec 10, 2024
2 parents 0cfc8de + 9f0f81b commit 5869b2d
Show file tree
Hide file tree
Showing 462 changed files with 6,188 additions and 4,107 deletions.
1 change: 0 additions & 1 deletion .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ Layout/SpaceInsideHashLiteralBraces:
- 'app/models/product_drive_participant.rb'
- 'app/models/distribution.rb'
- 'app/models/donation.rb'
- 'app/models/inventory_item.rb'
- 'app/models/item.rb'
- 'app/models/item_category.rb'
- 'app/models/kit.rb'
Expand Down
57 changes: 29 additions & 28 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ GEM
bugsnag (6.27.1)
concurrent-ruby (~> 1.0)
builder (3.3.0)
bullet (7.2.0)
bullet (8.0.0)
activesupport (>= 3.0.0)
uniform_notifier (~> 1.11)
capybara (3.40.0)
Expand All @@ -143,7 +143,7 @@ GEM
coderay (1.1.3)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
coverband (6.1.2)
coverband (6.1.4)
redis (>= 3.0)
crack (1.0.0)
bigdecimal
Expand All @@ -162,9 +162,9 @@ GEM
irb (~> 1.10)
reline (>= 0.3.8)
debug_inspector (1.2.0)
delayed_job (4.1.11)
delayed_job (4.1.12)
activesupport (>= 3.0, < 8.0)
delayed_job_active_record (4.1.8)
delayed_job_active_record (4.1.10)
activerecord (>= 3.0, < 8.0)
delayed_job (>= 3.0, < 5)
delayed_job_web (1.4.4)
Expand Down Expand Up @@ -209,15 +209,15 @@ GEM
dry-inflector (~> 1.0)
dry-logic (~> 1.4)
zeitwerk (~> 2.6)
erb_lint (0.6.0)
erb_lint (0.7.0)
activesupport
better_html (>= 2.0.1)
parser (>= 2.7.1.4)
rainbow
rubocop (>= 1)
smart_properties
erubi (1.13.0)
execjs (2.9.1)
execjs (2.10.0)
factory_bot (6.4.5)
activesupport (>= 5.0.0)
factory_bot_rails (6.4.3)
Expand Down Expand Up @@ -259,14 +259,14 @@ GEM
ffi (1.17.0-x86_64-darwin)
ffi (1.17.0-x86_64-linux-gnu)
filterrific (5.2.5)
flipper (1.3.0)
flipper (1.3.2)
concurrent-ruby (< 2)
flipper-active_record (1.3.0)
activerecord (>= 4.2, < 8)
flipper (~> 1.3.0)
flipper-ui (1.3.0)
flipper-active_record (1.3.2)
activerecord (>= 4.2, < 9)
flipper (~> 1.3.2)
flipper-ui (1.3.1)
erubi (>= 1.0.0, < 2.0.0)
flipper (~> 1.3.0)
flipper (~> 1.3.1)
rack (>= 1.4, < 4)
rack-protection (>= 1.5.3, < 5.0.0)
rack-session (>= 1.0.2, < 3.0.0)
Expand Down Expand Up @@ -321,7 +321,7 @@ GEM
jbuilder (2.13.0)
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
json (2.7.2)
json (2.7.5)
jwt (2.9.1)
base64
kaminari (1.2.2)
Expand Down Expand Up @@ -354,7 +354,7 @@ GEM
activesupport (>= 4)
railties (>= 4)
request_store (~> 1.0)
loofah (2.22.0)
loofah (2.23.1)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
lumberjack (1.2.9)
Expand All @@ -373,7 +373,7 @@ GEM
method_source (1.1.0)
mini_magick (4.13.2)
mini_mime (1.1.5)
minitest (5.25.1)
minitest (5.25.2)
monetize (1.12.0)
money (~> 6.12)
money (6.16.0)
Expand All @@ -388,7 +388,7 @@ GEM
multipart-post (2.4.1)
mustermann (3.0.0)
ruby2_keywords (~> 0.0.1)
mutex_m (0.2.0)
mutex_m (0.3.0)
nenv (0.3.0)
net-http-persistent (4.0.2)
connection_pool (~> 2.2)
Expand Down Expand Up @@ -442,7 +442,7 @@ GEM
activerecord (>= 6.1)
request_store (~> 1.4)
parallel (1.26.3)
parser (3.3.4.2)
parser (3.3.5.1)
ast (~> 2.4.1)
racc
pdf-core (0.9.0)
Expand Down Expand Up @@ -485,7 +485,7 @@ GEM
puma (6.4.3)
nio4r (~> 2.0)
racc (1.8.1)
rack (2.2.9)
rack (2.2.10)
rack-protection (3.1.0)
rack (~> 2.2, >= 2.2.4)
rack-session (1.0.2)
Expand Down Expand Up @@ -553,7 +553,7 @@ GEM
responders (3.1.1)
actionpack (>= 5.2)
railties (>= 5.2)
rexml (3.3.8)
rexml (3.3.9)
rolify (6.0.1)
rouge (4.1.2)
rspec (3.13.0)
Expand Down Expand Up @@ -588,9 +588,9 @@ GEM
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.32.1)
rubocop-ast (1.33.0)
parser (>= 3.3.1.0)
rubocop-performance (1.21.1)
rubocop-performance (1.22.1)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rails (2.25.1)
Expand All @@ -606,7 +606,7 @@ GEM
ffi (~> 1.12)
logger
ruby2_keywords (0.0.5)
sanitize (6.1.0)
sanitize (6.1.3)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
sass-rails (6.0.0)
Expand Down Expand Up @@ -657,26 +657,26 @@ GEM
standard-custom (1.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.50)
standard-performance (1.4.0)
standard-performance (1.5.0)
lint_roller (~> 1.1)
rubocop-performance (~> 1.21.0)
rubocop-performance (~> 1.22.0)
stimulus-rails (1.3.4)
railties (>= 6.0.0)
stringio (3.1.1)
strong_migrations (1.8.0)
activerecord (>= 5.2)
terser (1.2.3)
terser (1.2.4)
execjs (>= 0.3.0, < 3)
thor (1.3.2)
tilt (2.2.0)
timeout (0.4.1)
timeout (0.4.2)
ttfunk (1.7.0)
turbo-rails (2.0.10)
actionpack (>= 6.0.0)
railties (>= 6.0.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
unicode-display_width (2.6.0)
uniform_notifier (1.16.0)
version_gem (1.1.4)
warden (1.2.9)
Expand Down Expand Up @@ -704,6 +704,7 @@ PLATFORMS
arm64-darwin-21
arm64-darwin-22
arm64-darwin-23
arm64-darwin-24
x86_64-darwin-20
x86_64-darwin-21
x86_64-darwin-22
Expand Down Expand Up @@ -798,4 +799,4 @@ DEPENDENCIES
webmock (~> 3.24)

BUNDLED WITH
2.5.21
2.5.23
10 changes: 10 additions & 0 deletions app/assets/stylesheets/custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,13 @@
margin-top: 40px;
}
}

.accordion-button.saving::after {
background-image: none;
content: "Saving...";
font-size: 0.875rem;
color: #005568;
transform: none;
width: 3rem;
cursor: not-allowed;
}
5 changes: 3 additions & 2 deletions app/assets/stylesheets/simple_form-bootstrap/_form_abbr.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Source: http://simple-form-bootstrap.plataformatec.com.br/documentation

abbr[title] {
form abbr[title] {
text-decoration: none;
}
cursor: inherit;
}
6 changes: 5 additions & 1 deletion app/controllers/admin/base_items_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# [Super Admin] Manage the BaseItems -- this is the only place in the app where Base Items can be
# added / modified. Base Items are both the template and common thread for regular Items
#
# See #4656, BaseItems are pending significant changes/possible deletion
class Admin::BaseItemsController < AdminController
def edit
@base_item = BaseItem.find(params[:id])
Expand Down Expand Up @@ -40,7 +42,9 @@ def show

def destroy
@base_item = BaseItem.includes(:items).find(params[:id])
if @base_item.items.any? && @base_item.destroy
if @base_item.id == KitCreateService.find_or_create_kit_base_item!.id
redirect_to admin_base_items_path, alert: "You cannot delete the Kits base item. This is reserved for all Kits."
elsif @base_item.items.empty? && @base_item.destroy
redirect_to admin_base_items_path, notice: "Base Item deleted!"
else
redirect_to admin_base_items_path, alert: "Failed to delete Base Item. Are there still items attached?"
Expand Down
9 changes: 5 additions & 4 deletions app/controllers/admin/organizations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@ def new

def create
@organization = Organization.new(organization_params)
@user = User.new(user_params)

if @organization.save
Organization.seed_items(@organization)
@user = UserInviteService.invite(name: user_params[:name],
email: user_params[:email],
roles: [Role::ORG_USER, Role::ORG_ADMIN],
resource: @organization)
UserInviteService.invite(name: user_params[:name],
email: user_params[:email],
roles: [Role::ORG_USER, Role::ORG_ADMIN],
resource: @organization)
SnapshotEvent.publish(@organization) # need one to start with
redirect_to admin_organizations_path, notice: "Organization added!"
else
Expand Down
25 changes: 2 additions & 23 deletions app/controllers/audits_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ def index
end

def show
if Event.read_events?(@audit.organization)
@items = View::Inventory.items_for_location(@audit.storage_location)
else
@inventory_items = @audit.storage_location.inventory_items
end
@items = View::Inventory.items_for_location(@audit.storage_location)
end

def edit
Expand All @@ -28,24 +24,7 @@ def finalize
@audit.adjustment = Adjustment.new(organization_id: @audit.organization_id, storage_location_id: @audit.storage_location_id, user_id: current_user.id, comment: 'Created Automatically through the Auditing Process')
@audit.save

inventory_items = @audit.storage_location.inventory_items

inventory_items.each do |inventory_item|
line_item = @audit.line_items.find_by(item: inventory_item.item)

next if line_item.nil?

if line_item.quantity != inventory_item.quantity
@audit.adjustment.line_items.create(item_id: inventory_item.item.id, quantity: line_item.quantity - inventory_item.quantity)
end
end

increasing_adjustment, decreasing_adjustment = @audit.adjustment.split_difference
ActiveRecord::Base.transaction do
@audit.storage_location.increase_inventory(increasing_adjustment.line_item_values)
@audit.storage_location.decrease_inventory(decreasing_adjustment.line_item_values)
AuditEvent.publish(@audit)
end
AuditEvent.publish(@audit)
@audit.finalized!
redirect_to audit_path(@audit), notice: "Audit is Finalized."
rescue => e
Expand Down
8 changes: 6 additions & 2 deletions app/controllers/concerns/importable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ def import_csv
data = File.read(params[:file].path, encoding: "BOM|UTF-8")
csv = CSV.parse(data, headers: true).reject { |row| row.to_hash.values.any?(&:nil?) }
if csv.count.positive? && csv.first.headers.all? { |header| !header.nil? }
resource_model.import_csv(csv, current_organization.id)
flash[:notice] = "#{resource_model_humanized} were imported successfully!"
errors = resource_model.import_csv(csv, current_organization.id)
if errors.empty?
flash[:notice] = "#{resource_model_humanized} were imported successfully!"
else
flash[:error] = "The following #{resource_model_humanized} did not import successfully:\n#{errors.join("\n")}"
end
else
flash[:error] = "Check headers in file!"
end
Expand Down
Loading

0 comments on commit 5869b2d

Please sign in to comment.