ve.ui.MWTemplateDialog: Unbreak the logic to enable/disable "Apply" button

I have moved this block of code to the wrong place in change
13675e4a81. 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
This commit is contained in:
Bartosz Dziewoński 2018-11-16 01:08:29 +01:00
parent 2e19e941a5
commit 914e6905ed

View file

@ -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 );
};