remove legacy checkout view

This commit is contained in:
Mohamed ABDELLANI
2023-05-31 12:34:47 +01:00
committed by Filipe
parent c379dcacc5
commit fc0cca2210
28 changed files with 0 additions and 583 deletions

View File

@@ -1,22 +0,0 @@
angular.module('Darkswarm').controller "AccordionCtrl", ($scope, localStorageService, $timeout, $document, CurrentHub) ->
$scope.accordionSections = ["details", "billing", "shipping", "payment"]
$scope.accordion = { details: true, billing: true, shipping: true, payment: true }
$scope.show = (section) ->
$scope.accordion[section] = true
$scope.scrollTo = (section) ->
# Scrolling is confused by our position:fixed top bar - add an offset to scroll
# to the correct location, plus 5px buffer
offset_height = $("nav.top-bar").height() + 5
$document.scrollTo($("##{section}"), offset_height, 400)
$scope.$on 'purchaseFormInvalid', (event, form) ->
# Scroll to first invalid section
for section in $scope.accordionSections
if not form[section].$valid
$scope.show section
$timeout ->
$scope.scrollTo(section)
, 50
break

View File

@@ -1,12 +0,0 @@
angular.module('Darkswarm').controller "BillingCtrl", ($scope, $timeout, $controller) ->
angular.extend this, $controller('FieldsetMixin', {$scope: $scope})
$scope.name = "billing"
$scope.nextPanel = "shipping"
$scope.summary = ->
[$scope.order.bill_address.address1,
$scope.order.bill_address.city,
$scope.order.bill_address.zipcode]
$timeout $scope.onTimeout

View File

@@ -1,43 +0,0 @@
angular.module('Darkswarm').controller "CheckoutCtrl", ($scope, localStorageService, Checkout, CurrentUser, CurrentHub, $http) ->
$scope.Checkout = Checkout
$scope.submitted = false
# Bind to local storage
$scope.fieldsToBind = ["bill_address", "email", "payment_method_id", "shipping_method_id", "ship_address"]
prefix = "order_#{Checkout.order.id}#{CurrentUser.id or ""}#{CurrentHub.hub.id}"
for field in $scope.fieldsToBind
localStorageService.bind $scope, "Checkout.order.#{field}", Checkout.order[field], "#{prefix}_#{field}"
localStorageService.bind $scope, "Checkout.ship_address_same_as_billing", true, "#{prefix}_sameasbilling"
localStorageService.bind $scope, "Checkout.default_bill_address", false, "#{prefix}_defaultasbilladdress"
localStorageService.bind $scope, "Checkout.default_ship_address", false, "#{prefix}_defaultasshipaddress"
$scope.order = Checkout.order # Ordering is important
$scope.secrets = Checkout.secrets
$scope.enabled = !!CurrentUser.id?
$scope.purchase = (event, form) ->
event.preventDefault()
$scope.formdata = form
$scope.submitted = true
if CurrentUser.id
$scope.validateForm(form)
else
$scope.ensureUserIsGuest()
$scope.validateForm = ->
if $scope.formdata.$valid
$scope.Checkout.purchase()
else
$scope.$broadcast 'purchaseFormInvalid', $scope.formdata
$scope.ensureUserIsGuest = (callback = null) ->
$http.post("/user/registered_email", {email: $scope.order.email})
.then (response)->
window.CableReady.perform(response.data)
.catch ->
$scope.validateForm() if $scope.submitted
callback() if callback

View File

@@ -1,8 +0,0 @@
angular.module('Darkswarm').controller "CountryCtrl", ($scope, availableCountries) ->
$scope.countries = availableCountries
$scope.countriesById = $scope.countries.reduce (obj, country) ->
obj[country.id] = country
obj
, {}

View File

