fix IE errors with extra , at end of structures
[angular-mojolicious.git] / templates / conference / Registration.html.ep
index 2bb1f1b..21c2ae5 100644 (file)
@@ -5,17 +5,16 @@ if (typeof (console) === 'undefined') console = { debug: function() {} }; // moc
 function Registration($resource){
        this.master = {
                person: {
-                       name: '', surname: '', inst: '', email: '',
+                       name: '', surname: '', inst: '', email: ''
                },
-               type: '', // just attending
+               type: 'participant',
                work: {
                        title: '',
                        abstract: '',
-                       authors:[ { name:'', surname:'', inst:'', email:'' } ],
+                       authors:[ { name:'', surname:'', inst:'', email:'' } ]
                },
-               symposium: { organizers: [ {name:'', surname:'', inst:'', email:'' } ], work_nr: 1, },
+               symposium: { organizers: [ {name:'', surname:'', inst:'', email:'' } ], work_nr: 1 }
        };
-       this.last_saved = {};
        this.Registration = $resource( '/data/conference/Registration/:id', { id:'' } );
        this.Symposium = $resource( '/data/conference/Symposium/:id', { id:'' } );
        this.reset();
@@ -45,22 +44,20 @@ console.debug( 'load symposium ', s_id );
        },
        reset: function() {
                console.debug( this.Registration );
-               var current_symposium = null;
-               var current_person = null;
-               if ( this.registration && this.registration.type == 'symposium' ) {
-                       current_symposium = this.registration.symposium;
-                       current_person = this.registration.person;
-                       if ( this.registration.$id ) current_symposium.work_nr++; // only if saved
-console.debug( 'current_symposium', current_symposium, this.registration )
+               var last = this.registration;
+               if ( last && last.type == 'symposium' ) {
+                       if ( last.$id ) last.symposium.work_nr++; // only if saved
                }
                this.registration = new this.Registration( this.master );
-               if ( current_symposium ) {
-                       this.registration.symposium = current_symposium;
-                       this.registration.type = 'symposium';
-                       this.registration.person = current_person;
+               if ( last ) {
+                       this.registration.type      = last.type;
+                       this.registration.person    = last.person;
+
+                       if ( last.type == 'symposium' )
+                       this.registration.symposium = last.symposium;
                }
-               this.last_saved = {};
-console.debug( 'reset', current_symposium, this.registration, this.$location.hashPath );
+               this.last_saved = angular.copy( this.registration ); // FIXME was: {};
+console.debug( 'reset', this.registration, this.$location.hashPath, last );
        },
        save: function(){
                var self = this;
@@ -82,9 +79,14 @@ console.debug('save_symposium', self.symposium );
 
                        self.last_saved = angular.copy(registration);
                });
-       },
+       }
 };
 
+angular.validator.max_length = function(input, len) {
+       var ok = input.length <= len;
+console.debug( 'max_length', ok, input.length, len );
+       return ok ? '' : 'must be shorter than '+len+' characters';
+}
 
 </script>
 
