Update template dialog titles: Insert/Edit

Toggle depending on whether the transclusion existed or is new.

Bug: T276568
Change-Id: Ib9b76cac7cd57245e8db2ef10879069a86a6269e
This commit is contained in:
Adam Wight 2021-06-02 12:06:36 +02:00
parent 7fe5b6a433
commit d4eee82701
4 changed files with 24 additions and 17 deletions

View file

@ -2212,6 +2212,9 @@
"visualeditor-dialog-transclusion-required-parameter-is-blank",
"visualeditor-dialog-transclusion-single-mode",
"visualeditor-dialog-transclusion-title",
"visualeditor-dialog-transclusion-title-insert-template",
"visualeditor-dialog-transclusion-title-insert-known-template",
"visualeditor-dialog-transclusion-title-edit-known-template",
"visualeditor-dialog-transclusion-template-search",
"visualeditor-dialog-transclusion-template-search-help",
"visualeditor-dialog-transclusion-templates-menu-aria-label",

View file

@ -202,6 +202,9 @@
"visualeditor-dialog-transclusion-required-parameter-is-blank": "Are you sure you want to continue without filling the $1 {{PLURAL:$2|field|fields}}?",
"visualeditor-dialog-transclusion-single-mode": "Hide options",
"visualeditor-dialog-transclusion-title": "Transclusion",
"visualeditor-dialog-transclusion-title-insert-template": "Insert a template",
"visualeditor-dialog-transclusion-title-insert-known-template": "Insert: $1",
"visualeditor-dialog-transclusion-title-edit-known-template": "Edit: $1",
"visualeditor-dialog-transclusion-template-search": "Template search",
"visualeditor-dialog-transclusion-template-search-help": "Find the template you want to insert by searching for an identifying keyword. Templates that have descriptions are more likely to work well with this editor (VisualEditor).",
"visualeditor-dialog-transclusion-templates-menu-aria-label": "Template fields setup menu",

View file

@ -220,6 +220,9 @@
"visualeditor-dialog-transclusion-required-parameter-is-blank": "Label for the confirmation dialog opened if the user tries to insert/edit a template without filling all required fields.\n\nParameters:\n* $1 - Parameters missing, as a list using {{msg-mw|and}}, {{msg-mw|comma-separator}} and {{msg-mw|word-separator}}.\n* $2 - Number of parameters missing, for PLURAL support.",
"visualeditor-dialog-transclusion-single-mode": "Label for button that hides advanced options in transclusion dialog",
"visualeditor-dialog-transclusion-title": "{{Identical|Transclusion}}",
"visualeditor-dialog-transclusion-title-insert-template": "Label for the transclusion dialog when selecting a transclusion to insert.",
"visualeditor-dialog-transclusion-title-insert-known-template": "Label for the transclusion dialog when editing a transclusion to insert.\n\nParameters:\n* $1 - Transclusion name.",
"visualeditor-dialog-transclusion-title-edit-known-template": "Label for the transclusion dialog when editing an existing transclusion.\n\nParameters:\n* $1 - Transclusion name.",
"visualeditor-dialog-transclusion-template-search": "Dialog and fieldset label to search for a template.",
"visualeditor-dialog-transclusion-template-search-help": "Inline help for the template search field.",
"visualeditor-dialog-transclusion-templates-menu-aria-label": "ARIA label for screen readers on template fields setup menu.",

View file

@ -277,17 +277,6 @@ ve.ui.MWTemplateDialog.prototype.getPageFromPart = function ( part ) {
return null;
};
/**
* Get the label of a template or template placeholder.
*
* @param {ve.dm.MWTemplateModel|ve.dm.MWTemplatePlaceholderModel} part Part to check
* @return {string} Label of template or template placeholder
*/
ve.ui.MWTemplateDialog.prototype.getTemplatePartLabel = function ( part ) {
return part instanceof ve.dm.MWTemplateModel ?
part.getSpec().getLabel() : ve.msg( 'visualeditor-dialog-template-insert' );
};
/**
* @inheritdoc
*/
@ -324,13 +313,22 @@ ve.ui.MWTemplateDialog.prototype.setPageByName = function ( name ) {
* Update the dialog title.
*/
ve.ui.MWTemplateDialog.prototype.updateTitle = function () {
var parts = this.transclusionModel && this.transclusionModel.getParts();
var parts = this.transclusionModel && this.transclusionModel.getParts(),
title = ve.msg( 'visualeditor-dialog-transclusion-loading' );
this.title.setLabel(
parts && parts.length === 1 && parts[ 0 ] ?
this.getTemplatePartLabel( parts[ 0 ] ) :
ve.msg( 'visualeditor-dialog-transclusion-loading' )
);
if ( parts && parts.length === 1 && parts[ 0 ] ) {
if ( parts[ 0 ] instanceof ve.dm.MWTemplateModel ) {
title = ve.msg(
this.getMode() === 'insert' ?
'visualeditor-dialog-transclusion-title-insert-known-template' :
'visualeditor-dialog-transclusion-title-edit-known-template',
parts[ 0 ].getSpec().getLabel()
);
} else {
title = ve.msg( 'visualeditor-dialog-transclusion-title-insert-template' );
}
}
this.title.setLabel( title );
};
/**