From 0cc108206b593b435d0ea20833649ae8b3e375ed Mon Sep 17 00:00:00 2001 From: Will Marshall Date: Fri, 14 Mar 2014 17:06:03 +1100 Subject: [PATCH] Reworking the top details so it works in all pages --- app/controllers/shop/shop_controller.rb | 3 --- app/helpers/shared_helper.rb | 5 +++++ app/views/shop/_details.html.haml | 4 ++++ app/views/shop/{shop => }/_modals.html.haml | 4 ++-- app/views/shop/_tabs.html.haml | 7 +++++++ app/views/shop/shop/_about_us.html.haml | 4 ++-- app/views/shop/shop/_contact.html.haml | 14 +++++++------- app/views/shop/shop/_groups.html.haml | 2 +- app/views/shop/shop/_producers.html.haml | 2 +- app/views/shop/shop/show.html.haml | 13 ------------- 10 files changed, 29 insertions(+), 29 deletions(-) rename app/views/shop/{shop => }/_modals.html.haml (93%) create mode 100644 app/views/shop/_tabs.html.haml diff --git a/app/controllers/shop/shop_controller.rb b/app/controllers/shop/shop_controller.rb index 81c43f0b6a..c6928efe7d 100644 --- a/app/controllers/shop/shop_controller.rb +++ b/app/controllers/shop/shop_controller.rb @@ -5,9 +5,6 @@ class Shop::ShopController < BaseController before_filter :set_order_cycles def show - # All suppliers of all our products - @producers = Exchange.where(receiver_id: @distributor.id).map{ |ex| ex.variants.map {|v| v.product.supplier }}.flatten.uniq - @groups = current_distributor.groups end def products diff --git a/app/helpers/shared_helper.rb b/app/helpers/shared_helper.rb index 2906a308aa..8ddad2524f 100644 --- a/app/helpers/shared_helper.rb +++ b/app/helpers/shared_helper.rb @@ -8,5 +8,10 @@ module SharedHelper klass += @active_distributors.include?(distributor) ? ' active' : ' inactive' klass end + + # all suppliers of current distributor's products + def current_producers + Exchange.where(receiver_id: current_distributor.id).map{ |ex| ex.variants.map {|v| v.product.supplier }}.flatten.uniq + end end diff --git a/app/views/shop/_details.html.haml b/app/views/shop/_details.html.haml index 6b77e45a27..73a83fec5a 100644 --- a/app/views/shop/_details.html.haml +++ b/app/views/shop/_details.html.haml @@ -1,3 +1,5 @@ += render partial: "shop/modals" + %navigation %distributor.details.row #distributor_title @@ -9,3 +11,5 @@ %a{href: "/"} Change location = render partial: "shop/shop/order_cycles" + += render partial: "shop/tabs" diff --git a/app/views/shop/shop/_modals.html.haml b/app/views/shop/_modals.html.haml similarity index 93% rename from app/views/shop/shop/_modals.html.haml rename to app/views/shop/_modals.html.haml index d54822306b..ea21914397 100644 --- a/app/views/shop/shop/_modals.html.haml +++ b/app/views/shop/_modals.html.haml @@ -1,4 +1,4 @@ -- for producer in @producers +- for producer in current_producers .reveal-modal{id: "producer_details_#{producer.id}"} .row - if producer.logo.exists? @@ -18,7 +18,7 @@ -- for group in @groups +- for group in current_distributor.groups - for sibling in group.enterprises.except(current_distributor) .reveal-modal{id: "sibling_details_#{sibling.id}"} .row diff --git a/app/views/shop/_tabs.html.haml b/app/views/shop/_tabs.html.haml new file mode 100644 index 0000000000..f5acad4208 --- /dev/null +++ b/app/views/shop/_tabs.html.haml @@ -0,0 +1,7 @@ +%tabs + .row + .section-container.auto{"data-section" => "", "data-options" => "one_up: false"} + = render 'shop/shop/about_us' + = render 'shop/shop/producers' + = render 'shop/shop/groups' + = render 'shop/shop/contact' diff --git a/app/views/shop/shop/_about_us.html.haml b/app/views/shop/shop/_about_us.html.haml index d4530b3c6e..920a4a8236 100644 --- a/app/views/shop/shop/_about_us.html.haml +++ b/app/views/shop/shop/_about_us.html.haml @@ -3,8 +3,8 @@ %a{href: "#about"} About Us .content{"data-section-content" => ""} - %img.about.right{src: @distributor.promo_image.url(:large)} - %p= @distributor.long_description.andand.html_safe + %img.about.right{src: current_distributor.promo_image.url(:large)} + %p= current_distributor.long_description.andand.html_safe -#.panel -#= @distributor.distributor_info.andand.html_safe diff --git a/app/views/shop/shop/_contact.html.haml b/app/views/shop/shop/_contact.html.haml index c00723896b..bc5497c173 100644 --- a/app/views/shop/shop/_contact.html.haml +++ b/app/views/shop/shop/_contact.html.haml @@ -5,14 +5,14 @@ .panel %p %strong E - %a{href: "mailto:#{@distributor.email}"}= @distributor.email - - unless @distributor.website.blank? + %a{href: "mailto:#{current_distributor.email}"}= current_distributor.email + - unless current_distributor.website.blank? %br %strong W - %a{href: @distributor.website}= @distributor.website + %a{href: current_distributor.website}= current_distributor.website %br - = [@distributor.address.address1, @distributor.address.address2].join ", " + = [current_distributor.address.address1, current_distributor.address.address2].join ", " %br - = @distributor.address.city - = @distributor.address.state - = @distributor.address.zipcode + = current_distributor.address.city + = current_distributor.address.state + = current_distributor.address.zipcode diff --git a/app/views/shop/shop/_groups.html.haml b/app/views/shop/shop/_groups.html.haml index 814067e043..c3837bf635 100644 --- a/app/views/shop/shop/_groups.html.haml +++ b/app/views/shop/shop/_groups.html.haml @@ -3,7 +3,7 @@ %a{href: "#groups"} Our Groups .content{"data-section-content" => ""} %ul - - for group in @groups + - for group in current_distributor.groups %li %h4= group.name %ul diff --git a/app/views/shop/shop/_producers.html.haml b/app/views/shop/shop/_producers.html.haml index f59cb268c6..834d15d53f 100644 --- a/app/views/shop/shop/_producers.html.haml +++ b/app/views/shop/shop/_producers.html.haml @@ -3,7 +3,7 @@ %a{href: "#producers"} Our Producers .content{"data-section-content" => ""} %ul - - for producer in @producers + - for producer in current_producers %li %a{"data-reveal-id" => "producer_details_#{producer.id}"} = producer.name diff --git a/app/views/shop/shop/show.html.haml b/app/views/shop/shop/show.html.haml index 09a2b05491..462648bb6b 100644 --- a/app/views/shop/shop/show.html.haml +++ b/app/views/shop/shop/show.html.haml @@ -11,18 +11,5 @@ %strong {{ order_cycle.orders_close_at | date_in_words }} = render partial: "shop/details" - -# This partial generates the producer and group sibling modals - = render partial: "shop/shop/modals" - - %tabs - .row - .section-container.auto{"data-section" => "", "data-options" => "one_up: false"} - - = render 'shop/shop/about_us' - = render 'shop/shop/producers' - = render 'shop/shop/groups' - = render 'shop/shop/contact' - - %products.row = render partial: "shop/shop/products"