Merge "Don't use the edit form when reusing a reference"

This commit is contained in:
jenkins-bot 2024-08-02 10:11:46 +00:00 committed by Gerrit Code Review
commit 0ad0baa001
2 changed files with 23 additions and 14 deletions

View file

@ -121,11 +121,11 @@ ve.ui.MWReferenceDialog.prototype.onReuseSearchResultsChoose = function ( item )
this.selectedNode = null;
}
this.referenceModel = ref;
this.editPanel.setFormFieldsFromRef( ref );
this.executeAction( 'insert' );
this.insertReference( ref );
ve.track( 'activity.' + this.constructor.static.name, { action: 'reuse-choose' } );
this.close( { action: 'insert' } );
};
/**
@ -196,28 +196,36 @@ ve.ui.MWReferenceDialog.prototype.openReusePanel = function () {
ve.track( 'activity.' + this.constructor.static.name, { action: 'dialog-open-reuse' } );
};
/**
* Insert a reference at the end of the selection, could also be a reuse of an exising reference
*
* @private
* @param {ve.dm.MWReferenceModel} ref
*/
ve.ui.MWReferenceDialog.prototype.insertReference = function ( ref ) {
const surfaceModel = this.getFragment().getSurface();
if ( !ref.findInternalItem( surfaceModel ) ) {
ref.insertInternalItem( surfaceModel );
}
// Collapse returns a new fragment, so update this.fragment
this.fragment = this.getFragment().collapseToEnd();
ref.insertReferenceNode( this.getFragment() );
};
/**
* @override
*/
ve.ui.MWReferenceDialog.prototype.getActionProcess = function ( action ) {
if ( action === 'insert' || action === 'done' ) {
return new OO.ui.Process( () => {
const surfaceModel = this.getFragment().getSurface();
this.referenceModel.setGroup( this.editPanel.referenceGroupInput.getValue() );
// Insert reference (will auto-create an internal item if needed)
if ( !( this.selectedNode instanceof ve.dm.MWReferenceNode ) ) {
if ( !this.referenceModel.findInternalItem( surfaceModel ) ) {
this.referenceModel.insertInternalItem( surfaceModel );
}
// Collapse returns a new fragment, so update this.fragment
this.fragment = this.getFragment().collapseToEnd();
this.referenceModel.insertReferenceNode( this.getFragment() );
this.insertReference( this.referenceModel );
}
// Update internal item
this.referenceModel.updateInternalItem( surfaceModel );
this.referenceModel.updateInternalItem( this.getFragment().getSurface() );
this.close( { action: action } );
} );

View file

@ -198,6 +198,7 @@ ve.ui.MWReferenceEditPanel.prototype.setReferenceForEditing = function ( ref ) {
};
/**
* @private
* @param {ve.dm.MWReferenceModel} ref
*/
ve.ui.MWReferenceEditPanel.prototype.setFormFieldsFromRef = function ( ref ) {