reload symposium using _id stored in work
authorDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 5 Nov 2010 16:16:40 +0000 (17:16 +0100)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 5 Nov 2010 16:16:40 +0000 (17:16 +0100)
templates/conference/Work.html.ep

index c17aa3c..a0cd25d 100644 (file)
@@ -23,7 +23,15 @@ Work.prototype = {
                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 }, function(work) { work._changes = -1 })
+                       if (id) {
+                               var self = this;
+                               this.work = this.Work.get({ _id: id }, function(work) {
+                                       work._changes = -1
+                                       if ( work.symposium._id ) {
+                                               self.symposium = self.Symposium.get({ _id: work.symposium._id }, function() { self.work._changes-- });
+                                       }
+                               });
+                       }
                        else this.reset();
                }
        },
@@ -42,7 +50,6 @@ console.debug( 'current_symposium', current_symposium, this.work )
                        this.work.type = 'symposium';
                }
 console.debug( 'reset', current_symposium, this.work, this.$location.hashPath );
-               this.$location.hashPath = '';
        },
        save: function(){
                var self = this;
@@ -53,6 +60,7 @@ console.debug( 'reset', current_symposium, this.work, this.$location.hashPath );
                        // 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 = [];
                        }