/* Controllers */
-function RegistrationCtrl($scope, $log, Registration, $routeParams, $location, $route, Organizations, RegistrationState) {
+function RegistrationCtrl($scope, $log, Registration, $routeParams, $location, $route, Organizations, ValidStates) {
$scope.$routeParams = $routeParams;
$scope.$location = $location;
$scope.organizations = data;
$log.info('organizations promise ', $scope.organizations);
});
- $scope.RegistrationState = RegistrationState;
+ $scope.ValidStates = ValidStates();
$scope.info = { message: '', css_class: '' } ; // alert box
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' };
$scope.registration.state = new_state;
}
+ $scope.show_submission_type = function() {
+ // FIXME check if all submission are allowed by date and allow them!
+ if ( angular.isUndefined( $scope.user ) || angular.isUndefined( $scope.registration ) ) return false;
+ 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' ];
+RegistrationCtrl.$inject = [ '$scope', '$log', 'Registration', '$routeParams', '$location', '$route', 'Organizations', 'ValidStates' ];
-function ListCtrl($scope, $log, Registration, RegistrationTypes, $filter) {
+function ListCtrl($scope, $log, Registration, RegistrationTypes, $filter, ValidStates ) {
$scope.list = [];
$scope.list_results = 0;
page: 1,
limit: 10,
results: 1,
- last_page: 1
+ last_page: 1,
+ show_all: false
};
$scope.search = {};
$scope.ready = false;
states: true,
pager_numeric: false
};
+ $scope.ValidStates = ValidStates();
- $scope.all_registrations = Registration.query( function() {
+ $scope.create_counts = function( array ) {
+ $log.info('create_counts', array.length );
var Counts = {};
var inc_count = function(type) {
if ( ! angular.isNumber( Counts[type] ) ) {
Counts[type]++;
}
};
- angular.forEach( $scope.all_registrations, function(value, key) {
+ angular.forEach( array, function(value, key) {
if ( ! value.user ) {
- $log.error("all_registrations user corrupted for registration", key, value);
+ $log.error("create_counts user corrupted for registration", key, value);
return;
}
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);
$scope.Counts = Counts;
+ return Counts;
+ };
+ $scope.all_registrations = Registration.query( function(result) {
$scope.ready = true;
-
+ $log.info('Reqistration.query callback', result);
$scope.reset();
-
});
$scope.filter_list = function(newVal, oldVal) {
var filtered =
$filter('filter')($scope.all_registrations, $scope.search);
+ $scope.create_counts( filtered );
+
$log.info('pager before apply', $scope.pager);
$scope.pager.results = filtered.length;
var from = ( $scope.pager.page - 1 ) * $scope.pager.limit;
$scope.list = [];
angular.forEach( filtered, function(v,k) {
- if ( k >= from && k < from + $scope.pager.limit ) {
+ if ( k >= from && k < from + $scope.pager.limit || $scope.pager.show_all ) {
v.nr = k + 1;
this.push(v);
}
}
}
+ListCtrl.$inject = [ '$scope', '$log', 'Registration', 'RegistrationTypes', '$filter', 'ValidStates' ];
-ListCtrl.$inject = [ '$scope', '$log', 'Registration', 'RegistrationTypes', '$filter' ];