@@ -1,24 +0,0 @@
angular.module('Darkswarm').controller "DetailsCtrl", ($scope, $timeout, $http, CurrentUser, SpreeUser, $controller) ->
angular.extend this, $controller('FieldsetMixin', {$scope: $scope})
$scope.name = "details"
$scope.nextPanel = "billing"
$scope.login_or_next = (event) ->
event.preventDefault()
unless CurrentUser.id
$scope.ensureUserIsGuest($scope.next)
return
$scope.next()
$scope.summary = ->
[$scope.fullName(),
$scope.order.email,
$scope.order.bill_address.phone]
$scope.fullName = ->
[$scope.order.bill_address.firstname ? null,
$scope.order.bill_address.lastname ? null].join(" ").trim()
$timeout $scope.onTimeout

View File

@@ -1,19 +0,0 @@
angular.module('Darkswarm').controller "PaymentCtrl", ($scope, $timeout, savedCreditCards, Dates, $controller) ->
angular.extend this, $controller('FieldsetMixin', {$scope: $scope})
$scope.savedCreditCards = savedCreditCards
$scope.name = "payment"
$scope.months = Dates.months
$scope.years = Dates.years
$scope.secrets.card_month = "1"
$scope.secrets.card_year = moment().year()
for card in savedCreditCards when card.is_default
$scope.secrets.selected_card = card.id
break
$scope.summary = ->
[$scope.Checkout.paymentMethod()?.name]
$timeout $scope.onTimeout

View File

@@ -1,11 +0,0 @@
angular.module('Darkswarm').controller "ShippingCtrl", ($scope, $timeout, ShippingMethods, $controller) ->
angular.extend this, $controller('FieldsetMixin', {$scope: $scope})
$scope.ShippingMethods = ShippingMethods
$scope.name = "shipping"
$scope.nextPanel = "payment"
$scope.summary = ->
[$scope.Checkout.shippingMethod()?.name]
$timeout $scope.onTimeout

View File

@@ -89,16 +89,6 @@ module InjectionHelper
render partial: "json/injection_ams", locals: { name: "orderCycleData", json: json }
end
def inject_available_shipping_methods
inject_json_array "shippingMethods", available_shipping_methods,
Api::ShippingMethodSerializer, current_order: current_order
end
def inject_available_payment_methods
inject_json_array "paymentMethods", available_payment_methods,
Api::PaymentMethodSerializer, current_order: current_order
end
def inject_taxons
inject_json_array "taxons", Spree::Taxon.all.to_a, Api::TaxonSerializer
end

View File

@@ -6,16 +6,6 @@ module TermsAndConditionsHelper
rel: "noopener")
end
def render_terms_and_conditions
if platform_terms_required? && distributor_terms_required?
render("checkout/all_terms_and_conditions")
elsif platform_terms_required?
render "checkout/platform_terms_of_service"
elsif distributor_terms_required?
render "checkout/terms_and_conditions"
end
end
def any_terms_required?(distributor)
TermsOfService.required?(distributor)
end

View File

@@ -1,17 +0,0 @@
%accordion-heading
.row
.small-8.medium-9.columns
%em
%small
{{ summary() | printArray }}
.small-4.medium-3.columns.text-right
%span.accordion-up
%em
%small
= t :checkout_hide
%i.ofn-i_053-point-up
%span.accordion-down
%em
%small
= t :checkout_expand
%i.ofn-i_052-point-down

View File

@@ -1,4 +0,0 @@
%p
%input{ type: 'checkbox', id: 'accept_terms', ng: { model: "terms_and_conditions_accepted", init: "terms_and_conditions_accepted = #{all_terms_and_conditions_already_accepted?}" } }
%label.small{for: "accept_terms"}
= t('.message_html', terms_and_conditions_link: link_to( t(".terms_and_conditions"), current_order.distributor.terms_and_conditions, target: '_blank'), tos_link: link_to_platform_terms)

View File

@@ -1,2 +0,0 @@
%p.alert-box.info
= t '.message_html', cart: link_to(t('.cart'), "#{main_app.cart_path}#bought-products")

View File

