added symposium works
authorDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 14 Dec 2012 15:57:08 +0000 (16:57 +0100)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 14 Dec 2012 15:57:08 +0000 (16:57 +0100)
app/js/controllers.js
app/partials/registration.html

index 984d546..e20938e 100644 (file)
@@ -35,9 +35,10 @@ function RegistrationCtrl($scope, $log, Registration, $routeParams, $location, $
                                $scope.work = registration.work;
                        });
                } else {
-                       $scope.registration = new Registration({ user: {} });
+                       $scope.registration = new Registration({ user: {}, work: { persons: [] } });
                        $scope.user = $scope.registration.user;
                        $scope.work = $scope.registration.work;
+                       $scope.work.persons = [ $scope.user ]; // first author is person submitting work
                        $log.info("new Registration", $scope.registration);
                }
 
@@ -59,17 +60,15 @@ function RegistrationCtrl($scope, $log, Registration, $routeParams, $location, $
                        $scope.user.registration_type == 'symposium' ||
                        $scope.user.registration_type == 'round'
                ) {
-                       if ( $scope.work ) {
-                               $scope.work.type = $scope.user.registration_type;
-                               $log.info( $scope.user.registration_type, " type updated");
-                       } else {
-                               $scope.work = {
-                                       type: $scope.user.registration_type,
-                                       persons: [ $scope.user ],
-                               };
-                               $log.info( $scope.user.registration_type, " type created");
-                       }
+                       $scope.work.type = $scope.user.registration_type;
                        $scope.has_work = true;
+                       $log.info( $scope.user.registration_type, " type updated");
+
+                       if ( $scope.user.registration_type == 'symposium' && ! $scope.work.symposium_works ) {
+                               $scope.work.symposium_works = [{ persons: [{}] }]; // create first empty symposium work
+                               $log.info('created symposium_works');
+                       }
+
                } else {
                        $log.info( $scope.user.registration_type, "NO work" );
                        $scope.has_work = false;
@@ -84,15 +83,16 @@ function RegistrationCtrl($scope, $log, Registration, $routeParams, $location, $
                }
        }
 
-       $scope.addPerson = function() {
-               $scope.work.persons.push({ firstname: '' });
+       $scope.addPerson = function(persons) {
+               $log.info('addPerson', persons);
+               persons.push({ firstname: '' });
        };
  
-       $scope.removePerson = function(person) {
-               var persons = $scope.work.persons;
+       $scope.removePerson = function(persons,person) {
                for (var i = 0, ii = persons.length; i < ii; i++) {
                        if (person === persons[i]) {
                                persons.splice(i, 1);
+                               $log.info('removePerson', i, person);
                        }
                }
        };
index c00c9be..2a251af 100644 (file)
@@ -86,18 +86,42 @@ Organizacija koja uplaćuje račun
        <input ng-model="person.surname"   placeholder="surname" ng-required="has_work" />
        <input ng-model="person.organization" placeholder="organizacija" >
        <input ng-model="person.email" type="email" placeholder="e-mail@example.com" ng-required="has_work" />
-       <a href="" ng-click="removePerson(person)">remove</a>
+       <a href="" ng-click="removePerson(work.persons,person)">remove</a>
 </div>
-<a href="" ng-click="addPerson()">add another</a>
+<a href="" ng-click="addPerson(work.persons)">add another</a>
 <br>
 
-Sažetak ({{work.abstract.length || 0}}  od maks. 2000 znakova)
+sažetak ({{work.abstract.length || 0}}  od maks. 2000 znakova)
 <br>
 <textarea ng-model="work.abstract" ng-maxlength="2000" rows="10" cols="80" ng-required="has_work" ></textarea>
 
-
 </div><!-- has_work -->
 
+<div ng-show="work.type == 'symposium'">
+
+<h2>Prijava radova unutar simpozija {{work.title}}</h2>
+
+<div ng-repeat="work in work.symposium_works">
+
+<input ng-model="work.title" placeholder="title" ng-required="has_work" >
+<div ng-repeat="person in work.persons">
+       <input ng-model="person.firstname" placeholder="first name" ng-required="has_work" />
+       <input ng-model="person.surname"   placeholder="surname" ng-required="has_work" />
+       <input ng-model="person.organization" placeholder="organizacija" >
+       <input ng-model="person.email" type="email" placeholder="e-mail@example.com" ng-required="has_work" />
+       <a href="" ng-click="removePerson(work.persons,person)">remove</a>
+</div>
+<a href="" ng-click="addPerson(work.persons)">add another</a>
+<br>
+
+sažetak ({{work.abstract.length || 0}}  od maks. 2000 znakova)
+<br>
+<textarea ng-model="work.abstract" ng-maxlength="2000" rows="10" cols="80" ng-required="has_work" ></textarea>
+
+</div><!-- symposium_parts -->
+
+</div><!-- user.registration_type -->
+
 <button ng-click="update(registration)" ng-show="RegistrationForm.$valid">Register for conference</button>
 
 <pre>