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: {}, work: { persons: [] } });
39 $scope.user = $scope.registration.user;
40 $scope.work = $scope.registration.work;
41 $scope.work.persons = [ $scope.user ]; // first author is person submitting work
42 $log.info("new Registration", $scope.registration);
45 $log.info( $routeParams.registrationId );
48 $scope.$watch('user.registration_type', function( oldValue, newValue ) {
49 $log.info("registration_type watch", oldValue, newValue );
51 if ( oldValue === newValue ) return; // triggers on resource, so ignore it
52 if ( ! $scope.user ) { // resource triggers watch before loading json
53 $log.error("no user in scope");
58 $scope.user.registration_type == 'lecture' ||
59 $scope.user.registration_type == 'poster' ||
60 $scope.user.registration_type == 'symposium' ||
61 $scope.user.registration_type == 'round'
63 $scope.work.type = $scope.user.registration_type;
64 $scope.has_work = true;
65 $log.info( $scope.user.registration_type, " type updated");
67 if ( $scope.user.registration_type == 'symposium' && ! $scope.work.symposium_works ) {
68 $scope.work.symposium_works = [{ persons: [{}] }]; // create first empty symposium work
69 $log.info('created symposium_works');
73 $log.info( $scope.user.registration_type, "NO work" );
74 $scope.has_work = false;
78 $scope.change_student = function() {
79 if ( $scope.user.student ) {
80 $scope.user.hpd_member = false;
81 $scope.user.reception = false;
82 $scope.user.dinner = false;
86 $scope.addPerson = function(persons) {
87 $log.info('addPerson', persons);
88 persons.push({ firstname: '' });
91 $scope.removePerson = function(persons,person) {
92 for (var i = 0, ii = persons.length; i < ii; i++) {
93 if (person === persons[i]) {
95 $log.info('removePerson', i, person);
102 //RegistrationCtrl.$inject = [ '$scope', '$log' ];
107 MyCtrl2.$inject = [];