mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-05 22:26:07 +00:00
Fix Rails/HelperInstanceVariable
This commit is contained in:
@@ -445,11 +445,6 @@ Rails/HasManyOrHasOneDependent:
|
||||
# Include: app/helpers/**/*.rb
|
||||
Rails/HelperInstanceVariable:
|
||||
Exclude:
|
||||
- 'app/helpers/application_helper.rb'
|
||||
- 'app/helpers/injection_helper.rb'
|
||||
- 'app/helpers/order_cycles_helper.rb'
|
||||
- 'app/helpers/shared_helper.rb'
|
||||
- 'app/helpers/shop_helper.rb'
|
||||
- 'app/helpers/spree/admin/orders_helper.rb'
|
||||
- 'app/helpers/spree/orders_helper.rb'
|
||||
|
||||
|
||||
@@ -55,10 +55,10 @@ module ApplicationHelper
|
||||
end
|
||||
end
|
||||
|
||||
def body_classes
|
||||
def body_classes(hide_menu, shopfront_layout)
|
||||
classes = []
|
||||
classes << "off-canvas" unless @hide_menu
|
||||
classes << @shopfront_layout
|
||||
classes << "off-canvas" unless hide_menu
|
||||
classes << shopfront_layout
|
||||
end
|
||||
|
||||
def pdf_stylesheet_pack_tag(source)
|
||||
|
||||
@@ -12,7 +12,7 @@ module InjectionHelper
|
||||
"enterprises",
|
||||
enterprises || default_enterprise_query,
|
||||
Api::EnterpriseSerializer,
|
||||
enterprise_injection_data
|
||||
enterprise_injection_data,
|
||||
)
|
||||
end
|
||||
|
||||
@@ -56,15 +56,16 @@ module InjectionHelper
|
||||
|
||||
inject_json_array "enterprises",
|
||||
enterprises_and_relatives,
|
||||
Api::EnterpriseSerializer, enterprise_injection_data
|
||||
Api::EnterpriseSerializer,
|
||||
enterprise_injection_data
|
||||
end
|
||||
|
||||
def inject_group_enterprises
|
||||
def inject_group_enterprises(group)
|
||||
inject_json_array(
|
||||
"enterprises",
|
||||
@group.enterprises.activated.visible.all,
|
||||
group.enterprises.activated.visible.all,
|
||||
Api::EnterpriseSerializer,
|
||||
enterprise_injection_data
|
||||
enterprise_injection_data,
|
||||
)
|
||||
end
|
||||
|
||||
@@ -105,16 +106,16 @@ module InjectionHelper
|
||||
inject_json "openStreetMapConfig", {}, Api::OpenStreetMapConfigSerializer
|
||||
end
|
||||
|
||||
def inject_spree_api_key
|
||||
def inject_spree_api_key(spree_api_key)
|
||||
render partial: "json/injection_ams",
|
||||
locals: { name: 'spreeApiKey', json: "'#{@spree_api_key}'" }
|
||||
locals: { name: 'spreeApiKey', json: "'#{spree_api_key}'" }
|
||||
end
|
||||
|
||||
def inject_available_countries
|
||||
inject_json_array "availableCountries", available_countries, Api::CountrySerializer
|
||||
end
|
||||
|
||||
def inject_enterprise_attributes
|
||||
def inject_enterprise_attributes(enterprise_attributes)
|
||||
render partial: "json/injection_ams",
|
||||
locals: { name: 'enterpriseAttributes', json: @enterprise_attributes.to_json.to_s }
|
||||
end
|
||||
|
||||
@@ -55,8 +55,8 @@ module OrderCyclesHelper
|
||||
end
|
||||
end
|
||||
|
||||
def active_order_cycle_for_distributor?(_distributor)
|
||||
OrderCycle.active.with_distributor(@distributor).present?
|
||||
def active_order_cycle_for_distributor?(distributor)
|
||||
OrderCycle.active.with_distributor(distributor).present?
|
||||
end
|
||||
|
||||
def simple_index
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module ShopHelper
|
||||
def oc_select_options
|
||||
@order_cycles.map { |oc| { time: pickup_time(oc), id: oc.id } }
|
||||
def oc_select_options(order_cycles)
|
||||
order_cycles.map { |oc| { time: pickup_time(oc), id: oc.id } }
|
||||
end
|
||||
|
||||
def require_customer?
|
||||
@@ -48,12 +48,13 @@ module ShopHelper
|
||||
require_customer? || current_distributor.preferred_shopfront_message.present?
|
||||
end
|
||||
|
||||
def shopfront_closed_message?
|
||||
no_open_order_cycles? && current_distributor.preferred_shopfront_closed_message.present?
|
||||
def shopfront_closed_message?(order_cycles)
|
||||
no_open_order_cycles?(order_cycles) && \
|
||||
current_distributor.preferred_shopfront_closed_message.present?
|
||||
end
|
||||
|
||||
def no_open_order_cycles?
|
||||
@no_open_order_cycles ||= @order_cycles&.empty?
|
||||
def no_open_order_cycles?(order_cycles)
|
||||
@no_open_order_cycles ||= order_cycles&.empty?
|
||||
end
|
||||
|
||||
def show_shopping_cta?
|
||||
|
||||
@@ -14,15 +14,15 @@
|
||||
.select-label
|
||||
%span= t :enterprises_ready_for
|
||||
|
||||
- if oc_select_options.count == 1
|
||||
- if oc_select_options(@order_cycles).count == 1
|
||||
%p
|
||||
= oc_select_options.first[:time]
|
||||
= oc_select_options(@order_cycles).first[:time]
|
||||
|
||||
- else
|
||||
%select.select2.avenir#order_cycle_id{"ng-model" => "order_cycle.order_cycle_id",
|
||||
"ofn-change-order-cycle" => true,
|
||||
"disabled" => require_customer?,
|
||||
"ng-options" => "oc.id as oc.time for oc in #{oc_select_options.to_json}"}
|
||||
"ng-options" => "oc.id as oc.time for oc in #{oc_select_options(@order_cycles).to_json}"}
|
||||
|
||||
- if oc_select_options.count > 1
|
||||
- if oc_select_options(@order_cycles).count > 1
|
||||
%option{value: "", disabled: "", selected: ""}= t :shopping_oc_select
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
- content_for :injection_data do
|
||||
= inject_available_countries
|
||||
= inject_group_enterprises
|
||||
= inject_group_enterprises(@group)
|
||||
= inject_open_street_map_config
|
||||
- cache(*CacheService::FragmentCaching.ams_all_taxons) do
|
||||
= inject_taxons
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
= action_cable_meta_tag
|
||||
|
||||
%body{ class: body_classes, "body-scroll": "true", "data-turbo": "false" }
|
||||
%body{ class: body_classes(@hide_menu, @shopfront_layout), "body-scroll": "true", "data-turbo": "false" }
|
||||
.off-canvas-wrap{ offcanvas: true }
|
||||
.fixed.off-canvas-fixed
|
||||
= render "shared/menu/menu" unless @hide_menu
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
= render partial: "shared/google_maps_js"
|
||||
|
||||
- content_for :injection_data do
|
||||
= inject_spree_api_key
|
||||
= inject_spree_api_key(@spree_api_key)
|
||||
= inject_available_countries
|
||||
= inject_enterprise_attributes
|
||||
= inject_enterprise_attributes(@enterprise_attributes)
|
||||
|
||||
- steps = %w{about contact details finished images introduction}
|
||||
- steps += %w{logo promo social steps type}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
.small-12.columns
|
||||
.content
|
||||
.shopfront_closed_message
|
||||
- if shopfront_closed_message?
|
||||
- if shopfront_closed_message?(@order_cycles)
|
||||
= current_distributor.preferred_shopfront_closed_message.html_safe
|
||||
- else
|
||||
= t :shopping_oc_closed_description
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
- content_for :injection_data do
|
||||
= inject_current_order_cycle
|
||||
|
||||
- unless no_open_order_cycles? || require_customer?
|
||||
- unless no_open_order_cycles?(@order_cycles) || require_customer?
|
||||
%ordercycle{"ng-controller" => "OrderCycleCtrl", "ng-cloak" => true,
|
||||
"ng-class" => "{'requires-selection': !OrderCycle.selected()}"}
|
||||
%form.custom
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
= render partial: "shop/messages/customer_required"
|
||||
|
||||
- else
|
||||
- if no_open_order_cycles?
|
||||
- if no_open_order_cycles?(@order_cycles)
|
||||
= render partial: "shop/messages/closed_shop"
|
||||
|
||||
- else
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
= render partial: "shopping_shared/order_cycles"
|
||||
|
||||
%div{"ng-controller" => "ProductsCtrl"}
|
||||
- if no_open_order_cycles?
|
||||
- if no_open_order_cycles?(@order_cycles)
|
||||
= render partial: "shop/messages/closed_shop"
|
||||
- else
|
||||
= render partial: "shop/messages/select_oc"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
= t :orders_oc_expired_headline
|
||||
|
||||
%p
|
||||
- if active_order_cycle_for_distributor? current_distributor
|
||||
- if active_order_cycle_for_distributor? @distributor
|
||||
= t :orders_oc_expired_text_others_html, time: distance_of_time_in_words_to_now(@order_cycle.orders_close_at), link: link_to t(:orders_oc_expired_text_link), spree.clear_orders_path
|
||||
- else
|
||||
= t :orders_oc_expired_text, time: distance_of_time_in_words_to_now(@order_cycle.orders_close_at)
|
||||
|
||||
Reference in New Issue
Block a user