diff --git a/app/controllers/items_controller.rb b/app/controllers/items_controller.rb index 6a807efab7..704ea2db73 100644 --- a/app/controllers/items_controller.rb +++ b/app/controllers/items_controller.rb @@ -31,11 +31,11 @@ def index end def create - create = if Flipper.enabled?(:enable_packs) - ItemCreateService.new(organization_id: current_organization.id, item_params: item_params, request_unit_ids:) - else - ItemCreateService.new(organization_id: current_organization.id, item_params: item_params) - end + create = ItemCreateService.new( + organization_id: current_organization.id, + item_params: item_params, + request_unit_ids: request_unit_ids + ) result = create.call if result.success? @@ -182,11 +182,7 @@ def request_unit_ids # We need to update both the item and the request_units together and fail together def update_item - if Flipper.enabled?(:enable_packs) - update_item_and_request_units - else - @item.save - end + update_item_and_request_units end def update_item_and_request_units diff --git a/app/controllers/partners/requests_controller.rb b/app/controllers/partners/requests_controller.rb index 0595a0f342..3fc3a8e781 100644 --- a/app/controllers/partners/requests_controller.rb +++ b/app/controllers/partners/requests_controller.rb @@ -80,13 +80,11 @@ def partner_request_params def fetch_items @requestable_items = PartnerFetchRequestableItemsService.new(partner_id: partner.id).call - if Flipper.enabled?(:enable_packs) - # hash of (item ID => hash of (request unit name => request unit plural name)) - item_ids = @requestable_items.to_h.values - if item_ids.present? - @item_units = Item.where(id: item_ids).to_h do |i| - [i.id, i.request_units.to_h { |u| [u.name, u.name.pluralize] }] - end + # Packs are always enabled, so always fetch item units + item_ids = @requestable_items.to_h.values + if item_ids.present? + @item_units = Item.where(id: item_ids).to_h do |i| + [i.id, i.request_units.to_h { |u| [u.name, u.name.pluralize] }] end end end diff --git a/app/models/partners/item_request.rb b/app/models/partners/item_request.rb index 544d8f04af..078b448cba 100644 --- a/app/models/partners/item_request.rb +++ b/app/models/partners/item_request.rb @@ -37,7 +37,7 @@ def request_unit_is_supported end def name_with_unit(quantity_override = nil) - if Flipper.enabled?(:enable_packs) && request_unit.present? + if request_unit.present? "#{item&.name || name} - #{request_unit.pluralize(quantity_override || quantity.to_i)}" else item&.name || name diff --git a/app/pdfs/distribution_pdf.rb b/app/pdfs/distribution_pdf.rb index 56c9ad6a7e..0cb849befa 100644 --- a/app/pdfs/distribution_pdf.rb +++ b/app/pdfs/distribution_pdf.rb @@ -264,9 +264,7 @@ def insert_signature_fields else move_down 20 end - signature_lines_for "Received By:" - move_down 20 signature_lines_for "Delivered By:" end @@ -291,7 +289,7 @@ def signature_lines_for(label) end def request_display_qty(request_item) - if Flipper.enabled?(:enable_packs) && request_item&.unit + if request_item&.unit "#{request_item.quantity} #{request_item.unit.pluralize(request_item.quantity)}" else request_item&.quantity || "" diff --git a/app/pdfs/picklists_pdf.rb b/app/pdfs/picklists_pdf.rb index 63e03f3eb8..2ee121558d 100644 --- a/app/pdfs/picklists_pdf.rb +++ b/app/pdfs/picklists_pdf.rb @@ -144,7 +144,7 @@ def compute_and_render end def has_custom_units?(line_items) - Flipper.enabled?(:enable_packs) && line_items.any? { |line_item| line_item.request_unit } + line_items.any? { |line_item| line_item.request_unit } end def data_with_units(line_items) diff --git a/app/services/exports/export_request_service.rb b/app/services/exports/export_request_service.rb index 02da2c4c83..fe8ba09b0b 100644 --- a/app/services/exports/export_request_service.rb +++ b/app/services/exports/export_request_service.rb @@ -70,16 +70,14 @@ def compute_item_headers if item_request.item item = item_request.item item_names << item.name - if Flipper.enabled?(:enable_packs) - item.request_units.each do |unit| - item_names << "#{item.name} - #{unit.name.pluralize}" - end - - # It's possible that the unit is no longer valid, so we'd - # add that individually - if item_request.request_unit.present? - item_names << "#{item.name} - #{item_request.request_unit.pluralize}" - end + item.request_units.each do |unit| + item_names << "#{item.name} - #{unit.name.pluralize}" + end + + # It's possible that the unit is no longer valid, so we'd + # add that individually + if item_request.request_unit.present? + item_names << "#{item.name} - #{item_request.request_unit.pluralize}" end end end @@ -97,7 +95,15 @@ def build_row_data(request) row += Array.new(item_headers.size, 0) request.item_requests.each do |item_request| - item_name = item_request.item.present? ? item_request.name_with_unit(0) : DELETED_ITEMS_COLUMN_HEADER + item_name = if item_request.item.present? + if item_request.request_unit.present? + item_request.name_with_unit(0) + else + item_request.item.name + end + else + DELETED_ITEMS_COLUMN_HEADER + end item_column_idx = headers_with_indexes[item_name] row[item_column_idx] ||= 0 row[item_column_idx] += item_request.quantity.to_i diff --git a/app/services/item_create_service.rb b/app/services/item_create_service.rb index 01159d33e4..5450e36492 100644 --- a/app/services/item_create_service.rb +++ b/app/services/item_create_service.rb @@ -8,10 +8,7 @@ def initialize(organization_id:, item_params:, request_unit_ids: []) def call new_item = organization.items.new(item_params) new_item.save! - if Flipper.enabled?(:enable_packs) - new_item.sync_request_units!(@request_unit_ids) - end - + new_item.sync_request_units!(@request_unit_ids) Result.new(value: new_item) rescue StandardError => e Result.new(error: e) diff --git a/app/services/organization_update_service.rb b/app/services/organization_update_service.rb index d462a895ce..9173732671 100644 --- a/app/services/organization_update_service.rb +++ b/app/services/organization_update_service.rb @@ -18,15 +18,13 @@ def update(organization, params) org_params["partner_form_fields"] = org_params["partner_form_fields"].compact_blank end - if Flipper.enabled?(:enable_packs) - request_unit_names = org_params[:request_unit_names] || [] - # Find or create units for the organization - request_unit_ids = request_unit_names.compact_blank.map do |request_unit_name| - Unit.find_or_create_by(organization: organization, name: request_unit_name).id - end - org_params.delete(:request_unit_names) - org_params[:request_unit_ids] = request_unit_ids + request_unit_names = org_params[:request_unit_names] || [] + # Find or create units for the organization + request_unit_ids = request_unit_names.compact_blank.map do |request_unit_name| + Unit.find_or_create_by(organization: organization, name: request_unit_name).id end + org_params.delete(:request_unit_names) + org_params[:request_unit_ids] = request_unit_ids result = organization.update(org_params) diff --git a/app/views/items/_form.html.erb b/app/views/items/_form.html.erb index 7af1f6e98e..5196a04190 100644 --- a/app/views/items/_form.html.erb +++ b/app/views/items/_form.html.erb @@ -43,11 +43,9 @@ <%= f.input_field :package_size, class: "form-control", min: 0 %> <% end %> - <% 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" %> <% end %> - <% end %> <%= f.input :visible, label: "Item is Visible to Partners?", wrapper: :input_group do %> <%= f.check_box :visible_to_partners, {class: "input-group-text", id: "visible_to_partners"}, "true", "false" %> diff --git a/app/views/items/_item_list.html.erb b/app/views/items/_item_list.html.erb index 5a3fe1e521..0a2278027a 100644 --- a/app/views/items/_item_list.html.erb +++ b/app/views/items/_item_list.html.erb @@ -11,10 +11,8 @@ Add. Info Quantity Per Individual Fair Market Value (per item) - <% if Flipper.enabled?(:enable_packs) %> - <% unless current_organization.request_units.empty? %> - Custom Request Units - <% end %> + <% unless current_organization.request_units.empty? %> + Custom Request Units <% end %> Actions diff --git a/app/views/items/_item_row.html.erb b/app/views/items/_item_row.html.erb index 5efb0ab31d..0e1d160750 100644 --- a/app/views/items/_item_row.html.erb +++ b/app/views/items/_item_row.html.erb @@ -4,10 +4,8 @@ <%= truncate item_row.additional_info, length: 25 %> <%= item_row.distribution_quantity %> <%= dollar_value(item_row.value_in_cents) %> - <% if Flipper.enabled?(:enable_packs) %> - <% unless current_organization.request_units.empty? %> - <%= item_row.request_units.pluck(:name).join(', ') %> - <% end %> + <% unless current_organization.request_units.empty? %> + <%= item_row.request_units.pluck(:name).join(', ') %> <% end %> <%= view_button_to item_path(item_row) %> diff --git a/app/views/items/show.html.erb b/app/views/items/show.html.erb index 644f6e90e4..01a5e48dde 100644 --- a/app/views/items/show.html.erb +++ b/app/views/items/show.html.erb @@ -64,11 +64,9 @@ <%= @item.package_size || 0 %> - <% if Flipper.enabled?(:enable_packs) %> - Custom Units - <% item_units = @item.request_units&.pluck("item_units.name") %> - <%= item_units&.join("; ") %> - <% end %> + Custom Units + <% item_units = @item.request_units&.pluck("item_units.name") %> + <%= item_units&.join("; ") %> Item is visible to partners diff --git a/app/views/organizations/_details.html.erb b/app/views/organizations/_details.html.erb index 0a1fae3d51..90dee8f736 100644 --- a/app/views/organizations/_details.html.erb +++ b/app/views/organizations/_details.html.erb @@ -149,24 +149,22 @@ <%= humanize_boolean(@organization.enable_quantity_based_requests) %>