@@ -1,19 +0,0 @@
%section{"ng-show" => "!enabled"}
.row
.small-12.columns.text-center
%h3.pad-top
= t :checkout_headline
.row.pad-top{ "data-controller": "login-modal" }
- if guest_checkout_allowed?
.small-5.columns.text-center
%button.primary.expand{ "data-action": "click->login-modal#call" }
= t :label_login
.small-2.columns.text-center
%p.pad-top= "#{t :action_or}"
.small-5.columns.text-center
%button.neutral-btn.dark.expand{"ng-click" => "enabled = true"}
= t :checkout_as_guest
- else
.small-6.columns.small-centered
%button.primary.expand{ "data-action": "click->login-modal#call" }
= t :label_login

View File

@@ -1,46 +0,0 @@
%fieldset#billing
%ng-form{"ng-controller" => "BillingCtrl", name: "billing"}
%h5{"ng-class" => "{valid: billing.$valid, dirty: billing.$dirty || submitted}"}
%span.right
%label.label.round.alert.right
%i.ofn-i_009-close
%label.label.round.success.right
%i.ofn-i_051-check-big
= t :checkout_billing
%accordion-group{"is-open" => "accordion.billing",
"ng-class" => "{valid: billing.$valid, open: accordion.billing}"}
= render 'checkout/accordion_heading'
- if spree_current_user
.small-12.columns
%label
%input{type: :checkbox, "ng-model" => "Checkout.default_bill_address"}
= t :checkout_default_bill_address
%div{ "ng-controller" => "CountryCtrl" }
= f.fields_for :bill_address, @order.bill_address do |ba|
.row
.small-12.columns
= validated_input t(:address), "order.bill_address.address1", "ofn-focus" => "accordion['billing']"
.row
.small-12.columns
= validated_input t(:address2), "order.bill_address.address2", required: false
.row
.small-6.columns
= validated_input t(:city), "order.bill_address.city"
.small-6.columns
= validated_select t(:state), "order.bill_address.state_id", {}, {"ng-options" => "s.id as s.name for s in countriesById[order.bill_address.country_id].states"}
.row
.small-6.columns
= validated_input t(:postcode), "order.bill_address.zipcode"
.small-6.columns.right
= validated_select t(:country), "order.bill_address.country_id", {}, {"ng-init" => "order.bill_address.country_id = order.bill_address.country_id || #{DefaultCountry.id}", "ng-options" => "c.id as c.name for c in countries"}
.row
.small-12.columns.text-right
%button.primary{"ng-disabled" => "billing.$invalid", "ng-click" => "next($event)"}
= t :next

View File

@@ -1,33 +0,0 @@
%fieldset#details
%ng-form{"ng-controller" => "DetailsCtrl", name: "details"}
%h5{"ng-class" => "{valid: details.$valid, dirty: details.$dirty || submitted}"}
%span.right
%label.label.round.alert.right
%i.ofn-i_009-close
%label.label.round.success.right
%i.ofn-i_051-check-big
= t :checkout_details
%accordion-group{"is-open" => "accordion.details",
"ng-class" => "{valid: details.$valid, open: accordion.details}"}
= render 'checkout/accordion_heading'
.row
.small-6.columns
= validated_input t(:first_name), "order.bill_address.firstname"
.small-6.columns
= validated_input t(:last_name), "order.bill_address.lastname"
.row
.small-6.columns
= validated_input t(:email), 'order.email', type: "email", inputmode: "email", "ofn-focus" => "accordion['details']"
.small-6.columns
= validated_input t(:phone), 'order.bill_address.phone', inputmode: "tel"
.row
.small-12.columns.text-right
%button.primary{"ng-disabled" => "details.$invalid", "ng-click" => "login_or_next($event)"}
= t :next

View File

@@ -1,22 +0,0 @@
- content_for :injection_data do
= inject_available_shipping_methods
= inject_available_payment_methods
= inject_saved_credit_cards
= form_for current_order,
url: order_path(current_order),
html: {name: "checkout",
id: "checkout_form",
novalidate: true,
"ng-submit" => "purchase($event, checkout)"} do |f|
= render "checkout/details", f: f
= render "checkout/billing", f: f
= render "checkout/shipping", f: f
= render "checkout/payment", f: f
= render "checkout/already_ordered", f: f if show_bought_items?
= render_terms_and_conditions
%p
%button.button.primary{ type: :submit, ng: { disabled: "terms_and_conditions_accepted == false || platform_tos_accepted == false" } }
= t :checkout_send
/ {{ checkout.$valid }}

