mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-04-07 07:36:58 +00:00
Moving payment methods and shipping methods into their own services
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
Darkswarm.controller "ShippingCtrl", ($scope, $timeout) ->
|
||||
Darkswarm.controller "ShippingCtrl", ($scope, $timeout, ShippingMethods) ->
|
||||
angular.extend(this, new FieldsetMixin($scope))
|
||||
$scope.ShippingMethods = ShippingMethods
|
||||
$scope.name = "shipping"
|
||||
$scope.nextPanel = "payment"
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
Darkswarm.factory "AuthenticationService", (Navigation, $modal, $location, Redirections)->
|
||||
|
||||
new class AuthenticationService
|
||||
selectedPath: "/login"
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Darkswarm.factory 'Cart', (Order)->
|
||||
Darkswarm.factory 'Cart', (CurrentOrder)->
|
||||
# Handles syncing of current cart/order state to server
|
||||
new class Cart
|
||||
order: Order.order
|
||||
order: CurrentOrder.order
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Darkswarm.factory 'Checkout', (Order, $http, Navigation, CurrentHub, RailsFlashLoader, Loading)->
|
||||
Darkswarm.factory 'Checkout', (Order, ShippingMethods, PaymentMethods, $http, Navigation, CurrentHub, RailsFlashLoader, Loading)->
|
||||
new class Checkout
|
||||
errors: {}
|
||||
secrets: {}
|
||||
@@ -8,7 +8,7 @@ Darkswarm.factory 'Checkout', (Order, $http, Navigation, CurrentHub, RailsFlashL
|
||||
submit: ->
|
||||
Loading.message = "Submitting your order: please wait"
|
||||
$http.put('/checkout', {order: @preprocess()}).success (data, status)=>
|
||||
Navigation.go data.pat
|
||||
Navigation.go data.path
|
||||
.error (response, status)=>
|
||||
Loading.clear()
|
||||
@errors = response.errors
|
||||
@@ -47,7 +47,7 @@ Darkswarm.factory 'Checkout', (Order, $http, Navigation, CurrentHub, RailsFlashL
|
||||
munged_order
|
||||
|
||||
shippingMethod: ->
|
||||
@order.shipping_methods[@order.shipping_method_id] if @order.shipping_method_id
|
||||
ShippingMethods.shipping_methods_by_id[@order.shipping_method_id] if @order.shipping_method_id
|
||||
|
||||
requireShipAddress: ->
|
||||
@shippingMethod()?.require_ship_address
|
||||
@@ -56,7 +56,7 @@ Darkswarm.factory 'Checkout', (Order, $http, Navigation, CurrentHub, RailsFlashL
|
||||
@shippingMethod()?.price || 0.0
|
||||
|
||||
paymentMethod: ->
|
||||
@order.payment_methods[@order.payment_method_id]
|
||||
PaymentMethods.payment_methods_by_id[@order.payment_method_id]
|
||||
|
||||
cartTotal: ->
|
||||
@shippingPrice() + @order.display_total
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
Darkswarm.factory 'CurrentOrder', (currentOrder) ->
|
||||
new class CurrentOrder
|
||||
constructor: ->
|
||||
@[k] = v for k, v of currentOrder
|
||||
@cart_count ?= 0
|
||||
|
||||
order: currentOrder
|
||||
empty: =>
|
||||
@line_items.length == 0
|
||||
@order.line_items.length == 0
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
Darkswarm.factory 'Order', (order)->
|
||||
new class Order
|
||||
errors: {}
|
||||
order: order
|
||||
|
||||
|
||||
Reference in New Issue
Block a user