mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 10:35:48 +00:00
Hide unused paramters by default on multipart
Covers the base functionality to hide the parameters. Performance optimizations could be done in a follow up. Bug: T300640 Change-Id: Ia99b5da392273f1445e475a0720a656460612dcf
This commit is contained in:
parent
29f95e78ef
commit
b35ea59de5
|
@ -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;
|
||||
|
|
|
@ -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 );
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue