more changes after testing
[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
105
106 label {
107         display: block;
108         color: #D74F25;
109         color: #374E5A;
110         color: #afafaf;
111         margin-top: 10px;
112         font-size: 14px;
113         font-family: Arial;
114 }
115 h1 {
116 /*      margin-bottom: 6px;     */
117         padding-left: 20px;
118         font: 18px arial;
119         color: #0c1426;
120         text-decoration: none;
121         display: block;
122         background: url(http://mjesec.ffzg.hr/drzb2011/images/kvadrat.gif) no-repeat left;
123         border-bottom: 1px solid #CCC;
124 }
125 h2 {
126         margin-top: 40px;
127         font-size: 14px;
128         padding: 2px 0;
129         border-bottom: 2px solid #D74F25;
130         border-bottom: 1px solid #46d0fe;
131 }
132
133 a {
134         color: #D74F25;
135 }
136
137 label {
138         color: #374E5A;
139 }
140
141 .input {
142         color: #afafaf;
143         float: left;
144         margin: 2px;
145         padding: 0 6px;
146 }
147
148 .input1 {
149         width: 40.8em;
150 }
151
152 .input2 {
153         width: 8em;
154 }
155
156 .input3 {
157         width: 13em;
158 }
159 .input4 {
160         width: 10em;
161 }
162
163 .input5 {
164         width: 21.4em;
165 }
166 .input6 {
167         width: 6.3em;
168 }
169
170 .clear {
171         clear: both;
172 }
173
174
175 .authors {
176         clear: both;
177         margin-bottom: 6px;
178 }
179
180 .addPerson {
181         color: #D74F25;
182         color: #EDC8BC;
183         color: #EAB3A2;
184         font-size: 90%;
185 }
186
187 input, textarea, .gohome {
188         font: 14px arial;
189         color: #000000;
190         border: solid 1px #dedede;
191         padding: 6px;
192         background: #f6f6f6;
193 }
194
195 input:focus, textarea:focus
196 {
197         
198         background: #ffffff;
199         font-family: arial;
200         color: #000000;
201 /*      border: 1px solid #46d0fe; */
202 }
203
204 .ng-validation-error {
205         border: 1px solid #FF6666;
206         border: 1px solid #EDC8BC;
207         border: 1px solid #FF9966;
208         border: 1px solid #EAB3A2;
209         border: 1px solid #D74F25;
210         border: 1px solid #DC6844;
211         border: 1px solid #DE7F61;
212 }
213
214
215
216 #work, #submission {
217         margin-bottom: 20px;
218 }
219
220 .button {
221         width: 40.8em;
222 }
223
224 .button input {
225         float: left;
226         color: #ffffff;
227         display: block;
228         text-decoration: none;
229         background: #d74f25;
230 }
231
232 .button input:hover, .gohome:hover {
233         background: #dc6844;
234 }
235
236 .gohome  {
237         float: right;
238         color: #ffffff;
239         display: block;
240         text-decoration: none;
241         background: #d74f25;
242         padding: 7px;
243 }
244
245 .gohome a {
246         color: #fff;
247         text-decoration: none;
248 }
249
250
251 .warrning {
252         color: #FF6666;
253 }
254
255 .sworks {
256         margin-top: 20px;
257 }
258
259
260 .newWork {
261         clear: left;
262         margin-top: 50px;
263 }
264 .saved {
265         color: #D74F25; 
266         margin-top: 20px;
267         margin-bottom: 20px;
268 }
269 </style>
270
271
272
273 <h1>Registration and Proposal Submission</h1>
274
275 <div ng:controller="Registration" ng:init="$window.$root = this;">
276
277
278 <div id="participant">
279         <h2>Contact Information</h2>
280         <div class="labelTop">
281                 <div class="input input4">First name</div>
282                 <div class="input input4">Surname</div>
283         </div>
284         <div style="clear: both">
285                 <input class="input4" name="registration.person.name" ng:required>
286                 <input class="input4" name="registration.person.surname" ng:required>
287         </div>
288         <div class="labelTop">
289                 <div class="input input5">Institution</div>
290         </div>  
291         <div style="clear: both">
292                 <input class="input5" name="registration.person.inst">
293         </div>
294         <div class="labelTop">
295                 <div class="input input5">Address</div>
296         </div>  
297         <div style="clear: both">
298                 <input class="input5" name="registration.person.address1" ng:required>
299         </div>
300         <div class="labelTop">
301                 <div class="input input6">City</div>
302                 <div class="input input6">ZIP</div>
303                 <div class="input input6">Country</div>
304         </div>
305         <div style="clear: both">
306                 <input class="input6" name="registration.person.city" ng:required>
307                 <input class="input6" name="registration.person.zip">
308                 <input class="input6" name="registration.person.country">
309         </div>
310         <div class="labelTop">
311                 <div class="input input4">E-mail</div>
312                 <div class="input input4">Phone number</div>
313         </div>
314         <div style="clear: both">
315                 <input class="input4" name="registration.person.email" ng:validate="email" ng:required>
316                 <input class="input4" name="registration.person.phone">
317         </div>
318 </div>
319
320
321 <div id="submission">
322         <div>
323                 <h2>Registration Type</h2>
324                 <label><input type="radio" name="registration.type" value="participant" ng:required>Attendance with no presentation</label>
325                 <label><input type="radio" name="registration.type" value="participant" ng:required>Symposium participant</label>
326                 <label><input type="radio" name="registration.type" value="symposium" ng:required>Symposium organizer</label>
327                 <label><input type="radio" name="registration.type" value="lecture" ng:required>Oral presentation</label>
328                 <label><input type="radio" name="registration.type" value="poster" ng:required>Poster presentation</label>
329                 <label><input type="radio" name="registration.type" value="round" ng:required>Round table discussion</label>
330         </div>
331 </div>
332
333
334
335
336 <div id="work" ng:show="registration.type != 'participant'">
337         <div ng:show="registration.type == 'symposium'">
338
339                 <h2>Symposia</h2>
340                 <label for="registration.symposium.title">Topic:</label>
341                         <input class="input1" name="registration.symposium.title" ng:required>
342                 <label>Organizer:</label>
343                         <div class="input input2">First name</div><div class="input input2">Surname</div><div class="input input3">Institution</div><div class="input input2">E-mail</div>
344                         <div class="clear" ng:repeat="organizer in registration.symposium.organizers">
345                         <input class="input2" name="organizer.name" ng:required>
346                         <input class="input2" name="organizer.surname" ng:required>
347                         <input class="input3" name="organizer.inst" >
348                         <input class="input2" name="organizer.email" ng:required ng:validate="email">
349                         <a href="" ng:click="registration.symposium.organizers.$remove(organizer)">X</a>
350                         </div>
351                 <a class="addPerson" href="" ng:click="registration.symposium.organizers.$add()">Add another organizer</a>
352                 <label>Summary (2000 characters max.)</label>
353                         <textarea class="input1" name="registration.symposium.abstract" rows="10" ng:validate="max_length:2000" ng:required></textarea>
354                 <div ng:show="symposium">
355                         <label>List of already submitted works</label>
356                         <ol>
357                         <li ng:repeat="w in symposium.works">
358                         <a ng:show="registration.$id != w.$id" href="#{{w.$id}}" >{{w.title}}</a>
359                         <b ng:show="registration.$id == w.$id">{{w.title}}</b>
360                         </li>
361                         </ol>
362                 </div>
363         </div>
364
365
366         <h2 ng:show="registration.type == 'symposium'">Symposia paper ({{registration.symposium.work_nr}})</h2>
367         <h2 ng:show="registration.type == 'lecture'">Oral Presentation Sumbission</h2>
368         <h2 ng:show="registration.type == 'poster'">Poster Presentation Sumbission</h2>
369         <h2 ng:show="registration.type == 'round'">Round Table Disscussion Sumbission</h2>
370
371
372   <div ng:show="registration.type">
373
374         <label>Title:</label>
375                 <input class="input1" name="registration.work.title" ng:required>
376         <label>Authors</label>
377         <div>
378                 <div class="input input2">First name</div><div class="input input2">Surname</div><div class="input input3">Institution</div><div class="input input2">E-mail</div>
379         </div>
380         <div class="clear" ng:repeat="author in registration.work.authors">
381                 <input class="input2" name="author.name" ng:required>
382                 <input class="input2" name="author.surname" ng:required>
383                 <input class="input3" name="author.inst" >
384                 <input class="input2" name="author.email" ng:required ng:validate="email">
385                 <a href="" ng:click="registration.work.authors.$remove(author)">X</a>
386         </div>
387         <a class="addPerson" href="" ng:click="registration.work.authors.$add()">Add another author</a>
388
389
390         <label>Abstract (2000 characters max.):</label>
391                 <textarea class="input1" name="registration.work.abstract" rows="5" ng:validate="max_length:2000" ng:required></textarea>
392
393
394   </div> <!-- ng:show="registration.type" -->
395 </div>
396
397 <div class="button">
398 <input type="submit" value="Save" ng:click="save();" ng:show="! last_saved.$equals(registration) && $invalidWidgets.visible() == 0">
399 </div>
400
401 <div ng:show="$invalidWidgets.visible() &gt; 0" style="color:red; margin-top: 20px">Please fill all required fields correctly ({{$invalidWidgets.visible()}} fields left). Red colored fields call for your attention.
402 </div>
403
404
405
406
407 <div style="margin-bottom: 40px" ng:show="registration.$id && last_saved.$equals(registration)">
408         <div class="saved" ng:show="registration.type == 'participant'">
409                 Your registration has been submitted successfully.
410         </div>
411
412         <div class="saved" ng:show="registration.type != 'participant'" class="saved">
413                 <i>{{registration.work.title}}</i> submitted successfully.
414         </div>
415 <!--
416         Please review your data, correct and save if needed (just start typing and Save button will show automatically).
417 -->
418 <!--    
419         <div>
420         Registration ID: {{registration.$id}}. You can bookmark this page and review it later.
421         </div>
422 -->
423 </div>
424
425 <div class="button" ng:show="registration.$id && registration.type != 'participant' && last_saved.$equals(registration)">
426         <input type="reset" value="Submit another paper" ng:click="reset()">
427         <div class="gohome"><a href="http://psihologija.ffzg.hr/drzb2011/">Finish and go to the conference home page</a></div>
428 </div>
429
430 <!--
431 <div ng:show="registration.$id">
432 Permalink to <a href="#{{registration.$id}}">DRZB2011 registration</a> which you can bookmark
433 </div>
434 -->
435
436
437 <input type=checkbox name=debug style="float: right; clear: both">
438 <pre ng:show="debug">
439
440 dirty={{! last_saved.$equals(registration)}} invalid={{$invalidWidgets.visible()}}
441
442 registration = {{registration}}
443
444 last_saved = {{last_saved}}
445
446 master = {{master}}
447
448 symposium = {{symposium}}
449
450 $id={{$id}}
451 registration.$id={{registration.$id}}
452 </pre>
453