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">
151 .labelTop .pname, .labelTop .name, .labelTop .surname, .labelTop .pinst, .labelTop .email, .labelTop .city, .labelTop .address, .labelTop .contact {
158 .pname, .name, .surname, .email {
198 border: solid 1px #dedede;
203 input:focus, textarea:focus
209 border: 1px solid #46d0fe;
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;
237 text-decoration: none;
261 <h1>Registration and Proposal Submission</h1>
263 <div ng:controller="Registration" ng:init="$window.$root = this;">
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>
272 <div style="clear: both">
273 <input class="pname" name="registration.person.name" ng:required>
274 <input class="pname" name="registration.person.surname">
276 <div class="labelTop">
277 <div class="pinst">Institution</div>
279 <div style="clear: both">
280 <input class="pinst" name="registration.person.inst">
282 <div class="labelTop">
283 <div class="address">Address</div>
285 <div style="clear: both">
286 <input class="address" name="registration.person.address1">
287 <input class="address" name="registration.person.address2">
289 <div class="labelTop">
290 <div class="city">City</div>
291 <div class="city">ZIP</div>
292 <div class="city">Country</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">
299 <div class="labelTop">
300 <div class="contact">E-mail</div>
301 <div class="contact">Phone number</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">
310 <div id="submission">
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>
324 <div id="work" ng:show="registration.type != 'participant'">
325 <div ng:show="registration.type == 'symposium'">
327 <h2>Symposia Submission</h2>
328 <label>Topic:</label>
329 <input class="fl1" name="registration.symposium.title" ng:required>
330 <label>Organizer:</label>
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>
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>
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>
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>
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>
362 <div ng:show="registration.type">
364 <label>Title:</label>
365 <input class="fl1" name="registration.work.title" ng:required>
366 <label>Authors</label>
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>
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>
377 <a class="addPerson" href="" ng:click="registration.work.authors.$add()">Add another author</a>
380 <label>Summary:</label>
381 <textarea class="fl1" name="registration.work.abstract" rows="5" ng:validate="max_length:2000"></textarea>
384 </div> <!-- ng:show="registration.type" -->
387 <input type="submit" value="Save" ng:click="save();" ng:show="! last_saved.$equals(registration) && $invalidWidgets.visible() == 0">
389 <div ng:show="$invalidWidgets.visible() > 0" style="color:red; margin-top: 20px">Please fill all required fields ({{$invalidWidgets.visible()}} fields left).
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.
400 <div class="saved" ng:show="registration.type != 'participant'" class="saved">
401 <i>{{registration.work.title}}</i> has been submited successfully.<br>
404 Please review your data, correct and save if needed or <a href="http://psihologija.ffzg.hr/drzb2011/">go to conference home page</a>.
407 Registration ID: <a href="#{{registration.$id}}">{{registration.$id}}</a>.<br>You can bookmark this page and review it later.
412 <input type="reset" value="Another work proposal to submit?" ng:click="reset()" ng:show="registration.$id && registration.type != 'participant' && last_saved.$equals(registration)">
415 <div ng:show="registration.$id">
416 Permalink to <a href="#{{registration.$id}}">DRZB2011 registration</a> which you can bookmark
422 <input type=checkbox name=debug>
423 <pre ng:show="debug">
425 dirty={{! last_saved.$equals(registration)}} invalid={{$invalidWidgets.visible()}}
427 registration = {{registration}}
429 last_saved = {{last_saved}}
433 symposium = {{symposium}}
436 registration.$id={{registration.$id}}