mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-22 05:18:51 +00:00
Refactoring registration form controller
This commit is contained in:
@@ -1,20 +1,15 @@
|
||||
Darkswarm.controller "RegistrationFormCtrl", ($scope, RegistrationService, EnterpriseRegistrationService) ->
|
||||
$scope.submitted = false
|
||||
|
||||
$scope.valid = (form) ->
|
||||
$scope.submitted = !form.$valid
|
||||
form.$valid
|
||||
|
||||
$scope.create = (form) ->
|
||||
$scope.submitted = true
|
||||
if form.$valid
|
||||
EnterpriseRegistrationService.create()
|
||||
$scope.submitted = false
|
||||
EnterpriseRegistrationService.create() if $scope.valid(form)
|
||||
|
||||
$scope.update = (nextStep, form) ->
|
||||
$scope.submitted = true
|
||||
if form.$valid
|
||||
EnterpriseRegistrationService.update(nextStep)
|
||||
$scope.submitted = false
|
||||
EnterpriseRegistrationService.update(nextStep) if $scope.valid(form)
|
||||
|
||||
$scope.select = (nextStep, form) ->
|
||||
$scope.submitted = true
|
||||
if form.$valid
|
||||
RegistrationService.select(nextStep)
|
||||
$scope.submitted = false
|
||||
RegistrationService.select(nextStep) if $scope.valid(form)
|
||||
@@ -5,15 +5,14 @@
|
||||
%ng-include{ src: "'registration/steps.html'" }
|
||||
%form{ name: 'details', novalidate: true, ng: { controller: "RegistrationFormCtrl", submit: "select('address',details)" } }
|
||||
.row
|
||||
.small-12.columns
|
||||
.small-12.columns.field
|
||||
%label{ for: 'enterprise_name' } Enterprise Name:
|
||||
%input.chunky.small-12.columns{ id: 'enterprise_name', name: 'name', placeholder: "eg. Charlie's Awesome Farm", required: true, ng: { model: 'enterprise.name' } }
|
||||
{{ submitted + " " + details.name.$error.required }}
|
||||
%span.error.small-12.columns{ ng: { show: "details.name.$error.required && submitted" } }
|
||||
You need to enter a name for you enterprise!
|
||||
You need to enter a name for your enterprise!
|
||||
|
||||
.row#enterprise-types{ 'data-equalizer' => true }
|
||||
.small-12.columns
|
||||
.small-12.columns.field
|
||||
.row
|
||||
.small-12.columns
|
||||
%label Choose one:
|
||||
|
||||
@@ -34,10 +34,12 @@
|
||||
top: 0px
|
||||
right: 0px
|
||||
|
||||
.field
|
||||
margin-bottom: 15px
|
||||
|
||||
input.chunky
|
||||
padding: 8px
|
||||
font-size: 105%
|
||||
margin-bottom: 15px
|
||||
|
||||
label.indent-checkbox
|
||||
display: block
|
||||
|
||||
Reference in New Issue
Block a user