diff --git a/modules/ve-mw/tests/ui/layouts/ve.ui.MWTwoPaneTransclusionDialogLayout.test.js b/modules/ve-mw/tests/ui/layouts/ve.ui.MWTwoPaneTransclusionDialogLayout.test.js index 372b249909..f0357236f9 100644 --- a/modules/ve-mw/tests/ui/layouts/ve.ui.MWTwoPaneTransclusionDialogLayout.test.js +++ b/modules/ve-mw/tests/ui/layouts/ve.ui.MWTwoPaneTransclusionDialogLayout.test.js @@ -29,7 +29,7 @@ QUnit.test( 'can add and remove multiple pages', ( assert ) => { assert.strictEqual( layout.getPage( parameterPageB.getName() ), parameterPageB ); assert.strictEqual( layout.getPage( parameterPageC.getName() ), parameterPageC ); - layout.removePages( [ parameterPageA, parameterPageB ] ); + layout.removePages( [ parameterPageA.getName(), parameterPageB.getName() ] ); assert.strictEqual( layout.getPage( parameterPageA.getName() ), undefined ); assert.strictEqual( layout.getPage( parameterPageB.getName() ), undefined ); assert.strictEqual( layout.getPage( parameterPageC.getName() ), parameterPageC ); diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWTemplateDialog.js b/modules/ve-mw/ui/dialogs/ve.ui.MWTemplateDialog.js index 8393c0a1f4..88c1c2f4ee 100644 --- a/modules/ve-mw/ui/dialogs/ve.ui.MWTemplateDialog.js +++ b/modules/ve-mw/ui/dialogs/ve.ui.MWTemplateDialog.js @@ -106,15 +106,14 @@ ve.ui.MWTemplateDialog.prototype.onReplacePart = function ( removed, added ) { if ( removed ) { // Remove parameter pages of removed templates - var partPage = this.bookletLayout.getPage( removed.getId() ); if ( removed instanceof ve.dm.MWTemplateModel ) { var params = removed.getParameters(); for ( var name in params ) { - removePages.push( this.bookletLayout.getPage( params[ name ].getId() ) ); + removePages.push( params[ name ].getId() ); } removed.disconnect( this ); } - removePages.push( partPage ); + removePages.push( removed.getId() ); this.bookletLayout.removePages( removePages ); } @@ -207,9 +206,7 @@ ve.ui.MWTemplateDialog.prototype.onAddParameter = function ( param ) { * @param {ve.dm.MWParameterModel} param Removed param */ ve.ui.MWTemplateDialog.prototype.onRemoveParameter = function ( param ) { - var page = this.bookletLayout.getPage( param.getId() ); - - this.bookletLayout.removePages( [ page ] ); + this.bookletLayout.removePages( [ param.getId() ] ); this.touch(); }; diff --git a/modules/ve-mw/ui/layouts/ve.ui.MWTwoPaneTransclusionDialogLayout.js b/modules/ve-mw/ui/layouts/ve.ui.MWTwoPaneTransclusionDialogLayout.js index 4d69d6ed55..eb82210d41 100644 --- a/modules/ve-mw/ui/layouts/ve.ui.MWTwoPaneTransclusionDialogLayout.js +++ b/modules/ve-mw/ui/layouts/ve.ui.MWTwoPaneTransclusionDialogLayout.js @@ -274,7 +274,7 @@ ve.ui.MWTwoPaneTransclusionDialogLayout.prototype.addPages = function ( pages, i if ( currentIndex !== -1 && currentIndex + 1 < index ) { index--; } - remove.push( this.pages[ name ] ); + remove.push( name ); } } if ( remove.length ) { @@ -296,17 +296,19 @@ ve.ui.MWTwoPaneTransclusionDialogLayout.prototype.addPages = function ( pages, i * * To remove all pages from the booklet, you may wish to use the #clearPages method instead. * - * @param {OO.ui.PageLayout[]} pagesToRemove An array of pages to remove + * @param {string[]} pagesNamesToRemove */ -ve.ui.MWTwoPaneTransclusionDialogLayout.prototype.removePages = function ( pagesToRemove ) { +ve.ui.MWTwoPaneTransclusionDialogLayout.prototype.removePages = function ( pagesNamesToRemove ) { var layout = this, + pagesToRemove = [], isCurrentParameter = this.pages[ this.currentPageName ] instanceof ve.ui.MWParameterPage, isCurrentPageRemoved = false, prevSelectionCandidate, nextSelectionCandidate; this.stackLayout.getItems().forEach( function ( page ) { var pageName = page.getName(); - if ( pagesToRemove.indexOf( page ) !== -1 ) { + if ( pagesNamesToRemove.indexOf( pageName ) !== -1 ) { + pagesToRemove.push( page ); delete layout.pages[ pageName ]; // If the current page is removed, clear currentPageName if ( layout.currentPageName === pageName ) {