mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Starting on Angular models for Checkout, pretties
This commit is contained in:
2
app/assets/javascripts/darkswarm/checkout.js.coffee
Normal file
2
app/assets/javascripts/darkswarm/checkout.js.coffee
Normal file
@@ -0,0 +1,2 @@
|
||||
window.Checkout = angular.module("Checkout", ["ngResource", "filters"]).config ($httpProvider) ->
|
||||
$httpProvider.defaults.headers.post['X-CSRF-Token'] = $('meta[name="csrf-token"]').attr('content')
|
||||
@@ -0,0 +1,2 @@
|
||||
angular.module("Checkout").controller "CheckoutCtrl", ($scope, $rootScope) ->
|
||||
$scope.require_ship_method = false
|
||||
16
app/assets/stylesheets/darkswarm/forms.css.sass
Normal file
16
app/assets/stylesheets/darkswarm/forms.css.sass
Normal file
@@ -0,0 +1,16 @@
|
||||
@import variables
|
||||
|
||||
form
|
||||
fieldset
|
||||
padding: 0px
|
||||
border: none
|
||||
legend
|
||||
border: 1px solid $dark-grey
|
||||
border-left: 0px
|
||||
border-right: 0px
|
||||
padding: 16px 24px
|
||||
display: block
|
||||
width: 100%
|
||||
margin-bottom: 1em
|
||||
text-transform: uppercase
|
||||
color: #999999
|
||||
@@ -1 +1,2 @@
|
||||
$fawn: #f6efe5
|
||||
$dark-grey: #c7c7c7
|
||||
|
||||
@@ -1,76 +1,89 @@
|
||||
= form_for @order, url: "test" do |f|
|
||||
.large-8.columns
|
||||
%fieldset#details
|
||||
%legend Customer Details
|
||||
.row
|
||||
.large-6.columns
|
||||
= f.label :email, "Email Address"
|
||||
= f.text_field :email
|
||||
= f.fields_for @order.bill_address do |ba|
|
||||
.large-6.columns
|
||||
= ba.label :phone
|
||||
= ba.text_field :phone
|
||||
= f.fields_for @order.bill_address do |ba|
|
||||
%checkout{"ng-app" => "Checkout", "ng-controller" => "CheckoutCtrl"}
|
||||
= form_for @order, url: "test", html: { class: "custom" } do |f|
|
||||
.large-8.columns
|
||||
%fieldset#details
|
||||
%legend Customer Details
|
||||
.row
|
||||
.large-6.columns
|
||||
= ba.label :firstname
|
||||
= ba.text_field :firstname
|
||||
.large-6.columns
|
||||
= ba.label :lastname
|
||||
= ba.text_field :lastname
|
||||
|
||||
%fieldset
|
||||
%legend Billing Address
|
||||
= f.label :email, "Email Address"
|
||||
= f.text_field :email
|
||||
= f.fields_for @order.bill_address do |ba|
|
||||
.large-6.columns
|
||||
= ba.label :phone
|
||||
= ba.text_field :phone
|
||||
= f.fields_for @order.bill_address do |ba|
|
||||
.row
|
||||
.large-12.columns
|
||||
= ba.label :address1
|
||||
= ba.text_field :address1
|
||||
.row
|
||||
.large-12.columns
|
||||
= ba.label :address2
|
||||
= ba.text_field :address2
|
||||
.row
|
||||
.large-6.columns
|
||||
= ba.label :city
|
||||
= ba.text_field :city
|
||||
= ba.label :firstname
|
||||
= ba.text_field :firstname
|
||||
.large-6.columns
|
||||
= ba.label :country
|
||||
= ba.text_field :country
|
||||
.row
|
||||
.large-6.columns.right
|
||||
= ba.label :zipcode
|
||||
= ba.text_field :zipcode
|
||||
%fieldset#shipping
|
||||
%legend Shipping
|
||||
= fields_for @order.ship_address do |sa|
|
||||
.row
|
||||
.large-12.columns
|
||||
= sa.label :address1
|
||||
= sa.text_field :address1
|
||||
.row
|
||||
.large-12.columns
|
||||
= sa.label :address2
|
||||
= sa.text_field :address2
|
||||
= ba.label :lastname
|
||||
= ba.text_field :lastname
|
||||
|
||||
.row
|
||||
.large-6.columns
|
||||
= sa.label :city
|
||||
= sa.text_field :city
|
||||
.large-6.columns
|
||||
= sa.label :country
|
||||
= sa.text_field :country
|
||||
.row
|
||||
.large-6.columns.right
|
||||
= sa.label :zipcode
|
||||
= sa.text_field :zipcode
|
||||
.row
|
||||
.large-6.columns
|
||||
= sa.label :firstname
|
||||
= sa.text_field :firstname
|
||||
.large-6.columns
|
||||
= sa.label :lastname
|
||||
= sa.text_field :lastname
|
||||
%fieldset#payment
|
||||
%legend Payment Details
|
||||
This looks complicated :/
|
||||
%fieldset
|
||||
%legend Billing Address
|
||||
= f.fields_for @order.bill_address do |ba|
|
||||
.row
|
||||
.large-12.columns
|
||||
= ba.label :address1
|
||||
= ba.text_field :address1
|
||||
.row
|
||||
.large-12.columns
|
||||
= ba.label :address2
|
||||
= ba.text_field :address2
|
||||
.row
|
||||
.large-6.columns
|
||||
= ba.label :city
|
||||
= ba.text_field :city
|
||||
.large-6.columns
|
||||
= ba.label :country
|
||||
= ba.text_field :country
|
||||
.row
|
||||
.large-6.columns.right
|
||||
= ba.label :zipcode
|
||||
= ba.text_field :zipcode
|
||||
|
||||
%fieldset#shipping
|
||||
%legend Shipping
|
||||
|
||||
- for ship_method in current_distributor.shipping_methods.uniq
|
||||
.row
|
||||
.large-12.columns
|
||||
%label
|
||||
= f.radio_button :shipping_method, ship_method.id,
|
||||
"data-require-ship-address" => ship_method.require_ship_address
|
||||
%span.custom.radio
|
||||
= ship_method.name
|
||||
|
||||
= fields_for @order.ship_address do |sa|
|
||||
#ship_address{"ng-show" => "require_ship_method"}
|
||||
.row
|
||||
.large-12.columns
|
||||
= sa.label :address1
|
||||
= sa.text_field :address1
|
||||
.row
|
||||
.large-12.columns
|
||||
= sa.label :address2
|
||||
= sa.text_field :address2
|
||||
|
||||
.row
|
||||
.large-6.columns
|
||||
= sa.label :city
|
||||
= sa.text_field :city
|
||||
.large-6.columns
|
||||
= sa.label :country
|
||||
= sa.text_field :country
|
||||
.row
|
||||
.large-6.columns.right
|
||||
= sa.label :zipcode
|
||||
= sa.text_field :zipcode
|
||||
.row
|
||||
.large-6.columns
|
||||
= sa.label :firstname
|
||||
= sa.text_field :firstname
|
||||
.large-6.columns
|
||||
= sa.label :lastname
|
||||
= sa.text_field :lastname
|
||||
%fieldset#payment
|
||||
%legend Payment Details
|
||||
This looks complicated :/
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
%h2 Login
|
||||
= form_for Spree::User.new, :html => {'data-type' => :json}, :as => :spree_user, :url => spree.spree_user_session_path do |f|
|
||||
%p
|
||||
= f.label :email, t(:email)
|
||||
= f.email_field :email, :class => 'title', :tabindex => 1, :id => "login_spree_user_email"
|
||||
%p
|
||||
= f.label :password, t(:password)
|
||||
= f.password_field :password, :class => 'title', :tabindex => 2, :id => "login_spree_user_password"
|
||||
%p
|
||||
%label
|
||||
= f.check_box :remember_me
|
||||
= f.label :remember_me, t(:remember_me)
|
||||
%p= f.submit t(:login), :class => 'button primary', :tabindex => 3, :id => "login_spree_user_remember_me"
|
||||
%fieldset
|
||||
%legend I have an OFN Account
|
||||
%p
|
||||
= f.label :email, t(:email)
|
||||
= f.email_field :email, :class => 'title', :tabindex => 1, :id => "login_spree_user_email"
|
||||
%p
|
||||
= f.label :password, t(:password)
|
||||
= f.password_field :password, :class => 'title', :tabindex => 2, :id => "login_spree_user_password"
|
||||
%p
|
||||
%label
|
||||
= f.check_box :remember_me
|
||||
= f.label :remember_me, t(:remember_me)
|
||||
%p= f.submit t(:login), :class => 'button primary', :tabindex => 3, :id => "login_spree_user_remember_me"
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
%h2 Sign Up
|
||||
= form_for Spree::User.new, :as => :spree_user, :url => spree.spree_user_registration_path(@spree_user) do |f|
|
||||
%p
|
||||
= f.label :email, t(:email)
|
||||
= f.email_field :email, :class => 'title', :id => "signup_spree_user_email"
|
||||
%p
|
||||
= f.label :password, t(:password)
|
||||
= f.password_field :password, :class => 'title', :id => "signup_spree_user_password"
|
||||
%p
|
||||
= f.label :password_confirmation, t(:confirm_password)
|
||||
= f.password_field :password_confirmation, :class => 'title', :id => "signup_spree_user_password_confirmation"
|
||||
%fieldset
|
||||
%legend New to OFN?
|
||||
%p
|
||||
= f.label :email, t(:email)
|
||||
= f.email_field :email, :class => 'title', :id => "signup_spree_user_email"
|
||||
%p
|
||||
= f.label :password, t(:password)
|
||||
= f.password_field :password, :class => 'title', :id => "signup_spree_user_password"
|
||||
%p
|
||||
= f.label :password_confirmation, t(:confirm_password)
|
||||
= f.password_field :password_confirmation, :class => 'title', :id => "signup_spree_user_password_confirmation"
|
||||
|
||||
= f.submit "Sign Up", :class => 'button'
|
||||
= f.submit "Sign Up", :class => 'button'
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
- unless spree_current_user
|
||||
%section#checkout_login
|
||||
= render partial: "shop/checkout/login"
|
||||
%section#checkout_signup
|
||||
= render partial: "shop/checkout/signup"
|
||||
.row
|
||||
%section#checkout_login
|
||||
.large-4.columns
|
||||
= render partial: "shop/checkout/login"
|
||||
%section#checkout_signup
|
||||
.large-4.columns
|
||||
= render partial: "shop/checkout/signup"
|
||||
.large-2.columns
|
||||
Cart bitches!
|
||||
|
||||
|
||||
= render partial: "shop/checkout/form"
|
||||
|
||||
.row
|
||||
= render partial: "shop/checkout/form"
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20140204011203) do
|
||||
ActiveRecord::Schema.define(:version => 20140213003443) do
|
||||
|
||||
create_table "adjustment_metadata", :force => true do |t|
|
||||
t.integer "adjustment_id"
|
||||
@@ -744,14 +744,16 @@ ActiveRecord::Schema.define(:version => 20140204011203) do
|
||||
create_table "spree_shipping_methods", :force => true do |t|
|
||||
t.string "name"
|
||||
t.integer "zone_id"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.string "display_on"
|
||||
t.integer "shipping_category_id"
|
||||
t.boolean "match_none"
|
||||
t.boolean "match_all"
|
||||
t.boolean "match_one"
|
||||
t.datetime "deleted_at"
|
||||
t.boolean "require_ship_address", :default => true
|
||||
t.text "description"
|
||||
end
|
||||
|
||||
create_table "spree_skrill_transactions", :force => true do |t|
|
||||
|
||||
@@ -108,6 +108,40 @@ feature "As a consumer I want to check out my cart", js: true do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "logged in, distributor selected, order cycle selected, product in cart" do
|
||||
let(:user) { create_enterprise_user }
|
||||
before do
|
||||
login_to_consumer_section
|
||||
select_distributor
|
||||
select_order_cycle
|
||||
add_product_to_cart
|
||||
end
|
||||
|
||||
describe "with shipping methods" do
|
||||
let(:sm1) { create(:shipping_method, require_ship_address: true, name: "Frogs", description: "yellow") }
|
||||
let(:sm2) { create(:shipping_method, require_ship_address: true, name: "Donkeys", description: "blue") }
|
||||
before do
|
||||
distributor.shipping_methods << sm1
|
||||
distributor.shipping_methods << sm2
|
||||
visit "/shop/checkout"
|
||||
end
|
||||
it "shows all shipping methods" do
|
||||
page.should have_content "Frogs"
|
||||
page.should have_content "Donkeys"
|
||||
end
|
||||
|
||||
it "doesn't show ship address forms by default" do
|
||||
find("#ship_address").visible?.should be_false
|
||||
end
|
||||
|
||||
it "shows ship address forms when selected shipping method requires one" do
|
||||
# Fancy Foundation Forms are weird
|
||||
find("#order_shipping_method_#{sm1.id} + span").click
|
||||
find("#ship_address").visible?.should be_true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def select_distributor
|
||||
@@ -122,6 +156,7 @@ def select_order_cycle
|
||||
end
|
||||
|
||||
def add_product_to_cart
|
||||
|
||||
fill_in "variants[#{product.master.id}]", with: 5
|
||||
first("form.custom > input.button.right").click
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user