Show error placeholder in context item for orphaned subref

Bug: T372871
Change-Id: Ifc183b33793fb8e5c736488569f47838c138ce2e
This commit is contained in:
Adam Wight 2024-08-21 16:57:27 +02:00
parent 3c4d198eaa
commit 438eed5c54
4 changed files with 7 additions and 1 deletions

View file

@ -157,6 +157,7 @@
"cite-ve-dialog-reference-editing-reused",
"cite-ve-dialog-reference-editing-reused-long",
"cite-ve-dialog-reference-editing-extends",
"cite-ve-dialog-reference-missing-parent-ref",
"cite-ve-dialog-reference-options-group-label",
"cite-ve-dialog-reference-options-group-placeholder",
"cite-ve-dialog-reference-options-name-label",

View file

@ -38,6 +38,7 @@
"cite-ve-dialog-reference-editing-reused-long": "This reference is used {{PLURAL:$1|once|2=twice|$1 times}} on this page. Changes made here will be applied in all places where this reference is reused.",
"cite-ve-dialog-reference-editing-extends": "This is an extension of another reference.",
"cite-ve-dialog-reference-editing-extends-long": "This is an extension of another reference \"$1\".",
"cite-ve-dialog-reference-missing-parent-ref": "The parent reference cannot be found for this subreference.",
"cite-ve-dialog-reference-options-group-label": "Use this group",
"cite-ve-dialog-reference-options-group-placeholder": "General references",
"cite-ve-dialog-reference-options-name-label": "Re-use by this name",

View file

@ -52,6 +52,7 @@
"cite-ve-dialog-reference-editing-reused-long": "Text shown at the top of the reference dialog when editing a reference that is used multiple times. This is a more detailed version of {{msg-mw|cite-ve-dialog-reference-editing-reused}}.\n\nParameters:\n* $1 - Number of times used. This is always greater than 1.\n\nNote that the explicit '2' value is useful in English, but not necessarily for other languages. Don't translate the 2 value if it's not useful for your language.",
"cite-ve-dialog-reference-editing-extends": "Text shown in reference context menu when editing a reference that extends another reference.\n\nA longer message, adding the precision the other reference, is in {{msg-mw|Cite-ve-dialog-reference-editing-extends-long}}.",
"cite-ve-dialog-reference-editing-extends-long": "Text shown at the top of the reference dialog when editing a reference that extends another reference. This is a more detailed version of {{msg-mw|cite-ve-dialog-reference-editing-extends}}.\n\nParameter:\n* $1 the name of the parent reference",
"cite-ve-dialog-reference-missing-parent-ref": "Message that appears in popup dialogs when a subreference is missing its parent reference.",
"cite-ve-dialog-reference-options-group-label": "Label for the reference group input",
"cite-ve-dialog-reference-options-group-placeholder": "Placeholder for the reference group input",
"cite-ve-dialog-reference-options-name-label": "Label for the reference name input",

View file

@ -135,7 +135,10 @@ ve.ui.MWReferenceContextItem.prototype.getParentRef = function () {
}
const list = this.getFragment().getDocument().getInternalList();
const itemNode = list.getItemNode( list.keys.indexOf( extendsRef ) );
return new ve.ui.MWPreviewElement( itemNode, { useView: true } ).$element;
return itemNode ? new ve.ui.MWPreviewElement( itemNode, { useView: true } ).$element :
$( '<div>' )
.addClass( 've-ui-mwReferenceContextItem-muted' )
.text( ve.msg( 'cite-ve-dialog-reference-missing-parent-ref' ) );
};
/**