diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWTemplateDialog.js b/modules/ve-mw/ui/dialogs/ve.ui.MWTemplateDialog.js index 8584b7e25c..bb5ca1d309 100644 --- a/modules/ve-mw/ui/dialogs/ve.ui.MWTemplateDialog.js +++ b/modules/ve-mw/ui/dialogs/ve.ui.MWTemplateDialog.js @@ -21,6 +21,7 @@ * * @constructor * @param {Object} [config] Configuration options + * @property {ve.dm.MWTransclusionModel|null} transclusionModel */ ve.ui.MWTemplateDialog = function VeUiMWTemplateDialog( config ) { // Parent constructor @@ -570,6 +571,10 @@ ve.ui.MWTemplateDialog.prototype.getSetupProcess = function ( data ) { dialog.bookletLayout.outlineSelectWidget.$element ); dialog.bookletLayout.outlineSelectWidget.toggle( false ); + + if ( !dialog.transclusionModel.isSingleTemplate() ) { + dialog.pocSidebar.hideAllUnusedParameters(); + } } dialog.bookletLayout.autoFocus = true; diff --git a/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineTemplateWidget.js b/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineTemplateWidget.js index 3e7627478a..f16fd8fee2 100644 --- a/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineTemplateWidget.js +++ b/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineTemplateWidget.js @@ -30,7 +30,7 @@ ve.ui.MWTransclusionOutlineTemplateWidget = function VeUiMWTransclusionOutlineTe } ); this.initializeParameterList(); - this.toggleFilters(); + this.toggleFilters( !this.transclusionModel.isSingleTemplate() ); }; /* Inheritance */ @@ -177,7 +177,10 @@ ve.ui.MWTransclusionOutlineTemplateWidget.prototype.onParameterAddedToTemplateMo // All parameters known via the spec already have a checkbox var item = this.parameterList.findItemFromData( paramName ); - if ( !item ) { + if ( item ) { + // Reset the "hide unused" filter for this field, it's going to be used + item.toggle( true ); + } else { item = this.createCheckbox( paramName ); this.parameterList.addItems( [ item ], this.findCanonicalPosition( paramName ) ); @@ -247,8 +250,9 @@ ve.ui.MWTransclusionOutlineTemplateWidget.prototype.onParameterWidgetListChanged /** * @private + * @param {boolean} [initiallyHideUnused=false] */ -ve.ui.MWTransclusionOutlineTemplateWidget.prototype.toggleFilters = function () { +ve.ui.MWTransclusionOutlineTemplateWidget.prototype.toggleFilters = function ( initiallyHideUnused ) { var numParams = this.parameterList && this.parameterList.getItemCount(), visible = numParams >= this.constructor.static.searchableParameterCount; if ( this.searchWidget ) { @@ -256,6 +260,9 @@ ve.ui.MWTransclusionOutlineTemplateWidget.prototype.toggleFilters = function () this.toggleUnusedWidget.toggle( visible ); } else if ( visible ) { this.initializeFilters(); + if ( initiallyHideUnused === true ) { + this.toggleUnusedWidget.toggleUnusedParameters( false ); + } } }; @@ -338,10 +345,9 @@ ve.ui.MWTransclusionOutlineTemplateWidget.prototype.filterParameters = function } } ); + this.toggleUnusedWidget.toggle( !query ); this.infoWidget.toggle( nothingFound ); self.emit( 'filterParametersById', visibility ); - - this.toggleUnusedWidget.toggle( !query ); }; /** diff --git a/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineToggleUnusedWidget.js b/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineToggleUnusedWidget.js index 49af6e75b7..89defee9fd 100644 --- a/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineToggleUnusedWidget.js +++ b/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineToggleUnusedWidget.js @@ -38,18 +38,33 @@ OO.inheritClass( ve.ui.MWTransclusionOutlineToggleUnusedWidget, OO.ui.ButtonWidg /** * Handles clicks on the button by mouse or keyboard interaction. * + * @private * @fires toggleUnusedFields */ ve.ui.MWTransclusionOutlineToggleUnusedWidget.prototype.onClick = function () { - this.showUnusedFields = !this.showUnusedFields; - this.setLabel( ve.msg( this.showUnusedFields ? 'visualeditor-dialog-transclusion-filter-hide-unused' : - 'visualeditor-dialog-transclusion-filter-show-all' ) ); - this.emit( 'toggleUnusedFields', this.showUnusedFields ); + this.toggleUnusedParameters(); +}; + +/** + * @param {boolean} [showUnused] + * @fires toggleUnusedFields + */ +ve.ui.MWTransclusionOutlineToggleUnusedWidget.prototype.toggleUnusedParameters = function ( showUnused ) { + showUnused = showUnused === undefined ? !this.showUnusedFields : showUnused; + if ( showUnused !== this.showUnusedFields ) { + this.showUnusedFields = showUnused; + this.setLabel( ve.msg( this.showUnusedFields ? + 'visualeditor-dialog-transclusion-filter-hide-unused' : + 'visualeditor-dialog-transclusion-filter-show-all' + ) ); + this.emit( 'toggleUnusedFields', this.showUnusedFields ); + } }; /** * Handles toggling the visibility of the button. * + * @private * @param {boolean} visible * @fires toggleUnusedFields */ diff --git a/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineWidget.js b/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineWidget.js index 69cd2db79f..3c8ab9a76f 100644 --- a/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineWidget.js +++ b/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineWidget.js @@ -127,6 +127,17 @@ ve.ui.MWTransclusionOutlineWidget.prototype.addPartWidget = function ( part, new } }; +ve.ui.MWTransclusionOutlineWidget.prototype.hideAllUnusedParameters = function () { + for ( var id in this.partWidgets ) { + var partWidget = this.partWidgets[ id ]; + if ( partWidget instanceof ve.ui.MWTransclusionOutlineTemplateWidget && + partWidget.toggleUnusedWidget + ) { + partWidget.toggleUnusedWidget.toggleUnusedParameters( false ); + } + } +}; + /** * This is inspired by {@see OO.ui.SelectWidget.selectItem}, but isn't one. *