mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-12 03:50:22 +00:00
Standing Orders: form split into ngForm elements with staggered validation
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
angular.module("admin.standingOrders").controller "DetailsController", ($scope, StatusMessage) ->
|
||||
$scope.submitted = false
|
||||
|
||||
$scope.next = ->
|
||||
$scope.submitted = true
|
||||
if $scope.standing_order_details_form.$valid
|
||||
StatusMessage.clear()
|
||||
$scope.setView('products')
|
||||
else
|
||||
StatusMessage.display 'failure', 'Oops! There seems to be a problem...'
|
||||
@@ -0,0 +1,9 @@
|
||||
angular.module("admin.standingOrders").controller "ProductsController", ($scope, StatusMessage) ->
|
||||
$scope.next = ->
|
||||
if $scope.standingOrder.standing_line_items.length > 0
|
||||
StatusMessage.clear()
|
||||
$scope.setView('review')
|
||||
else
|
||||
StatusMessage.display 'failure', 'Please add at least one product'
|
||||
|
||||
$scope.back = -> $scope.setView('details')
|
||||
@@ -7,20 +7,13 @@ angular.module("admin.standingOrders").controller "StandingOrderController", ($s
|
||||
$scope.errors = StandingOrder.errors
|
||||
$scope.newItem = { variant_id: 0, quantity: 1 }
|
||||
$scope.distributor_id = $scope.standingOrder.shop_id # variant selector requires distributor_id
|
||||
$scope.views = ['details','products','review']
|
||||
$scope.view = if $scope.standingOrder.id? then $scope.views[$scope.views.length-1] else $scope.views[0]
|
||||
$scope.view = if $scope.standingOrder.id? then 'review' else 'details'
|
||||
|
||||
$scope.save = ->
|
||||
$scope.standing_order_form.$setPristine()
|
||||
StandingOrder.save()
|
||||
|
||||
$scope.next = ->
|
||||
viewIndex = $scope.views.indexOf($scope.view)
|
||||
$scope.view = $scope.views[viewIndex+1]
|
||||
|
||||
$scope.back = ->
|
||||
viewIndex = $scope.views.indexOf($scope.view)
|
||||
$scope.view = $scope.views[viewIndex-1]
|
||||
$scope.setView = (view) -> $scope.view = view
|
||||
|
||||
$scope.addStandingLineItem = ->
|
||||
StandingOrder.buildItem($scope.newItem)
|
||||
|
||||
Reference in New Issue
Block a user