diff --git a/app/assets/javascripts/darkswarm/directives/producer_modal.js.coffee b/app/assets/javascripts/darkswarm/directives/producer_modal.js.coffee
index d64b2663f7..a8d8253289 100644
--- a/app/assets/javascripts/darkswarm/directives/producer_modal.js.coffee
+++ b/app/assets/javascripts/darkswarm/directives/producer_modal.js.coffee
@@ -1,7 +1,9 @@
Darkswarm.directive "producerModal", ($modal)->
restrict: 'E'
replace: true
- template: "{{enterprise.name}}"
+ template: ""
+ transclude: true
link: (scope, elem, attrs, ctrl)->
elem.on "click", =>
scope.modalInstance = $modal.open(controller: ctrl, templateUrl: 'producer_modal.html', scope: scope)
+
diff --git a/app/assets/javascripts/darkswarm/directives/product_modal.js.coffee b/app/assets/javascripts/darkswarm/directives/product_modal.js.coffee
new file mode 100644
index 0000000000..428fde3633
--- /dev/null
+++ b/app/assets/javascripts/darkswarm/directives/product_modal.js.coffee
@@ -0,0 +1,9 @@
+Darkswarm.directive "productModal", ($modal)->
+ restrict: 'E'
+ replace: true
+ template: ""
+ transclude: true
+ link: (scope, elem, attrs, ctrl)->
+ elem.on "click", =>
+ scope.modalInstance = $modal.open(controller: ctrl, templateUrl: 'product_modal.html', scope: scope)
+
diff --git a/app/assets/javascripts/darkswarm/filters/filter_groups.js.coffee b/app/assets/javascripts/darkswarm/filters/filter_groups.js.coffee
new file mode 100644
index 0000000000..b209068dcf
--- /dev/null
+++ b/app/assets/javascripts/darkswarm/filters/filter_groups.js.coffee
@@ -0,0 +1,10 @@
+Darkswarm.filter "groups", (Matcher)->
+ (groups, text)->
+ groups ||= []
+ text ?= ""
+
+ groups.filter (group)=>
+ Matcher.match([
+ group.name, group.long_description
+ ], text) || group.enterprises.some (e)->
+ Matcher.match [e.name], text
diff --git a/app/assets/javascripts/darkswarm/services/navigation.js.coffee b/app/assets/javascripts/darkswarm/services/navigation.js.coffee
index cf64cd1666..fd59d0f348 100644
--- a/app/assets/javascripts/darkswarm/services/navigation.js.coffee
+++ b/app/assets/javascripts/darkswarm/services/navigation.js.coffee
@@ -1,4 +1,4 @@
-Darkswarm.factory 'Navigation', ($location) ->
+Darkswarm.factory 'Navigation', ($location, $window) ->
new class Navigation
path: null
@@ -10,7 +10,6 @@ Darkswarm.factory 'Navigation', ($location) ->
$location.path(@path)
toggle: (path = false)=>
- console.log "toggling"
@path = path || @path
if $location.path() == @path
$location.path("/")
@@ -18,4 +17,7 @@ Darkswarm.factory 'Navigation', ($location) ->
@navigate(path)
go: (path)->
- window.location.pathname = path
+ if path.match /^http/
+ $window.location.href = path
+ else
+ $window.location.pathname = path
diff --git a/app/assets/javascripts/templates/product_modal.html.haml b/app/assets/javascripts/templates/product_modal.html.haml
new file mode 100644
index 0000000000..1f0c1a7564
--- /dev/null
+++ b/app/assets/javascripts/templates/product_modal.html.haml
@@ -0,0 +1,9 @@
+.row
+ .columns.small-12.large-6
+ %img.product-img{"ng-src" => "{{product.master.images[0].large_url}}", "ng-if" => "product.master.images[0]"}
+ .columns.small-12.large-6.product-header
+ %h2
+ %render-svg{path: "{{product.primary_taxon.icon}}"}
+ {{product.name}}
+ %p {{product.description}}
+%ng-include{src: "'partials/close.html'"}
diff --git a/app/controllers/checkout_controller.rb b/app/controllers/checkout_controller.rb
index 884a5da2f4..77137f5940 100644
--- a/app/controllers/checkout_controller.rb
+++ b/app/controllers/checkout_controller.rb
@@ -138,9 +138,8 @@ class CheckoutController < Spree::CheckoutController
render :edit and return
end
- redirect_to(main_app.shop_paypal_payment_url(@order, :payment_method_id => payment_method.id))
+ render json: {path: main_app.paypal_payment_url(@order, :payment_method_id => payment_method.id)}, status: 200
true
-
end
# Overriding to customize the cancel url
diff --git a/app/serializers/api/taxon_serializer.rb b/app/serializers/api/taxon_serializer.rb
index dc32347dd9..a907532a6b 100644
--- a/app/serializers/api/taxon_serializer.rb
+++ b/app/serializers/api/taxon_serializer.rb
@@ -1,3 +1,7 @@
class Api::TaxonSerializer < ActiveModel::Serializer
- attributes :id, :name, :permalink
+ attributes :id, :name, :permalink, :icon
+
+ def icon
+ object.icon(:original)
+ end
end
diff --git a/app/views/groups/index.html.haml b/app/views/groups/index.html.haml
index dd37a32b78..f2ae6e550a 100644
--- a/app/views/groups/index.html.haml
+++ b/app/views/groups/index.html.haml
@@ -20,7 +20,7 @@
"ng-debounce" => "150",
"ofn-disable-enter" => true}
- .group{"ng-repeat" => "group in Groups.groups | filter:query | orderBy:order",
+ .group{"ng-repeat" => "group in Groups.groups | groups:query | orderBy:order",
name: "group{{group.id}}",
id: "group{{group.id}}"}
.row.pad-top{bindonce: true}
@@ -42,6 +42,7 @@
%li{"ng-repeat" => "enterprise in group.enterprises", "scroll-after-load" => true}
%hub-modal{"ng-if" => "enterprise.is_distributor"}
%producer-modal{"ng-if" => "!enterprise.is_distributor", "show-hub-actions" => 'true'}
+ {{ enterprise.name }}
.row.group_footer
.small-12.columns
diff --git a/app/views/home/_fat.html.haml b/app/views/home/_fat.html.haml
index 8de0524ea3..16dc3eaafb 100644
--- a/app/views/home/_fat.html.haml
+++ b/app/views/home/_fat.html.haml
@@ -28,7 +28,7 @@
Our producers
%ul.bullet-list
%li{"ng-repeat" => "enterprise in hub.producers"}
- %producer-modal
+ %producer-modal {{ enterprise.name }}
.row.active_table_row.link{"ng-show" => "open()"}
.cta-container.columns.small-12
diff --git a/app/views/modals/_product.html.haml b/app/views/modals/_product.html.haml
deleted file mode 100644
index 6d50f9c09d..0000000000
--- a/app/views/modals/_product.html.haml
+++ /dev/null
@@ -1,11 +0,0 @@
-%ofn-modal{title: "{{product.name}}"}
- .row
- .columns.small-12.large-6
- %img.product-img{"ng-src" => "{{product.master.images[0].large_url}}", "ng-if" => "product.master.images[0]"}
- .columns.small-12.large-6.product-header
- %h2
- %render-svg{path: "{{product.primary_taxon.icon}}"}
- {{product.name}}
- %p {{product.description}}
- %a.close-reveal-modal{"ng-click" => "$close()"}
- %i.ofn-i_009-close
diff --git a/app/views/shop/products/_master.html.haml b/app/views/shop/products/_master.html.haml
index 4c00365f71..92a17be43d 100644
--- a/app/views/shop/products/_master.html.haml
+++ b/app/views/shop/products/_master.html.haml
@@ -1,5 +1,5 @@
.small-1.columns
- %span.bulk{"bo-if" => "product.group_buy"} bulk
+ %i.ofn-i_056-bulk{"bo-if" => "product.group_buy"}
.small-4.columns
diff --git a/app/views/shop/products/_summary.html.haml b/app/views/shop/products/_summary.html.haml
index ec018065c8..b21b535315 100644
--- a/app/views/shop/products/_summary.html.haml
+++ b/app/views/shop/products/_summary.html.haml
@@ -1,14 +1,15 @@
.row.summary
.small-1.columns
- %img{"bo-src" => "product.master.images[0].small_url"}
+ %product-modal
+ %img{"bo-src" => "product.master.images[0].small_url"}
.small-4.columns.summary-header
%render-svg{path: "{{product.primary_taxon.icon}}"}
- = render partial: "modals/product"
+ %product-modal {{ product.name }}
.small-5.columns
%i.ofn-i_036-producers
- = render partial: "modals/producer"
+ %producer-modal {{ enterprise.name }}
.small-2.columns.summary-price.text-right.price
%span{"ng-if" => "hasVariants"}
diff --git a/app/views/shop/products/_variants.html.haml b/app/views/shop/products/_variants.html.haml
index fed7753ff3..5d6a59535e 100644
--- a/app/views/shop/products/_variants.html.haml
+++ b/app/views/shop/products/_variants.html.haml
@@ -2,7 +2,7 @@
"ng-repeat" => "variant in product.variants"}
.small-1.columns
- %span.bulk{"bo-if" => "product.group_buy"} bulk
+ %i.ofn-i_056-bulk{"bo-if" => "product.group_buy"}
.small-4.columns
diff --git a/app/views/spree/checkout/payment/_paypalexpress.html.haml b/app/views/spree/checkout/payment/_paypalexpress.html.haml
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/config/routes.rb b/config/routes.rb
index d166116086..51826d6777 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -16,7 +16,7 @@ Openfoodnetwork::Application.routes.draw do
get '/checkout', :to => 'checkout#edit' , :as => :checkout
put '/checkout', :to => 'checkout#update' , :as => :update_checkout
- get "/checkout/paypal_payment", to: 'checkout#paypal_payment', as: :paypal_payment
+ get '/checkout/paypal_payment/:order_id', to: 'checkout#paypal_payment', as: :paypal_payment
resources :enterprises do
collection do
diff --git a/spec/features/consumer/shopping/shopping_spec.rb b/spec/features/consumer/shopping/shopping_spec.rb
index e75f7f6f21..377f56c102 100644
--- a/spec/features/consumer/shopping/shopping_spec.rb
+++ b/spec/features/consumer/shopping/shopping_spec.rb
@@ -79,6 +79,9 @@ feature "As a consumer I want to shop with a distributor", js: true do
page.should have_content product.name
page.should have_content product.master.display_name
page.should have_content product.master.display_as
+
+ open_product_modal product
+ modal_should_be_open_for product
end
end
end
diff --git a/spec/javascripts/unit/darkswarm/filters/filter_groups_spec.js.coffee b/spec/javascripts/unit/darkswarm/filters/filter_groups_spec.js.coffee
new file mode 100644
index 0000000000..e7e2614f7f
--- /dev/null
+++ b/spec/javascripts/unit/darkswarm/filters/filter_groups_spec.js.coffee
@@ -0,0 +1,34 @@
+describe "filtering Groups", ->
+ filterGroups = null
+ groups = [{
+ name: "test"
+ long_description: "roger"
+ enterprises: [{
+ name: "kittens"
+ }, {
+ name: "kittens"
+ }]
+ }, {
+ name: "blankness"
+ long_description: "in the sky"
+ enterprises: [{
+ name: "ponies"
+ }, {
+ name: "ponies"
+ }]
+ }
+ ]
+
+ beforeEach ->
+ module 'Darkswarm'
+ inject ($filter) ->
+ filterGroups = $filter('groups')
+
+ it "filters by name", ->
+ expect(filterGroups(groups, "test")[0]).toBe groups[0]
+
+ it "filters by description", ->
+ expect(filterGroups(groups, "sky")[0]).toBe groups[1]
+
+ it "filters by enterprise name", ->
+ expect(filterGroups(groups, "ponies")[0]).toBe groups[1]
diff --git a/spec/javascripts/unit/darkswarm/navigation.js.coffee b/spec/javascripts/unit/darkswarm/navigation.js.coffee
deleted file mode 100644
index 3701a7bded..0000000000
--- a/spec/javascripts/unit/darkswarm/navigation.js.coffee
+++ /dev/null
@@ -1,11 +0,0 @@
-describe 'Navigation service', ->
- Navigation = null
-
- beforeEach ->
- module 'Darkswarm'
- inject ($injector)->
- Navigation = $injector.get("Navigation")
-
- it "caches the path provided", ->
- Navigation.navigate "/foo"
- expect(Navigation.path).toEqual "/foo"
diff --git a/spec/javascripts/unit/darkswarm/services/map_spec.js.coffee b/spec/javascripts/unit/darkswarm/services/map_spec.js.coffee
index c10c2c22f8..3ef21705d3 100644
--- a/spec/javascripts/unit/darkswarm/services/map_spec.js.coffee
+++ b/spec/javascripts/unit/darkswarm/services/map_spec.js.coffee
@@ -7,6 +7,7 @@ describe "Hubs service", ->
active: false
orders_close_at: new Date()
type: "hub"
+ visible: true
}
]
diff --git a/spec/javascripts/unit/darkswarm/services/navigation.js.coffee b/spec/javascripts/unit/darkswarm/services/navigation.js.coffee
new file mode 100644
index 0000000000..8b5912bff8
--- /dev/null
+++ b/spec/javascripts/unit/darkswarm/services/navigation.js.coffee
@@ -0,0 +1,28 @@
+describe 'Navigation service', ->
+ Navigation = null
+ window =
+ location:
+ href: null
+ pathname: null
+
+ beforeEach ->
+ module 'Darkswarm', ($provide) ->
+ $provide.value "$window", window
+ null
+ inject ($injector)->
+ Navigation = $injector.get("Navigation")
+
+
+ it "caches the path provided", ->
+ Navigation.navigate "/foo"
+ expect(Navigation.path).toEqual "/foo"
+
+ describe "redirecting", ->
+ it "redirects to full URLs", ->
+ Navigation.go "http://google.com"
+ expect(window.location.href).toEqual "http://google.com"
+
+ it "redirects to paths", ->
+ Navigation.go "/woo/yeah"
+ expect(window.location.pathname).toEqual "/woo/yeah"
+
\ No newline at end of file
diff --git a/spec/support/request/ui_component_helper.rb b/spec/support/request/ui_component_helper.rb
index ebf95548d6..32d6abd77e 100644
--- a/spec/support/request/ui_component_helper.rb
+++ b/spec/support/request/ui_component_helper.rb
@@ -38,13 +38,17 @@ module UIComponentHelper
have_selector ".login-modal"
end
+ def open_product_modal(product)
+ find("a", text: product.name).click
+ end
+
def open_enterprise_modal(enterprise)
find("a", text: enterprise.name).click
end
- def modal_should_be_open_for(enterprise)
+ def modal_should_be_open_for(object)
within ".reveal-modal" do
- page.should have_content enterprise.name
+ page.should have_content object.name
end
end