make invalid abstract big and red
[angular-drzb] / app / js / controllers.js
index f0e6d03..e173fd5 100644 (file)
@@ -3,10 +3,11 @@
 /* Controllers */
 
 
-function RegistrationCtrl($scope, $log, Registration, $routeParams, $location, $route) {
+function RegistrationCtrl($scope, $log, Registration, $routeParams, $location, $route, View) {
 
        $scope.$routeParams = $routeParams;
        $scope.$location = $location;
+       $scope.organizations = [];
 
        $scope.update = function(registration) {
 
@@ -43,7 +44,27 @@ function RegistrationCtrl($scope, $log, Registration, $routeParams, $location, $
                }
 
                $log.info( $routeParams.registrationId );
+
+               $scope.view = new View();
+if(0){//FIXME
+               $scope.view.$get({ view: 'organizations' }, function(result) {
+                       $log.info('View organizations', result);
+                       angular.forEach( result.rows, function(value, key) {
+                               this.push( value.key ); // name of organization
+                       }, $scope.organizations );
+                       $log.info('organizations', $scope.organizations);
+               });
+}else{//FIXME
+               $scope.view.$key_array({ view: 'organizations' }, function(result) {
+                       $log.info('key_array', result);
+//                     $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);
+               });
        }
+}//FIXME
 
        $scope.$watch('user.registration_type', function( oldValue, newValue ) {
                $log.info("registration_type watch", oldValue, newValue );
@@ -84,7 +105,6 @@ function RegistrationCtrl($scope, $log, Registration, $routeParams, $location, $
        $scope.change_student = function() {
                if ( $scope.user.student ) {
                        $scope.user.hpd_member = false;
-                       $scope.user.reception = false;
                        $scope.user.dinner = false;
                }
        }
@@ -107,6 +127,33 @@ function RegistrationCtrl($scope, $log, Registration, $routeParams, $location, $
                works.push({ persons: [{}] });
        }
 
+       $scope.symposium_work_remove = function(work_index) {
+               if ( ! angular.isNumber(work_index) ) {
+                       $log.error("work_index", work_index);
+                       return;
+               }
+               var works = $scope.work.symposium_works;
+               $log.info('symposium_work_remove', works, work_index);
+               var removed = works.splice( work_index, 1 );
+               if ( angular.isArray(removed) && removed[0] ) {
+                       removed = removed[0];
+                       removed.deleted = true;
+                       if ( ! angular.isArray( $scope.work.symposium_works_deleted ) )
+                               $scope.work.symposium_works_deleted = [];
+                       $scope.work.symposium_works_deleted.push( removed );
+                       $log.info("work deleted", works);
+               } else {
+                       $log.warn("symposium_work_remove no work to remove", works, work);
+               }
+       }
+
+       $scope.abstract_class = function(abstract) {
+               return abstract.length < 2000 ? 'ok' : 'ng-invalid';
+       }
+       $scope.abstract_length = function(abstract) {
+               return abstract.length < 2000 ? abstract.length : 2000 - abstract.length;
+       }
+
        $scope.reset();
 }
 //RegistrationCtrl.$inject = [ '$scope', '$log' ];