From 13bfaf235e0c79598b9746c8e36f3db157b8bd30 Mon Sep 17 00:00:00 2001 From: Valentin Zickner Date: Tue, 24 Nov 2015 17:43:58 +0100 Subject: [PATCH 1/6] Implemented basic overview over volunteers. --- index.html | 1 + js/app.js | 5 +++++ js/organisation.js | 15 +++++++++++++++ partials/organisation/volunteerList.html | 19 +++++++++++++++++++ 4 files changed, 40 insertions(+) create mode 100644 js/organisation.js create mode 100644 partials/organisation/volunteerList.html diff --git a/index.html b/index.html index 9e0e825..733686b 100644 --- a/index.html +++ b/index.html @@ -15,6 +15,7 @@ + diff --git a/js/app.js b/js/app.js index 172d470..7f33947 100644 --- a/js/app.js +++ b/js/app.js @@ -30,6 +30,11 @@ angular.module('Come2HelpApp', [ controllerAs: 'ctrl' }). + when('/organisation/volunteerList', { + templateUrl: 'partials/organisation/volunteerList.html', + controller: 'VolunteerListController', + controllerAs: 'ctrl' + }). otherwise({ redirectTo: '/map' }); diff --git a/js/organisation.js b/js/organisation.js new file mode 100644 index 0000000..2890a5b --- /dev/null +++ b/js/organisation.js @@ -0,0 +1,15 @@ +angular.module('Come2HelpController').factory('Volunteers', ['$resource', function ($resource) { + return $resource('api/volunteers/:id'); +}]); + +angular.module('Come2HelpController').controller('VolunteerListController', ['Volunteers', function (Volunteers) { + var vm = this; + + Volunteers.query({ + latitude: 49, + longitude: 8, + distance: 1000000000 + }, function (data) { + vm.volunteers = data; + }); +}]); diff --git a/partials/organisation/volunteerList.html b/partials/organisation/volunteerList.html new file mode 100644 index 0000000..dafe947 --- /dev/null +++ b/partials/organisation/volunteerList.html @@ -0,0 +1,19 @@ +

{{ 'Volunteers' | translate }}

