Merge "Filter right content side of the template dialog as well"

This commit is contained in:
jenkins-bot 2021-08-06 10:26:55 +00:00 committed by Gerrit Code Review
commit 5dabf57f94
3 changed files with 41 additions and 1 deletions

View file

@ -475,6 +475,7 @@ ve.ui.MWTemplateDialog.prototype.getSetupProcess = function ( data ) {
this.pocSidebar = new ve.ui.MWTransclusionOutlineContainerWidget(
this.bookletLayout
);
this.pocSidebar.connect( this, { filterParameter: 'onFilterParameter' } );
} else {
this.pocSidebar.clear();
}
@ -575,6 +576,16 @@ ve.ui.MWTemplateDialog.prototype.initializeNewTemplateParameters = function () {
*/
ve.ui.MWTemplateDialog.prototype.initializeTemplateParameters = function () {};
/**
* @private
*/
ve.ui.MWTemplateDialog.prototype.onFilterParameter = function ( partId, isVisible ) {
var page = this.bookletLayout.getPage( partId );
if ( page ) {
page.toggle( isVisible );
}
};
/**
* @inheritdoc
*/

View file

@ -32,6 +32,12 @@ OO.inheritClass( ve.ui.MWTransclusionOutlineContainerWidget, OO.ui.Widget );
/* Events */
/**
* @event filterParameter
* @param {string} partId Unique id of the parameter, e.g. something like "part_1/param1"
* @param {boolean} isVisible
*/
/**
* @param {ve.dm.MWTransclusionPartModel|null} removed Removed part
* @param {ve.dm.MWTransclusionPartModel|null} added Added part
@ -92,6 +98,9 @@ ve.ui.MWTransclusionOutlineContainerWidget.prototype.addPartWidget = function (
if ( part instanceof ve.dm.MWTemplateModel ) {
widget = new ve.ui.MWTransclusionOutlineTemplateWidget( part );
// This forwards events from the nested ve.ui.MWTransclusionOutlineTemplateWidget upwards.
// The array syntax is a way to call `this.emit( 'filterParameter' )`.
widget.connect( this, { filterParameter: [ 'emit', 'filterParameter' ] } );
} else if ( part instanceof ve.dm.MWTemplatePlaceholderModel ) {
widget = new ve.ui.MWTransclusionOutlinePlaceholderWidget( part );
} else if ( part instanceof ve.dm.MWTransclusionContentModel ) {

View file

@ -72,6 +72,18 @@ ve.ui.MWTransclusionOutlineTemplateWidget = function VeUiMWTransclusionOutlineTe
OO.inheritClass( ve.ui.MWTransclusionOutlineTemplateWidget, ve.ui.MWTransclusionOutlinePartWidget );
/* Events */
/**
* Triggered when the user uses the search widget at the top to filter the list of parameters.
*
* @event filterParameter
* @param {string} partId Unique id of the parameter, e.g. something like "part_1/param1"
* @param {boolean} isVisible
*/
/* Methods */
/**
* @param {string} paramName
* @return {ve.ui.MWTemplateOutlineParameterCheckboxLayout}
@ -169,9 +181,12 @@ ve.ui.MWTransclusionOutlineTemplateWidget.prototype.onCheckboxListChange = funct
* parameter's primary name, aliases, label, and description. But not e.g. the example value.
*
* @param {string} query user input
* @fires filterParameter
*/
ve.ui.MWTransclusionOutlineTemplateWidget.prototype.onFilterChange = function ( query ) {
var spec = this.templateModel.getSpec(),
var self = this,
template = this.templateModel,
spec = this.templateModel.getSpec(),
checkboxes = this.parameters,
nothingFound = true;
@ -196,6 +211,11 @@ ve.ui.MWTransclusionOutlineTemplateWidget.prototype.onFilterChange = function (
checkbox.toggle( foundSomeMatch );
nothingFound = nothingFound && !foundSomeMatch;
var param = template.getParameter( paramName );
if ( param ) {
self.emit( 'filterParameter', param.getId(), foundSomeMatch );
}
} );
this.infoWidget.toggle( nothingFound );