mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Checkout: When error, open offending accordion section
This commit is contained in:
@@ -6,6 +6,15 @@ Darkswarm.controller "AccordionCtrl", ($scope, storage, $timeout, CurrentHub) ->
|
||||
billing: false
|
||||
storage.bind $scope, "accordion", {storeName: "accordion_#{$scope.order.id}#{CurrentHub.hub.id}#{$scope.order.user_id}"}
|
||||
|
||||
$scope.show = (name)->
|
||||
$scope.accordion[name] = true
|
||||
$scope.show = (section)->
|
||||
$scope.accordion[section] = true
|
||||
|
||||
$scope.$on 'purchaseFormInvalid', (event, form) ->
|
||||
# Scroll to first invalid section
|
||||
# TODO: hide all first
|
||||
# TODO: Use Object.keys($scope.accordion)
|
||||
sections = ["details", "billing", "shipping", "payment"]
|
||||
for section in sections
|
||||
if not form[section].$valid
|
||||
$scope.show section
|
||||
break
|
||||
|
||||
@@ -21,4 +21,7 @@ Darkswarm.controller "CheckoutCtrl", ($scope, storage, Checkout, CurrentUser, Cu
|
||||
$scope.purchase = (event, form) ->
|
||||
event.preventDefault()
|
||||
$scope.submitted = true
|
||||
$scope.Checkout.submit() if form.$valid
|
||||
if form.$valid
|
||||
$scope.Checkout.submit()
|
||||
else
|
||||
$scope.$broadcast 'purchaseFormInvalid', form
|
||||
|
||||
Reference in New Issue
Block a user