Merge branch 'master' of github.com:dpavlin/angular-mojolicious
[angular-mojolicious.git] / templates / conference / Work.html.ep
index c17aa3c..a0eb396 100644 (file)
@@ -23,7 +23,18 @@ 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.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 }, function() { self.work._changes-- });
+                                       }
+                               });
+                       }
                        else this.reset();
                }
        },
@@ -42,7 +53,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 +63,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 = [];
                        }
@@ -72,7 +83,7 @@ console.debug( 'reset', current_symposium, this.work, this.$location.hashPath );
 <div ng:controller="Work" ng:init="$window.$root = this; work._changes = 0" ng:eval="work._changes = work._changes + 1">
 
 <h2>Vrsta rada:</h2>
-<input type="radio" name="work.type" value="symposium"> Simpozij
+<label><input type="radio" name="work.type" value="symposium"> Simpozij</label>
 
 <div ng:show="work.type == 'symposium'" style="background:#f0f0f0">
 <!--
@@ -100,9 +111,9 @@ Organizator:
 
 <br/>
 
-       <input type="radio" name="work.type" value="lecture"> Predavanje <br/>
-       <input type="radio" name="work.type" value="poster"> Poster <br/>
-       <input type="radio" name="work.type" value="round"> Okrugli stol <br/>
+<label><input type="radio" name="work.type" value="lecture"> Predavanje </label><br/>
+<label><input type="radio" name="work.type" value="poster"> Poster </label><br/>
+<label><input type="radio" name="work.type" value="round"> Okrugli stol </label><br/>
 
 <hr>