mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-29 00:30:44 +00:00
Merge "Disable Apply Changes in reference dialog until changes have been made"
This commit is contained in:
commit
7a0e11ed0c
|
@ -137,13 +137,20 @@ ve.ui.MWReferenceDialog.static.getImportRules = function () {
|
||||||
|
|
||||||
/* Methods */
|
/* Methods */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the reference document we're editing has any content.
|
||||||
|
* @return {boolean} Document has content
|
||||||
|
*/
|
||||||
|
ve.ui.MWReferenceDialog.prototype.documentHasContent = function () {
|
||||||
|
// TODO: Check for other types of empty, e.g. only whitespace?
|
||||||
|
return this.referenceModel.getDocument().data.countNonInternalElements() > 2;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle reference surface change events
|
* Handle reference surface change events
|
||||||
*/
|
*/
|
||||||
ve.ui.MWReferenceDialog.prototype.onDocumentTransact = function () {
|
ve.ui.MWReferenceDialog.prototype.onDocumentTransact = function () {
|
||||||
var data = this.referenceModel.getDocument().data,
|
var hasContent = this.documentHasContent();
|
||||||
// TODO: Check for other types of empty, e.g. only whitespace?
|
|
||||||
hasContent = data.countNonInternalElements() > 2;
|
|
||||||
|
|
||||||
this.actions.setAbilities( {
|
this.actions.setAbilities( {
|
||||||
apply: hasContent,
|
apply: hasContent,
|
||||||
|
@ -152,6 +159,15 @@ ve.ui.MWReferenceDialog.prototype.onDocumentTransact = function () {
|
||||||
} );
|
} );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle reference group input change events
|
||||||
|
*/
|
||||||
|
ve.ui.MWReferenceDialog.prototype.onReferenceGroupInputChange = function () {
|
||||||
|
this.actions.setAbilities( {
|
||||||
|
apply: this.documentHasContent()
|
||||||
|
} );
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle search select events.
|
* Handle search select events.
|
||||||
*
|
*
|
||||||
|
@ -277,6 +293,7 @@ ve.ui.MWReferenceDialog.prototype.initialize = function () {
|
||||||
$overlay: this.$overlay,
|
$overlay: this.$overlay,
|
||||||
emptyGroupName: ve.msg( 'visualeditor-dialog-reference-options-group-placeholder' )
|
emptyGroupName: ve.msg( 'visualeditor-dialog-reference-options-group-placeholder' )
|
||||||
} );
|
} );
|
||||||
|
this.referenceGroupInput.input.connect( this, { change: 'onReferenceGroupInputChange' } );
|
||||||
this.referenceGroupField = new OO.ui.FieldLayout( this.referenceGroupInput, {
|
this.referenceGroupField = new OO.ui.FieldLayout( this.referenceGroupInput, {
|
||||||
$: this.$,
|
$: this.$,
|
||||||
align: 'top',
|
align: 'top',
|
||||||
|
@ -375,7 +392,8 @@ ve.ui.MWReferenceDialog.prototype.getSetupProcess = function ( data ) {
|
||||||
// If not, set disabled based on whether or not there are any existing ones.
|
// If not, set disabled based on whether or not there are any existing ones.
|
||||||
this.actions.setAbilities( {
|
this.actions.setAbilities( {
|
||||||
select: !( this.selectedNode instanceof ve.dm.MWReferenceNode ) &&
|
select: !( this.selectedNode instanceof ve.dm.MWReferenceNode ) &&
|
||||||
!this.search.isIndexEmpty()
|
!this.search.isIndexEmpty(),
|
||||||
|
apply: false
|
||||||
} );
|
} );
|
||||||
|
|
||||||
this.referenceGroupInput.populateMenu( this.getFragment().getDocument().getInternalList() );
|
this.referenceGroupInput.populateMenu( this.getFragment().getDocument().getInternalList() );
|
||||||
|
|
Loading…
Reference in a new issue