6 function RegistrationCtrl($scope, $log, Registration, $routeParams, $location, $route) {
8 $scope.$routeParams = $routeParams;
9 $scope.$location = $location;
11 $scope.update = function(registration) {
13 if ( ! $scope.has_work && registration.work ) {
14 delete( registration.work );
15 $log.info("removed work");
18 registration.$save( function(registration) {
19 $log.info("saved", registration);
20 $log.info('id =', registration.id);
21 if ( registration.id ) {
22 $location.path( '/registration-finished/' + registration.id );
24 $log.error("can't find id in ", registration);
29 $scope.reset = function() {
30 if ( $routeParams.registrationId ) {
31 $scope.registration = new Registration();
32 $scope.registration.$get({ registrationId: $routeParams.registrationId }, function(registration) {
33 $log.info("get Registration", registration);
34 $scope.user = registration.user;
35 $scope.work = registration.work;
38 $scope.registration = new Registration({ user: {} });
39 $log.info("new Registration", $scope.user);
40 $scope.user = $scope.registration.user;
41 $scope.work = $scope.registration.work;
44 $log.info( $routeParams.registrationId );
47 $scope.$watch('user.registration_type', function( oldValue, newValue ) {
48 $log.info("registration_type watch", oldValue, newValue );
51 $scope.user.registration_type == 'lecture' ||
52 $scope.user.registration_type == 'poster' ||
53 $scope.user.registration_type == 'symposium' ||
54 $scope.user.registration_type == 'round'
57 $scope.work.type = $scope.user.registration_type;
58 $log.info( $scope.user.registration_type, " type updated");
61 type: $scope.user.registration_type,
62 persons: [ $scope.user ],
64 $log.info( $scope.user.registration_type, " type created");
66 $scope.has_work = true;
68 $log.info( $scope.user.registration_type, "NO work" );
69 $scope.has_work = false;
73 $scope.change_student = function() {
74 if ( $scope.user.student ) {
75 $scope.user.hpd_member = false;
76 $scope.user.reception = false;
77 $scope.user.dinner = false;
81 $scope.addPerson = function() {
82 $scope.work.persons.push({ firstname: '' });
85 $scope.removePerson = function(person) {
86 var persons = $scope.work.persons;
87 for (var i = 0, ii = persons.length; i < ii; i++) {
88 if (person === persons[i]) {
96 //RegistrationCtrl.$inject = [ '$scope', '$log' ];
101 MyCtrl2.$inject = [];