mozreview: update model when adding reviewers to trigger draft banner display (bug 1236999); r=smacleod
authorGregory Szorc <gps@mozilla.com>
Wed, 06 Jan 2016 13:04:54 -0800
changeset 362077 96657fb045a9a38fa63342d249c02315d50a0575
parent 362076 fba5aff085482be39febe8f7b851eb2bc1a853e7
child 362078 04fe92f9ec0c4dec280b5bb9cf06c0778bebe000
push id16998
push userrwood@mozilla.com
push dateMon, 02 May 2016 19:42:03 +0000
reviewerssmacleod
bugs1236999
mozreview: update model when adding reviewers to trigger draft banner display (bug 1236999); r=smacleod Review Board 2.5 added a check in the review request view's showBanner() that this.model.get('hasDraft') is true. For reasons I don't fully understand, the model isn't getting refreshed when we set a draft field on it. This patch sets the hasDraft attribute manually. I think ideally we'd refresh the view's model instance, but I'm not sure how to do that.
pylib/mozreview/mozreview/static/mozreview/js/commits.js
--- a/pylib/mozreview/mozreview/static/mozreview/js/commits.js
+++ b/pylib/mozreview/mozreview/static/mozreview/js/commits.js
@@ -139,16 +139,22 @@
                 .html(error.errorText);
 
               // Revert the list back to what we started with.
               $(this).text(originalContents);
             },
             success: function() {
               MozReview.parentEditor.decr("editCount");
               MozReview.parentEditor.set('public', false);
+              // Our draft relies on a field that isn't part of RB's front-end
+              // model, so changes aren't picked up by the model automatically.
+              // Manually record a draft exists so the banner will be displayed.
+              var view = RB.PageManager.getPage().reviewRequestEditorView;
+              view.model.set("hasDraft", true);
+
               MozReview.parentEditor.trigger('saved');
 
             }
           }, this);
       }
     });
   }