mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Making the auto-closing more granular on checkout
This commit is contained in:
@@ -9,8 +9,8 @@ Darkswarm.controller "AccordionCtrl", ($scope, storage, $timeout) ->
|
||||
$scope.show = (name)->
|
||||
$scope.accordion[name] = true
|
||||
|
||||
$timeout =>
|
||||
if $scope.checkout.$valid
|
||||
for k, v of $scope.accordion
|
||||
$scope.accordion[k] = false
|
||||
#$timeout =>
|
||||
#if $scope.checkout.$valid
|
||||
#for k, v of $scope.accordion
|
||||
#$scope.accordion[k] = false
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Darkswarm.controller "BillingCtrl", ($scope) ->
|
||||
Darkswarm.controller "BillingCtrl", ($scope, $timeout) ->
|
||||
angular.extend(this, new FieldsetMixin($scope))
|
||||
$scope.name = "billing"
|
||||
$scope.nextPanel = "shipping"
|
||||
@@ -8,3 +8,4 @@ Darkswarm.controller "BillingCtrl", ($scope) ->
|
||||
$scope.order.bill_address.city,
|
||||
$scope.order.bill_address.zipcode]
|
||||
|
||||
#$timeout $scope.onTimeout
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
Darkswarm.controller "DetailsCtrl", ($scope) ->
|
||||
Darkswarm.controller "DetailsCtrl", ($scope, $timeout) ->
|
||||
angular.extend(this, new FieldsetMixin($scope))
|
||||
|
||||
$scope.name = "details"
|
||||
$scope.nextPanel = "billing"
|
||||
|
||||
@@ -12,3 +11,5 @@ Darkswarm.controller "DetailsCtrl", ($scope) ->
|
||||
$scope.fullName = ->
|
||||
[$scope.order.bill_address.firstname ? null,
|
||||
$scope.order.bill_address.lastname ? null].join(" ").trim()
|
||||
|
||||
$timeout $scope.onTimeout
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Darkswarm.controller "PaymentCtrl", ($scope) ->
|
||||
Darkswarm.controller "PaymentCtrl", ($scope, $timeout) ->
|
||||
angular.extend(this, new FieldsetMixin($scope))
|
||||
$scope.name = "payment"
|
||||
|
||||
@@ -6,3 +6,4 @@ Darkswarm.controller "PaymentCtrl", ($scope) ->
|
||||
$scope.years = [moment().year()..(moment().year()+15)]
|
||||
$scope.secrets.card_month = "1"
|
||||
$scope.secrets.card_year = moment().year()
|
||||
$timeout $scope.onTimeout
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
Darkswarm.controller "ShippingCtrl", ($scope) ->
|
||||
Darkswarm.controller "ShippingCtrl", ($scope, $timeout) ->
|
||||
angular.extend(this, new FieldsetMixin($scope))
|
||||
$scope.name = "shipping"
|
||||
$scope.nextPanel = "payment"
|
||||
|
||||
$timeout $scope.onTimeout
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
window.FieldsetMixin = ($scope)->
|
||||
$scope.next = (event)->
|
||||
event.preventDefault()
|
||||
$scope.next = (event = false)->
|
||||
event.preventDefault() if event
|
||||
$scope.show $scope.nextPanel
|
||||
|
||||
$scope.onTimeout = ->
|
||||
if $scope[$scope.name].$valid
|
||||
$scope.next()
|
||||
|
||||
$scope.valid = ->
|
||||
$scope.form().$valid
|
||||
|
||||
|
||||
@@ -30,11 +30,3 @@ describe "AccordionCtrl", ->
|
||||
scope.order =
|
||||
id: 129
|
||||
ctrl = $controller 'AccordionCtrl', {$scope: scope}
|
||||
|
||||
it "automatically closes all sections if the entire form is valid", ->
|
||||
waitsFor ->
|
||||
(scope.accordion.details and
|
||||
scope.accordion.shipping and
|
||||
scope.accordion.payment and
|
||||
scope.accordion.billing) == false
|
||||
, "the accordion to close", 100
|
||||
|
||||
Reference in New Issue
Block a user