Alex Monk has uploaded a new change for review.
https://gerrit.wikimedia.org/r/286917
Change subject: [WIP] Improve template parameter type fallback/return
......................................................................
[WIP] Improve template parameter type fallback/return
TODO: Test with all types
See T133681
Change-Id: Icbab365fdc9f275c454f90debc7dd85f17ea303f
---
M extension.json
M modules/ve-mw/i18n/en.json
M modules/ve-mw/i18n/qqq.json
M modules/ve-mw/ui/pages/ve.ui.MWParameterPage.js
M modules/ve-mw/ui/themes/default/pages/ve.ui.MWParameterPage.css
5 files changed, 60 insertions(+), 23 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor
refs/changes/17/286917/1
diff --git a/extension.json b/extension.json
index 02bf29b..cf1c4ae 100644
--- a/extension.json
+++ b/extension.json
@@ -1631,6 +1631,7 @@
"visualeditor-dialog-transclusion-required-parameter-dialog-title",
"visualeditor-dialog-transclusion-required-parameter-is-blank",
"visualeditor-dialog-transclusion-single-mode",
+ "visualeditor-dialog-transclusion-smart-return",
"visualeditor-dialog-transclusion-title",
"visualeditor-dialogbutton-template-tooltip",
"visualeditor-dialogbutton-transclusion-tooltip",
diff --git a/modules/ve-mw/i18n/en.json b/modules/ve-mw/i18n/en.json
index 32b847f..c97c3bf 100644
--- a/modules/ve-mw/i18n/en.json
+++ b/modules/ve-mw/i18n/en.json
@@ -207,6 +207,7 @@
"visualeditor-dialog-transclusion-required-parameter-dialog-title":
"Required {{PLURAL:$1|parameter|parameters}} missing",
"visualeditor-dialog-transclusion-required-parameter-is-blank": "Are
you sure you want to continue without filling the $1
{{PLURAL:$2|parameter|parameters}}?",
"visualeditor-dialog-transclusion-single-mode": "Hide options",
+ "visualeditor-dialog-transclusion-smart-return": "Return to smart
input",
"visualeditor-dialog-transclusion-title": "Transclusion",
"visualeditor-dialogbutton-media-tooltip": "Media",
"visualeditor-dialogbutton-meta-tooltip": "Page settings",
diff --git a/modules/ve-mw/i18n/qqq.json b/modules/ve-mw/i18n/qqq.json
index f38ac9b..c346f9d 100644
--- a/modules/ve-mw/i18n/qqq.json
+++ b/modules/ve-mw/i18n/qqq.json
@@ -218,6 +218,7 @@
"visualeditor-dialog-transclusion-required-parameter-dialog-title":
"Title for the confirmation dialog opened if the user tries to insert/edit a
template without filling all required fields.\n\nParameters:\n* $1 - Number of
parameters missing, for PLURAL support.",
"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-smart-return": "Label of the button
that converts plain wikitext inputs into complex validation-required type-based
inputs.",
"visualeditor-dialog-transclusion-title": "{{Identical|Transclusion}}",
"visualeditor-dialogbutton-media-tooltip": "{{Identical|Media}}",
"visualeditor-dialogbutton-meta-tooltip": "{{Identical|Page settings}}",
diff --git a/modules/ve-mw/ui/pages/ve.ui.MWParameterPage.js
b/modules/ve-mw/ui/pages/ve.ui.MWParameterPage.js
index d9c403a..864bd65 100644
--- a/modules/ve-mw/ui/pages/ve.ui.MWParameterPage.js
+++ b/modules/ve-mw/ui/pages/ve.ui.MWParameterPage.js
@@ -45,10 +45,26 @@
this.rawFallbackButton = new OO.ui.ButtonWidget( {
framed: false,
icon: 'wikiText',
- title: ve.msg( 'visualeditor-dialog-transclusion-raw-fallback' )
+ title: ve.msg( 'visualeditor-dialog-transclusion-raw-fallback'
),
+ classes: [ 've-ui-mwParameterPage-rawFallbackButton' ]
} ).connect( this, { click: 'onRawFallbackButtonClick' } );
+ this.smartInputButton = new OO.ui.ButtonWidget( {
+ framed: false,
+ icon: 'noWikiText',
+ title: ve.msg( 'visualeditor-dialog-transclusion-smart-return'
),
+ classes: [ 've-ui-mwParameterPage-smartInputButton' ]
+ } ).connect( this, { click: 'onSmartInputButtonClick' } );
- this.valueInput = this.createValueInput()
+
+ this.valueInput = this.createSmartValueInput();
+ if ( this.valueInput ) {
+ this.$element.addClass( 've-ui-mwParameterPage-smart' );
+ } else {
+ this.$element.addClass( 've-ui-mwParameterPage-raw' );
+ this.valueInput = new OO.ui.TextInputWidget(
this.getDefaultInputConfig() );
+ this.valueInput.$input.addClass(
've-ui-mwParameter-wikitextFallbackInput' );
+ }
+ this.valueInput
.setValue( this.parameter.getValue() )
.connect( this, { change: 'onValueInputChange' } );
@@ -88,10 +104,14 @@
this.$info
.addClass( 've-ui-mwParameterPage-info' )
.append( this.$labelElement, this.statusIndicator.$element );
+
+ if ( this.parameter.getType() !== 'string' ) {
+ this.$actions.append( this.rawFallbackButton.$element );
+ }
this.$actions
.addClass( 've-ui-mwParameterPage-actions' )
.append(
- this.rawFallbackButton.$element,
+ this.smartInputButton.$element,
this.infoButton.$element,
this.removeButton.$element
);
@@ -192,6 +212,7 @@
var required = this.parameter.isRequired(),
valueInputConfig = {
autosize: true,
+ multiline: true,
required: required,
validate: required ? 'non-empty' : null
};
@@ -215,15 +236,15 @@
* Create a value input widget based on the parameter type and whether it is
* required or not.
*
- * @return {OO.ui.InputWidget}
+ * @return {OO.ui.InputWidget|undefined}
*/
-ve.ui.MWParameterPage.prototype.createValueInput = function () {
+ve.ui.MWParameterPage.prototype.createSmartValueInput = function () {
var type = this.parameter.getType(),
value = this.parameter.getValue(),
valueInputConfig = this.getDefaultInputConfig();
- this.rawValueInput = false;
delete valueInputConfig.validate;
+ delete valueInputConfig.multiline;
// TODO:
// * wiki-file-name
@@ -263,13 +284,9 @@
)
) {
return
ve.ui.MWExternalLinkAnnotationWidget.static.createExternalLinkInputWidget(
valueInputConfig );
- } else if ( type !== 'line' ) {
- this.rawValueInput = true;
- valueInputConfig.multiline = true;
- this.rawFallbackButton.$element.detach();
+ } else if ( type === 'line' ) {
+ return new OO.ui.TextInputWidget( valueInputConfig );
}
-
- return new OO.ui.TextInputWidget( valueInputConfig );
};
/**
@@ -295,6 +312,8 @@
if ( this.outlineItem ) {
this.outlineItem.setFlags( { empty: this.isEmpty() } );
}
+
+ this.smartInputButton.setDisabled( !this.createSmartValueInput() );
};
/**
@@ -309,20 +328,31 @@
*/
ve.ui.MWParameterPage.prototype.onRawFallbackButtonClick = function () {
this.valueInput.$element.detach();
- if ( this.rawValueInput ) {
- this.valueInput = this.createValueInput()
- .setValue( this.valueInput.getValue() );
- } else {
- this.valueInput = new OO.ui.TextInputWidget(
this.getDefaultInputConfig() )
- .setValue( this.edited ? this.valueInput.getValue() :
this.originalValue );
- this.valueInput.$input.addClass(
've-ui-mwParameter-wikitextFallbackInput' );
- this.rawValueInput = true;
- }
+ this.valueInput = new OO.ui.TextInputWidget(
this.getDefaultInputConfig() )
+ .setValue( this.edited ? this.valueInput.getValue() :
this.originalValue );
+ this.valueInput.$input.addClass(
've-ui-mwParameter-wikitextFallbackInput' );
+ this.$element.addClass( 've-ui-mwParameterPage-raw' );
+ this.$element.removeClass( 've-ui-mwParameterPage-smart' );
+
this.valueInput.connect( this, { change: 'onValueInputChange' } );
this.$field.append( this.valueInput.$element );
};
/**
+ * Handle click events from the smart input button
+ */
+ve.ui.MWParameterPage.prototype.onSmartInputButtonClick = function () {
+ this.valueInput.$element.detach();
+ this.$element.removeClass( 've-ui-mwParameterPage-raw' );
+ this.$element.addClass( 've-ui-mwParameterPage-smart' );
+ this.valueInput = this.createSmartValueInput()
+ .setValue( this.valueInput.getValue() );
+ this.valueInput.connect( this, { change: 'onValueInputChange' } );
+ this.$field.append( this.valueInput.$element );
+};
+
+
+/**
* Handle click events from the add button
*/
ve.ui.MWParameterPage.prototype.onAddButtonFocus = function () {
diff --git a/modules/ve-mw/ui/themes/default/pages/ve.ui.MWParameterPage.css
b/modules/ve-mw/ui/themes/default/pages/ve.ui.MWParameterPage.css
index b02c5c1..e64fcb5 100644
--- a/modules/ve-mw/ui/themes/default/pages/ve.ui.MWParameterPage.css
+++ b/modules/ve-mw/ui/themes/default/pages/ve.ui.MWParameterPage.css
@@ -67,7 +67,9 @@
}
.ve-ui-mwParameterPage-infoButton,
-.ve-ui-mwParameterPage-removeButton {
+.ve-ui-mwParameterPage-removeButton,
+.ve-ui-mwParameterPage-rawFallbackButton,
+.ve-ui-mwParameterPage-smartInputButton {
display: none;
}
@@ -77,7 +79,9 @@
}
.oo-ui-pageLayout-active .ve-ui-mwParameterPage-infoButton,
-.oo-ui-pageLayout-active .ve-ui-mwParameterPage-removeButton {
+.oo-ui-pageLayout-active .ve-ui-mwParameterPage-removeButton,
+.ve-ui-mwParameterPage-smart .ve-ui-mwParameterPage-rawFallbackButton,
+.ve-ui-mwParameterPage-raw .ve-ui-mwParameterPage-smartInputButton {
display: inline-block;
}
--
To view, visit https://gerrit.wikimedia.org/r/286917
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Icbab365fdc9f275c454f90debc7dd85f17ea303f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Alex Monk <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits