Files
openfoodnetwork/app/helpers/shared_helper.rb
Dusan Orlovic 120e299653 Use activate instead of changeActivePanel/ChangeActiveTab
Remove shop-tabs controllers since we can listen on `"data-action":
"orderCycleSelected@window->tabs-and-panels#activateDefaultPanel"`

Test for cases:
* activate by clicking on tab
* activateDefaultPanel on orderCycleSelected event
* activateFromWindowLocationOrDefaultPanelTarget to activate tab based
  on achor in URL
2023-12-16 10:00:17 +01:00

26 lines
697 B
Ruby

# frozen_string_literal: true
module SharedHelper
def distributor_link_class(distributor)
cart = current_order(true)
@active_distributors ||= Enterprise.distributors_with_active_order_cycles
klass = "shop-distributor"
klass += " empties-cart" unless cart.line_items.empty? || cart.distributor == distributor
klass += @active_distributors.include?(distributor) ? ' active' : ' inactive'
klass
end
def enterprise_user?
spree_current_user&.enterprises&.count.to_i > 0
end
def admin_user?
spree_current_user&.has_spree_role? 'admin'
end
def current_shop_products_path
"#{main_app.enterprise_shop_path(current_distributor)}#/shop_panel"
end
end