Merge "ve.ui.MWCitationDialog: Unbreak the logic to enable/disable actions"

This commit is contained in:
jenkins-bot 2019-01-03 18:41:09 +00:00 committed by Gerrit Code Review
commit 6a51ea98b3

View file

@ -103,38 +103,15 @@ ve.ui.MWCitationDialog.prototype.getSetupProcess = function ( data ) {
}, this ); }, this );
}; };
ve.ui.MWCitationDialog.prototype.onTransclusionReady = function () {
// Parent method
ve.ui.MWCitationDialog.super.prototype.onTransclusionReady.call( this );
if ( !this.hasUsefulParameter() ) {
this.actions.setAbilities( { apply: false, insert: false } );
}
};
/** /**
* @inheritdoc * @inheritdoc
*/ */
ve.ui.MWCitationDialog.prototype.setPageByName = function ( param ) { ve.ui.MWCitationDialog.prototype.setApplicableStatus = function () {
var hasUsefulParameter = this.hasUsefulParameter(); ve.ui.MWCitationDialog.super.prototype.setApplicableStatus.call( this );
// Parent method disables 'apply' if no changes were made (this is okay for us), and
// Parent method // disables 'insert' if transclusion is empty (but it is never empty in our case).
ve.ui.MWCitationDialog.super.prototype.setPageByName.call( this, param ); // Instead, disable 'insert' if no parameters were added.
this.actions.setAbilities( { insert: this.hasUsefulParameter() } );
this.actions.setAbilities( { apply: hasUsefulParameter, insert: hasUsefulParameter } );
};
/**
* @inheritdoc
*/
ve.ui.MWCitationDialog.prototype.onAddParameterBeforeLoad = function ( page ) {
var dialog = this,
hasUsefulParameter = this.hasUsefulParameter();
page.preLoad = true;
page.valueInput.on( 'change', function () {
dialog.actions.setAbilities( { apply: hasUsefulParameter, insert: hasUsefulParameter } );
} );
}; };
/** /**
@ -149,7 +126,7 @@ ve.ui.MWCitationDialog.prototype.hasUsefulParameter = function () {
page = this.bookletLayout.pages[ name ]; page = this.bookletLayout.pages[ name ];
if ( if (
page instanceof ve.ui.MWParameterPage && page instanceof ve.ui.MWParameterPage &&
( !page.preLoad || page.valueInput.getValue() !== '' ) page.valueInput.getValue() !== ''
) { ) {
return true; return true;
} }