mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Adding group siblings to the shop page
This commit is contained in:
@@ -7,6 +7,7 @@ class Shop::ShopController < BaseController
|
||||
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
|
||||
@@ -14,7 +15,6 @@ class Shop::ShopController < BaseController
|
||||
.products_distributed_by(current_distributor).andand
|
||||
.select { |p| p.has_stock_for_distribution?(current_order_cycle, current_distributor) }.andand
|
||||
.sort_by {|p| p.name }
|
||||
|
||||
render json: "", status: 404
|
||||
end
|
||||
end
|
||||
|
||||
13
app/views/shop/shop/_groups.html.haml
Normal file
13
app/views/shop/shop/_groups.html.haml
Normal file
@@ -0,0 +1,13 @@
|
||||
%section
|
||||
%p.title.avenir{"data-section-title" => ""}
|
||||
%a{href: "#groups"} Our Groups
|
||||
.content{"data-section-content" => ""}
|
||||
%ul
|
||||
- for group in @groups
|
||||
%li
|
||||
%h4= group.name
|
||||
%ul
|
||||
- for sibling in group.enterprises.except(current_distributor)
|
||||
%li
|
||||
%a{"data-reveal-id" => "sibling_details_#{sibling.id}"}
|
||||
= sibling.name
|
||||
19
app/views/shop/shop/_modals.html.haml
Normal file
19
app/views/shop/shop/_modals.html.haml
Normal file
@@ -0,0 +1,19 @@
|
||||
- for producer in @producers
|
||||
.reveal-modal{id: "producer_details_#{producer.id}"}
|
||||
%h2
|
||||
%img.left{src: producer.logo.url(:thumb)}
|
||||
= producer.name
|
||||
%img.about.right{src: producer.promo_image.url(:large)}
|
||||
= producer.description.andand.html_safe
|
||||
%a.close-reveal-modal ×
|
||||
|
||||
- for group in @groups
|
||||
- for sibling in group.enterprises.except(current_distributor)
|
||||
.reveal-modal{id: "sibling_details_#{sibling.id}"}
|
||||
%h2
|
||||
%img.left{src: sibling.logo.url(:thumb)}
|
||||
= sibling.name
|
||||
%img.about.right{src: sibling.promo_image.url(:large)}
|
||||
= sibling.description.andand.html_safe
|
||||
%a.close-reveal-modal ×
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
- for producer in @producers
|
||||
.reveal-modal{id: "producer_details_#{producer.id}"}
|
||||
%h2
|
||||
%img.left{src: producer.logo.url(:thumb)}
|
||||
= producer.name
|
||||
%img.about.right{src: producer.promo_image.url(:large)}
|
||||
= producer.description.andand.html_safe
|
||||
%a.close-reveal-modal ×
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
%strong {{ order_cycle.orders_close_at | date_in_words }}
|
||||
= render partial: "shop/details"
|
||||
|
||||
-# This partial generates the producer detail popovers
|
||||
= render partial: "shop/shop/producer_details"
|
||||
-# This partial generates the producer and group sibling modals
|
||||
= render partial: "shop/shop/modals"
|
||||
|
||||
%tabs
|
||||
.row
|
||||
@@ -20,12 +20,7 @@
|
||||
|
||||
= render 'shop/shop/about_us'
|
||||
= render 'shop/shop/producers'
|
||||
|
||||
%section
|
||||
%p.title.avenir{"data-section-title" => ""}
|
||||
%a{href: "#groups"} Our Groups
|
||||
.content{"data-section-content" => ""}
|
||||
%p Coming Soon
|
||||
= render 'shop/shop/groups'
|
||||
|
||||
%section
|
||||
%p.title.avenir{"data-section-title" => ""}
|
||||
|
||||
@@ -14,6 +14,18 @@ describe Shop::ShopController do
|
||||
controller.stub(:current_distributor).and_return d
|
||||
end
|
||||
|
||||
describe "Tabs and plumbing" do
|
||||
it "builds a list of sibling distributors" do
|
||||
sibling1 = create(:distributor_enterprise)
|
||||
sibling2 = create(:distributor_enterprise)
|
||||
g1 = create(:enterprise_group, on_front_page: true, enterprises: [d, sibling1])
|
||||
g2 = create(:enterprise_group, on_front_page: true, enterprises: [d, sibling2])
|
||||
|
||||
spree_get :show
|
||||
assigns[:groups].sort.should == [g1, g2].sort
|
||||
end
|
||||
end
|
||||
|
||||
describe "Selecting order cycles" do
|
||||
it "should select an order cycle when only one order cycle is open" do
|
||||
oc1 = create(:order_cycle, distributors: [d])
|
||||
@@ -42,7 +54,7 @@ describe Shop::ShopController do
|
||||
it "should return the order cycle details when the oc is selected" do
|
||||
oc1 = create(:order_cycle, distributors: [d])
|
||||
oc2 = create(:order_cycle, distributors: [d])
|
||||
|
||||
|
||||
spree_post :order_cycle, order_cycle_id: oc2.id
|
||||
response.should be_success
|
||||
response.body.should have_content oc2.id
|
||||
|
||||
Reference in New Issue
Block a user