Merge "Use new upstream defaults for actions"

This commit is contained in:
jenkins-bot 2019-02-22 14:53:52 +00:00 committed by Gerrit Code Review
commit 7c5906bcdf
3 changed files with 14 additions and 31 deletions

View file

@ -122,7 +122,7 @@ ve.ui.MWCitationDialog.prototype.updateTitle = function () {
*/
ve.ui.MWCitationDialog.prototype.setApplicableStatus = function () {
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 'done' if no changes were made (this is okay for us), and
// disables 'insert' if transclusion is empty (but it is never empty in our case).
// Instead, disable 'insert' if no parameters were added.
this.actions.setAbilities( { insert: this.hasUsefulParameter() } );
@ -155,7 +155,7 @@ ve.ui.MWCitationDialog.prototype.getActionProcess = function ( action ) {
var dialog = this;
if (
this.inDialog !== 'reference' &&
( action === 'apply' || action === 'insert' )
( action === 'done' || action === 'insert' )
) {
return new OO.ui.Process( function () {
var deferred = $.Deferred();

View file

@ -36,7 +36,7 @@ ve.ui.MWReferenceDialog.static.title =
ve.ui.MWReferenceDialog.static.actions = [
{
action: 'apply',
action: 'done',
label: OO.ui.deferMsg( 'visualeditor-dialog-action-apply' ),
flags: [ 'progressive', 'primary' ],
modes: 'edit'
@ -147,9 +147,9 @@ ve.ui.MWReferenceDialog.prototype.documentHasContent = function () {
/*
* Determine whether any changes have been made (and haven't been undone).
*
* @return {boolean} Dialog can be applied
* @return {boolean} Changes have been made
*/
ve.ui.MWReferenceDialog.prototype.canApply = function () {
ve.ui.MWReferenceDialog.prototype.isModified = function () {
return this.documentHasContent() &&
( this.referenceTarget.hasBeenModified() ||
this.referenceGroupInput.getValue() !== this.originalGroup );
@ -162,7 +162,7 @@ ve.ui.MWReferenceDialog.prototype.onTargetChange = function () {
var hasContent = this.documentHasContent();
this.actions.setAbilities( {
apply: this.canApply(),
done: this.isModified(),
insert: hasContent,
select: !hasContent && !this.search.isIndexEmpty()
} );
@ -173,7 +173,7 @@ ve.ui.MWReferenceDialog.prototype.onTargetChange = function () {
*/
ve.ui.MWReferenceDialog.prototype.onReferenceGroupInputChange = function () {
this.actions.setAbilities( {
apply: this.canApply()
done: this.isModified()
} );
};
@ -349,7 +349,7 @@ ve.ui.MWReferenceDialog.prototype.useExistingReference = function ( action ) {
* @inheritdoc
*/
ve.ui.MWReferenceDialog.prototype.getActionProcess = function ( action ) {
if ( action === 'insert' || action === 'apply' ) {
if ( action === 'insert' || action === 'done' ) {
return new OO.ui.Process( function () {
var surfaceModel = this.getFragment().getSurface();
@ -371,7 +371,7 @@ ve.ui.MWReferenceDialog.prototype.getActionProcess = function ( action ) {
this.close( { action: action } );
}, this );
} else if ( action === 'back' ) {
this.actions.setMode( this.selectedNode ? 'edit' : 'insert' );
this.actions.setMode( this.getMode() );
this.panels.setItem( this.editPanel );
this.editPanel.$element.find( '.ve-ce-documentNode' )[ 0 ].focus();
} else if ( action === 'select' || action === 'insert-select' ) {
@ -396,10 +396,9 @@ ve.ui.MWReferenceDialog.prototype.getSetupProcess = function ( data ) {
);
} else {
this.useReference( null );
this.actions.setAbilities( { apply: false, insert: false } );
this.actions.setAbilities( { done: false, insert: false } );
}
this.actions.setMode( this.selectedNode ? 'edit' : 'insert' );
this.search.setInternalList( this.getFragment().getDocument().getInternalList() );
if ( data.useExisting ) {
@ -411,7 +410,7 @@ ve.ui.MWReferenceDialog.prototype.getSetupProcess = function ( data ) {
this.actions.setAbilities( {
select: !( this.selectedNode instanceof ve.dm.MWReferenceNode ) &&
!this.search.isIndexEmpty(),
apply: false
done: false
} );
this.referenceGroupInput.populateMenu( this.getFragment().getDocument().getInternalList() );

View file

@ -34,20 +34,6 @@ ve.ui.MWReferencesListDialog.static.modelClasses = [ ve.dm.MWReferencesListNode
ve.ui.MWReferencesListDialog.static.size = 'medium';
ve.ui.MWReferencesListDialog.static.actions = [
{
action: 'apply',
label: OO.ui.deferMsg( 'visualeditor-dialog-action-apply' ),
flags: [ 'progressive', 'primary' ],
modes: 'edit'
},
{
label: OO.ui.deferMsg( 'visualeditor-dialog-action-cancel' ),
flags: [ 'safe', 'back' ],
modes: 'edit'
}
];
/* Methods */
/**
@ -103,10 +89,10 @@ ve.ui.MWReferencesListDialog.prototype.onChange = function () {
};
/**
* Update the 'apply' action according to whether there are changes
* Update the 'done' action according to whether there are changes
*/
ve.ui.MWReferencesListDialog.prototype.updateActions = function () {
this.actions.setAbilities( { apply: this.isModified() } );
this.actions.setAbilities( { done: this.isModified() } );
};
/**
@ -132,7 +118,7 @@ ve.ui.MWReferencesListDialog.prototype.isModified = function () {
* @inheritdoc
*/
ve.ui.MWReferencesListDialog.prototype.getActionProcess = function ( action ) {
if ( action === 'apply' ) {
if ( action === 'done' ) {
return new OO.ui.Process( function () {
var refGroup, listGroup, isResponsive, mwData, attrChanges, doc,
surfaceModel = this.getFragment().getSurface();
@ -185,8 +171,6 @@ ve.ui.MWReferencesListDialog.prototype.getSetupProcess = function ( data ) {
throw new Error( 'Cannot open dialog: references list must be selected' );
}
this.actions.setMode( 'edit' );
this.groupInput.setValue( this.selectedNode.getAttribute( 'refGroup' ) );
this.groupInput.populateMenu( this.getFragment().getDocument().getInternalList() );