Rename event to be descriptive, not prescriptive

Events should be named based on what happened, not what the
side-effect will be.

Change-Id: I563db48181e1db79ca22ef2ba1e25d5186976110
This commit is contained in:
Adam Wight 2022-07-01 12:42:23 +02:00
parent d93e35a0d1
commit 1653815e8c
4 changed files with 7 additions and 7 deletions

View file

@ -186,7 +186,7 @@ ve.ui.MWTemplateDialog.prototype.onAddParameter = function ( param ) {
$overlay: this.$overlay
} )
.connect( this, {
focusTemplateParameterById: this.bookletLayout.focusPart.bind( this.bookletLayout )
templateParameterAdded: this.bookletLayout.focusPart.bind( this.bookletLayout )
} );
}
this.bookletLayout.addPages( [ page ], this.transclusionModel.getIndex( param ) );

View file

@ -141,7 +141,7 @@ ve.ui.MWAddParameterPage.prototype.updateParameterNameValidation = function ( va
/**
* @private
* @fires focusTemplateParameterById
* @fires templateParameterAdded
*/
ve.ui.MWAddParameterPage.prototype.onParameterNameSubmitted = function () {
var name = this.paramInputField.getValue().trim();
@ -157,7 +157,7 @@ ve.ui.MWAddParameterPage.prototype.onParameterNameSubmitted = function () {
var param = new ve.dm.MWParameterModel( this.template, name );
this.template.addParameter( param );
this.emit( 'focusTemplateParameterById', param.getId() );
this.emit( 'templateParameterAdded', param.getId() );
ve.track( 'activity.transclusion', {
action: 'add-unknown-parameter'

View file

@ -60,7 +60,7 @@ OO.inheritClass( ve.ui.MWTransclusionOutlineTemplateWidget, ve.ui.MWTransclusion
/* Events */
/**
* @event focusTemplateParameterById
* @event templateParameterAdded
* @param {string} pageName Unique id of the {@see OO.ui.BookletLayout} page, e.g. something like
* "part_1" or "part_1/param1".
*/
@ -289,14 +289,14 @@ ve.ui.MWTransclusionOutlineTemplateWidget.prototype.onParameterRemovedFromTempla
* @private
* @param {OO.ui.OptionWidget} item
* @param {boolean} selected
* @fires focusTemplateParameterById
* @fires templateParameterAdded
*/
ve.ui.MWTransclusionOutlineTemplateWidget.prototype.onTemplateParameterChoose = function ( item, selected ) {
this.onTemplateParameterSelectionChanged( item, selected );
var param = this.templateModel.getParameter( item.getData() );
if ( param && selected ) {
this.emit( 'focusTemplateParameterById', param.getId() );
this.emit( 'templateParameterAdded', param.getId() );
}
};

View file

@ -108,7 +108,7 @@ ve.ui.MWTransclusionOutlineWidget.prototype.addPartWidget = function ( part, new
widget.connect( this, {
// We can forward these events as is. The parameter's unique ids are reused as page
// names in {@see ve.ui.MWTemplateDialog.onAddParameter}.
focusTemplateParameterById: [ 'emit', 'focusPageByName' ],
templateParameterAdded: [ 'emit', 'focusPageByName' ],
filterParametersById: [ 'emit', 'filterPagesByName' ]
} );
} else if ( part instanceof ve.dm.MWTemplatePlaceholderModel ) {