mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Merge branch 'new_shop'
This commit is contained in:
@@ -11,5 +11,4 @@
|
||||
|
||||
ofn-modal {
|
||||
display: block;
|
||||
}
|
||||
|
||||
}
|
||||
5
app/assets/stylesheets/darkswarm/forms.css.sass
Normal file
5
app/assets/stylesheets/darkswarm/forms.css.sass
Normal file
@@ -0,0 +1,5 @@
|
||||
@import mixins
|
||||
@import branding
|
||||
|
||||
fieldset
|
||||
border: 0
|
||||
6
app/assets/stylesheets/darkswarm/shopping-cart.css.sass
Normal file
6
app/assets/stylesheets/darkswarm/shopping-cart.css.sass
Normal file
@@ -0,0 +1,6 @@
|
||||
@import mixins
|
||||
@import branding
|
||||
|
||||
#edit-cart
|
||||
button, .button
|
||||
margin: 0
|
||||
@@ -11,6 +11,16 @@ Spree::OrdersController.class_eval do
|
||||
include OrderCyclesHelper
|
||||
layout 'darkswarm'
|
||||
|
||||
# Patching to redirect to shop if order is empty
|
||||
def edit
|
||||
@order = current_order(true)
|
||||
if @order.line_items.empty?
|
||||
redirect_to main_app.shop_path
|
||||
else
|
||||
associate_user
|
||||
end
|
||||
end
|
||||
|
||||
# Patch Orders#populate to populate multi_cart (if enabled)
|
||||
def populate
|
||||
if OpenFoodNetwork::FeatureToggle.enabled? :multi_cart
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"ng-debounce" => "150",
|
||||
"ofn-disable-enter" => true}
|
||||
.small-6.columns
|
||||
%input.button.right{type: :submit, value: "Add to Cart"}
|
||||
%input.button.primary.right{type: :submit, value: "Add to Cart"}
|
||||
|
||||
%div{bindonce: true}
|
||||
%product{"ng-controller" => "ProductNodeCtrl",
|
||||
@@ -26,4 +26,4 @@
|
||||
|
||||
.row
|
||||
.small-12.columns
|
||||
%input.button.right.add_to_cart{type: :submit, value: "Add to Cart"}
|
||||
%input.button.primary.right.add_to_cart{type: :submit, value: "Add to Cart"}
|
||||
|
||||
@@ -15,3 +15,5 @@
|
||||
|
||||
.row
|
||||
= render partial: "shop/products/form"
|
||||
|
||||
= render partial: "shared/footer"
|
||||
@@ -19,4 +19,28 @@
|
||||
= order_form.fields_for :line_items do |item_form|
|
||||
= render :partial => 'line_item', :locals => { :variant => item_form.object.variant, :line_item => item_form.object, :item_form => item_form }
|
||||
|
||||
%tfoot#edit-cart
|
||||
%tr
|
||||
%td
|
||||
Product
|
||||
\:
|
||||
%span.order-total.item-total= number_to_currency @order.item_total
|
||||
%td
|
||||
Distribution
|
||||
\:
|
||||
%span.order-total.distribution-total= order_distribution_subtotal(@order)
|
||||
%td
|
||||
%td
|
||||
= button_tag :class => 'neutral-btn dark expand small', :id => 'update-button' do
|
||||
%i.fi-refresh
|
||||
= t(:update)
|
||||
%td
|
||||
%h5.order-total.grand-total= @order.display_total
|
||||
%td#empty-cart
|
||||
/ This needs help from Will - would like a link not button
|
||||
%span#clear_cart_link{"data-hook" => ""}
|
||||
= link_to "Empty cart", empty_cart_path, method: :put
|
||||
-#= form_tag empty_cart_path, :method => :put do
|
||||
-#= submit_tag t(:empty_cart), :class => 'button alert expand small'
|
||||
|
||||
= render "spree/orders/adjustments" unless @order.adjustments.eligible.blank?
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
%td.cart-item-total{"data-hook" => "cart_item_total"}
|
||||
= line_item.display_amount.to_html unless line_item.quantity.nil?
|
||||
|
||||
%td.cart-item-delete{"data-hook" => "cart_item_delete"}
|
||||
%td.cart-item-delete.text-center{"data-hook" => "cart_item_delete"}
|
||||
{{ quantity }}
|
||||
= link_to image_tag('icons/delete.png'), '#', :class => 'delete',
|
||||
:id => "delete_#{dom_id(line_item)}"
|
||||
|
||||
@@ -24,35 +24,18 @@
|
||||
.row
|
||||
= render :partial => 'form', :locals => { :order_form => order_form }
|
||||
|
||||
#subtotal.row{'data-hook' => ""}
|
||||
.columns.large-5
|
||||
%h5
|
||||
Product
|
||||
\:
|
||||
%span.order-total.item-total= number_to_currency @order.item_total
|
||||
.columns.large-4
|
||||
%h5
|
||||
Distribution
|
||||
\:
|
||||
%span.order-total.distribution-total= order_distribution_subtotal(@order)
|
||||
.columns.large-3
|
||||
%h4
|
||||
Cart Total
|
||||
\:
|
||||
%span.order-total.grand-total= @order.display_total
|
||||
|
||||
.links{'data-hook' => "cart_buttons"}
|
||||
.row
|
||||
#empty-cart.columns.large-8{"data-hook" => ""}
|
||||
= form_tag empty_cart_path, :method => :put do
|
||||
#clear_cart_link{"data-hook" => ""}
|
||||
= link_to "Continue Shopping", main_app.shop_path, class: "button secondary"
|
||||
= t(:or)
|
||||
= submit_tag t(:empty_cart), :class => 'button secondary'
|
||||
|
||||
.columns.large-8{"data-hook" => ""}
|
||||
|
||||
%a.button.large.secondary{href: main_app.shop_path}
|
||||
%i.fi-arrow-left
|
||||
Continue shopping
|
||||
.columns.large-4.text-right
|
||||
= button_tag :class => 'secondary', :id => 'update-button' do
|
||||
= t(:update)
|
||||
= t(:or)
|
||||
= link_to "Checkout", main_app.checkout_path, class: "button checkout primary", id: "checkout-link"
|
||||
%a#checkout-link.button.large.primary{href: main_app.checkout_path}
|
||||
Checkout
|
||||
%i.fi-arrow-right
|
||||
|
||||
= render partial: "shared/footer"
|
||||
|
||||
|
||||
@@ -2,12 +2,23 @@ require 'spec_helper'
|
||||
|
||||
describe Spree::OrdersController do
|
||||
let(:distributor) { double(:distributor) }
|
||||
let(:order) { create(:order) }
|
||||
let(:order_cycle) { create(:simple_order_cycle) }
|
||||
|
||||
it "redirects home when no distributor is selected" do
|
||||
spree_get :edit
|
||||
response.should redirect_to root_path
|
||||
end
|
||||
|
||||
it "redirects to shop when order is empty" do
|
||||
controller.stub(:current_distributor).and_return(distributor)
|
||||
controller.stub(:current_order_cycle).and_return(order_cycle)
|
||||
controller.stub(:current_order).and_return order
|
||||
order.stub_chain(:line_items, :empty?).and_return true
|
||||
spree_get :edit
|
||||
response.should redirect_to shop_path
|
||||
end
|
||||
|
||||
it "redirects to the shop when no order cycle is selected" do
|
||||
controller.stub(:current_distributor).and_return(distributor)
|
||||
spree_get :edit
|
||||
|
||||
Reference in New Issue
Block a user