-
Notifications
You must be signed in to change notification settings - Fork 6
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 #42 from valentinz/volunteer-list
Implementation of Volunteer Overview
- Loading branch information
Showing
7 changed files
with
123 additions
and
2 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
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,24 @@ | ||
angular.module('Come2HelpController').factory('Volunteers', ['$resource', function ($resource) { | ||
return $resource('api/volunteers/:id'); | ||
}]); | ||
|
||
angular.module('Come2HelpController').controller('VolunteerListController', ['Volunteers', 'geocoder', function (Volunteers, geocoder) { | ||
var vm = this; | ||
|
||
vm.volunteers = []; | ||
|
||
vm.search = function () { | ||
var result = geocoder.geocode('Germany, ' + vm.zipCode, function (results) { | ||
var latitude = results.results[0].geometry.location.lat(); | ||
var longitude = results.results[0].geometry.location.lng(); | ||
|
||
Volunteers.query({ | ||
latitude: latitude, | ||
longitude: longitude, | ||
distance: vm.distance * 1000 | ||
}, function (data) { | ||
vm.volunteers = data; | ||
}); | ||
}); | ||
}; | ||
}]); |
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,30 @@ | ||
<h1>{{ 'Volunteers' | translate }}</h1> | ||
<form class="navbar-form navbar-left" role="search" ng-submit="ctrl.search()"> | ||
<div class="form-group"> | ||
<input class="form-control" ng-model="ctrl.zipCode" placeholder="{{ 'Zip Code' | translate }}"/> | ||
<div class="input-group"> | ||
<input class="form-control" ng-model="ctrl.distance" placeholder="{{ 'Distance' | translate }}"/> | ||
<span class="input-group-addon">{{ 'km' | translate }}</span> | ||
</div> | ||
</div> | ||
<button type="submit" class="btn btn-default">{{ 'Search' | translate }}</button> | ||
</form> | ||
|
||
<table class="table table-striped" st-table="ctrl.displayedVolunteers" st-safe-src="ctrl.volunteers"> | ||
<tr> | ||
<th st-sort="givenName">{{ 'Given Name' | translate }}</th> | ||
<th st-sort="surname">{{ 'Surname' | translate }}</th> | ||
<th st-sort="address.zipCode">{{ 'Zip Code' | translate }}</th> | ||
<th st-sort="phone">{{ 'Phone' | translate }}</th> | ||
<th st-sort="email">{{ 'E-Mail' | translate }}</th> | ||
<th>{{ 'Abilities' | translate }}</th> | ||
</tr> | ||
<tr ng-repeat="volunteer in ctrl.displayedVolunteers"> | ||
<td>{{volunteer.givenName}}</td> | ||
<td>{{volunteer.surname}}</td> | ||
<td>{{volunteer.address.zipCode}}</td> | ||
<td>{{volunteer.phone}}</td> | ||
<td>{{volunteer.email}}</td> | ||
<td>{{volunteer.abilities}}</td> | ||
</tr> | ||
</table> |
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,33 @@ | ||
require('./asserters')(); | ||
|
||
var mock = require('./http-mock'); | ||
|
||
describe('Volunteer List', function () { | ||
this.timeout(2 * 60 * 1000); | ||
|
||
var volunteers = by.repeater('volunteer in ctrl.displayedVolunteers'); | ||
|
||
it('is default an empty list', function () { | ||
expect(element.all(volunteers).count()).to.eventually.equal(0); | ||
}); | ||
|
||
it('allows searching zip code of "Karlsruhe" and result contains two "Max Mustermann" entries', function () { | ||
mock(['volunteers']); | ||
|
||
browser.getPart('organisation/volunteerList'); | ||
|
||
var zipCode = browser.findElement(by.model('ctrl.zipCode')); | ||
zipCode.sendKeys('76133'); | ||
|
||
var distance = browser.findElement(by.model('ctrl.distance')); | ||
distance.sendKeys('10'); | ||
|
||
element(by.partialButtonText('Search')).click(function () { | ||
expect(element.all(volunteers).count()).to.eventually.equal(2); | ||
for (var i = 0; i < 2; i++) { | ||
expect(element(volunteers.column('volunteer.surname').row(i)).getInnerHtml()).to.eventually.contain('Mustermann'); | ||
expect(element(volunteers.column('volunteer.givenName').row(i)).getInnerHtml()).to.eventually.contain('Max'); | ||
} | ||
}); | ||
}); | ||
}); |