View File

@@ -1,37 +0,0 @@
%fieldset#payment
%ng-form{"ng-controller" => "PaymentCtrl", name: "payment"}
%h5{"ng-class" => "{valid: payment.$valid, dirty: payment.$dirty || submitted}"}
%span.right
%label.label.round.alert.right
%i.ofn-i_009-close
%label.label.round.success.right
%i.ofn-i_051-check-big
= t :checkout_payment
%accordion-group{"is-open" => "accordion.payment",
"ng-class" => "{valid: payment.$valid, open: accordion.payment}"}
= render 'checkout/accordion_heading'
.row
.small-12.medium-12.large-6.columns
- available_payment_methods.each do |method|
.row
.small-12.columns
%label
= radio_button_tag "order[payments_attributes][][payment_method_id]", method.id, false,
required: true,
name: "order.payment_method_id",
"ng-model" => "order.payment_method_id"
= method.name
= "(#{payment_method_price(method, @order)})"
%small.error.medium.input-text{"ng-show" => "!fieldValid('order.payment_method_id')"}
= "{{ fieldErrors('order.payment_method_id') }}"
.row{"ng-if" => "order.payment_method_id == #{method.id}"}
.small-12.columns
= render partial: "spree/checkout/payment/#{method.method_type}", :locals => { :payment_method => method }
.small-12.medium-12.large-6.columns
#distributor_address.panel{"ng-show" => "Checkout.paymentMethod().description"}
%span.pre-wrap {{ Checkout.paymentMethod().description }}

View File

@@ -1,10 +0,0 @@
%p
%input{ type: "checkbox",
id: "accept_terms",
ng: {
model: "platform_tos_accepted",
init: "platform_tos_accepted = #{platform_tos_already_accepted?}"
}
}
%label.small{for: "accept_terms"}
= t(".message_html", tos_link: link_to_platform_terms)

View File

@@ -1,61 +0,0 @@
%fieldset#shipping
%ng-form{"ng-controller" => "ShippingCtrl", name: "shipping"}
%h5{"ng-class" => "{valid: shipping.$valid, dirty: shipping.$dirty || submitted}"}
%span.right
%label.label.round.alert.right
%i.ofn-i_009-close
%label.label.round.success.right
%i.ofn-i_051-check-big
= t :checkout_shipping
%accordion-group{"is-open" => "accordion.shipping",
"ng-class" => "{valid: shipping.$valid, open: accordion.shipping}"}
= render 'checkout/accordion_heading'
.small-12.columns.medium-12.columns.large-6.columns
%label{"ng-repeat" => "method in ShippingMethods.shipping_methods | orderBy: 'name'"}
%input{type: :radio,
required: true,
name: "order.shipping_method_id",
"ng-value" => "method.id",
"ng-model" => "order.shipping_method_id"}
{{ method.name }}
%em.light{"ng-show" => "!method.price || method.price == 0"}
= "(#{t(:checkout_method_free)})"
%em.light{"ng-hide" => "!method.price || method.price == 0"}
({{ method.price | localizeCurrency }})
%small.error.medium.input-text{"ng-show" => "!fieldValid('order.shipping_method_id')"}
= "{{ fieldErrors('order.shipping_method_id') }}"
%label{"ng-if" => "Checkout.requireShipAddress()"}
%input{type: :checkbox, "ng-model" => "Checkout.ship_address_same_as_billing"}
= t :checkout_address_same
- if spree_current_user
%label{"ng-if" => "Checkout.requireShipAddress()"}
%input{type: :checkbox, "ng-model" => "Checkout.default_ship_address"}
= t :checkout_default_ship_address
.small-12.columns.medium-12.columns.large-6.columns
#distributor_address.panel{"ng-show" => "Checkout.shippingMethod().description"}
%span{ style: "white-space: pre-wrap;" }{{ Checkout.shippingMethod().description }}
%br/
%br/
- if @order.order_cycle.pickup_time_for(@order.distributor)
= t :checkout_ready_for
= @order.order_cycle.pickup_time_for(@order.distributor)
= f.fields_for :ship_address, @order.ship_address do |sa|
= render 'checkout/shipping_ship_address'
.row
.small-12.columns
%label{ for: 'order_special_instructions'}= t(:checkout_instructions)
= f.text_area :special_instructions, size: "60x4", "ng-model" => "order.special_instructions"
.row
.small-12.columns.text-right
%button.primary{"ng-disabled" => "shipping.$invalid", "ng-click" => "next($event)"}
= t :next

