From 914e6905ed8924f7d9324594b2619820a4908ec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Dziewo=C5=84ski?= Date: Fri, 16 Nov 2018 01:08:29 +0100 Subject: [PATCH] ve.ui.MWTemplateDialog: Unbreak the logic to enable/disable "Apply" button I have moved this block of code to the wrong place in change 13675e4a81ea2508f60e9799836b8baecf317c1b. As a result, `this.loaded` was being set early, so the dialog was treating all of the pre-existing transclusion parts as newly inserted, and the "Apply" button was therefore always enabled. Bug: T209661 Change-Id: I3c1b45f91738ab6fc4a6f6d61ae5bf925c9a1bb5 --- .../ui/dialogs/ve.ui.MWTemplateDialog.js | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWTemplateDialog.js b/modules/ve-mw/ui/dialogs/ve.ui.MWTemplateDialog.js index 08a4761750..353c9d3ae9 100644 --- a/modules/ve-mw/ui/dialogs/ve.ui.MWTemplateDialog.js +++ b/modules/ve-mw/ui/dialogs/ve.ui.MWTemplateDialog.js @@ -449,7 +449,7 @@ ve.ui.MWTemplateDialog.prototype.getSetupProcess = function ( data ) { return ve.ui.MWTemplateDialog.super.prototype.getSetupProcess.call( this, data ) .next( function () { var template, promise, - bookletLayout = this.bookletLayout; + dialog = this; // Properties this.loaded = false; @@ -463,10 +463,10 @@ ve.ui.MWTemplateDialog.prototype.getSetupProcess = function ( data ) { } ); // Detach the form while building for performance - bookletLayout.$element.detach(); + this.bookletLayout.$element.detach(); // HACK: Prevent any setPage() calls (from #onReplacePart) from focussing stuff, it messes // with OOUI logic for marking fields as invalid (T199838). We set it back to true below. - bookletLayout.autoFocus = false; + this.bookletLayout.autoFocus = false; // Initialization if ( !this.selectedNode ) { @@ -494,15 +494,15 @@ ve.ui.MWTemplateDialog.prototype.getSetupProcess = function ( data ) { } this.actions.setAbilities( { apply: false, insert: false } ); - // Add missing required and suggested parameters to each transclusion. - this.transclusionModel.addPromptedParameters(); - - this.loaded = true; - this.$element.addClass( 've-ui-mwTemplateDialog-ready' ); - this.$body.append( bookletLayout.$element ); - return promise.then( function () { - bookletLayout.autoFocus = true; + // Add missing required and suggested parameters to each transclusion. + dialog.transclusionModel.addPromptedParameters(); + + dialog.loaded = true; + dialog.$element.addClass( 've-ui-mwTemplateDialog-ready' ); + dialog.$body.append( dialog.bookletLayout.$element ); + + dialog.bookletLayout.autoFocus = true; } ); }, this ); };