Merge "Highlight corresponding template parameter in new sidebar"

This commit is contained in:
jenkins-bot 2021-09-02 10:10:13 +00:00 committed by Gerrit Code Review
commit c8e00fb98a
4 changed files with 53 additions and 0 deletions

View file

@ -488,9 +488,14 @@ ve.ui.MWTemplateDialog.prototype.getSetupProcess = function ( data ) {
filterParameters: 'onFilterParameters', filterParameters: 'onFilterParameters',
focusPart: 'focusPart' focusPart: 'focusPart'
} ); } );
// FIXME: Check if we can merge these two "set"/"focusin" event handlers
this.bookletLayout.connect( this, { this.bookletLayout.connect( this, {
set: 'onBookletLayoutSetPage' set: 'onBookletLayoutSetPage'
} ); } );
this.bookletLayout.stackLayout.$element.on(
'focusin',
this.onBookletLayoutPageFocused.bind( this )
);
} else { } else {
this.pocSidebar.clear(); this.pocSidebar.clear();
} }
@ -636,6 +641,22 @@ ve.ui.MWTemplateDialog.prototype.onBookletLayoutSetPage = function ( page ) {
this.pocSidebar.selectPartById( partId ); this.pocSidebar.selectPartById( partId );
}; };
/**
* Modeled after {@see OO.ui.BookletLayout.onStackLayoutFocus}.
*
* @private
* @param {jQuery.Event} e
*/
ve.ui.MWTemplateDialog.prototype.onBookletLayoutPageFocused = function ( e ) {
var $focusedPage = $( e.target ).closest( '.oo-ui-pageLayout' );
for ( var pageName in this.bookletLayout.pages ) {
if ( this.bookletLayout.getPage( pageName ).$element[ 0 ] === $focusedPage[ 0 ] ) {
this.pocSidebar.highlightSubItemByPageName( pageName );
break;
}
}
};
/** /**
* @inheritdoc * @inheritdoc
*/ */

View file

@ -143,6 +143,19 @@ ve.ui.MWTransclusionOutlineContainerWidget.prototype.selectPartById = function (
} }
}; };
/**
* @param {string} pageName
*/
ve.ui.MWTransclusionOutlineContainerWidget.prototype.highlightSubItemByPageName = function ( pageName ) {
var ids = pageName.split( '/', 2 ),
partId = ids[ 0 ],
paramName = ids[ 1 ];
// Note this code-path (currently) doesn't care about top-level parts
if ( partId in this.partWidgets && paramName !== undefined ) {
this.partWidgets[ partId ].highlightParameter( paramName );
}
};
/** /**
* This is inspired by {@see OO.ui.SelectWidget.findSelectedItem}, but isn't one. * This is inspired by {@see OO.ui.SelectWidget.findSelectedItem}, but isn't one.
* *

View file

@ -68,6 +68,18 @@ ve.ui.MWTransclusionOutlineParameterSelectWidget.prototype.addItems = function (
return ve.ui.MWTransclusionOutlineParameterSelectWidget.super.prototype.addItems.call( this, items, index ); return ve.ui.MWTransclusionOutlineParameterSelectWidget.super.prototype.addItems.call( this, items, index );
}; };
/**
* @param {string} paramName
*/
ve.ui.MWTransclusionOutlineParameterSelectWidget.prototype.highlightParameter = function ( paramName ) {
var item = this.findItemFromData( paramName );
// Intentionally drop any highlighting if the parameter can't be found
this.highlightItem( item );
if ( item ) {
this.scrollItemIntoView( item );
}
};
/** /**
* @param {string} paramName * @param {string} paramName
*/ */

View file

@ -118,6 +118,13 @@ ve.ui.MWTransclusionOutlineTemplateWidget.prototype.findCanonicalPosition = func
return insertAt; return insertAt;
}; };
/**
* @param {string} paramName
*/
ve.ui.MWTransclusionOutlineTemplateWidget.prototype.highlightParameter = function ( paramName ) {
this.parameters.highlightParameter( paramName );
};
/** /**
* @private * @private
* @param {ve.dm.MWParameterModel} param * @param {ve.dm.MWParameterModel} param