mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-13 04:00:21 +00:00
Moving our inputs to magical helpers
This commit is contained in:
@@ -2,10 +2,6 @@ Darkswarm.controller "DetailsCtrl", ($scope) ->
|
||||
angular.extend(this, new FieldsetMixin($scope))
|
||||
$scope.name = "details"
|
||||
|
||||
|
||||
#$scope.detailsValid = ->
|
||||
#$scope.detailsFields().every (field)->
|
||||
#$scope.checkout[field].$valid
|
||||
|
||||
#$scope.$watch ->
|
||||
#$scope.detailsValid()
|
||||
|
||||
@@ -17,44 +17,3 @@ Darkswarm.controller "CheckoutCtrl", ($scope, Order, storage) ->
|
||||
event.preventDefault()
|
||||
$scope.Order.submit()
|
||||
|
||||
FieldsetController = ($scope)->
|
||||
$scope.field = (path)->
|
||||
$scope[$scope.name][path]
|
||||
|
||||
$scope.fieldValid = (path)->
|
||||
not ($scope.dirty(path) and $scope.invalid(path))
|
||||
|
||||
$scope.dirty = (name)->
|
||||
$scope.field(name).$dirty
|
||||
|
||||
$scope.invalid = (name)->
|
||||
$scope.field(name).$invalid
|
||||
|
||||
$scope.error = (name)->
|
||||
$scope.field(name).$error
|
||||
|
||||
$scope.fieldErrors = (path)->
|
||||
# TODO: display server errors
|
||||
errors = for error, invalid of $scope.error(path)
|
||||
if invalid
|
||||
switch error
|
||||
when "required" then "must not be blank"
|
||||
when "number" then "must be number"
|
||||
when "email" then "must be email address"
|
||||
(errors.filter (error) -> error?).join ", "
|
||||
|
||||
|
||||
|
||||
Darkswarm.controller "DetailsSubCtrl", ($scope) ->
|
||||
angular.extend(this, new FieldsetController($scope))
|
||||
$scope.name = "details"
|
||||
#$scope.detailsValid = ->
|
||||
#$scope.detailsFields().every (field)->
|
||||
#$scope.checkout[field].$valid
|
||||
|
||||
#$scope.$watch ->
|
||||
#$scope.detailsValid()
|
||||
#, (valid)->
|
||||
#if valid
|
||||
#$scope.show("billing")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user