mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-12-03 19:16:09 +00:00
Merge "Show error message in ref edit dialog for orphaned subref"
This commit is contained in:
commit
1bbae40ca5
|
@ -261,18 +261,21 @@ ve.ui.MWReferenceEditPanel.prototype.updateReuseWarningFromRef = function ( ref
|
|||
* @param {ve.dm.MWReferenceModel} ref
|
||||
*/
|
||||
ve.ui.MWReferenceEditPanel.prototype.updateExtendsWarningFromRef = function ( ref ) {
|
||||
const mainRefId = this.internalList.keys.indexOf( ref.extendsRef );
|
||||
if ( mainRefId !== -1 ) {
|
||||
const itemNode = this.internalList.getItemNode( mainRefId );
|
||||
const $parentRefPreview = new ve.ui.MWPreviewElement( itemNode, { useView: true } ).$element;
|
||||
if ( ref.extendsRef ) {
|
||||
const mainRefId = this.internalList.keys.indexOf( ref.extendsRef );
|
||||
this.extendsWarning.setLabel(
|
||||
$( '<p>' )
|
||||
.text( mw.msg( 'cite-ve-dialog-reference-editing-extends' ) )
|
||||
.append( $parentRefPreview )
|
||||
.append( mainRefId === -1 ?
|
||||
$( '<div>' )
|
||||
.addClass( 've-ui-mwReferenceContextItem-muted' )
|
||||
.text( ve.msg( 'cite-ve-dialog-reference-missing-parent-ref' ) ) :
|
||||
new ve.ui.MWPreviewElement( this.internalList.getItemNode( mainRefId ), { useView: true } ).$element )
|
||||
);
|
||||
this.extendsWarning.toggle( true );
|
||||
} else {
|
||||
this.extendsWarning.toggle( false );
|
||||
}
|
||||
|
||||
this.extendsWarning.toggle( mainRefId !== -1 );
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -46,12 +46,13 @@ QUnit.test( 'sub refs', ( assert ) => {
|
|||
|
||||
assert.false( editPanel.reuseWarning.isVisible() );
|
||||
assert.true( editPanel.extendsWarning.isVisible() );
|
||||
assert.true( !!editPanel.extendsWarning.getLabel().text().indexOf( 'Bar' ) );
|
||||
assert.true( editPanel.extendsWarning.getLabel().text().indexOf( 'Bar' ) !== -1 );
|
||||
|
||||
// test sub ref with missing main ref
|
||||
ref.extendsRef = 'literal/notexist';
|
||||
editPanel.setReferenceForEditing( ref );
|
||||
|
||||
assert.false( editPanel.reuseWarning.isVisible() );
|
||||
assert.false( editPanel.extendsWarning.isVisible() );
|
||||
assert.true( editPanel.extendsWarning.isVisible() );
|
||||
assert.true( editPanel.extendsWarning.getLabel().text().indexOf( 'cite-ve-dialog-reference-missing-parent-ref' ) !== -1 );
|
||||
} );
|
||||
|
|
Loading…
Reference in a new issue