X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=templates%2Fconference%2FWork.html.ep;h=e1d73c831cc7125c5ce13518093d40041431cc36;hb=9aabf01994845ae1102edd7dbba3e4e6f82b0f2a;hp=cf83fb0ca8810549e45d8d95d23d66202e448234;hpb=f37c11c0c16145a7897b9676b5e73ebdc8483dce;p=angular-mojolicious.git diff --git a/templates/conference/Work.html.ep b/templates/conference/Work.html.ep index cf83fb0..e1d73c8 100644 --- a/templates/conference/Work.html.ep +++ b/templates/conference/Work.html.ep @@ -8,11 +8,11 @@ function Work($resource){ title: '', abstract: '', authors:[ { name:'', surname:'', inst:'', email:'' } ], - symposium: { authors: [ {name:'', surname:'', inst:'', email:'' } ], work_nr: 1, }, - _changes: 0, + symposium: { organizer: [ {name:'', surname:'', inst:'', email:'' } ], work_nr: 1, }, }; - this.Work = $resource( '/data/conference/Work/:_id', { _id:'' } ); - this.Symposium = $resource( '/data/conference/Symposium/:_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); } @@ -21,17 +21,17 @@ 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 ) { +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) { - work._changes = -1 + 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 + 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 }, function() { self.work._changes-- }); + self.symposium = self.Symposium.get({ id: s_id }); } }); } @@ -43,8 +43,7 @@ console.debug( 'load symposium ', s_id ); var current_symposium = null; if ( this.work && this.work.type == 'symposium' ) { current_symposium = this.work.symposium; - if ( this.work._id ) current_symposium.work_nr++; - // if is required because reset is called twice -- once with saved records and once with new empty one + 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 ); @@ -52,24 +51,27 @@ console.debug( 'current_symposium', current_symposium, this.work ) this.work.symposium = current_symposium; this.work.type = 'symposium'; } + this.last_saved_work = {}; console.debug( 'reset', current_symposium, this.work, this.$location.hashPath ); }, save: function(){ var self = this; this.work.$save(function(work){ - self.$location.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' ) return; - 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 = []; + 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.symposium.works[ work.symposium.work_nr - 1 ] = work; - console.debug('save_symposium', self.symposium ); - self.symposium.$save(function() { work._changes-- }); + + self.last_saved_work = angular.copy(work); }); }, get_symposium: function() { this.symposium }, @@ -78,120 +80,100 @@ console.debug( 'reset', current_symposium, this.work, this.$location.hashPath ); -

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
+
+
+

-Radovi prijavljeni u ovom simpoziju: +Works which are part of this symposium:
    -
  1. {{w.title}}
  2. +
  3. +{{w.title}} +{{w.title}} +
-

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

+

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}}