diff --git a/modules/ve-cite/ve.ui.MWReferenceEditPanel.js b/modules/ve-cite/ve.ui.MWReferenceEditPanel.js index 8f8e507c1..339d3c8a4 100644 --- a/modules/ve-cite/ve.ui.MWReferenceEditPanel.js +++ b/modules/ve-cite/ve.ui.MWReferenceEditPanel.js @@ -200,7 +200,8 @@ ve.ui.MWReferenceEditPanel.static.getImportRules = function () { */ ve.ui.MWReferenceEditPanel.prototype.setInternalList = function ( internalList ) { this.internalList = internalList; - this.referenceGroupInput.populateMenu( this.internalList ); + const docRefs = ve.dm.MWDocumentReferences.static.refsForDoc( internalList.getDocument() ); + this.referenceGroupInput.populateMenu( docRefs.getAllGroupNames() ); }; /** diff --git a/modules/ve-cite/ve.ui.MWReferenceGroupInputWidget.js b/modules/ve-cite/ve.ui.MWReferenceGroupInputWidget.js index 93227da94..c3b09a037 100644 --- a/modules/ve-cite/ve.ui.MWReferenceGroupInputWidget.js +++ b/modules/ve-cite/ve.ui.MWReferenceGroupInputWidget.js @@ -38,18 +38,18 @@ OO.inheritClass( ve.ui.MWReferenceGroupInputWidget, OO.ui.ComboBoxInputWidget ); /** * Populate the reference group menu * - * @param {ve.dm.InternalList} internalList Internal list with which to populate the menu + * @param {string[]} groups Group names */ -ve.ui.MWReferenceGroupInputWidget.prototype.populateMenu = function ( internalList ) { +ve.ui.MWReferenceGroupInputWidget.prototype.populateMenu = function ( groups ) { const items = [ new OO.ui.MenuOptionWidget( { data: '', label: this.emptyGroupName } ) ]; - for ( const groupName in internalList.getNodeGroups() ) { + groups.forEach( ( groupName ) => { const match = groupName.match( /^mwReference\/(.+)/ ); if ( match ) { items.push( new OO.ui.MenuOptionWidget( { data: match[ 1 ], label: match[ 1 ] } ) ); } - } + } ); this.menu.clearItems().addItems( items ).toggle( false ); }; diff --git a/modules/ve-cite/ve.ui.MWReferencesListDialog.js b/modules/ve-cite/ve.ui.MWReferencesListDialog.js index 4bed148b5..7ca65c7e7 100644 --- a/modules/ve-cite/ve.ui.MWReferencesListDialog.js +++ b/modules/ve-cite/ve.ui.MWReferencesListDialog.js @@ -168,7 +168,8 @@ ve.ui.MWReferencesListDialog.prototype.getSetupProcess = function ( data ) { } this.groupInput.setValue( this.selectedNode.getAttribute( 'refGroup' ) ); - this.groupInput.populateMenu( this.getFragment().getDocument().getInternalList() ); + const docRefs = ve.dm.MWDocumentReferences.static.refsForDoc( this.getFragment().getDocument() ); + this.groupInput.populateMenu( docRefs.getAllGroupNames() ); this.responsiveCheckbox.setSelected( this.selectedNode.getAttribute( 'isResponsive' ) ); diff --git a/tests/qunit/ve-cite/ve.ui.MWReferenceGroupInputWidget.test.js b/tests/qunit/ve-cite/ve.ui.MWReferenceGroupInputWidget.test.js index 4557657d0..47ad8713a 100644 --- a/tests/qunit/ve-cite/ve.ui.MWReferenceGroupInputWidget.test.js +++ b/tests/qunit/ve-cite/ve.ui.MWReferenceGroupInputWidget.test.js @@ -11,12 +11,10 @@ QUnit.test( 'Constructor', ( assert ) => { } ); QUnit.test( 'populateMenu', ( assert ) => { - const doc = ve.dm.citeExample.createExampleDocument( 'references' ); - const widget = new ve.ui.MWReferenceGroupInputWidget( { emptyGroupName: 'empty' } ); - widget.populateMenu( doc.getInternalList() ); + widget.populateMenu( [ 'mwReference/', 'mwReference/foo' ] ); assert.strictEqual( widget.getMenu().getItemCount(), 2 );