mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-09-24 02:38:40 +00:00
Added new input page for undocumented parameters
Bug: T272487 Change-Id: Ic5dcd36c9f647f9b52b98e5a520a1df1960a5b48
This commit is contained in:
parent
d6316145b5
commit
5c9fbca085
|
@ -2144,6 +2144,7 @@
|
|||
"modules/ve-mw/ui/widgets/ve.ui.MWMoreParametersResultWidget.js",
|
||||
"modules/ve-mw/ui/widgets/ve.ui.MWNoParametersResultWidget.js",
|
||||
"modules/ve-mw/ui/widgets/ve.ui.MWTemplateTitleInputWidget.js",
|
||||
"modules/ve-mw/ui/pages/ve.ui.MWAddParameterPage.js",
|
||||
"modules/ve-mw/ui/pages/ve.ui.MWTemplatePage.js",
|
||||
"modules/ve-mw/ui/pages/ve.ui.MWParameterPage.js",
|
||||
"modules/ve-mw/ui/pages/ve.ui.MWParameterPlaceholderPage.js",
|
||||
|
@ -2201,7 +2202,10 @@
|
|||
"visualeditor-dialog-transclusion-add-content",
|
||||
"visualeditor-dialog-transclusion-add-wikitext",
|
||||
"visualeditor-dialog-transclusion-add-param",
|
||||
"visualeditor-dialog-transclusion-add-param-help",
|
||||
"visualeditor-dialog-transclusion-add-param-save",
|
||||
"visualeditor-dialog-transclusion-add-template",
|
||||
"visualeditor-dialog-transclusion-add-undocumented-param",
|
||||
"visualeditor-dialog-transclusion-collapse-options",
|
||||
"visualeditor-dialog-transclusion-content",
|
||||
"visualeditor-dialog-transclusion-contextitem-description",
|
||||
|
|
|
@ -174,7 +174,10 @@
|
|||
"visualeditor-dialog-transclusion-add-content": "Add content",
|
||||
"visualeditor-dialog-transclusion-add-wikitext": "Add wikitext",
|
||||
"visualeditor-dialog-transclusion-add-param": "Add more information",
|
||||
"visualeditor-dialog-transclusion-add-param-help": "If known, enter undocumented parameter names. If the parameter is not already part of the template, adding it will have no effect. You may find information about existing parameters on the [[{{ns:template}}:$1|template's page]].",
|
||||
"visualeditor-dialog-transclusion-add-param-save": "Add parameter",
|
||||
"visualeditor-dialog-transclusion-add-template": "Add template",
|
||||
"visualeditor-dialog-transclusion-add-undocumented-param": "Add undocumented parameter",
|
||||
"visualeditor-dialog-transclusion-collapse-options": "Hide options",
|
||||
"visualeditor-dialog-transclusion-content": "Content",
|
||||
"visualeditor-dialog-transclusion-contextitem-description": "Generated from: $1",
|
||||
|
|
|
@ -192,7 +192,10 @@
|
|||
"visualeditor-dialog-transclusion-add-content": "Label for button that adds parameter content to a transclusion.",
|
||||
"visualeditor-dialog-transclusion-add-wikitext": "Label for button that adds parameter wikitext to a transclusion.",
|
||||
"visualeditor-dialog-transclusion-add-param": "Label for button that adds a parameter to a transcluded template.",
|
||||
"visualeditor-dialog-transclusion-add-param-help": "Help text for new undocumented parameter input field.",
|
||||
"visualeditor-dialog-transclusion-add-param-save": "Label for save button that adds a new undocumented parameter to a transcluded template.",
|
||||
"visualeditor-dialog-transclusion-add-template": "Label for button that adds the specified template to the page.\n{{Identical|Add template}}",
|
||||
"visualeditor-dialog-transclusion-add-undocumented-param": "Label for button that adds a new undocumented parameter to a transcluded template.",
|
||||
"visualeditor-dialog-transclusion-collapse-options": "Label for button that hides advanced options in transclusion dialog",
|
||||
"visualeditor-dialog-transclusion-content": "Label for editor of content between transclusion parts.\n{{Identical|Content}}",
|
||||
"visualeditor-dialog-transclusion-contextitem-description": "Message shown to an editor when they click on a template or group of templates that form a transclusion, listing the template(s) from which the transclusion is constructed.\n\n* $1 – the name of the template, or a list of the names of the templates if there are multiple.\n* $2 - number of templates for PLURAL support.",
|
||||
|
|
|
@ -198,6 +198,10 @@ ve.ui.MWTemplateDialog.prototype.onAddParameter = function ( param ) {
|
|||
|
||||
if ( param.getName() ) {
|
||||
page = new ve.ui.MWParameterPage( param, param.getId(), { $overlay: this.$overlay, readOnly: this.isReadOnly() } );
|
||||
} else if ( this.useNewSidebar ) {
|
||||
page = new ve.ui.MWAddParameterPage( param, param.getId(), {
|
||||
$overlay: this.$overlay
|
||||
} );
|
||||
} else {
|
||||
// This branch is triggered when we receive a synthetic placeholder event with name=''.
|
||||
page = new ve.ui.MWParameterPlaceholderPage( param, param.getId(), {
|
||||
|
|
110
modules/ve-mw/ui/pages/ve.ui.MWAddParameterPage.js
Normal file
110
modules/ve-mw/ui/pages/ve.ui.MWAddParameterPage.js
Normal file
|
@ -0,0 +1,110 @@
|
|||
/**
|
||||
* Placeholder page for a currently unnamed parameter. Represented as a unnamed
|
||||
* {@see ve.dm.MWParameterModel} in the corresponding {@see ve.dm.MWTemplateModel}.
|
||||
*
|
||||
* @class
|
||||
* @extends OO.ui.PageLayout
|
||||
*
|
||||
* @constructor
|
||||
* @param {ve.dm.MWParameterModel} parameter Reference to a placeholder parameter with an empty
|
||||
* name, as well as to the template the parameter belongs to
|
||||
* @param {string} name Unique symbolic name of page
|
||||
* @param {Object} [config] Configuration options
|
||||
* @cfg {jQuery} [$overlay] Overlay to render dropdowns in
|
||||
*/
|
||||
ve.ui.MWAddParameterPage = function VeUiMWAddParameterPage( parameter, name, config ) {
|
||||
// Configuration initialization
|
||||
config = ve.extendObject( {
|
||||
scrollable: false
|
||||
}, config );
|
||||
|
||||
// Parent constructor
|
||||
ve.ui.MWAddParameterPage.super.call( this, name, config );
|
||||
|
||||
this.template = parameter.getTemplate();
|
||||
this.isExpanded = false;
|
||||
|
||||
// Header button to expand
|
||||
this.addParameterInputHeader = new OO.ui.ButtonWidget( {
|
||||
label: ve.msg( 'visualeditor-dialog-transclusion-add-undocumented-param' ),
|
||||
icon: 'add',
|
||||
framed: false,
|
||||
inline: true,
|
||||
classes: [ 've-ui-mwTransclusionDialog-addParameterFieldset-header' ]
|
||||
} )
|
||||
.connect( this, { click: 'togglePlaceholder' } );
|
||||
|
||||
// Input field and button
|
||||
this.paramInputField = new OO.ui.TextInputWidget().connect( this, { enter: 'onParameterInput' } );
|
||||
var saveButton = new OO.ui.ButtonWidget( {
|
||||
label: ve.msg( 'visualeditor-dialog-transclusion-add-param-save' ),
|
||||
flags: [ 'primary', 'progressive' ]
|
||||
} )
|
||||
.connect( this, { click: 'onParameterInput' } );
|
||||
|
||||
this.addParameterInputField = new OO.ui.ActionFieldLayout(
|
||||
this.paramInputField,
|
||||
saveButton,
|
||||
{ classes: [ 've-ui-mwTransclusionDialog-addParameterFieldset-input' ] }
|
||||
);
|
||||
|
||||
var rawTemplateName = this.template.getTarget().wt,
|
||||
title = mw.Title.newFromText( this.template.getTitle() || rawTemplateName ),
|
||||
link = title.getRelativeText( mw.config.get( 'wgNamespaceIds' ).template );
|
||||
this.addParameterFieldset = new OO.ui.FieldsetLayout( {
|
||||
label: this.addParameterInputHeader.$element,
|
||||
helpInline: true,
|
||||
help: mw.message( 'visualeditor-dialog-transclusion-add-param-help', link ).parseDom(),
|
||||
classes: [ 've-ui-mwTransclusionDialog-addParameterFieldset' ],
|
||||
$content: this.addParameterInputField.$element
|
||||
} );
|
||||
|
||||
// Init visibility
|
||||
this.togglePlaceholder( false );
|
||||
|
||||
// Initialization
|
||||
this.$element
|
||||
.addClass( 've-ui-mwParameterPlaceholderPage' )
|
||||
.append( this.addParameterFieldset.$element );
|
||||
};
|
||||
|
||||
/* Inheritance */
|
||||
|
||||
OO.inheritClass( ve.ui.MWAddParameterPage, OO.ui.PageLayout );
|
||||
|
||||
/* Methods */
|
||||
|
||||
ve.ui.MWAddParameterPage.prototype.onParameterInput = function () {
|
||||
var name = this.paramInputField.getValue().trim();
|
||||
this.paramInputField.setValue( '' );
|
||||
|
||||
if ( !name || this.template.hasParameter( name ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( this.template.getSpec().isParameterDocumented( name ) ) {
|
||||
// TODO: This special case needs a proper error message for the user
|
||||
return;
|
||||
}
|
||||
|
||||
this.template.addParameter( new ve.dm.MWParameterModel( this.template, name ) );
|
||||
|
||||
ve.track( 'activity.transclusion', {
|
||||
action: 'add-unknown-parameter'
|
||||
} );
|
||||
};
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {boolean} [expand]
|
||||
*/
|
||||
ve.ui.MWAddParameterPage.prototype.togglePlaceholder = function ( expand ) {
|
||||
this.isExpanded = expand === undefined ? !this.isExpanded : !!expand;
|
||||
|
||||
this.addParameterInputField.toggle( this.isExpanded );
|
||||
this.addParameterInputHeader.setIcon( this.isExpanded ? 'subtract' : 'add' );
|
||||
this.addParameterFieldset.$element.toggleClass(
|
||||
've-ui-mwTransclusionDialog-addParameterFieldset-collapsed',
|
||||
!this.isExpanded
|
||||
);
|
||||
};
|
|
@ -232,7 +232,9 @@ ve.ui.MWParameterPage = function VeUiMWParameterPage( parameter, name, config )
|
|||
var addButton = new OO.ui.ButtonWidget( {
|
||||
framed: false,
|
||||
icon: 'parameter',
|
||||
label: ve.msg( 'visualeditor-dialog-transclusion-add-param' )
|
||||
label: veConfig.transclusionDialogNewSidebar ?
|
||||
ve.msg( 'visualeditor-dialog-transclusion-add-undocumented-param' ) :
|
||||
ve.msg( 'visualeditor-dialog-transclusion-add-param' )
|
||||
} )
|
||||
.connect( this, { click: 'addPlaceholderParameter' } );
|
||||
$( '<div>' )
|
||||
|
|
|
@ -28,6 +28,22 @@
|
|||
padding-bottom: 5em;
|
||||
}
|
||||
|
||||
.ve-ui-mwTransclusionDialog-addParameterFieldset-collapsed .oo-ui-inline-help {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.ve-ui-mwTransclusionDialog-addParameterFieldset-input {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.ve-ui-mwTransclusionDialog-addParameterFieldset-input .oo-ui-fieldLayout-field {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.ve-ui-mwTransclusionDialog-addParameterFieldset-header.oo-ui-iconElement .oo-ui-iconElement-icon {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.ve-ui-mwTransclusionDialog-removeButton {
|
||||
position: absolute;
|
||||
top: 0.85714286em; /* Equals ≈`12px` */
|
||||
|
|
Loading…
Reference in a new issue