@@ -260,23 +262,9 @@ input.ng-validation-error {
 
 <div ng:controller="Registration" ng:init="$window.$root = this;">
 
-<div id="choose" ng:show="! registration.symposium.$id">
-       <h2>Please choose:</h2>
-       <input type="radio" name="registration.category" value="participant">Just attending the conference<br/>
-       <input type="radio" name="registration.category" value="submission">I want to submit a work<br/>
-</div>
 
-<div id="submission" ng:show="registration.category == 'submission'">
-       <div ng:show="! registration.symposium.$id">
-               <h2>Choose submittion type:</h2>
-               <input type="radio" name="registration.type" value="symposium" ng:required>Symposia<br/>
-               <input type="radio" name="registration.type" value="lecture" ng:required>Oral presentation<br/>
-               <input type="radio" name="registration.type" value="poster" ng:required>Poster presentation<br/>
-               <input type="radio" name="registration.type" value="round" ng:required>Round table discussion<br/>
-       </div>
-</div>
-<div id="participant" ng:show="registration.category == 'participant' || registration.type">
-       <h2>Participant Registration</h2>
+<div id="participant">
+       <h2>Contact Information</h2>
        <div class="labelTop">
                <div class="pname">First name</div>
                <div class="pname">Surname</div>
@@ -319,8 +307,21 @@ input.ng-validation-error {
 </div>
 
 
+<div id="submission">
+       <div>
+               <h2>Choose submittion type:</h2>
+               <label><input type="radio" name="registration.type" value="participant" ng:required>Participant</label>
+               <label><input type="radio" name="registration.type" value="symposium" ng:required>Symposia</label>
+               <label><input type="radio" name="registration.type" value="lecture" ng:required>Oral presentation</label>
+               <label><input type="radio" name="registration.type" value="poster" ng:required>Poster presentation</label>
+               <label><input type="radio" name="registration.type" value="round" ng:required>Round table discussion</label>
+       </div>
+</div>
+
+
 
-<div id="work" ng:show="registration.type">
+
+<div id="work" ng:show="registration.type != 'participant'">
        <div ng:show="registration.type == 'symposium'">
 
                <h2>Symposia Submission</h2>
@@ -339,7 +340,7 @@ input.ng-validation-error {
                </div>
                <a class="addPerson" href="" ng:click="registration.symposium.organizers.$add()">Add another organizer</a>
                <label>Summary:</label>
-                       <textarea class="fl1" name="registration.symposium.abstract" rows="5" ></textarea>
+                       <textarea class="fl1" name="registration.symposium.abstract" rows="5" ng:validate="max_length:2000"></textarea>
                <div ng:show="symposium">
                        <label>List of already submitted works</label>
                        <ol>
@@ -350,10 +351,15 @@ input.ng-validation-error {
                        </ol>
                </div>
        </div>
-        <h2 ng:show="registration.type == 'symposium'">Work no. {{registration.symposium.work_nr}}.  in <i>{{registration.symposium.title}}</i> </h2>
-        <h2 ng:show="registration.type == 'lecture'">Oral Presentation Sumbission</h2>
-        <h2 ng:show="registration.type == 'poster'">Poster Presentation Sumbission</h2>
-        <h2 ng:show="registration.type == 'round'">Round Table Disscussion Sumbission</h2>
+
+
+       <h2 ng:show="registration.type == 'symposium'">Work no. {{registration.symposium.work_nr}}.  in <i>{{registration.symposium.title}}</i> </h2>
+       <h2 ng:show="registration.type == 'lecture'">Oral Presentation Sumbission</h2>
+       <h2 ng:show="registration.type == 'poster'">Poster Presentation Sumbission</h2>
+       <h2 ng:show="registration.type == 'round'">Round Table Disscussion Sumbission</h2>
+
+
+  <div ng:show="registration.type">
 
        <label>Title:</label>
                <input class="fl1" name="registration.work.title" ng:required>
@@ -372,34 +378,39 @@ input.ng-validation-error {
 
 
        <label>Summary:</label>
-               <textarea class="fl1" name="registration.work.abstract" rows="5"></textarea>
+               <textarea class="fl1" name="registration.work.abstract" rows="5" ng:validate="max_length:2000"></textarea>
+
+
+  </div> <!-- ng:show="registration.type" -->
 </div>
-<div ng:show="registration.$id && registration.type == 'symposium'" class="saved">
-       <i>{{registration.symposium.work_nr}}. {{registration.work.title}}</i> has been submited successfully.<br>
+
+<input type="submit" value="Save" ng:click="save();" ng:show="! last_saved.$equals(registration) && $invalidWidgets.visible() == 0">
+
+<div ng:show="$invalidWidgets.visible() &gt; 0" style="color:red; margin-top: 20px">Please fill all required fields ({{$invalidWidgets.visible()}} fields left).
 </div>
 
-<!--
-<div id="buttons" ng:show="registration.category == 'participant' || registration.type">
--->
-<div id="buttons" ng:show="registration.category == 'participant' || registration.type">
-       <span ng:show="$invalidWidgets.visible() == 0">
-       <input type="submit" value="Save" ng:click="save();" ng:show="! last_saved.$equals(registration)">
-       <span ng:show="registration.work && registration.work.$id">
-               <input type="reset" value="Add another work" ng:click="reset()">
-               or <a href="http://psihologija.ffzg.hr/drzb2011/">go to conference home page</a></span>.<br>
-       </span>
-
-       <div ng:show="$invalidWidgets.visible() &gt; 0" style="color:red; margin-top: 20px">Please fill all required fields ({{$invalidWidgets.visible()}} fields left).
+
+
+
+<div style="margin-bottom: 40px" ng:show="registration.$id && last_saved.$equals(registration)">
+       <div class="saved" ng:show="registration.type == 'participant'">
+               Your registration has been submitted successfully.
+       </div>
+
+       <div class="saved" ng:show="registration.type != 'participant'" class="saved">
+               <i>{{registration.work.title}}</i> has been submited successfully.<br>
        </div>
-</div>
 
-<div ng:show="registration.$id" class="saved">
-       <span ng:show="registration.category == 'participant'">Your registration has been submitted successfully.<br><br>
-               Please review your data, correct and save if needed or <a href="http://psihologija.ffzg.hr/drzb2011/">go to conference home page</a>.<br><br>
-        </span>
+       Please review your data, correct and save if needed or <a href="http://psihologija.ffzg.hr/drzb2011/">go to conference home page</a>.
+
+       <div>
+       Registration ID: <a href="#{{registration.$id}}">{{registration.$id}}</a>.<br>You can bookmark this page and review it later.
+       </div>
 </div>
 
 
+<input type="reset" value="Another work proposal to submit?" ng:click="reset()" ng:show="registration.$id && registration.type != 'participant' && last_saved.$equals(registration)">
+
 <!--
 <div ng:show="registration.$id">
 Permalink to <a href="#{{registration.$id}}">DRZB2011 registration</a> which you can bookmark
@@ -407,12 +418,13 @@ Permalink to <a href="#{{registration.$id}}">DRZB2011 registration</a> which you
 -->
 
 <hr>
-Debug Information:
-{{$window.location.href}}
-<pre>
-registration = {{registration}}
 
-dirty={{! last_saved.$equals(registration)}}
+<input type=checkbox name=debug>
+<pre ng:show="debug">
+
+dirty={{! last_saved.$equals(registration)}} invalid={{$invalidWidgets.visible()}}
+
+registration = {{registration}}
 
 last_saved = {{last_saved}}
 
@@ -424,4 +436,3 @@ $id={{$id}}
 registration.$id={{registration.$id}}
 </pre>
 
-</div>