mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-11 16:49:26 +00:00
Render subrefs indented under parent
With this patch, we show reflists in a hierarchical view with subrefs listed under their parent. TODO in follow-up patch: numbering of subrefs is still incorrect. Change-Id: Ia82658af72caebd29241b9bd329d236ddc3f1e6d
This commit is contained in:
parent
d03d2d8d20
commit
2748f659a8
|
@ -244,7 +244,7 @@ ve.ce.MWReferencesListNode.prototype.update = function () {
|
|||
const topLevelNodes = groupedByParent[ '' ] || [];
|
||||
this.$reflist.append(
|
||||
topLevelNodes.map( ( node ) => this.renderListItem(
|
||||
nodes, internalList, refGroup, node
|
||||
nodes, internalList, groupedByParent, refGroup, node
|
||||
) )
|
||||
);
|
||||
|
||||
|
@ -259,11 +259,13 @@ ve.ce.MWReferencesListNode.prototype.update = function () {
|
|||
* @private
|
||||
* @param {Object} nodes Node group object, containing nodes and key order array
|
||||
* @param {ve.dm.InternalList} internalList Internal list
|
||||
* @param {Object.<string, ve.dm.MWReferenceNode[]>} groupedByParent Mapping
|
||||
* from parent ref name (or '' for top-level) to refs
|
||||
* @param {string} refGroup Reference group
|
||||
* @param {ve.dm.MWReferenceNode} node Reference node to render as a footnote body
|
||||
* @return {jQuery} Rendered list item
|
||||
*/
|
||||
ve.ce.MWReferencesListNode.prototype.renderListItem = function ( nodes, internalList, refGroup, node ) {
|
||||
ve.ce.MWReferencesListNode.prototype.renderListItem = function ( nodes, internalList, groupedByParent, refGroup, node ) {
|
||||
const listIndex = node.getAttribute( 'listIndex' );
|
||||
const key = internalList.keys[ listIndex ];
|
||||
const keyedNodes = ( nodes.keyedNodes[ key ] || [] )
|
||||
|
@ -317,6 +319,17 @@ ve.ce.MWReferencesListNode.prototype.renderListItem = function ( nodes, internal
|
|||
e.preventDefault();
|
||||
} );
|
||||
}
|
||||
const listKey = node.getAttribute( 'listKey' );
|
||||
const subrefs = groupedByParent[ listKey ] || [];
|
||||
if ( subrefs.length ) {
|
||||
$li.append(
|
||||
$( '<ol>' ).append(
|
||||
subrefs.map( ( subNode ) => this.renderListItem(
|
||||
nodes, internalList, groupedByParent, refGroup, subNode
|
||||
) )
|
||||
)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$li.append(
|
||||
$( '<span>' )
|
||||
|
|
Loading…
Reference in a new issue