mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-05 22:26:07 +00:00
Renaming some methods in our experimental
This commit is contained in:
@@ -3,24 +3,24 @@ Darkswarm.controller "CheckoutCtrl", ($scope, Order, storage) ->
|
||||
$scope.order = $scope.Order = Order
|
||||
$scope.accordion = {}
|
||||
|
||||
storage.bind $scope, "user", { defaultValue: true}
|
||||
$scope.disable = ->
|
||||
$scope.user = false
|
||||
$scope.details = true
|
||||
|
||||
$scope.show = (name)->
|
||||
$scope.accordion[name] = true
|
||||
|
||||
storage.bind $scope, "accordion.user", { defaultValue: true}
|
||||
storage.bind $scope, "accordion.details"
|
||||
storage.bind $scope, "accordion.billing"
|
||||
storage.bind $scope, "accordion.shipping"
|
||||
storage.bind $scope, "accordion.payment"
|
||||
|
||||
# Validation utilities to keep things DRY
|
||||
$scope.dirtyValid = (name)->
|
||||
$scope.dirty(name) and $scope.valid(name)
|
||||
$scope.dirtyInvalid = (name)->
|
||||
$scope.dirty(name) and $scope.invalid(name)
|
||||
$scope.dirty = (name)->
|
||||
$scope.checkout[name].$dirty
|
||||
$scope.valid = (name)->
|
||||
$scope.invalid = (name)->
|
||||
$scope.checkout[name].$invalid
|
||||
|
||||
# Validations
|
||||
$scope.error = (name)->
|
||||
$scope.checkout[name].$error
|
||||
$scope.required = (name)->
|
||||
@@ -43,10 +43,12 @@ Darkswarm.controller "DetailsSubCtrl", ($scope) ->
|
||||
$scope.detailsValid()
|
||||
, (valid)->
|
||||
if valid
|
||||
$scope.accordion.details = false
|
||||
$scope.accordion.billing = true
|
||||
$scope.show("billing")
|
||||
|
||||
$scope.detailsFields = ->
|
||||
|
||||
{"order[email]" : {email: "must be email", required: "field required"}}
|
||||
|
||||
["order[email]",
|
||||
"order[bill_address_attributes][phone]",
|
||||
"order[bill_address_attributes][firstname]",
|
||||
@@ -54,14 +56,14 @@ Darkswarm.controller "DetailsSubCtrl", ($scope) ->
|
||||
|
||||
$scope.emailName = 'order[email]'
|
||||
$scope.emailValid = ->
|
||||
$scope.dirtyValid($scope.emailName)
|
||||
$scope.dirtyInvalid($scope.emailName)
|
||||
$scope.emailError = ->
|
||||
return "can't be blank" if $scope.required($scope.emailName)
|
||||
return "must be valid" if $scope.email($scope.emailName)
|
||||
|
||||
$scope.phoneName = "order[bill_address_attributes][phone]"
|
||||
$scope.phoneValid = ->
|
||||
$scope.dirtyValid($scope.phoneName)
|
||||
$scope.dirtyInvalid($scope.phoneName)
|
||||
$scope.phoneError = ->
|
||||
"must be a number"
|
||||
|
||||
|
||||
@@ -6,4 +6,4 @@
|
||||
.large-4.columns.text-center{"ng-controller" => "AuthenticationActionsCtrl"}
|
||||
%button{"ng-click" => "toggle('/signup')"} Signup
|
||||
.large-4.columns.text-center
|
||||
%button{"ng-click" => "disable()"} Checkout as guest
|
||||
%button{"ng-click" => "show('details')"} Checkout as guest
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
%fieldset#details
|
||||
%accordion-group{"is-open" => "accordion.details"}
|
||||
%div{"ng-controller" => "DetailsSubCtrl"}
|
||||
{{ detailsValid() }}
|
||||
%accordion-heading
|
||||
.row
|
||||
.large-6.columns
|
||||
@@ -12,8 +11,8 @@
|
||||
.row
|
||||
.large-6.columns
|
||||
= f.email_field :email, required: "", "ng-model" => "order.email",
|
||||
"ng-change" => "next()",
|
||||
"ng-class" => "{error: '!emailValid()'}"
|
||||
|
||||
%small.error.medium.input-text{"ng-show" => "emailValid()"}
|
||||
{{ emailError() }}
|
||||
|
||||
@@ -31,4 +30,3 @@
|
||||
|
||||
.large-6.columns
|
||||
= ba.text_field :lastname, "ng-model" => "order.bill_address.lastname"
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
= render partial: "shop/details"
|
||||
|
||||
%accordion.row{"close-others" => "false"}
|
||||
%accordion.row{"close-others" => "true"}
|
||||
%checkout{"ng-controller" => "CheckoutCtrl"}
|
||||
.large-9.columns
|
||||
- unless spree_current_user
|
||||
|
||||
@@ -8,6 +8,7 @@ describe Shop::CheckoutController do
|
||||
order.stub(:checkout_allowed?).and_return true
|
||||
controller.stub(:check_authorization).and_return true
|
||||
end
|
||||
|
||||
it "redirects home when no distributor is selected" do
|
||||
get :edit
|
||||
response.should redirect_to root_path
|
||||
@@ -46,6 +47,7 @@ describe Shop::CheckoutController do
|
||||
end
|
||||
|
||||
describe "building the order" do
|
||||
|
||||
before do
|
||||
controller.stub(:current_distributor).and_return(distributor)
|
||||
controller.stub(:current_order_cycle).and_return(order_cycle)
|
||||
|
||||
Reference in New Issue
Block a user