fix IE errors with extra , at end of structures
[angular-mojolicious.git] / templates / conference / Registration.html.ep
index 8511e62..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;
@@ -74,16 +71,22 @@ console.debug( 'reset', current_symposium, this.registration, this.$location.has
                                        self.symposium = new self.Symposium( registration.symposium );
                                        self.symposium.works = [];
                                }
-                               self.symposium.works[ work.symposium.work_nr - 1 ] = registration.work;
+                               registration.work.$id = registration.$id; // preserve $id
+                               self.symposium.works[ registration.symposium.work_nr - 1 ] = registration.work;
 console.debug('save_symposium', self.symposium );
                                self.symposium.$save();
                        }
 
                        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>
 
@@ -106,7 +109,6 @@ label, h2 {
        margin-top: 10px;
        font-size: 14px;
        font-family: Arial;
-       font-weight: normal;
 }
 
 h2 {
@@ -117,49 +119,76 @@ h2 {
 
 a {
        color: #D74F25;
-       font-size: 80%;
-}
-
-.symposium, .work {
-       width: 615px;
 }
 
 label {
        color: #374E5A;
 }
 
-.authors-label .name, .authors-label .surname, .authors-label .inst, .authors-label .email {
+.fl {
        color: #afafaf;
        float: left;
        margin: 2px;
        padding: 0 6px;
 }
 
-.name, .surname, .email {
-       width: 18%;
+.fl1 {
+       width: 40.8em;
 }
 
-.inst {
-       width: 30%;
+.fl2 {
+       width: 8em;
 }
 
-.title, .summary {
-       width: 93%;
+.fl3 {
+       width: 13em;
 }
 
-.authors {
+.flClear {
        clear: both;
-       margin-bottom: 6px;
 }
 
-.authors-label {
-       clear: right;
+.labelTop .pname, .labelTop .name, .labelTop .surname, .labelTop .pinst, .labelTop .email, .labelTop .city, .labelTop .address, .labelTop .contact {
+       color: #afafaf;
+       float: left;
+       margin: 2px;
+       padding: 0 6px;
 }
 
+.pname, .name, .surname, .email {
+       width: 10em;
+}
 
+.pinst {
+       width: 21.4em;
+}
+
+.address {
+       width: 14.1em;
+}
+
+.city {
+       width: 9em;
+}
+
+.contact {
+       width: 10em;
+}
+
+.title, .summary {
+       width: 93%;
+}
+
+.authors {
+       clear: both;
+       margin-bottom: 6px;
+}
 
-.addNew {
-       padding-right: 30px;
+.addPerson {
+       color: #D74F25;
+       color: #EDC8BC;
+       color: #EAB3A2;
+       font-size: 90%;
 }
 
 input, textarea
@@ -183,8 +212,9 @@ input:focus, textarea:focus
 input.ng-validation-error {
        border: 1px solid #D74F25;
        border: 1px solid #FF6666;
-       border: 1px solid #FF9966;
        border: 1px solid #EDC8BC;
+       border: 1px solid #FF9966;
+       border: 1px solid #EAB3A2;
 }
 
 .warrning {
@@ -217,6 +247,13 @@ input.ng-validation-error {
        clear: left;
        margin-top: 50px;
 }
+.saved {
+       color: #D74F25; 
+       margin-top: 20px;
+}
+#buttons {
+       margin-top: 20px;
+}
 </style>
 
 
@@ -225,111 +262,177 @@ input.ng-validation-error {
 
 <div ng:controller="Registration" ng:init="$window.$root = this;">
 
-<div id="registration">
-
-<input class="name" name="registration.person.name" ng:required>
-<input class="name" name="registration.person.surname" ng:required>
-
-<input name="registration.person.inst">
-<input name="registration.person.email" ng:validate="email">
 
+<div id="participant">
+       <h2>Contact Information</h2>
+       <div class="labelTop">
+               <div class="pname">First name</div>
+               <div class="pname">Surname</div>
+       </div>
+       <div style="clear: both">
+               <input class="pname" name="registration.person.name" ng:required>
+               <input class="pname" name="registration.person.surname">
+       </div>
+       <div class="labelTop">
+               <div class="pinst">Institution</div>
+       </div>  
+       <div style="clear: both">
+               <input class="pinst" name="registration.person.inst">
+       </div>
+       <div class="labelTop">
+               <div class="address">Address</div>
+       </div>  
+       <div style="clear: both">
+               <input class="address" name="registration.person.address1">
+               <input class="address" name="registration.person.address2">
+       </div>
+       <div class="labelTop">
+               <div class="city">City</div>
+               <div class="city">ZIP</div>
+               <div class="city">Country</div>
+       </div>
+       <div style="clear: both">
+               <input class="city" name="registration.person.city">
+               <input class="city" name="registration.person.zip">
+               <input class="city" name="registration.person.country">
+       </div>
+       <div class="labelTop">
+               <div class="contact">E-mail</div>
+               <div class="contact">Phone number</div>
+       </div>
+       <div style="clear: both">
+               <input class="contact" name="registration.person.email" ng:validate="email" ng:required>
+               <input class="contact" name="registration.person.phone">
+       </div>
 </div>
 
-<div id="submission">
-
-<h2>Type of conference submission:</h2>
-
-<input type="radio" name="registration.type" value="">Just attending conference<br/>
-<input type="radio" name="registration.type" value="symposium">Symposia<br/>
-<input type="radio" name="registration.type" value="lecture">Oral presentation<br/>
-<input type="radio" name="registration.type" value="poster">Poster presentation<br/>
-<input type="radio" name="registration.type" value="round">Round table discussion<br/>
-
-<div id="submit_work" ng:show="registration.type">
-
-<div ng:show="registration.type == 'symposium'" style="background:#f0f0f0">
 
-<label>Topic of symposium: <input name="registration.symposium.title" size="60" ng:required></label><br/>
-   
-<label>Summary: <br/>
-<textarea name="registration.symposium.abstract" cols="50" rows="5"></textarea>
-</label>
-<br/>
-
-Organizer:
-<div ng:repeat="organizer in registration.symposium.organizers">
-[<a href="" ng:click="registration.symposium.organizer.$remove(author)">X</a>]
-<input name="organizer.name" ng:required>
-<input name="organizer.surname" ng:required>
-<input name="organizer.inst" >
-<input name="organizer.email" ng:required>
+<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>
-[<a href="" ng:click="registration.symposium.organizer.$add()">Add another organizer</a>]
 
-</div>
-<hr>
 
-<div ng:show="symposium">
-Works which are part of this symposium:
-<ol>
-<li ng:repeat="w in symposium.works"><a href="#{{w.$id}}">{{w.title}}</a></li>
-</ol>
 
+
+<div id="work" ng:show="registration.type != 'participant'">
+       <div ng:show="registration.type == 'symposium'">
+
+               <h2>Symposia Submission</h2>
+               <label>Topic:</label>
+                       <input class="fl1" name="registration.symposium.title" ng:required>
+               <label>Organizer:</label>
+               <div>
+                       <div class="fl fl2">First name</div><div class="fl fl2">Surname</div><div class="fl fl3">Institution</div><div class="fl fl2">E-mail</div>
+               </div>
+               <div class="flClear" ng:repeat="organizer in registration.symposium.organizers">
+                       <input class="fl2" name="organizer.name" ng:required>
+                       <input class="fl2" name="organizer.surname" ng:required>
+                       <input class="fl3" name="organizer.inst" >
+                       <input class="fl2" name="organizer.email" ng:required>
+                       <a href="" ng:click="registration.symposium.organizers.$remove(organizer)">X</a>
+               </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" ng:validate="max_length:2000"></textarea>
+               <div ng:show="symposium">
+                       <label>List of already submitted works</label>
+                       <ol>
+                       <li ng:repeat="w in symposium.works">
+                       <a ng:show="registration.$id != w.$id" href="#{{w.$id}}" >{{w.title}}</a>
+                       <b ng:show="registration.$id == w.$id">{{w.title}}</b>
+                       </li>
+                       </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>
+
+
+  <div ng:show="registration.type">
+
+       <label>Title:</label>
+               <input class="fl1" name="registration.work.title" ng:required>
+       <label>Authors</label>
+       <div>
+               <div class="fl fl2">First name</div><div class="fl fl2">Surname</div><div class="fl fl3">Institution</div><div class="fl fl2">E-mail</div>
+       </div>
+       <div class="flClear" ng:repeat="author in registration.work.authors">
+               <input class="fl2" name="author.name" ng:required>
+               <input class="fl2" name="author.surname" ng:required>
+               <input class="fl3" name="author.inst" >
+               <input class="fl2" name="author.email" ng:required>
+               <a href="" ng:click="registration.work.authors.$remove(author)">X</a>
+       </div>
+       <a class="addPerson" href="" ng:click="registration.work.authors.$add()">Add another author</a>
+
+
+       <label>Summary:</label>
+               <textarea class="fl1" name="registration.work.abstract" rows="5" ng:validate="max_length:2000"></textarea>
+
+
+  </div> <!-- ng:show="registration.type" -->
 </div>
 
-<h2>Autors<span ng:show="registration.type == 'symposium'"> of {{registration.symposium.work_nr}}. work </span></h2>
+<input type="submit" value="Save" ng:click="save();" ng:show="! last_saved.$equals(registration) && $invalidWidgets.visible() == 0">
 
-<div ng:repeat="author in registration.work.authors">
-[<a href="" ng:click="registration.work.authors.$remove(author)">X</a>]
-<input name="author.name" ng:required>
-<input name="author.surname" ng:required>
-<input name="author.inst" >
-<input name="author.email" ng:required>
+<div ng:show="$invalidWidgets.visible() &gt; 0" style="color:red; margin-top: 20px">Please fill all required fields ({{$invalidWidgets.visible()}} fields left).
 </div>
-[<a href="" ng:click="registration.work.authors.$add()">Add another author</a>]
 
-<hr>    
 
-<label>Title: <input name="registration.work.title" size="60" ng:required></label><br/>
 
-<label>Summary:<br>
-<textarea name="registration.work.abstract" cols="50" rows="5"></textarea>
-</label>
-<br/>
 
-</div>
+<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 id="buttons">
+       <div class="saved" ng:show="registration.type != 'participant'" class="saved">
+               <i>{{registration.work.title}}</i> has been submited successfully.<br>
+       </div>
 
-<span ng:show="$invalidWidgets.visible() == 0">
-<input type="submit" value="Save" ng:click="save();" ng:show="! last_saved.$equals(registration)">
-<input type="reset" value="Add another work" ng:click="reset()" ng:show="registration && registration.$id">
-</span>
+       Please review your data, correct and save if needed or <a href="http://psihologija.ffzg.hr/drzb2011/">go to conference home page</a>.
 
-<b ng:show="$invalidWidgets.visible() &gt; 0" style="color:#800">{{$invalidWidgets.visible()}} errors to fix in submission form</b>
+       <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
 </div>
-
-</div><!-- registration.type == just attending -->
+-->
 
 <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}}
 
 master = {{master}}
 
+symposium = {{symposium}}
+
 $id={{$id}}
 registration.$id={{registration.$id}}
 </pre>
 
-</div>