diff --git a/modules/ve-cite/ve.ui.MWReferenceDialog.js b/modules/ve-cite/ve.ui.MWReferenceDialog.js index 62118e5ad..b555f039a 100644 --- a/modules/ve-cite/ve.ui.MWReferenceDialog.js +++ b/modules/ve-cite/ve.ui.MWReferenceDialog.js @@ -103,20 +103,21 @@ ve.ui.MWReferenceDialog.prototype.onReuseSearchResultsExtends = function ( origi newRef.extendsRef = originalRef.getListKey(); newRef.group = originalRef.getGroup(); - this.getManager() - .openWindow( 'setExtendsContent', { - originalRef: originalRef, - newRef: newRef, - internalList: this.getFragment().getDocument().getInternalList() - } ) - .closing.then( ( data ) => { - if ( data && data.action && data.action === 'insert' ) { - newRef.insertInternalItem( this.getFragment().getSurface() ); - newRef.insertReferenceNode( this.getFragment() ); + this.actions.setMode( 'insert' ); + this.panels.setItem( this.editPanel ); + this.title.setLabel( ve.msg( 'cite-ve-dialog-reference-title-add-details' ) ); - this.close( { action: 'extends-choose' } ); - } - } ); + const docRefs = ve.dm.MWDocumentReferences.static.refsForDoc( + this.getFragment().getDocument() + ); + this.editPanel.setDocumentReferences( docRefs ); + + this.actions.setAbilities( { insert: false } ); + + this.editPanel.setReferenceForEditing( newRef ); + this.editPanel.setReadOnly( this.isReadOnly() ); + + this.trackedInputChange = false; }; /** diff --git a/modules/ve-cite/ve.ui.MWReferenceEditPanel.js b/modules/ve-cite/ve.ui.MWReferenceEditPanel.js index f4bbc8d3e..9ec07badf 100644 --- a/modules/ve-cite/ve.ui.MWReferenceEditPanel.js +++ b/modules/ve-cite/ve.ui.MWReferenceEditPanel.js @@ -41,6 +41,13 @@ ve.ui.MWReferenceEditPanel = function VeUiMWReferenceEditPanel( config ) { * @member {string|null} */ this.originalGroup = null; + /** + * If the edit panel is used to insert a sub-reference + * + * @member {boolean} + * @private + */ + this.isInsertingSubRef = false; // Create content editor this.referenceTarget = ve.init.target.createTargetWidget( @@ -216,6 +223,7 @@ ve.ui.MWReferenceEditPanel.prototype.setDocumentReferences = function ( docRefs */ ve.ui.MWReferenceEditPanel.prototype.setReferenceForEditing = function ( ref ) { this.referenceModel = ref; + this.isInsertingSubRef = ref.extendsRef && !ref.getDocument().data.hasContent(); this.setFormFieldsFromRef( ref ); this.updateReuseWarningFromRef( ref ); @@ -240,6 +248,12 @@ ve.ui.MWReferenceEditPanel.prototype.getReferenceFromEditing = function () { ve.ui.MWReferenceEditPanel.prototype.setFormFieldsFromRef = function ( ref ) { this.referenceTarget.setDocument( ref.getDocument() ); + if ( this.isInsertingSubRef ) { + this.referenceTarget.getSurface().setPlaceholder( + ve.msg( 'cite-ve-dialog-reference-editing-add-details-placeholder' ) + ); + } + this.optionsFieldset.toggle( !ref.extendsRef ); this.originalGroup = ref.getGroup(); @@ -274,7 +288,10 @@ ve.ui.MWReferenceEditPanel.prototype.updateExtendsWarningFromRef = function ( re .getInternalModelNode( ref.extendsRef ); this.extendsWarning.setLabel( $( '
' ) - .text( ve.msg( 'cite-ve-dialog-reference-editing-extends' ) ) + .text( ve.msg( this.isInsertingSubRef ? + 'cite-ve-dialog-reference-editing-add-details' : + 'cite-ve-dialog-reference-editing-extends' + ) ) .append( parentNode ? new ve.ui.MWPreviewElement( parentNode, { useView: true } ).$element : $( '