controller logic to show submission and registration radio buttons
[angular-drzb] / app / js / controllers.js
index 977758c..6ff5079 100644 (file)
@@ -27,7 +27,8 @@ function RegistrationCtrl($scope, $log, Registration, $routeParams, $location, $
                registration.$save( function(registration) {
                        $log.info('id =', registration.id, 'state = ', registration.state);
                        if ( registration.id && registration.state ) {
-                               if ( ! info_message ) {
+                               $log.error( $location.path(), registration.state, $routeParams );
+                               if ( $location.path().split(/\//)[1] != registration.state ) {
                                        $location.path( '/' + registration.state + '/' + registration.id );
                                } else {
                                        $scope.info = { message: info_message, css_class: 'alert-success' };
@@ -157,6 +158,19 @@ function RegistrationCtrl($scope, $log, Registration, $routeParams, $location, $
                $scope.registration.state = new_state;
        }
 
+       $scope.show_submission_type = function() {
+               // FIXME check if all submission are allowed by date and allow them!
+               return (
+                       angular.isUndefined( $scope.user.registration_type ) // new registration
+                       || angular.isUndefined( $scope.registration.state ) // not saved yet
+                       || $scope.registration.state == 'draft'
+                       || $scope.registration.state == 'confirmation'
+               ) ? false : true;
+       }
+       $scope.show_registration_type = function() {
+               return true;
+       }
+
        $scope.reset();
 }
 RegistrationCtrl.$inject = [ '$scope', '$log', 'Registration', '$routeParams', '$location', '$route', 'Organizations', 'RegistrationState' ];
@@ -218,6 +232,9 @@ function ListCtrl($scope, $log, Registration, RegistrationTypes, $filter, Regist
                                value[f] = v == true || v == 'yes' ? true : false;
                        });
 
+                       // count registration state
+                       inc_count( 'state+' + value.state );
+
 //                     $log.info( key, value, Counts[type]  );
                });
                $log.info('Counts', Counts);