Adding basic validation to reg process

This commit is contained in:
Rob H
2014-08-24 11:20:00 +10:00
parent 800eecea33
commit 412e906ed3
3 changed files with 27 additions and 6 deletions

View File

@@ -1,9 +1,7 @@
Darkswarm.controller "RegistrationCtrl", ($scope, RegistrationService, EnterpriseRegistrationService, availableCountries) ->
$scope.currentStep = RegistrationService.currentStep
$scope.select = RegistrationService.select
$scope.enterprise = EnterpriseRegistrationService.enterprise
$scope.create = EnterpriseRegistrationService.create
$scope.update = EnterpriseRegistrationService.update
$scope.select = RegistrationService.select
$scope.steps = ['details','address','contact','about','images','social']

View File

@@ -0,0 +1,20 @@
Darkswarm.controller "RegistrationFormCtrl", ($scope, RegistrationService, EnterpriseRegistrationService) ->
$scope.submitted = false
$scope.create = (form) ->
$scope.submitted = true
if form.$valid
EnterpriseRegistrationService.create()
$scope.submitted = false
$scope.update = (nextStep, form) ->
$scope.submitted = true
if form.$valid
EnterpriseRegistrationService.update(nextStep)
$scope.submitted = false
$scope.select = (nextStep, form) ->
$scope.submitted = true
if form.$valid
RegistrationService.select(nextStep)
$scope.submitted = false

View File

@@ -3,11 +3,14 @@
%h2 Let's Get Started
%h5 Woot! First we need to know what sort of enterprise you are:
%ng-include{ src: "'registration/steps.html'" }
%form
%form{ name: 'details', novalidate: true, ng: { controller: "RegistrationFormCtrl", submit: "select('address',details)" } }
.row
.small-12.columns
%label{ for: 'enterprise_name' } Enterprise Name:
%input.chunky.small-12.columns{ id: 'enterprise_name', placeholder: "eg. Charlie's Awesome Farm", ng: { model: '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!
.row#enterprise-types{ 'data-equalizer' => true }
.small-12.columns
@@ -35,4 +38,4 @@
%p Hey there, Jack-of-all-trades! Not only do you produce things to eat &/or drink, you also want to sell your yummies through an Open Food Network shopfront.
.row.buttons
.small-12.columns
%input.button.primary{ type: "button", value: "Continue", ng: { click: "select('address')" } }
%input.button.primary.right{ type: "submit", value: "Continue" }