authors table view
[angular-drzb] / app / js / controllers.js
index c7a043c..ab41a03 100644 (file)
@@ -7,9 +7,13 @@ function RegistrationCtrl($scope, $log, Registration, $routeParams, $location, $
        $scope.$routeParams = $routeParams;
        $scope.$location = $location;
        $scope.organizations = [];
-       View.getArrayPromise('organizations?group=true;format=key_array').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();
 
@@ -331,3 +335,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' ];
+
+