Merge pull request #50 from alberanid/master

fixes #47: set attended attribute in separate call to trigger actions
This commit is contained in:
Davide Alberani 2015-04-20 21:42:38 +02:00
commit c232da7dde

View file

@ -104,10 +104,10 @@ eventManControllers.controller('EventDetailsCtrl', ['$scope', 'Event', 'Person',
var original_data = angular.copy(person_data);
person_data.person_id = person_data._id;
person_data._id = $stateParams.id;
person_data.attended = true;
Event.addPerson(person_data, function() {
// This could be improved adding it only locally.
//$scope.event.persons.push(person_data);
$scope.setPersonAttribute(person_data, 'attended', true, function() {
Event.get($stateParams, function(data) {
$scope.event.persons = angular.fromJson(data).persons;
});
@ -119,6 +119,7 @@ eventManControllers.controller('EventDetailsCtrl', ['$scope', 'Event', 'Person',
}
$scope.newPerson = {};
});
});
$scope.query = '';
};
@ -135,7 +136,7 @@ eventManControllers.controller('EventDetailsCtrl', ['$scope', 'Event', 'Person',
}
};
$scope.setPersonAttribute = function(person, key, value) {
$scope.setPersonAttribute = function(person, key, value, callback) {
$log.debug('EventDetailsCtrl.setPersonAttribute.event_id: ' + $stateParams.id);
$log.debug('EventDetailsCtrl.setPersonAttribute.person_id: ' + person.person_id);
$log.debug('EventDetailsCtrl.setPersonAttribute.key: ' + key + ' value: ' + value);
@ -146,11 +147,12 @@ eventManControllers.controller('EventDetailsCtrl', ['$scope', 'Event', 'Person',
$log.debug('EventDetailsCtrl.setPersonAttribute.data');
$log.debug(data);
$scope.event.persons = data;
if (callback) {
callback(data);
}
});
};
$scope.focusinControl = {};
$scope.setPersonAttributeAndRefocus = function(person, key, value) {
$scope.setPersonAttribute(person, key, value);
$scope.query = '';