mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Confirm change hub when it would empty cart
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
$(document).ready ->
|
||||
$("#order_order_cycle_id").change -> $("#order_cycle_select").submit()
|
||||
$("#reset_order_cycle").click -> return false unless confirm "Performing this action will clear your cart."
|
||||
|
||||
|
||||
$("#reset_order_cycle").click -> return false unless confirm "Changing your collection date will clear your cart."
|
||||
$(".shop-distributor.empties-cart").click -> return false unless confirm "Changing your location will clear your cart."
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class HomeController < ApplicationController
|
||||
class HomeController < BaseController
|
||||
layout 'landing_page'
|
||||
|
||||
def new_landing_page
|
||||
|
||||
9
app/helpers/temp_landing_page_helper.rb
Normal file
9
app/helpers/temp_landing_page_helper.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
module TempLandingPageHelper
|
||||
def temp_landing_page_distributor_link_class(distributor)
|
||||
cart = current_order(true)
|
||||
|
||||
klass = "shop-distributor"
|
||||
klass += " empties-cart" unless cart.line_items.empty? || cart.distributor == distributor
|
||||
klass
|
||||
end
|
||||
end
|
||||
@@ -8,6 +8,7 @@
|
||||
= favicon_link_tag "favicon.ico"
|
||||
= stylesheet_link_tag "search/all"
|
||||
= javascript_include_tag "search/all"
|
||||
= javascript_include_tag "store/shop_front"
|
||||
= render "layouts/bugherd_script"
|
||||
|
||||
= csrf_meta_tags
|
||||
@@ -37,7 +38,7 @@
|
||||
.row.distributor-link-row
|
||||
.large-12.columns
|
||||
= succeed ',' do
|
||||
= link_to "<strong>#{distributor.name}</strong>".html_safe, shop_enterprise_path(distributor)
|
||||
= link_to "<strong>#{distributor.name}</strong>".html_safe, shop_enterprise_path(distributor), {class: temp_landing_page_distributor_link_class(distributor)}
|
||||
|
||||
%span.secondary= distributor.city
|
||||
%footer
|
||||
|
||||
31
spec/helpers/temp_landing_page_helper_spec.rb
Normal file
31
spec/helpers/temp_landing_page_helper_spec.rb
Normal file
@@ -0,0 +1,31 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe HtmlHelper do
|
||||
subject do
|
||||
obj = Object.new
|
||||
obj.extend TempLandingPageHelper
|
||||
end
|
||||
|
||||
it "does not require emptying the cart when it is empty" do
|
||||
d = double(:distributor)
|
||||
order = double(:order, line_items: [])
|
||||
subject.stub(:current_order) { order }
|
||||
subject.temp_landing_page_distributor_link_class(d).should_not =~ /empties-cart/
|
||||
end
|
||||
|
||||
it "does not require emptying the cart when we are on the same distributor" do
|
||||
d = double(:distributor)
|
||||
order = double(:order, line_items: [double(:line_item)], distributor: d)
|
||||
subject.stub(:current_order) { order }
|
||||
subject.temp_landing_page_distributor_link_class(d).should_not =~ /empties-cart/
|
||||
end
|
||||
|
||||
it "requires emptying the cart otherwise" do
|
||||
d1 = double(:distributor)
|
||||
d2 = double(:distributor)
|
||||
order = double(:order, line_items: [double(:line_item)], distributor: d2)
|
||||
subject.stub(:current_order) { order }
|
||||
subject.temp_landing_page_distributor_link_class(d1).should =~ /empties-cart/
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user