added user.org_member
[angular-drzb] / app / js / controllers.js
index 092e07e..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,
@@ -311,17 +316,43 @@ function ListCtrl($scope, $log, Registration, RegistrationTypes, $filter, ValidS
                $scope.pager.page = 1;
        }
 
-       $scope.print_hide = function(v) {
-               $log.info('print_hide', v);
-               if ( v ) {
-                       angular.element('.print-hide').hide();
-                       angular.element('.print-add-center').addClass('print-center');
-               } else {
-                       angular.element('.print-hide').show();
-                       angular.element('.print-add-center').removeClass('print-center');
+       $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' ];
+
+