-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from valentinz/volunteer-frontend
Volunteer registration form with some tests
- Loading branch information
Showing
20 changed files
with
329 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[ | ||
{ | ||
"id": 12, | ||
"name": "Ability 1" | ||
}, | ||
{ | ||
"id": 14, | ||
"name": "Ability 2" | ||
} | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
angular.module('Come2HelpController').factory('Abilities', ['$resource', function ($resource) { | ||
return $resource('api/abilities/:id'); | ||
}]); | ||
|
||
angular.module('Come2HelpController').factory('Volunteers', ['$resource', function ($resource) { | ||
return $resource('api/volunteers/:id'); | ||
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
angular.module('Come2HelpController').controller('RegisterController', ['Abilities', 'Volunteers', '$routeParams', '$location', function (Abilities, Volunteers, $routeParams, $location) { | ||
var vm = this; | ||
|
||
vm.errors = null; | ||
|
||
Abilities.query(function (data) { | ||
vm.abilities = data; | ||
}); | ||
|
||
vm.doRegister = function () { | ||
Volunteers.save({ | ||
'givenName': vm.givenName, | ||
'surname': vm.surname, | ||
'address': { | ||
'zipCode': vm.zipCode | ||
}, | ||
'phone': vm.phone, | ||
'adult': vm.adult == true | ||
|
||
}, function() { | ||
vm.errors = null; | ||
|
||
vm.givenName = ''; | ||
vm.surname = ''; | ||
vm.zipCode = ''; | ||
vm.phone = ''; | ||
vm.adult = null; | ||
|
||
$location.path('/register/done'); | ||
}, function (response) { | ||
vm.errors = {}; | ||
|
||
for (var i = 0; i < response.data.clientErrors.length; i++) { | ||
var errorData = response.data.clientErrors[i]; | ||
vm.errors[errorData.path] = true; | ||
} | ||
}); | ||
}; | ||
}]); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<form class="form-horizontal" ng-submit="ctrl.doRegister()"> | ||
|
||
<div ng-show="ctrl.errors" id="error" class="alert alert-danger" role="alert">{{ 'Please correct the highlighted fields.' | translate }}</div> | ||
|
||
<div ng-class="['form-group', {'has-error': ctrl.errors.surname}, {'has-error': ctrl.errors.givenName}]"> | ||
<label for="surname" class="col-sm-2 control-label">{{ 'Name' | translate }}</label> | ||
<div class="col-sm-5"> | ||
<input class="form-control" ng-model="ctrl.givenName" id="givenName" placeholder="{{ 'Givenname' | translate }}" value="" type="text"> | ||
</div> | ||
<div class="col-sm-5"> | ||
<input class="form-control" ng-model="ctrl.surname" name="surname" id="surname" placeholder="{{ 'Surname' | translate }}" value="" type="text"> | ||
</div> | ||
</div> | ||
<div ng-class="['form-group', {'has-error': ctrl.errors.zipCode}]"> | ||
<label for="zipCode" class="col-sm-2 control-label">{{ 'Zip Code' | translate }}</label> | ||
<div class="col-sm-10"> | ||
<input class="form-control" ng-model="ctrl.zipCode" name="city" id="zipCode" placeholder="{{ 'Zip Code' | translate }}" value="" type="text"> | ||
</div> | ||
</div> | ||
<div ng-class="['form-group', {'has-error': ctrl.errors.email}]"> | ||
<label for="email" class="col-sm-2 control-label">{{ 'E-Mail-Address' | translate }}</label> | ||
<div class="col-sm-10"> | ||
<input class="form-control" ng-model="ctrl.email" name="email" id="email" placeholder="{{ 'E-Mail-Address' | translate }}" value="" type="text"> | ||
</div> | ||
</div> | ||
<div ng-class="['form-group', {'has-error': ctrl.errors.phone}]"> | ||
<label for="phone" class="col-sm-2 control-label">{{ 'Phone' | translate }}</label> | ||
<div class="col-sm-10"> | ||
<input class="form-control" ng-model="ctrl.phone" name="phone" id="phone" placeholder="{{ 'Phone' | translate }}" value="" type="text"> | ||
</div> | ||
</div> | ||
<div ng-class="['form-group', {'has-error': ctrl.errors.adult}]"> | ||
<label for="adult" class="col-sm-2 control-label">{{ 'Is Adult' | translate }}</label> | ||
<div class="col-sm-1"> | ||
<input class="form-control" ng-model="ctrl.adult" name="adult" id="adult" value="true" type="checkbox"> | ||
</div> | ||
</div> | ||
<div ng-class="['form-group', {'has-error': ctrl.errors.abilities}]"> | ||
<label for="inputAbilities[]" class="col-sm-2 control-label">{{ 'Abilities' | translate }}</label> | ||
<div class="col-sm-8" ng-repeat="ability in ctrl.abilities"> | ||
<input type="checkbox" name="inputAbilities[]" id="inputAbilities[]" value="{{ability.id}}"> <span>{{ability.name}}</span> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<div class="col-sm-offset-2 col-sm-10"> | ||
<button class="btn btn-primary" type="submit">{{ 'Register' | translate }}</button> | ||
</div> | ||
</div> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<div class="jumbotron"> | ||
<h1>{{ 'Thank you for register!' | translate }}</h1> | ||
<p>{{ 'We will contact you ...' | translate }}</p> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module.exports = [ | ||
{ | ||
request: { | ||
path: '/abilities', | ||
method: 'GET' | ||
}, | ||
response: { | ||
status: 200, | ||
data: [{ | ||
id: 42, | ||
name: 'Mocked Ability 1' | ||
}, | ||
{ | ||
id: 69, | ||
name: 'Mocked Ability 1' | ||
}] | ||
} | ||
} | ||
]; |
Oops, something went wrong.