X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=templates%2Fconference%2FWork.html.ep;h=e1d73c831cc7125c5ce13518093d40041431cc36;hb=9aabf01994845ae1102edd7dbba3e4e6f82b0f2a;hp=253287d9cdcce96fe6daaa2c193a4bb099cfdd22;hpb=ac4d21c7fbbeb944f8ef2029ae09fd2ad352baad;p=angular-mojolicious.git diff --git a/templates/conference/Work.html.ep b/templates/conference/Work.html.ep index 253287d..e1d73c8 100644 --- a/templates/conference/Work.html.ep +++ b/templates/conference/Work.html.ep @@ -8,9 +8,11 @@ function Work($resource){ title: '', abstract: '', authors:[ { name:'', surname:'', inst:'', email:'' } ], - symposium: { authors: [ {name:'', surname:'', inst:'', email:'' } ], work_nr: 1, }, + symposium: { organizer: [ {name:'', surname:'', inst:'', email:'' } ], work_nr: 1, }, }; - this.Work = $resource( '/data/conference/Work/:_id', { _id:'' } ); + this.last_saved_work = {}; + this.Work = $resource( '/data/conference/Work/:id', { id:'' } ); + this.Symposium = $resource( '/data/conference/Symposium/:id', { id:'' } ); this.reset(); this.$watch('$location.hashPath', this.hash_change); } @@ -19,147 +21,159 @@ Work.$inject=['$resource']; Work.prototype = { hash_change: function() { var id = this.$location.hashPath; -console.debug( 'hash_change', id, this.work._id ); - if ( id != this.work._id ) { - if (id) this.work = this.Work.get({ _id: id }) +console.debug( 'hash_change', id, this.work.$id ); + if ( id != this.work.$id ) { + if (id) { + var self = this; + this.work = this.Work.get({ id: id }, function(work) { + self.last_saved_work = angular.copy(work); + if ( work.type == 'symposium' ) { + var s_id = work.symposium.$id || work.$id; + // first work doesn't have symposium.$id, but we used same $id +console.debug( 'load symposium ', s_id ); + self.symposium = self.Symposium.get({ id: s_id }); + } + }); + } else this.reset(); } }, reset: function() { console.debug( this.Work ); - var symposium = null; + var current_symposium = null; if ( this.work && this.work.type == 'symposium' ) { - symposium = this.work.symposium; - if ( this.work._id ) symposium.work_nr++; - // if is required because reset is called twice -- once with saved records and once with new empty one -console.debug( 'symposium', symposium, this.work ) + current_symposium = this.work.symposium; + if ( this.work.$id ) current_symposium.work_nr++; // only if saved +console.debug( 'current_symposium', current_symposium, this.work ) } this.work = new this.Work( this.master ); - if ( symposium ) { - this.work.symposium = symposium; + if ( current_symposium ) { + this.work.symposium = current_symposium; this.work.type = 'symposium'; } -console.debug( 'reset', symposium, this.work, this.$location.hashPath ); - this.$location.hashPath = ''; + this.last_saved_work = {}; +console.debug( 'reset', current_symposium, this.work, this.$location.hashPath ); }, save: function(){ - var l = this.$location; + var self = this; this.work.$save(function(work){ - l.hashPath = work._id; - work._changes = -1; // it seems that save call issues one ng:eval + self.$location.hashPath = work.$id; + + // save symposium to separate resource + if ( work.type == 'symposium' ) { + if ( ! self.symposium ) { + self.work.symposium.$id = work.$id; // reuse $id of first work for symposium + self.symposium = new self.Symposium( work.symposium ); + self.symposium.works = []; + } + self.symposium.works[ work.symposium.work_nr - 1 ] = work; + console.debug('save_symposium', self.symposium ); + self.symposium.$save(); + } + + self.last_saved_work = angular.copy(work); }); - } + }, + get_symposium: function() { this.symposium }, }; -

Prijava rada

+

Conference work submission

-
+
-

Vrsta rada:

- Simpozij +

Type of work:

+
- -Tema simpozija:
+
-Sažetak:
-
+ +
-Organizator: -
-[X] +Organizer: +
+[X] - +
-[Add another organizer] +[Add another organizer]

- Predavanje
- Poster
- Okrugli stol
+
+
+

-

Autori {{work.symposium.work_nr}}. rada

+
+Works which are part of this symposium: +
    +
  1. +{{w.title}} +{{w.title}} +
  2. +
+ +
+ +

Autors of {{work.symposium.work_nr}}. work

[X] - +
[Add another author] -
- Naslov:
+
- Sazetak:
-
+ +
- - - - + + + + - {{$invalidWidgets.visible()}} errors to fix in submission form +{{$invalidWidgets.visible()}} errors to fix in submission form -
- permalink to {{work.title}} -
+
+Permalink to {{work.title}} which you can bookmark +

Debug Information: {{$window.location.href}} -
work = {{work}}
-
master = {{master}}
-
+work = {{work}}
+
+dirty={{! last_saved_work.$equals(work)}}
+
+last_saved_work = {{last_saved_work}}
+
+master = {{master}}
+
 $id={{$id}}
 work.$id={{work.$id}}
-work._id={{work._id}}
+work.$id={{work.$id}}