- <% if Flipper.enabled?(:enable_packs) %> -
-
Custom Request units used (please use singular form -- e.g. pack, not packs)
-

- <% if @organization.request_units.length > 0 %> - <% @organization.request_units.map do |unit| %> - <%= fa_icon "angle-right" %> - - <%= unit.name.titlecase %> -
- <% end %> - <% else %> +

+
Custom Request units used (please use singular form -- e.g. pack, not packs)
+

+ <% if @organization.request_units.length > 0 %> + <% @organization.request_units.map do |unit| %> <%= fa_icon "angle-right" %> - None + + <%= unit.name.titlecase %> +
<% end %> -

-
- <% end %> + <% else %> + <%= fa_icon "angle-right" %> + None + <% end %> +

+

Other emails

diff --git a/app/views/organizations/edit.html.erb b/app/views/organizations/edit.html.erb index 4e44a78e43..632ac18037 100644 --- a/app/views/organizations/edit.html.erb +++ b/app/views/organizations/edit.html.erb @@ -129,25 +129,23 @@ <%= f.input :enable_child_based_requests, label: 'Enable Partners to make child-based Requests?', as: :radio_buttons, collection: [[true, 'Yes'], [false, 'No']], label_method: :second, value_method: :first %> <%= f.input :enable_individual_requests, label: 'Enable Partners to make Requests by indicating number of individuals needing each Item?', as: :radio_buttons, collection: [[true, 'Yes'], [false, 'No']], label_method: :second, value_method: :first %> <%= f.input :enable_quantity_based_requests, label: 'Enable Partners to make quantity-based Requests?', as: :radio_buttons, collection: [[true, 'Yes'], [false, 'No']], label_method: :second, value_method: :first %> - <% if Flipper.enabled?(:enable_packs) %> - <%= label_tag "organization[request_unit_names]", 'Custom request units used. Please use singular form -- e.g. pack, not packs. There will be a default "unit" entry provided.' %> - <%= select_tag( - "organization[request_unit_names]", - options_from_collection_for_select( - current_organization.request_units, - 'name', - 'name', - ->(_) { true } # Select all of the current request units - ), - { - multiple: true, - class: 'form-control custom-select', - 'data-controller': 'select2', - 'data-select2-hide-dropdown-value': true, - 'data-select2-config-value': '{"selectOnClose": "true", "tags": "true", "tokenSeparators": [",", "\t"]}' - } - ) %> - <% end %> + <%= label_tag "organization[request_unit_names]", 'Custom request units used. Please use singular form -- e.g. pack, not packs. There will be a default "unit" entry provided.' %> + <%= select_tag( + "organization[request_unit_names]", + options_from_collection_for_select( + current_organization.request_units, + 'name', + 'name', + ->(_) { true } # Select all of the current request units + ), + { + multiple: true, + class: 'form-control custom-select', + 'data-controller': 'select2', + 'data-select2-hide-dropdown-value': true, + 'data-select2-config-value': '{"selectOnClose": "true", "tags": "true", "tokenSeparators": [",", "\t"]}' + } + ) %>

Other emails

diff --git a/app/views/partners/dashboards/_requests_in_progress.html.erb b/app/views/partners/dashboards/_requests_in_progress.html.erb index 71a2f84151..5e1a16d287 100644 --- a/app/views/partners/dashboards/_requests_in_progress.html.erb +++ b/app/views/partners/dashboards/_requests_in_progress.html.erb @@ -24,7 +24,7 @@ <% request.item_requests.each do |item_request| %> - <% if Flipper.enabled?(:enable_packs) && item_request.request_unit %> + <% if item_request.request_unit %> <%= pluralize(item_request.quantity, item_request.request_unit) %> — <% else %> diff --git a/app/views/partners/requests/_error.html.erb b/app/views/partners/requests/_error.html.erb index d4c4b6708b..71b68a6bb4 100644 --- a/app/views/partners/requests/_error.html.erb +++ b/app/views/partners/requests/_error.html.erb @@ -8,7 +8,7 @@

Oops! Something went wrong with your Request

Ensure each line item has a item selected AND a quantity greater than 0. - <% if Flipper.enabled?(:enable_packs) && (current_partner&.organization || current_organization).request_units.any? %> + <% if (current_partner&.organization || current_organization).request_units.any? %> Please ensure a single unit is selected for each item that supports it. <% end %>

diff --git a/app/views/partners/requests/_item_request.html.erb b/app/views/partners/requests/_item_request.html.erb index 2afdbcc112..4a26c47044 100644 --- a/app/views/partners/requests/_item_request.html.erb +++ b/app/views/partners/requests/_item_request.html.erb @@ -12,7 +12,7 @@ <%= field.number_field :quantity, label: false, step: 1, min: 1, class: 'form-control' %> - <% if Flipper.enabled?(:enable_packs) && (current_partner ? current_partner.organization.request_units.any? : current_organization.request_units.any?) %> + <% if (current_partner ? current_partner.organization.request_units.any? : current_organization.request_units.any?) %> <%= field.label :request_unit, "Unit", {class: 'sr-only'} %> <%= field.select :request_unit, [], {include_blank: 'units'}, diff --git a/app/views/partners/requests/new.html.erb b/app/views/partners/requests/new.html.erb index 8392e17828..4a89ed1556 100644 --- a/app/views/partners/requests/new.html.erb +++ b/app/views/partners/requests/new.html.erb @@ -42,7 +42,7 @@ Item Requested Quantity - <% if Flipper.enabled?(:enable_packs) && (current_partner ? current_partner.organization.request_units.any? : current_organization.request_units.any?) %> + <% if (current_partner ? current_partner.organization.request_units.any? : current_organization.request_units.any?) %> Units (if applicable) <% end %> diff --git a/app/views/partners/requests/show.html.erb b/app/views/partners/requests/show.html.erb index c658860818..4306be174d 100644 --- a/app/views/partners/requests/show.html.erb +++ b/app/views/partners/requests/show.html.erb @@ -56,7 +56,7 @@ <% @partner_request.item_requests.each do |item| %>
  • <%= item.name %> - <%= item.quantity %> - <% if Flipper.enabled?(:enable_packs) && item.request_unit %> + <% if item.request_unit %> <%= item.request_unit.pluralize(item.quantity.to_i) %> <% end %>
  • diff --git a/app/views/partners/requests/validate.html.erb b/app/views/partners/requests/validate.html.erb index 87be2655b2..0020859e6f 100644 --- a/app/views/partners/requests/validate.html.erb +++ b/app/views/partners/requests/validate.html.erb @@ -11,7 +11,7 @@ Item Name Total Items - <% if Flipper.enabled?(:enable_packs) && @partner_request.item_requests.any?( &:request_unit ) %> + <% if @partner_request.item_requests.any?( &:request_unit ) %> Units <% end %> @@ -21,7 +21,7 @@ <%= line_item.name %> <%= line_item.quantity %> - <% if Flipper.enabled?(:enable_packs) && @partner_request.item_requests.any?( &:request_unit ) %> + <% if @partner_request.item_requests.any?( &:request_unit ) %> <%= line_item.request_unit&.pluralize(line_item.quantity.to_i) %> <% end %> diff --git a/app/views/requests/show.html.erb b/app/views/requests/show.html.erb index c2560ce0cd..567fba50ed 100644 --- a/app/views/requests/show.html.erb +++ b/app/views/requests/show.html.erb @@ -67,8 +67,7 @@ Item Quantity - <% custom_units = Flipper.enabled?(:enable_packs) && - @request.item_requests.any? { |item| item.request_unit } %> + <% custom_units = @request.item_requests.any? { |item| item.request_unit } %> <% if custom_units %> Units (if applicable) <% end %> diff --git a/app/views/requests_confirmation_mailer/confirmation_email.html.erb b/app/views/requests_confirmation_mailer/confirmation_email.html.erb index ae7f75f4d4..26d6327f90 100644 --- a/app/views/requests_confirmation_mailer/confirmation_email.html.erb +++ b/app/views/requests_confirmation_mailer/confirmation_email.html.erb @@ -4,7 +4,7 @@