mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-06 22:36:07 +00:00
Partialising the _distributor render
This commit is contained in:
12
app/helpers/shared_helper.rb
Normal file
12
app/helpers/shared_helper.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
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
|
||||
end
|
||||
|
||||
@@ -1,11 +1,2 @@
|
||||
module TempLandingPageHelper
|
||||
def temp_landing_page_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
|
||||
end
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
%ul#supplier-distributors
|
||||
- if @distributors.delete @enterprise
|
||||
%li= link_to "Buy direct from the farm", shop_enterprise_path(@enterprise), {class: temp_landing_page_distributor_link_class(@enterprise)}
|
||||
%li= link_to "Buy direct from the farm", shop_enterprise_path(@enterprise), {class: distributor_link_class(@enterprise)}
|
||||
|
||||
- @distributors.each do |distributor|
|
||||
%li= link_to distributor.name, shop_enterprise_path(distributor), {class: temp_landing_page_distributor_link_class(distributor)}
|
||||
%li= render partial: "shared/distributor", object: distributor
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
.large-12.columns.centered
|
||||
%h3 WHERE WOULD YOU LIKE TO SHOP?
|
||||
%p.secondary Select your hub from the list below
|
||||
|
||||
- @groups.in_groups_of(4, false) do |row|
|
||||
.row.landing-page-row.hub_group{:class => (row.last == @groups.last ? "with-bottom-border" : "")}
|
||||
- row.each do |group|
|
||||
@@ -38,10 +39,7 @@
|
||||
- group.enterprises.is_distributor.by_name.each do |distributor|
|
||||
.row.distributor-link-row
|
||||
.large-12.columns
|
||||
= succeed ',' do
|
||||
= link_to "<strong>#{distributor.name}</strong>".html_safe, shop_enterprise_path(distributor), {class: temp_landing_page_distributor_link_class(distributor)}
|
||||
|
||||
%span.secondary= distributor.city
|
||||
= render partial: "shared/distributor", object: distributor
|
||||
%footer
|
||||
.row.landing-page-row
|
||||
.large-6.columns.text-left
|
||||
|
||||
3
app/views/shared/_distributor.html.haml
Normal file
3
app/views/shared/_distributor.html.haml
Normal file
@@ -0,0 +1,3 @@
|
||||
= succeed ',' do
|
||||
= link_to "<strong>#{distributor.name}</strong>".html_safe, shop_enterprise_path(distributor), {class: distributor_link_class(distributor)}
|
||||
%span.secondary= distributor.city
|
||||
Reference in New Issue
Block a user