+ + + + + + + + + + + + + + + + + +
{{ 'Given Name' | translate }}{{ 'Surname' | translate }}{{ 'Zip Code' | translate }}{{ 'Phone' | translate }}{{ 'E-Mail' | translate }}{{ 'Abilities' | translate }}
{{volunteer.givenName}}{{volunteer.surname}}{{volunteer.address.zipCode}}{{volunteer.phone}}{{volunteer.email}}{{volunteer.abilities}}
\ No newline at end of file From 48f636ff74f77879d51ccb049a96c47aed98aea8 Mon Sep 17 00:00:00 2001 From: Valentin Zickner Date: Fri, 27 Nov 2015 10:53:02 +0100 Subject: [PATCH 2/6] Added first test of volunteer list. --- test/behaviour/mocks/volunteers.js | 25 +++++++++++++++++++++++++ test/behaviour/organisation.js | 21 +++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 test/behaviour/mocks/volunteers.js create mode 100644 test/behaviour/organisation.js diff --git a/test/behaviour/mocks/volunteers.js b/test/behaviour/mocks/volunteers.js new file mode 100644 index 0000000..660bad4 --- /dev/null +++ b/test/behaviour/mocks/volunteers.js @@ -0,0 +1,25 @@ +module.exports = { + request: { + path: '/volunteers', + method: 'GET' + }, + response: { + data: [{ + id: 1, + givenName: 'Max 1', + surname: 'Mustermann 1', + address: {zipCode: '76133'}, + phone: '01234 567890', + adult: true, + abilities: [] + }, { + id: 1, + givenName: 'Max 2', + surname: 'Mustermann 2', + address: {zipCode: '76133'}, + phone: '01234 567890', + adult: true, + abilities: [] + }] + } +}; \ No newline at end of file diff --git a/test/behaviour/organisation.js b/test/behaviour/organisation.js new file mode 100644 index 0000000..dcbabe0 --- /dev/null +++ b/test/behaviour/organisation.js @@ -0,0 +1,21 @@ +require('./asserters')(); + +var mock = require('./http-mock'); + +describe('Volunteer List', function () { + this.timeout(2 * 60 * 1000); + + var volunteers = by.repeater('volunteer in ctrl.volunteers'); + + it('contains two "Max Mustermann" entries', function () { + mock(['volunteers']); + + browser.getPart('organisation/volunteerList'); + + 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'); + } + }); +}); \ No newline at end of file From 3b5ed813e6d499b7c4e0e3d4bc71054049d44913 Mon Sep 17 00:00:00 2001 From: Valentin Zickner Date: Sun, 29 Nov 2015 23:05:33 +0100 Subject: [PATCH 3/6] Integrated smart table. --- bower.json | 3 ++- index.html | 1 + js/app.js | 3 ++- partials/organisation/volunteerList.html | 14 +++++++------- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/bower.json b/bower.json index ecb1d32..94849da 100644 --- a/bower.json +++ b/bower.json @@ -22,7 +22,8 @@ "angular-translate": "~2.8.0", "lodash": "~3.10.1", "bootstrap": "~3.3.5", - "angular-google-maps": "~2.2.1" + "angular-google-maps": "~2.2.1", + "angular-smart-table": "~2.1.5" }, "resolutions": { "angular": "1.4.6" diff --git a/index.html b/index.html index 733686b..b6ced5b 100644 --- a/index.html +++ b/index.html @@ -13,6 +13,7 @@ + diff --git a/js/app.js b/js/app.js index 7f33947..5761c5a 100644 --- a/js/app.js +++ b/js/app.js @@ -2,7 +2,8 @@ angular.module('Come2HelpApp', [ 'ngRoute', 'Come2HelpController', 'uiGmapgoogle-maps', - 'pascalprecht.translate' + 'pascalprecht.translate', + 'smart-table' ]) .config(['$routeProvider', function ($routeProvider) { diff --git a/partials/organisation/volunteerList.html b/partials/organisation/volunteerList.html index dafe947..a37d233 100644 --- a/partials/organisation/volunteerList.html +++ b/partials/organisation/volunteerList.html @@ -1,14 +1,14 @@

{{ 'Volunteers' | translate }}

- +
- - - - - + + + + + - + From 9599ead3c6844f07f492491ffe0b490fa326b2eb Mon Sep 17 00:00:00 2001 From: Valentin Zickner Date: Sun, 29 Nov 2015 23:30:33 +0100 Subject: [PATCH 4/6] Integrated search toolbar. --- js/organisation.js | 25 ++++++++++++++++-------- partials/organisation/volunteerList.html | 11 +++++++++++ 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/js/organisation.js b/js/organisation.js index 2890a5b..bc7df78 100644 --- a/js/organisation.js +++ b/js/organisation.js @@ -2,14 +2,23 @@ angular.module('Come2HelpController').factory('Volunteers', ['$resource', functi return $resource('api/volunteers/:id'); }]); -angular.module('Come2HelpController').controller('VolunteerListController', ['Volunteers', function (Volunteers) { +angular.module('Come2HelpController').controller('VolunteerListController', ['Volunteers', 'geocoder', function (Volunteers, geocoder) { var vm = this; - Volunteers.query({ - latitude: 49, - longitude: 8, - distance: 1000000000 - }, function (data) { - vm.volunteers = data; - }); + 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; + }); + }); + }; }]); diff --git a/partials/organisation/volunteerList.html b/partials/organisation/volunteerList.html index a37d233..b2e8c2a 100644 --- a/partials/organisation/volunteerList.html +++ b/partials/organisation/volunteerList.html @@ -1,4 +1,15 @@

{{ 'Volunteers' | translate }}

+ +
+ +
+ + {{ 'km' | translate }} +
+
+ + +
{{ 'Given Name' | translate }}{{ 'Surname' | translate }}{{ 'Zip Code' | translate }}{{ 'Phone' | translate }}{{ 'E-Mail' | translate }}{{ 'Given Name' | translate }}{{ 'Surname' | translate }}{{ 'Zip Code' | translate }}{{ 'Phone' | translate }}{{ 'E-Mail' | translate }} {{ 'Abilities' | translate }}
{{volunteer.givenName}} {{volunteer.surname}} {{volunteer.address.zipCode}}
From 2c48f359cd13c244234aef3761302325f402cf5a Mon Sep 17 00:00:00 2001 From: Valentin Zickner Date: Sun, 29 Nov 2015 23:52:34 +0100 Subject: [PATCH 5/6] Improved tests of volunteer list. --- test/behaviour/mocks/volunteers.js | 4 ++-- test/behaviour/organisation.js | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/test/behaviour/mocks/volunteers.js b/test/behaviour/mocks/volunteers.js index 660bad4..444538c 100644 --- a/test/behaviour/mocks/volunteers.js +++ b/test/behaviour/mocks/volunteers.js @@ -1,4 +1,4 @@ -module.exports = { +module.exports = [{ request: { path: '/volunteers', method: 'GET' @@ -22,4 +22,4 @@ module.exports = { abilities: [] }] } -}; \ No newline at end of file +}]; \ No newline at end of file diff --git a/test/behaviour/organisation.js b/test/behaviour/organisation.js index dcbabe0..d19a09e 100644 --- a/test/behaviour/organisation.js +++ b/test/behaviour/organisation.js @@ -5,13 +5,26 @@ var mock = require('./http-mock'); describe('Volunteer List', function () { this.timeout(2 * 60 * 1000); - var volunteers = by.repeater('volunteer in ctrl.volunteers'); + var volunteers = by.repeater('volunteer in ctrl.displayedVolunteers'); - it('contains two "Max Mustermann" entries', function () { + 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(); + + 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'); From 6ab0f3ffabef468eba43d72408dd596cda87d333 Mon Sep 17 00:00:00 2001 From: Valentin Zickner Date: Mon, 30 Nov 2015 00:14:16 +0100 Subject: [PATCH 6/6] Fixed test for several browsers. --- test/behaviour/organisation.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/test/behaviour/organisation.js b/test/behaviour/organisation.js index d19a09e..7b16fe6 100644 --- a/test/behaviour/organisation.js +++ b/test/behaviour/organisation.js @@ -22,13 +22,12 @@ describe('Volunteer List', function () { var distance = browser.findElement(by.model('ctrl.distance')); distance.sendKeys('10'); - element(by.partialButtonText('Search')).click(); - - - 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'); - } + 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'); + } + }); }); }); \ No newline at end of file
{{ 'Given Name' | translate }}