View File

@@ -1,28 +0,0 @@
.small-12.columns
#ship_address{"ng-if" => "Checkout.requireShipAddress()"}
%div.visible{"ng-if" => "!Checkout.ship_address_same_as_billing"}
%div{ "ng-controller" => "CountryCtrl" }
.row
.small-6.columns
= validated_input t(:first_name), "order.ship_address.firstname", "ofn-focus" => "accordion['shipping']"
.small-6.columns
= validated_input t(:last_name), "order.ship_address.lastname"
.row
.small-12.columns
= validated_input t(:address), "order.ship_address.address1"
.row
.small-12.columns
= validated_input t(:address2), "order.ship_address.address2", required: false
.row
.small-6.columns
= validated_input t(:city), "order.ship_address.city"
.small-6.columns
= validated_select t(:state), "order.ship_address.state_id", {}, {"ng-options" => "s.id as s.name for s in countriesById[order.ship_address.country_id].states"}
.row
.small-6.columns
= validated_input t(:postcode), "order.ship_address.zipcode"
.small-6.columns.right
= validated_select t(:country), "order.ship_address.country_id", {}, {"ng-init" => "order.ship_address.country_id = order.ship_address.country_id || #{DefaultCountry.id}", "ng-options" => "c.id as c.name for c in countries"}
.row
.small-6.columns
= validated_input t(:phone), "order.ship_address.phone"

View File

@@ -1,34 +0,0 @@
%orderdetails
= form_for current_order, url: "#", html: {"ng-submit" => "purchase($event, checkout)"} do |f|
%fieldset
%legend
= t :checkout_your_order
%table
%tr.subtotal
%th
= t :checkout_cart_total
%td.cart-total.text-right= display_checkout_subtotal(@order)
- checkout_adjustments_for(current_order, exclude: [:shipping, :payment, :line_item]).each do |adjustment|
%tr.adjustment
%th= adjustment.label
%td.text-right= adjustment.display_amount.to_html
%tr.shipping
%th
= t :checkout_shipping_price
%td.text-right {{ Checkout.shippingPrice() | localizeCurrency }}
%tr.transaction-fee
%th
= t :payment_method_fee
%td.text-right {{ Checkout.paymentPrice() | localizeCurrency }}
%tr.total
%th
= t :checkout_total_price
%td.text-right {{ Checkout.cartTotal() | localizeCurrency }}
//= f.submit "Purchase", class: "button", "ofn-focus" => "accordion['payment']"
%a.button.secondary{href: main_app.cart_url}
= t :checkout_back_to_cart

View File

@@ -1,3 +0,0 @@
%p
%input{ type: 'checkbox', id: 'accept_terms', ng: { model: "terms_and_conditions_accepted", init: "terms_and_conditions_accepted=#{terms_and_conditions_already_accepted?}" } }
%label.small{for: "accept_terms"}= t('.message_html', terms_and_conditions_link: link_to( t( '.link_text' ), current_order.distributor.terms_and_conditions, target: '_blank'))

View File

