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