Show specific error message in reflist when parent is missing

Bug: T372871
Change-Id: Idce84adc0100dfd73f02611f2825f3be1d2da223
This commit is contained in:
Adam Wight 2024-08-21 16:56:34 +02:00 committed by WMDE-Fisch
parent e9d2aecb5f
commit ab7d60ca05
4 changed files with 6 additions and 3 deletions

View file

@ -90,6 +90,7 @@
"messages": [
"cite-ve-referenceslist-isempty",
"cite-ve-referenceslist-isempty-default",
"cite-ve-referenceslist-missing-parent",
"cite-ve-referenceslist-missingref",
"cite-ve-referenceslist-missingref-in-list",
"cite-ve-referenceslist-missingreflist"

View file

@ -59,6 +59,7 @@
"cite-ve-reference-input-placeholder": "Search within current citations",
"cite-ve-referenceslist-isempty": "There are no references with the group \"$1\" on this page to include in this list.",
"cite-ve-referenceslist-isempty-default": "There are no references on this page to include in this list.",
"cite-ve-referenceslist-missing-parent": "There are subreferences with a missing parent reference.",
"cite-ve-referenceslist-missingref": "This reference is defined in a template or other generated block, and for now can only be edited in source mode.",
"cite-ve-referenceslist-missingref-in-list": "This reference is defined in a template or other generated block, and for now can only be previewed in source mode.",
"cite-ve-referenceslist-missingreflist": "This reference list is generated by a template.",

View file

@ -73,6 +73,7 @@
"cite-ve-reference-input-placeholder": "Placeholder text for reference search field: searches existing on-page references.",
"cite-ve-referenceslist-isempty": "Message that appears in the references list when there are no references on the page of that group.\n\nParameters:\n* $1 - reference-group name",
"cite-ve-referenceslist-isempty-default": "Message that appears in the references list when there are no references on the page in the default group.",
"cite-ve-referenceslist-missing-parent": "Message that appears in place of the parent reference in the reference list, when a subreference has no corresponding parent.",
"cite-ve-referenceslist-missingref": "Message that appears as a tooltip on the reference, for references that are generated by a template or are otherwise uneditable.\n\nSee also:\n* {{msg-mw|visualeditor-dialog-meta-languages-readonlynote}}",
"cite-ve-referenceslist-missingref-in-list": "Message that appears in the references list for references that are generated by a template or are otherwise uneditable.\n\nSee also:\n* {{msg-mw|visualeditor-dialog-meta-languages-readonlynote}}",
"cite-ve-referenceslist-missingreflist": "Message that appears as a tooltip on the reference list for lists that are generated by a template.",

View file

@ -275,6 +275,7 @@ ve.ce.MWReferencesListNode.prototype.renderListItem = function ( nodes, internal
// Exclude placeholders and references defined inside the references list node
( backRefNode ) => !backRefNode.getAttribute( 'placeholder' ) && !backRefNode.findParent( ve.dm.MWReferencesListNode )
);
const subrefs = groupRefs.subRefsByParent[ key ] || [];
const $li = $( '<li>' )
.css( '--footnote-number', `"${ groupRefs.getIndexLabel( key ) }."` )
@ -323,15 +324,14 @@ ve.ce.MWReferencesListNode.prototype.renderListItem = function ( nodes, internal
} );
}
} else {
// TODO: Special rendering for missing parent of orphaned subrefs?
$li.append(
$( '<span>' )
.addClass( 've-ce-mwReferencesListNode-muted' )
.text( ve.msg( 'cite-ve-referenceslist-missingref-in-list' ) )
.text( subrefs.length ? ve.msg( 'cite-ve-referenceslist-missing-parent' ) :
ve.msg( 'cite-ve-referenceslist-missingref-in-list' ) )
).addClass( 've-ce-mwReferencesListNode-missingRef' );
}
const subrefs = groupRefs.getSubrefs( key );
if ( subrefs.length ) {
$li.append(
$( '<ol>' ).append(