@@ -1,36 +0,0 @@
- content_for(:title) do
= t :checkout_title
- content_for :injection_data do
= inject_enterprise_and_relatives
= inject_available_countries
.darkswarm.footer-pad
- content_for :order_cycle_form do
%closing
= t :checkout_now
%p
= t :checkout_order_ready
%strong
= pickup_time current_order_cycle
- content_for :ordercycle_sidebar do
.show-for-large-up.large-4.columns
= render partial: "shopping_shared/order_cycles"
= render partial: "shopping_shared/header"
.sub-header.show-for-medium-down
= render partial: "shopping_shared/order_cycles"
%accordion{"close-others" => "false"}
%checkout.row{"ng-controller" => "CheckoutCtrl"}
.small-12.medium-8.columns
- unless spree_current_user
= render partial: "checkout/authentication"
%div{"ng-show" => "enabled", "ng-controller" => "AccordionCtrl"}
= render partial: "checkout/form"
.small-12.medium-4.columns
= render partial: "checkout/summary"
= render partial: "shared/footer"

View File

@@ -1,27 +0,0 @@
.row
.small-6.columns
%label
= t :first_name
-# Changing name not permitted by default (in checkout) - can be enabled by setting an allow_name_change variable in $scope
%input{type: :text, "ng-disabled" => "!allow_name_change", "ng-value" => "order.bill_address.firstname"}
.small-6.columns
%label
= t :last_name
%input{type: :text, "ng-disabled" => "!allow_name_change", "ng-value" => "order.bill_address.lastname"}
.small-6.columns
= validated_input t(:card_number), "secrets.card_number", maxlength: 19, autocomplete: "off"
.small-6.columns
= validated_input t(:card_securitycode), "secrets.card_verification_value"
.row
.small-12.columns
%label{for: "secrets.card_month"}
= t :card_expiry_date
.row
.small-6.columns
%select{"ng-model" => "secrets.card_month", "ng-options" => "currMonth.value as currMonth.key for currMonth in months", name: "secrets.card_month"}
.small-6.columns
%select{"ng-model" => "secrets.card_year", "ng-options" => "year for year in years", name: "secrets.card_year"}

View File

@@ -1 +0,0 @@
-# This file intentionally overrides the view in the spree_paypal_express gem

View File

@@ -1,22 +0,0 @@
- content_for :injection_data do
- if Stripe.publishable_key
:javascript
angular.module('Darkswarm').value("stripeObject", Stripe("#{Stripe.publishable_key}"))
.row{ "ng-show" => "savedCreditCards.length > 0" }
.small-12.columns
%h6= t('.used_saved_card')
%select{ name: "selected_card", required: false, ng: { model: "secrets.selected_card", options: "card.id as card.formatted for card in savedCreditCards" } }
%option{ value: "" }= "{{ secrets.selected_card ? '#{t('.enter_new_card')}' : '#{t('.choose_one')}' }}"
%h6{ ng: { if: '!secrets.selected_card' } }
= t('.or_enter_new_card')
%div{ ng: { if: '!secrets.selected_card' } }
%stripe-elements
- if spree_current_user
.row
.small-12.columns.text-right
= check_box_tag 'secrets.save_requested_by_customer', '1', false, 'ng-model' => 'secrets.save_requested_by_customer'
= label_tag 'secrets.save_requested_by_customer', t('.remember_this_card')

View File

@@ -1,22 +0,0 @@
- content_for :injection_data do
- if Stripe.publishable_key
:javascript
angular.module('Darkswarm').value("stripeObject", Stripe("#{Stripe.publishable_key}"))
.row{ "ng-show" => "savedCreditCards.length > 0" }
.small-12.columns
%h6= t('.used_saved_card')
%select{ name: "selected_card", required: false, ng: { model: "secrets.selected_card", options: "card.id as card.formatted for card in savedCreditCards" } }
%option{ value: "" }= "{{ secrets.selected_card ? '#{t('.enter_new_card')}' : '#{t('.choose_one')}' }}"
%h6{ ng: { if: '!secrets.selected_card' } }
= t('.or_enter_new_card')
%div{ ng: { if: '!secrets.selected_card' } }
%stripe-elements
- if spree_current_user
.row
.small-12.columns.text-right
= check_box_tag 'secrets.save_requested_by_customer', '1', false, 'ng-model' => 'secrets.save_requested_by_customer'
= label_tag 'secrets.save_requested_by_customer', t('.remember_this_card')