21c2ae5617b29ba04194bb106dbfffe134d98995
[angular-mojolicious.git] / templates / conference / Registration.html.ep
1 <script>
2
3 if (typeof (console) === 'undefined') console = { debug: function() {} }; // mock console.debug
4
5 function Registration($resource){
6         this.master = {
7                 person: {
8                         name: '', surname: '', inst: '', email: ''
9                 },
10                 type: 'participant',
11                 work: {
12                         title: '',
13                         abstract: '',
14                         authors:[ { name:'', surname:'', inst:'', email:'' } ]
15                 },
16                 symposium: { organizers: [ {name:'', surname:'', inst:'', email:'' } ], work_nr: 1 }
17         };
18         this.Registration = $resource( '/data/conference/Registration/:id', { id:'' } );
19         this.Symposium = $resource( '/data/conference/Symposium/:id', { id:'' } );
20         this.reset();
21         this.$watch('$location.hashPath', this.hash_change);
22 }
23 Registration.$inject=['$resource'];
24
25 Registration.prototype = {
26         hash_change: function() {
27                 var id = this.$location.hashPath;
28 console.debug( 'hash_change', id, this.registration.$id );
29                 if ( id != this.registration.$id ) {
30                         if (id) {
31                                 var self = this;
32                                 this.registration = this.Registration.get({ id: id }, function(registration) {
33                                         self.last_saved = angular.copy(registration);
34                                         if ( registration.type == 'symposium' ) {
35                                                 var s_id = registration.symposium.$id || registration.$id;
36                                                 // first registration doesn't have symposium.$id, but we used same $id
37 console.debug( 'load symposium ', s_id );
38                                                 self.symposium = self.Symposium.get({ id: s_id });
39                                         }
40                                 });
41                         }
42                         else this.reset();
43                 }
44         },
45         reset: function() {
46                 console.debug( this.Registration );
47                 var last = this.registration;
48                 if ( last && last.type == 'symposium' ) {
49                         if ( last.$id ) last.symposium.work_nr++; // only if saved
50                 }
51                 this.registration = new this.Registration( this.master );
52                 if ( last ) {
53                         this.registration.type      = last.type;
54                         this.registration.person    = last.person;
55
56                         if ( last.type == 'symposium' )
57                         this.registration.symposium = last.symposium;
58                 }
59                 this.last_saved = angular.copy( this.registration ); // FIXME was: {};
60 console.debug( 'reset', this.registration, this.$location.hashPath, last );
61         },
62         save: function(){
63                 var self = this;
64                 this.registration.$save(function(registration){
65                         self.$location.hashPath = registration.$id;
66
67                         // save symposium to separate resource
68                         if ( registration.type == 'symposium' ) {
69                                 if ( ! self.symposium ) { 
70                                         self.registration.symposium.$id = registration.$id; // reuse $id of first work for symposium
71                                         self.symposium = new self.Symposium( registration.symposium );
72                                         self.symposium.works = [];
73                                 }
74                                 registration.work.$id = registration.$id; // preserve $id
75                                 self.symposium.works[ registration.symposium.work_nr - 1 ] = registration.work;
76 console.debug('save_symposium', self.symposium );
77                                 self.symposium.$save();
78                         }
79
80                         self.last_saved = angular.copy(registration);
81                 });
82         }
83 };
84
85 angular.validator.max_length = function(input, len) {
86         var ok = input.length <= len;
87 console.debug( 'max_length', ok, input.length, len );
88         return ok ? '' : 'must be shorter than '+len+' characters';
89 }
90
91 </script>
92
93
94 <style type="text/css">
95
96 body {
97         background: #F6F6F6;
98         margin: 40px;
99         font-family: Arial;
100         color: #374E5A;
101         font-size: 14px;
102         line-height: 16px;
103 }
104 label, h2 {
105         display: block;
106         color: #D74F25;
107         color: #374E5A;
108         color: #afafaf;
109         margin-top: 10px;
110         font-size: 14px;
111         font-family: Arial;
112 }
113
114 h2 {
115         margin-top: 40px;
116         color: #374E5A;
117         color: #D74F25;
118 }
119
120 a {
121         color: #D74F25;
122 }
123
124 label {
125         color: #374E5A;
126 }
127
128 .fl {
129         color: #afafaf;
130         float: left;
131         margin: 2px;
132         padding: 0 6px;
133 }
134
135 .fl1 {
136         width: 40.8em;
137 }
138
139 .fl2 {
140         width: 8em;
141 }
142
143 .fl3 {
144         width: 13em;
145 }
146
147 .flClear {
148         clear: both;
149 }
150
151 .labelTop .pname, .labelTop .name, .labelTop .surname, .labelTop .pinst, .labelTop .email, .labelTop .city, .labelTop .address, .labelTop .contact {
152         color: #afafaf;
153         float: left;
154         margin: 2px;
155         padding: 0 6px;
156 }
157
158 .pname, .name, .surname, .email {
159         width: 10em;
160 }
161
162 .pinst {
163         width: 21.4em;
164 }
165
166 .address {
167         width: 14.1em;
168 }
169
170 .city {
171         width: 9em;
172 }
173
174 .contact {
175         width: 10em;
176 }
177
178 .title, .summary {
179         width: 93%;
180 }
181
182 .authors {
183         clear: both;
184         margin-bottom: 6px;
185 }
186
187 .addPerson {
188         color: #D74F25;
189         color: #EDC8BC;
190         color: #EAB3A2;
191         font-size: 90%;
192 }
193
194 input, textarea
195 {
196         font: 14px arial;
197         color: #000000;
198         border: solid 1px #dedede;
199         padding: 6px;
200         background: #f6f6f6;
201 }
202
203 input:focus, textarea:focus
204 {
205         
206         background: #ffffff;
207         font-family: arial;
208         color: #000000;
209         border: 1px solid #46d0fe;
210 }
211
212 input.ng-validation-error {
213         border: 1px solid #D74F25;
214         border: 1px solid #FF6666;
215         border: 1px solid #EDC8BC;
216         border: 1px solid #FF9966;
217         border: 1px solid #EAB3A2;
218 }
219
220 .warrning {
221         color: #FF6666;
222 }
223
224 .sworks {
225         margin-top: 20px;
226 }
227
228 .save {
229         margin-top: 10px;
230 }
231
232 .save input 
233 {
234         float: left;
235         color: #ffffff;
236         display: block;
237         text-decoration: none;
238         background: #d74f25;
239 }
240
241 .save input:hover
242 {
243         background: #dc6844;
244 }
245
246 .newWork {
247         clear: left;
248         margin-top: 50px;
249 }
250 .saved {
251         color: #D74F25; 
252         margin-top: 20px;
253 }
254 #buttons {
255         margin-top: 20px;
256 }
257 </style>
258
259
260
261 <h1>Registration and Proposal Submission</h1>
262
263 <div ng:controller="Registration" ng:init="$window.$root = this;">
264
265
266 <div id="participant">
267         <h2>Contact Information</h2>
268         <div class="labelTop">
269                 <div class="pname">First name</div>
270                 <div class="pname">Surname</div>
271         </div>
272         <div style="clear: both">
273                 <input class="pname" name="registration.person.name" ng:required>
274                 <input class="pname" name="registration.person.surname">
275         </div>
276         <div class="labelTop">
277                 <div class="pinst">Institution</div>
278         </div>  
279         <div style="clear: both">
280                 <input class="pinst" name="registration.person.inst">
281         </div>
282         <div class="labelTop">
283                 <div class="address">Address</div>
284         </div>  
285         <div style="clear: both">
286                 <input class="address" name="registration.person.address1">
287                 <input class="address" name="registration.person.address2">
288         </div>
289         <div class="labelTop">
290                 <div class="city">City</div>
291                 <div class="city">ZIP</div>
292                 <div class="city">Country</div>
293         </div>
294         <div style="clear: both">
295                 <input class="city" name="registration.person.city">
296                 <input class="city" name="registration.person.zip">
297                 <input class="city" name="registration.person.country">
298         </div>
299         <div class="labelTop">
300                 <div class="contact">E-mail</div>
301                 <div class="contact">Phone number</div>
302         </div>
303         <div style="clear: both">
304                 <input class="contact" name="registration.person.email" ng:validate="email" ng:required>
305                 <input class="contact" name="registration.person.phone">
306         </div>
307 </div>
308
309
310 <div id="submission">
311         <div>
312                 <h2>Choose submittion type:</h2>
313                 <label><input type="radio" name="registration.type" value="participant" ng:required>Participant</label>
314                 <label><input type="radio" name="registration.type" value="symposium" ng:required>Symposia</label>
315                 <label><input type="radio" name="registration.type" value="lecture" ng:required>Oral presentation</label>
316                 <label><input type="radio" name="registration.type" value="poster" ng:required>Poster presentation</label>
317                 <label><input type="radio" name="registration.type" value="round" ng:required>Round table discussion</label>
318         </div>
319 </div>
320
321
322
323
324 <div id="work" ng:show="registration.type != 'participant'">
325         <div ng:show="registration.type == 'symposium'">
326
327                 <h2>Symposia Submission</h2>
328                 <label>Topic:</label>
329                         <input class="fl1" name="registration.symposium.title" ng:required>
330                 <label>Organizer:</label>
331                 <div>
332                         <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>
333                 </div>
334                 <div class="flClear" ng:repeat="organizer in registration.symposium.organizers">
335                         <input class="fl2" name="organizer.name" ng:required>
336                         <input class="fl2" name="organizer.surname" ng:required>
337                         <input class="fl3" name="organizer.inst" >
338                         <input class="fl2" name="organizer.email" ng:required>
339                         <a href="" ng:click="registration.symposium.organizers.$remove(organizer)">X</a>
340                 </div>
341                 <a class="addPerson" href="" ng:click="registration.symposium.organizers.$add()">Add another organizer</a>
342                 <label>Summary:</label>
343                         <textarea class="fl1" name="registration.symposium.abstract" rows="5" ng:validate="max_length:2000"></textarea>
344                 <div ng:show="symposium">
345                         <label>List of already submitted works</label>
346                         <ol>
347                         <li ng:repeat="w in symposium.works">
348                         <a ng:show="registration.$id != w.$id" href="#{{w.$id}}" >{{w.title}}</a>
349                         <b ng:show="registration.$id == w.$id">{{w.title}}</b>
350                         </li>
351                         </ol>
352                 </div>
353         </div>
354
355
356         <h2 ng:show="registration.type == 'symposium'">Work no. {{registration.symposium.work_nr}}.  in <i>{{registration.symposium.title}}</i> </h2>
357         <h2 ng:show="registration.type == 'lecture'">Oral Presentation Sumbission</h2>
358         <h2 ng:show="registration.type == 'poster'">Poster Presentation Sumbission</h2>
359         <h2 ng:show="registration.type == 'round'">Round Table Disscussion Sumbission</h2>
360
361
362   <div ng:show="registration.type">
363
364         <label>Title:</label>
365                 <input class="fl1" name="registration.work.title" ng:required>
366         <label>Authors</label>
367         <div>
368                 <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>
369         </div>
370         <div class="flClear" ng:repeat="author in registration.work.authors">
371                 <input class="fl2" name="author.name" ng:required>
372                 <input class="fl2" name="author.surname" ng:required>
373                 <input class="fl3" name="author.inst" >
374                 <input class="fl2" name="author.email" ng:required>
375                 <a href="" ng:click="registration.work.authors.$remove(author)">X</a>
376         </div>
377         <a class="addPerson" href="" ng:click="registration.work.authors.$add()">Add another author</a>
378
379
380         <label>Summary:</label>
381                 <textarea class="fl1" name="registration.work.abstract" rows="5" ng:validate="max_length:2000"></textarea>
382
383
384   </div> <!-- ng:show="registration.type" -->
385 </div>
386
387 <input type="submit" value="Save" ng:click="save();" ng:show="! last_saved.$equals(registration) && $invalidWidgets.visible() == 0">
388
389 <div ng:show="$invalidWidgets.visible() &gt; 0" style="color:red; margin-top: 20px">Please fill all required fields ({{$invalidWidgets.visible()}} fields left).
390 </div>
391
392
393
394
395 <div style="margin-bottom: 40px" ng:show="registration.$id && last_saved.$equals(registration)">
396         <div class="saved" ng:show="registration.type == 'participant'">
397                 Your registration has been submitted successfully.
398         </div>
399
400         <div class="saved" ng:show="registration.type != 'participant'" class="saved">
401                 <i>{{registration.work.title}}</i> has been submited successfully.<br>
402         </div>
403
404         Please review your data, correct and save if needed or <a href="http://psihologija.ffzg.hr/drzb2011/">go to conference home page</a>.
405
406         <div>
407         Registration ID: <a href="#{{registration.$id}}">{{registration.$id}}</a>.<br>You can bookmark this page and review it later.
408         </div>
409 </div>
410
411
412 <input type="reset" value="Another work proposal to submit?" ng:click="reset()" ng:show="registration.$id && registration.type != 'participant' && last_saved.$equals(registration)">
413
414 <!--
415 <div ng:show="registration.$id">
416 Permalink to <a href="#{{registration.$id}}">DRZB2011 registration</a> which you can bookmark
417 </div>
418 -->
419
420 <hr>
421
422 <input type=checkbox name=debug>
423 <pre ng:show="debug">
424
425 dirty={{! last_saved.$equals(registration)}} invalid={{$invalidWidgets.visible()}}
426
427 registration = {{registration}}
428
429 last_saved = {{last_saved}}
430
431 master = {{master}}
432
433 symposium = {{symposium}}
434
435 $id={{$id}}
436 registration.$id={{registration.$id}}
437 </pre>
438