Partialising the _distributor render

This commit is contained in:
Will Marshall
2013-11-06 15:36:39 +11:00
parent f9a4718bdd
commit 406f8033fe
5 changed files with 19 additions and 15 deletions

View 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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View 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