MozReview: 'maybeSave' unpublished comments within dropdown dialog (Bug 1291628). r?smacleod draft
authorDavid Walsh <dwalsh@mozilla.com>
Wed, 03 Aug 2016 13:17:59 -0500
changeset 62 102d440cadfc0a80051e3518c61741f9a12fa81a
parent 60 4eef0c7d274dd45e756d50ef938831fe5a1b8353
child 63 5263e5bb77923155c696e435c74a1ed1dad5b12c
child 66 f16e9374be7a5dc02f0eb2acefcccd01d0043870
push idunknown
push userunknown
push dateunknown
reviewerssmacleod
bugs1291628
MozReview: 'maybeSave' unpublished comments within dropdown dialog (Bug 1291628). r?smacleod MozReview-Commit-ID: 7sMNZ3YfWRL
reviewboard/reviewboard/static/rb/js/views/draftReviewBannerView_mozreview.js
--- a/reviewboard/reviewboard/static/rb/js/views/draftReviewBannerView_mozreview.js
+++ b/reviewboard/reviewboard/static/rb/js/views/draftReviewBannerView_mozreview.js
@@ -97,17 +97,19 @@ RB.DraftReviewBannerView = Backbone.View
              * means that we might miss out on some teardown that was
              * scheduled. We defer changing the location until the next tick
              * of the event loop to let any teardown occur.
              */
             _.defer(_.bind(function() {
                 // MozReview: Whacks <form> elements left over from the RDV
                 // Important so that browser's "Are you sure you want to leave
                 // this page" confirmation doesn't pop up.
-                this._RDVInstance.close();
+                if(this._RDVInstance) {
+                    this._RDVInstance.close();
+                }
 
                 window.location = this.model.get('parentObject').get('reviewURL');
             }, this));
         }, this);
     },
 
     /*
      * Handler for the Edit Review button.
@@ -170,20 +172,26 @@ RB.DraftReviewBannerView = Backbone.View
     },
 
     /*
      * Handler for the Publish button.
      *
      * Publishes the review.
      */
     _onPublishClicked: function() {
+      if(this._RDVInstance) {
+        this._RDVInstance._saveReview(true);
+      }
+      else {
         this.model.publish({
-            attrs: ['public']
+          attrs: ['public']
         });
-        return false;
+      }
+
+      return false;
     },
 
     /*
      * Handler for the Discard button.
      *
      * Prompts the user to confirm that they want the review discarded.
      * If they confirm, the review will be discarded.
      */