From: Dobrica Pavlinusic Date: Sun, 7 Nov 2010 08:58:56 +0000 (+0100) Subject: fix first save X-Git-Url: http://git.rot13.org/?p=angular-mojolicious.git;a=commitdiff_plain;h=fffe39e57bbe78da952ff3c91b0d1a48ef192295 fix first save we need to copy data into last_saved_work after we modify symposium --- diff --git a/templates/conference/Work.html.ep b/templates/conference/Work.html.ep index f75bd24..96cb3c3 100644 --- a/templates/conference/Work.html.ep +++ b/templates/conference/Work.html.ep @@ -58,18 +58,20 @@ console.debug( 'reset', current_symposium, this.work, this.$location.hashPath ); var self = this; this.work.$save(function(work){ self.$location.hashPath = work._id; - self.last_saved_work = angular.copy(work); // 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(); + + self.last_saved_work = angular.copy(work); }); }, get_symposium: function() { this.symposium },