diff --git a/Gemfile.lock b/Gemfile.lock index c8a029d17d..3d2da2e2a4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -801,4 +801,4 @@ DEPENDENCIES webmock (~> 3.23) BUNDLED WITH - 2.5.16 + 2.5.19 diff --git a/app/controllers/adjustments_controller.rb b/app/controllers/adjustments_controller.rb index 627491232a..b0d7121ae8 100644 --- a/app/controllers/adjustments_controller.rb +++ b/app/controllers/adjustments_controller.rb @@ -15,7 +15,7 @@ def index @paginated_adjustments = @adjustments.page(params[:page]) @storage_locations = Adjustment.storage_locations_adjusted_for(current_organization).uniq - @users = current_organization.users + @users = current_organization.users.sort_by { |user| user.name.to_s.downcase } respond_to do |format| format.html diff --git a/app/controllers/audits_controller.rb b/app/controllers/audits_controller.rb index c6d8e2c99d..fddd4a64d4 100644 --- a/app/controllers/audits_controller.rb +++ b/app/controllers/audits_controller.rb @@ -6,7 +6,7 @@ class AuditsController < ApplicationController def index @selected_location = filter_params[:at_location] @audits = current_organization.audits.class_filter(filter_params) - @storage_locations = Audit.storage_locations_audited_for(current_organization).uniq + @storage_locations = Audit.storage_locations_audited_for(current_organization).uniq.sort_by{ |sl| sl.name.to_s.downcase } end def show diff --git a/app/controllers/barcode_items_controller.rb b/app/controllers/barcode_items_controller.rb index e4935894a1..057d60c56c 100644 --- a/app/controllers/barcode_items_controller.rb +++ b/app/controllers/barcode_items_controller.rb @@ -2,7 +2,7 @@ # anomaly here is the :find action, which has some special logic built-in to it, see the comments below. class BarcodeItemsController < ApplicationController def index - @items = Item.gather_items(current_organization, @global) + @items = Item.gather_items(current_organization, @global).alphabetized @base_items = BaseItem.alphabetized @selected_barcodeable_id = filter_params[:barcodeable_id] @selected_partner_key = filter_params[:by_item_partner_key] diff --git a/app/controllers/distributions_controller.rb b/app/controllers/distributions_controller.rb index a56003a716..20e6254d4d 100644 --- a/app/controllers/distributions_controller.rb +++ b/app/controllers/distributions_controller.rb @@ -48,9 +48,9 @@ def index .apply_filters(filter_params, helpers.selected_range) @paginated_distributions = @distributions.page(params[:page]) @items = current_organization.items.alphabetized - @item_categories = current_organization.item_categories + @item_categories = current_organization.item_categories.alphabetized @storage_locations = current_organization.storage_locations.active_locations.alphabetized - @partners = @distributions.collect(&:partner).uniq.sort_by(&:name) + @partners = @distributions.collect(&:partner).uniq @selected_item = filter_params[:by_item_id].presence @total_value_all_distributions = total_value(@distributions) @total_items_all_distributions = total_items(@distributions, @selected_item) diff --git a/app/controllers/donations_controller.rb b/app/controllers/donations_controller.rb index a925ab6c41..be2cb64e58 100644 --- a/app/controllers/donations_controller.rb +++ b/app/controllers/donations_controller.rb @@ -34,15 +34,15 @@ def index @paginated_donations_quantity = @paginated_donations.collect(&:total_quantity).sum @total_value_all_donations = total_value(@donations) @total_money_raised = total_money_raised(@donations) - @storage_locations = @donations.filter_map { |donation| donation.storage_location if !donation.storage_location.discarded_at }.compact.uniq.sort + @storage_locations = @donations.filter_map { |donation| donation.storage_location if !donation.storage_location.discarded_at }.compact.uniq.sort_by { |sl| sl.name.to_s.downcase } @selected_storage_location = filter_params[:at_storage_location] - @sources = @donations.collect(&:source).uniq.sort + @sources = @donations.collect(&:source).uniq.sort_by { |source| source.to_s.downcase } @selected_source = filter_params[:by_source] - @donation_sites = @donations.collect(&:donation_site).compact.uniq.sort_by { |site| site.name.downcase } + @donation_sites = @donations.collect(&:donation_site).compact.uniq.sort_by { |site| site.name.to_s.downcase } @selected_donation_site = filter_params[:from_donation_site] @selected_product_drive = filter_params[:by_product_drive] @selected_product_drive_participant = filter_params[:by_product_drive_participant] - @manufacturers = @donations.collect(&:manufacturer).compact.uniq.sort + @manufacturers = @donations.collect(&:manufacturer).compact.uniq.sort_by { |manufacturer| manufacturer.name.to_s.downcase } @selected_manufacturer = filter_params[:from_manufacturer] respond_to do |format| diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index 18e3d827ca..4655e10f60 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb @@ -14,8 +14,8 @@ def index if params.dig(:filters, :date_range).present? @events = @events.during(helpers.selected_range) end - @items = current_organization.items.sort_by(&:name) - @locations = current_organization.storage_locations + @items = current_organization.items.alphabetized + @locations = current_organization.storage_locations.alphabetized respond_to do |format| format.html do diff --git a/app/controllers/items_controller.rb b/app/controllers/items_controller.rb index cd066bac84..64981ec06d 100644 --- a/app/controllers/items_controller.rb +++ b/app/controllers/items_controller.rb @@ -8,9 +8,9 @@ def index .alphabetized .class_filter(filter_params) .group('items.id') - @items = @items.active unless params[:include_inactive_items] + @items = @items.active.alphabetized unless params[:include_inactive_items] - @item_categories = current_organization.item_categories.includes(:items).order('name ASC') + @item_categories = current_organization.item_categories.includes(:items).alphabetized @kits = current_organization.kits.includes(line_items: :item, inventory_items: :storage_location) @storages = current_organization.storage_locations.active_locations.order(id: :asc) @@ -59,13 +59,13 @@ def create def new @base_items = BaseItem.without_kit.alphabetized - @item_categories = current_organization.item_categories + @item_categories = current_organization.item_categories.alphabetized @item = current_organization.items.new end def edit @base_items = BaseItem.without_kit.alphabetized - @item_categories = current_organization.item_categories + @item_categories = current_organization.item_categories.alphabetized @item = current_organization.items.find(params[:id]) end diff --git a/app/models/base_item.rb b/app/models/base_item.rb index d910a46f25..a85560b35d 100644 --- a/app/models/base_item.rb +++ b/app/models/base_item.rb @@ -23,7 +23,7 @@ class BaseItem < ApplicationRecord scope :by_partner_key, ->(partner_key) { where(partner_key: partner_key) } scope :without_kit, -> { where.not(name: 'Kit') } - scope :alphabetized, -> { order(:name) } + scope :alphabetized, -> { order('LOWER(name)') } def to_h { partner_key: partner_key, name: name } diff --git a/app/models/item.rb b/app/models/item.rb index 66ca08f5c7..e2db26a1c6 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -56,7 +56,7 @@ class Item < ApplicationRecord scope :loose, -> { where(kit_id: nil) } scope :visible, -> { where(visible_to_partners: true) } - scope :alphabetized, -> { order(:name) } + scope :alphabetized, -> { order('LOWER(name)') } scope :by_base_item, ->(base_item) { where(base_item: base_item) } scope :by_partner_key, ->(partner_key) { where(partner_key: partner_key) } diff --git a/app/models/item_category.rb b/app/models/item_category.rb index c005bfe9b7..11a7cb08af 100644 --- a/app/models/item_category.rb +++ b/app/models/item_category.rb @@ -18,4 +18,6 @@ class ItemCategory < ApplicationRecord belongs_to :organization has_many :items, -> { order(name: :asc) }, inverse_of: :item_category, dependent: :nullify has_many :partner_groups, dependent: :nullify + + scope :alphabetized, -> { order('LOWER(name)') } end diff --git a/app/models/partner.rb b/app/models/partner.rb index 9ac073d186..851f644d58 100644 --- a/app/models/partner.rb +++ b/app/models/partner.rb @@ -63,7 +63,7 @@ class Partner < ApplicationRecord .order(:name) } - scope :alphabetized, -> { order(:name) } + scope :alphabetized, -> { order('LOWER(name)') } scope :active, -> { where.not(status: :deactivated) } include Filterable diff --git a/app/models/unit.rb b/app/models/unit.rb index cfe4731589..6a1282a799 100644 --- a/app/models/unit.rb +++ b/app/models/unit.rb @@ -11,4 +11,6 @@ class Unit < ApplicationRecord belongs_to :organization validates :name, uniqueness: {scope: :organization} + + scope :alphabetized, -> { order('LOWER(name)') } end diff --git a/app/models/user.rb b/app/models/user.rb index 52e16fcc63..06dc32aa61 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -71,7 +71,6 @@ class User < ApplicationRecord validate :password_complexity default_scope -> { kept } - scope :alphabetized, -> { order(discarded_at: :desc, name: :asc) } scope :partner_users, -> { with_role(Role::PARTNER, :any) } scope :org_users, -> { with_role(Role::ORG_USER, :any) } scope :search_name, ->(query) { where("name ilike ?", "%#{query}%") } diff --git a/app/views/barcode_items/index.html.erb b/app/views/barcode_items/index.html.erb index fa8d97d260..9fed8e557d 100644 --- a/app/views/barcode_items/index.html.erb +++ b/app/views/barcode_items/index.html.erb @@ -33,10 +33,10 @@ <%= form_with(url: barcode_items_path, method: :get) do |f| %>
- <%= filter_select(label: "Filter by Item Category", scope: :barcodeable_id, collection: @items.alphabetized, key: :id, value: :name, selected: @selected_barcodeable_id) %> + <%= filter_select(label: "Filter by Item Category", scope: :barcodeable_id, collection: @items, key: :id, value: :name, selected: @selected_barcodeable_id) %>
- <%= filter_select(label: "Filter by Base Item", scope: :by_item_partner_key, collection: @base_items.order('name'), key: :partner_key, value: :name, selected: @selected_partner_key) %> + <%= filter_select(label: "Filter by Base Item", scope: :by_item_partner_key, collection: @base_items, key: :partner_key, value: :name, selected: @selected_partner_key) %>
<%= filter_text(label: "Filter By Barcode (Boop it!)", scope: :by_value, selected: @selected_barcode_id) %> diff --git a/app/views/events/index.html.erb b/app/views/events/index.html.erb index ea24a1f682..83f965ceaa 100644 --- a/app/views/events/index.html.erb +++ b/app/views/events/index.html.erb @@ -46,7 +46,7 @@ selected: params.dig(:filters, :by_type)) %>
- <%= filter_select(scope: :by_storage_location, collection: current_organization.storage_locations, + <%= filter_select(scope: :by_storage_location, collection: @locations, selected:params.dig(:filters, :by_storage_location)) %>
diff --git a/app/views/items/_form.html.erb b/app/views/items/_form.html.erb index 15dc7ebbb3..73c358ad36 100644 --- a/app/views/items/_form.html.erb +++ b/app/views/items/_form.html.erb @@ -45,7 +45,7 @@ <% if Flipper.enabled?(:enable_packs) %> <%= f.input :request_units, label: "Additional Custom Request Units" do %> - <%= f.association :request_units, as: :check_boxes, collection: current_organization.request_units, checked: selected_item_request_units(@item), label_method: :name, value_method: :id, class: "form-check-input" %> + <%= f.association :request_units, as: :check_boxes, collection: current_organization.request_units.alphabetized, checked: selected_item_request_units(@item), label_method: :name, value_method: :id, class: "form-check-input" %> <% end %> <% end %> diff --git a/app/views/line_items/_line_item_fields.html.erb b/app/views/line_items/_line_item_fields.html.erb index 437f278b12..59d91b1a29 100644 --- a/app/views/line_items/_line_item_fields.html.erb +++ b/app/views/line_items/_line_item_fields.html.erb @@ -15,8 +15,8 @@ <%= field.input :item_id, disabled: requested.present?, - collection: @items, prompt: "Choose an item", - include_blank: "", + collection: @items, + include_blank: false, label: false, input_html: { class: "my-0 line_item_name", "data-controller": "select2" } %> <% if requested.present? %> diff --git a/app/views/storage_locations/_source.html.erb b/app/views/storage_locations/_source.html.erb index 5f775d59ed..a865318979 100644 --- a/app/views/storage_locations/_source.html.erb +++ b/app/views/storage_locations/_source.html.erb @@ -10,7 +10,8 @@ label: label, error: error, selected: storage_location_for_source(source.object), - include_blank: true, + include_blank: false, + prompt: "Choose a storage location", input_html: { data: { storage_location_inventory_path: inventory_storage_location_path(