X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=app%2Fjs%2Fcontrollers.js;h=f336b513ef78d078039c3d31ee450d785406025c;hb=1e9833fc37565e466ab85d3d16be4cf7d777b896;hp=7b47fb568d3ad2bf8b8ca6a837e3bc8291d6fac0;hpb=3cab1010e9908594ae7ef55e3aa615487e6528a4;p=angular-drzb diff --git a/app/js/controllers.js b/app/js/controllers.js index 7b47fb5..f336b51 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -2,14 +2,18 @@ /* Controllers */ -function RegistrationCtrl($scope, $log, Registration, $routeParams, $location, $route, Organizations, ValidStates) { +function RegistrationCtrl($scope, $log, Registration, $routeParams, $location, $route, View, ValidStates) { $scope.$routeParams = $routeParams; $scope.$location = $location; $scope.organizations = []; - Organizations.getArrayPromise().then(function(data) { - $scope.organizations = data; - $log.info('organizations promise ', $scope.organizations); + View.getPromise('organizations?group=true;format=key_array').then(function(data) { + if ( angular.isArray(data.rows) ) { + $scope.organizations = data.rows; + $log.info('organizations promise ', $scope.organizations); + } else { + $log.info('no rows in', data); + } }); $scope.ValidStates = ValidStates(); @@ -187,7 +191,7 @@ function RegistrationCtrl($scope, $log, Registration, $routeParams, $location, $ $scope.reset(); } -RegistrationCtrl.$inject = [ '$scope', '$log', 'Registration', '$routeParams', '$location', '$route', 'Organizations', 'ValidStates' ]; +RegistrationCtrl.$inject = [ '$scope', '$log', 'Registration', '$routeParams', '$location', '$route', 'View', 'ValidStates' ]; function ListCtrl($scope, $log, Registration, RegistrationTypes, $filter, ValidStates ) { @@ -202,7 +206,14 @@ function ListCtrl($scope, $log, Registration, RegistrationTypes, $filter, ValidS }; $scope.search = {}; $scope.ready = false; - $scope.filters = [ 'student', 'hpd_member', 'reception', 'dinner' ]; + $scope.filters = [ + { select: 'user.student', label: 'student', name: 'filter_student' }, + { select: 'user.hpd_member', label: 'HPD', name: 'filter_hpd' }, + { select: 'user.reception', label: 'reception', name: 'filter_reception' }, + { select: 'user.dinner', label: 'dinner', name: 'filter_dinner' }, + { select: 'payment.received', label: 'payment', name: 'filter_payment' }, + { select: 'user.org_member', label: 'organisation', name: 'filter_org' } + ]; $scope.show = { registration_type: true, filters: true, @@ -231,26 +242,29 @@ function ListCtrl($scope, $log, Registration, RegistrationTypes, $filter, ValidS var type = value.user.registration_type; inc_count( type ); inc_count( '' ); // total - angular.forEach( $scope.filters, function(subtype) { - var v = value.user[subtype]; + angular.forEach( $scope.filters, function(filter) { + var s = filter.select.split(/\./); + var v = value[s[0]]; + if ( angular.isDefined( v ) ) { + v = v[s[1]]; + } if ( v === 'yes' || v === true ) { - inc_count( subtype ); - inc_count( type + '+' + subtype ); - inc_count( '+' + subtype ); // total + inc_count( filter.name ); + inc_count( type + '+' + filter.name ); + inc_count( '+' + filter.name ); // total + value[filter.name] = true; + } else { + value[filter.name] = false; } }); // for filter value.registration_type = type; - angular.forEach( $scope.filters, function(f) { - var v = value.user[f]; - value[f] = v == true || v == 'yes' ? true : false; - }); // count registration state inc_count( 'state+' + value.state ); -// $log.info( key, value, Counts[type] ); +// $log.info( key, value ); }); $log.info('Counts', Counts); $scope.Counts = Counts; @@ -301,7 +315,44 @@ function ListCtrl($scope, $log, Registration, RegistrationTypes, $filter, ValidS $log.info('reset', $scope.search ); $scope.pager.page = 1; } + + $scope.print = { + layout: false, + center: '', + bold: '', + toggle: function(v) { + $log.info('print_hide', v); + $scope.print.layout = ! $scope.print.layout; + if ( v ) { + $scope.print.center = 'print-center'; + $scope.print.bold = 'print-bold'; + } else { + $scope.print.center = ''; + $scope.print.bold = ''; + } + } + } } ListCtrl.$inject = [ '$scope', '$log', 'Registration', 'RegistrationTypes', '$filter', 'ValidStates' ]; + +function AuthorsCtrl($scope, $log, View ) { + $scope.message = 'Loading data...'; + $scope.ready = false; + View.getPromise('authors?format=key_distinct').then(function(data) { + if ( angular.isArray(data.rows) ) { + $scope.data = data; + $scope.authors = $scope.data.rows; + $scope.ready = true; + $log.info('authors promise ', data); + } else { + $log.info('no rows in', data); + $scope.message = 'No rows found'; + } + }); +} + +AuthorsCtrl.$inject = [ '$scope', '$log', 'View' ]; + +