added user.org_member
[angular-drzb] / app / js / controllers.js
index b98fb99..f336b51 100644 (file)
@@ -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 ) {
 
@@ -207,7 +211,8 @@ function ListCtrl($scope, $log, Registration, RegistrationTypes, $filter, ValidS
                { 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: 'payment.received', label: 'payment', name: 'filter_payment' },
+               { select: 'user.org_member', label: 'organisation', name: 'filter_org' }
        ];
        $scope.show = {
                registration_type: true,
@@ -314,13 +319,16 @@ function ListCtrl($scope, $log, Registration, RegistrationTypes, $filter, ValidS
        $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 = '';
                        }
                }
        }
@@ -328,3 +336,23 @@ function ListCtrl($scope, $log, Registration, RegistrationTypes, $filter, ValidS
 
 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' ];
+
+