diff --git a/app/assets/images/matte.png b/app/assets/images/matte.png new file mode 100644 index 0000000000..845642cab2 Binary files /dev/null and b/app/assets/images/matte.png differ diff --git a/app/assets/javascripts/darkswarm/overrides.js.coffee b/app/assets/javascripts/darkswarm/overrides.js.coffee new file mode 100644 index 0000000000..6db1441f08 --- /dev/null +++ b/app/assets/javascripts/darkswarm/overrides.js.coffee @@ -0,0 +1,20 @@ +Foundation.libs.section.toggle_active = (e)-> + $this = $(this) + self = Foundation.libs.section + region = $this.parent() + content = $this.siblings(self.settings.content_selector) + section = region.parent() + settings = $.extend({}, self.settings, self.data_options(section)) + prev_active_region = section.children(self.settings.region_selector).filter("." + self.settings.active_class) + + #for anchors inside [data-section-title] + e.preventDefault() if not settings.deep_linking and content.length > 0 + e.stopPropagation() #do not catch same click again on parent + unless region.hasClass(self.settings.active_class) + prev_active_region.removeClass self.settings.active_class + region.addClass self.settings.active_class + #force resize for better performance (do not wait timer) + self.resize region.find(self.settings.section_selector).not("[" + self.settings.resized_data_attr + "]"), true + else if not settings.one_up# and (self.small(section) or self.is_vertical_nav(section) or self.is_horizontal_nav(section) or self.is_accordion(section)) + region.removeClass self.settings.active_class + settings.callback section diff --git a/app/controllers/shop_controller.rb b/app/controllers/shop_controller.rb index 33457dd7a9..36d3504c5a 100644 --- a/app/controllers/shop_controller.rb +++ b/app/controllers/shop_controller.rb @@ -5,6 +5,8 @@ class 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 end def products diff --git a/app/controllers/suburbs_controller.rb b/app/controllers/suburbs_controller.rb index 21c4040d22..4fe73f29d8 100644 --- a/app/controllers/suburbs_controller.rb +++ b/app/controllers/suburbs_controller.rb @@ -2,4 +2,4 @@ class SuburbsController < ActionController::Base def index @suburbs = Suburb.matching(params[:term]).order(:name).limit(8) end -end \ No newline at end of file +end diff --git a/app/views/shop/_products.html.haml b/app/views/shop/_products.html.haml index 245f6eee80..e7fbf55055 100644 --- a/app/views/shop/_products.html.haml +++ b/app/views/shop/_products.html.haml @@ -12,7 +12,7 @@ %tbody{"ng-repeat" => "product in data.products "} %tr.product %td - %img{src: "{{ product.master.images[0].small_url }}"} + -#%img{src: "{{ product.master.images[0].small_url }}"} -#{{product.master.images[0].alt}} %td %h5 diff --git a/app/views/shop/show.html.haml b/app/views/shop/show.html.haml index 2c4532478c..2e874ed521 100644 --- a/app/views/shop/show.html.haml +++ b/app/views/shop/show.html.haml @@ -5,7 +5,8 @@ %h4 = @distributor.name %location= @distributor.address.city - %small Change location + %small + %a{href: "/"} Change location = render partial: "shop/order_cycles" -#%description @@ -23,7 +24,9 @@ %p.title.avenir{"data-section-title" => ""} %a{href: "#producers"} Our Producers .content{"data-section-content" => ""} - %p Content of section 2. + %ul + - for producer in @producers + %li= producer.name %section %p.title.avenir{"data-section-title" => ""} diff --git a/spec/controllers/shop_controller_spec.rb b/spec/controllers/shop_controller_spec.rb index 8f355c259b..5f2a677679 100644 --- a/spec/controllers/shop_controller_spec.rb +++ b/spec/controllers/shop_controller_spec.rb @@ -8,6 +8,7 @@ describe ShopController do response.should redirect_to root_path end + describe "with a distributor in place" do before do controller.stub(:current_distributor).and_return d @@ -56,6 +57,22 @@ describe ShopController do end + describe "producers/suppliers" do + let(:supplier) { create(:supplier_enterprise) } + let(:product) { create(:product, supplier: supplier) } + let(:order_cycle) { create(:order_cycle, distributors: [d], coordinator: create(:distributor_enterprise)) } + + before do + exchange = Exchange.find(order_cycle.exchanges.to_enterprises(d).outgoing.first.id) + exchange.variants << product.master + end + + it "builds a list of producers/suppliers" do + spree_get :show + assigns[:producers].should == [supplier] + end + end + describe "returning products" do let(:product) { create(:product) } let(:order_cycle) { create(:order_cycle, distributors: [d], coordinator: create(:distributor_enterprise)) } diff --git a/spec/features/consumer/shopping_spec.rb b/spec/features/consumer/shopping_spec.rb index e5bd0c3cc7..9a136df99d 100644 --- a/spec/features/consumer/shopping_spec.rb +++ b/spec/features/consumer/shopping_spec.rb @@ -17,6 +17,25 @@ feature "As a consumer I want to shop with a distributor", js: true do page.should have_text distributor.name end + describe "With products in order cycles" do + let(:supplier) { create(:supplier_enterprise) } + let(:product) { create(:product, supplier: supplier) } + let(:order_cycle) { create(:order_cycle, distributors: [distributor], coordinator: create(:distributor_enterprise)) } + + before do + exchange = Exchange.find(order_cycle.exchanges.to_enterprises(distributor).outgoing.first.id) + exchange.variants << product.master + end + + it "shows the suppliers/producers for a distributor" do + visit shop_path + click_link "Our Producers" + page.should have_content supplier.name + end + + end + + describe "selecting an order cycle" do it "selects an order cycle if only one is open" do # create order cycle