3 if (typeof (console) === 'undefined') console = { debug: function() {} }; // mock console.debug
5 function Registration($resource){
8 name: '', surname: '', inst: '', email: '',
14 authors:[ { name:'', surname:'', inst:'', email:'' } ],
16 symposium: { organizers: [ {name:'', surname:'', inst:'', email:'' } ], work_nr: 1, },
18 this.Registration = $resource( '/data/conference/Registration/:id', { id:'' } );
19 this.Symposium = $resource( '/data/conference/Symposium/:id', { id:'' } );
21 this.$watch('$location.hashPath', this.hash_change);
23 Registration.$inject=['$resource'];
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 ) {
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 });
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
51 this.registration = new this.Registration( this.master );
53 this.registration.type = last.type;
54 this.registration.person = last.person;
56 if ( last.type == 'symposium' )
57 this.registration.symposium = last.symposium;
59 this.last_saved = angular.copy( this.registration ); // FIXME was: {};
60 console.debug( 'reset', this.registration, this.$location.hashPath, last );
64 this.registration.$save(function(registration){
65 self.$location.hashPath = registration.$id;
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 = [];
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();
80 self.last_saved = angular.copy(registration);
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';
94 <style type="text/css">
174 input, textarea, .gohome
178 border: solid 1px #dedede;
183 input:focus, textarea:focus
189 border: 1px solid #46d0fe;
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;
208 text-decoration: none;
212 .button input:hover, .gohome:hover {
220 text-decoration: none;
226 text-decoration: none;
252 <h1>Registration and Proposal Submission</h1>
254 <div ng:controller="Registration" ng:init="$window.$root = this;">
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>
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>
267 <div class="labelTop">
268 <div class="input input5">Institution</div>
270 <div style="clear: both">
271 <input class="input5" name="registration.person.inst">
273 <div class="labelTop">
274 <div class="input input5">Address</div>
276 <div style="clear: both">
277 <input class="input5" name="registration.person.address1" ng:required>
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>
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">
289 <div class="labelTop">
290 <div class="input input4">E-mail</div>
291 <div class="input input4">Phone number</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">
300 <div id="submission">
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>
314 <div id="work" ng:show="registration.type != 'participant'">
315 <div ng:show="registration.type == 'symposium'">
318 <label>Topic:</label>
319 <input class="input1" name="registration.symposium.title" ng:required>
320 <label>Organizer:</label>
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>
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>
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>
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>
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>
352 <div ng:show="registration.type">
354 <label>Title:</label>
355 <input class="input1" name="registration.work.title" ng:required>
356 <label>Authors</label>
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>
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>
367 <a class="addPerson" href="" ng:click="registration.work.authors.$add()">Add another author</a>
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>
374 </div> <!-- ng:show="registration.type" -->
378 <input type="submit" value="Save" ng:click="save();" ng:show="! last_saved.$equals(registration) && $invalidWidgets.visible() == 0">
381 <div ng:show="$invalidWidgets.visible() > 0" style="color:red; margin-top: 20px">Please fill all required fields ({{$invalidWidgets.visible()}} fields left).
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.
392 <div class="saved" ng:show="registration.type != 'participant'" class="saved">
393 <i>{{registration.work.title}}</i> submitted successfully.
396 Please review your data, correct and save if needed (just start typing and Save button will show automatically).
400 Registration ID: {{registration.$id}}. You can bookmark this page and review it later.
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>
411 <div ng:show="registration.$id">
412 Permalink to <a href="#{{registration.$id}}">DRZB2011 registration</a> which you can bookmark
417 <input type=checkbox name=debug style="float: right; clear: both">
418 <pre ng:show="debug">
420 dirty={{! last_saved.$equals(registration)}} invalid={{$invalidWidgets.visible()}}
422 registration = {{registration}}
424 last_saved = {{last_saved}}
428 symposium = {{symposium}}
431 registration.$id={{registration.$id}}