mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-23 22:45:20 +00:00
Merge "Use the default edit dialog to create a sub-ref"
This commit is contained in:
commit
91bf6c9efd
|
@ -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;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -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(
|
||||
$( '<p>' )
|
||||
.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 :
|
||||
$( '<div>' )
|
||||
|
@ -282,6 +299,7 @@ ve.ui.MWReferenceEditPanel.prototype.updateExtendsWarningFromRef = function ( re
|
|||
.text( ve.msg( 'cite-ve-dialog-reference-missing-parent-ref' ) )
|
||||
)
|
||||
);
|
||||
this.extendsWarning.setIcon( this.isInsertingSubRef ? null : 'alert' );
|
||||
this.extendsWarning.toggle( true );
|
||||
} else {
|
||||
this.extendsWarning.toggle( false );
|
||||
|
|
Loading…
Reference in a new issue