Merge "Don't allow inserting blank citations"

This commit is contained in:
jenkins-bot 2014-06-04 22:57:27 +00:00 committed by Gerrit Code Review
commit 0ce474ab47
2 changed files with 57 additions and 0 deletions

View file

@ -160,6 +160,54 @@ ve.ui.MWCitationDialog.prototype.getSetupProcess = function ( data ) {
}, this );
};
ve.ui.MWCitationDialog.prototype.onTransclusionReady = function () {
// Parent method
ve.ui.MWCitationDialog.super.prototype.onTransclusionReady.call( this );
if ( !this.hasUsefulParameter() ) {
this.applyButton.setDisabled( true );
}
};
/**
* @inheritdoc
*/
ve.ui.MWCitationDialog.prototype.setPageByName = function ( param ) {
// Parent method
ve.ui.MWCitationDialog.super.prototype.setPageByName.call( this, param );
this.applyButton.setDisabled( !this.hasUsefulParameter() );
};
/**
* @inheritdoc
*/
ve.ui.MWCitationDialog.prototype.onAddParameterBeforeLoad = function ( page ) {
var citeDialog = this;
page.preLoad = true;
page.valueInput.on( 'change', function () {
citeDialog.applyButton.setDisabled( !citeDialog.hasUsefulParameter() );
} );
};
/**
* Works out whether there are any set parameters that aren't just placeholders
* @return boolean
*/
ve.ui.MWCitationDialog.prototype.hasUsefulParameter = function () {
var foundUseful = false;
$.each( this.bookletLayout.pages, function () {
if (
this instanceof ve.ui.MWParameterPage &&
( !this.preLoad || this.valueInput.getValue() !== '' )
) {
foundUseful = true;
return false;
}
} );
return foundUseful;
};
/**
* @inheritdoc
*/

View file

@ -149,9 +149,18 @@ ve.ui.MWTemplateDialog.prototype.onAddParameter = function ( param ) {
this.bookletLayout.addPages( [ page ], this.transclusionModel.getIndex( param ) );
if ( this.loaded && !this.preventReselection ) {
this.setPageByName( param.getId() );
} else {
this.onAddParameterBeforeLoad( page );
}
};
/**
* Additional handling of parameter addition events before loading.
*
* @param {ve.ui.MWParameterPage} page Parameter page object
*/
ve.ui.MWTemplateDialog.prototype.onAddParameterBeforeLoad = function () {};
/**
* Handle remove param events.
*