Dropping current producers, switching to suppliers and using Angular

This commit is contained in:
Will Marshall
2014-05-29 16:12:58 +10:00
parent 06bac3de85
commit e44853346e
8 changed files with 15 additions and 72 deletions

View File

@@ -0,0 +1,2 @@
Darkswarm.controller "ProducersTabCtrl", ($scope, CurrentHub) ->
$scope.CurrentHub = CurrentHub

View File

@@ -14,16 +14,6 @@ module SharedHelper
klass
end
# all suppliers of current distributor's products
def current_producers
if current_distributor && current_order_cycle
variants = current_order_cycle.variants_distributed_by(current_distributor)
Enterprise.supplying_variant_in(variants)
else
[]
end
end
def enterprise_user?
spree_current_user.andand.enterprises.andand.count.to_i > 0
end

View File

@@ -1,2 +1,6 @@
object current_distributor
attributes :name, :id
child suppliers: :producers do
extends "json/producer"
end

View File

@@ -6,11 +6,7 @@ child distributed_taxons: :taxons do
end
child suppliers: :producers do
attributes :name, :id, :description, :long_description
node :promo_image do |producer|
producer.promo_image.url
end
extends "json/producer"
end
node :pickup do |hub|

View File

@@ -0,0 +1,5 @@
attributes :name, :id, :description, :long_description
node :promo_image do |producer|
producer.promo_image.url
end

View File

@@ -1,22 +1,3 @@
- for producer in current_producers
.reveal-modal{id: "producer_details_#{producer.id}", "data-reveal" => ""}
.row
- if producer.logo.exists?
.large-1.columns
%img.left{src: producer.logo.url(:thumb)}
.large-11.columns
%h2
= producer.name
.row
.large-8.columns
= producer.long_description.andand.html_safe
- if producer.promo_image.exists?
.large-4.columns
%img.about.right{src: producer.promo_image.url(:large)}
%a.close-reveal-modal ×
- for group in current_distributor.groups
- for sibling in group.enterprises.except(current_distributor)
.reveal-modal{id: "sibling_details_#{sibling.id}", "data-reveal" => ""}

View File

@@ -1,6 +1,4 @@
.content#producers
.content#producers{"ng-controller" => "ProducersTabCtrl"}
%ul
- for producer in current_producers
%li
%a{"data-reveal-id" => "producer_details_#{producer.id}", "data-reveal" => ""}
= producer.name
%li{"ng-repeat" => "producer in CurrentHub.producers"}
= render partial: "modals/producer"

View File

@@ -23,37 +23,4 @@ describe SharedHelper do
helper.stub(:current_order) { order }
helper.distributor_link_class(d1).should =~ /empties-cart/
end
describe "finding current producers" do
it "finds producers for the current distribution" do
s = create(:supplier_enterprise)
d = create(:distributor_enterprise)
p = create(:simple_product)
oc = create(:simple_order_cycle, suppliers: [s], distributors: [d], variants: [p.master])
helper.stub(:current_order_cycle) { oc }
helper.stub(:current_distributor) { d }
helper.current_producers.should == [s]
end
it "returns [] when no order cycle set" do
d = double(:distributor)
helper.stub(:current_order_cycle) { nil }
helper.stub(:current_distributor) { d }
helper.current_producers.should == []
end
it "returns [] when no distributor set" do
oc = double(:order_cycle)
helper.stub(:current_order_cycle) { oc }
helper.stub(:current_distributor) { nil }
helper.current_producers.should == []
end
end
end