From ce1f4b6103c90ef5fbc01188f63e947dff743bd9 Mon Sep 17 00:00:00 2001 From: Davide Alberani Date: Tue, 7 Apr 2015 23:20:42 +0200 Subject: [PATCH] add registered person from event details --- angular_app/event-info.html | 6 +++--- angular_app/js/controllers.js | 36 +++++++++++++++++++++-------------- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/angular_app/event-info.html b/angular_app/event-info.html index 6536566..76b165f 100644 --- a/angular_app/event-info.html +++ b/angular_app/event-info.html @@ -72,7 +72,7 @@ {{'Email' | translate}} - @@ -91,14 +91,14 @@ - + {{person.name}} {{person.surname}}
{{person.email}} - + diff --git a/angular_app/js/controllers.js b/angular_app/js/controllers.js index 6593b2a..ede4b99 100644 --- a/angular_app/js/controllers.js +++ b/angular_app/js/controllers.js @@ -76,23 +76,30 @@ eventManControllers.controller('EventDetailsCtrl', ['$scope', 'Event', 'Person', $scope.eventForm.$dirty = false; }; - $scope.fastAddPerson = function(newPerson) { - $log.debug('EventDetailsCtrl.fastAddPerson.newPerson:'); - $log.debug(newPerson); - var person = new Person(newPerson); - person.$save(function(p) { - var data = angular.copy(p); - data.person_id = data._id; - data._id = $stateParams.id; - data.attended = true; - Event.addAttendee(data, function() { - $scope.event = Event.get($stateParams); - $scope.allPersons = Person.all(); - $scope.newPerson = {}; - }); + $scope._addAttendee = function(person_data) { + person_data.person_id = person_data._id; + person_data._id = $stateParams.id; + person_data.attended = true; + Event.addAttendee(person_data, function() { + $scope.event = Event.get($stateParams); + $scope.allPersons = Person.all(); + $scope.newPerson = {}; }); }; + $scope.fastAddPerson = function(person, isNew) { + $log.debug('EventDetailsCtrl.fastAddPerson.person:'); + $log.debug(person); + if (isNew) { + var personObj = new Person(person); + personObj.$save(function(p) { + $scope._addAttendee(angular.copy(p)); + }); + } else { + $scope._addAttendee(person); + } + }; + $scope.updateAttendee = function(person, attended) { $log.debug('EventDetailsCtrl.event_id: ' + $stateParams.id); $log.debug('EventDetailsCtrl.person_id: ' + person.person_id); @@ -116,6 +123,7 @@ eventManControllers.controller('EventDetailsCtrl', ['$scope', 'Event', 'Person', }, function(data) { $scope.event.persons = data; + $scope.allPersons = Person.all(); }); }; }]