calculate order server-side and pass just names of organizations
authorDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 9 Jan 2013 17:56:34 +0000 (18:56 +0100)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 9 Jan 2013 17:56:34 +0000 (18:56 +0100)
app/js/controllers.js
app/js/services.js

index 7c47eb8..eabec94 100644 (file)
@@ -46,7 +46,7 @@ function RegistrationCtrl($scope, $log, Registration, $routeParams, $location, $
                $log.info( $routeParams.registrationId );
 
                $scope.view = new View();
-if(1){//FIXME
+if(0){//FIXME
                $scope.view.$get({ view: 'organizations' }, function(result) {
                        $log.info('View organizations', result);
                        angular.forEach( result.rows, function(value, key) {
@@ -57,7 +57,10 @@ if(1){//FIXME
 }else{//FIXME
                $scope.view.$key_array({ view: 'organizations' }, function(result) {
                        $log.info('key_array', result);
-                       $scope.organizations = result.rows;
+//                     $scope.organizations = result.rows; // FIXME doesn't refresh bs-typeahead
+                       angular.forEach( result.rows, function(o) {
+                               this.push( o );
+                       }, $scope.organizations );
                        $log.info('organizations', $scope.organizations);
                });
        }
index c513978..88ff3c4 100644 (file)
@@ -40,7 +40,7 @@ angular.module('myApp.services', [ 'ngResource' ]).
        }).
        factory('View', function($resource) {
                return $resource('/:database/_design/registration/_view/:view?group=true;format=:format', { database: 'drzb2013' }, {
-                       key_array: {method:'GET', params:{ format:'key_array' }, isArray:true}
+                       key_array: {method:'GET', params:{ format:'key_array' }, isArray:false}
                });
 
        });