jenkins-bot has submitted this change and it was merged.
Change subject: Auto-select first auto-added required param and fix param order
......................................................................
Auto-select first auto-added required param and fix param order
Symptoms:
* When adding a template with required parameters, the last parameter
is initially focused
* Parameters and parts appear out of order, and adding/remove/moving
them shows them in almost random placement
Diagnoses:
* Parameters are auto-focused when added, and parameters are auto-added
in forward order
* TransclusionModel's process method had a bug in which the code to
derive an offset from the item being removed would not be reachable
due to an inverted logic statement
Prognosis:
* Fatal, with a 10% chance of survival
Treatment:
* Set focus on the first parameter after auto-adding required
parameters to a template
* Invert the logic in TransclusionModel's process method, so that if
the index IS undefined we will proceed to define it
Change-Id: I299053b63045ec933747831f1b4aa63493760f8b
---
M modules/ve-mw/dm/models/ve.dm.MWTransclusionModel.js
M modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js
M modules/ve-mw/ui/pages/ve.ui.MWTemplatePlaceholderPage.js
3 files changed, 11 insertions(+), 4 deletions(-)
Approvals:
Catrope: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/ve-mw/dm/models/ve.dm.MWTransclusionModel.js
b/modules/ve-mw/dm/models/ve.dm.MWTransclusionModel.js
index 7cbfbeb..abd1df1 100644
--- a/modules/ve-mw/dm/models/ve.dm.MWTransclusionModel.js
+++ b/modules/ve-mw/dm/models/ve.dm.MWTransclusionModel.js
@@ -114,17 +114,20 @@
// Auto-remove if already existing
this.removePart( item.add );
- // Add at index, or end if none was given
+ // Use specified index
index = item.index;
- if ( index !== undefined && item.remove ) {
+ // Derive index from removal if given
+ if ( index === undefined && item.remove ) {
index = ve.indexOf( item.remove, this.parts );
if ( index !== -1 ) {
remove = 1;
}
}
+ // Use last index as a last resort
if ( index === undefined || index === -1 ) {
index = this.parts.length;
}
+
this.parts.splice( index, remove, item.add );
if ( item.add ) {
item.add.connect( this, { 'change': [ 'emit', 'change'
] } );
diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js
b/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js
index a4ba58a..663d9ec 100644
--- a/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js
+++ b/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js
@@ -92,6 +92,11 @@
// Add required params to user created templates
if ( added instanceof ve.dm.MWTemplateModel &&
this.loaded ) {
added.addRequiredParameters();
+ names = added.getParameterNames();
+ params = added.getParameters();
+ if ( names.length ) {
+ this.setPageByName(
params[names[0]].getId() );
+ }
}
}
}
diff --git a/modules/ve-mw/ui/pages/ve.ui.MWTemplatePlaceholderPage.js
b/modules/ve-mw/ui/pages/ve.ui.MWTemplatePlaceholderPage.js
index a59270b..8298c0f 100644
--- a/modules/ve-mw/ui/pages/ve.ui.MWTemplatePlaceholderPage.js
+++ b/modules/ve-mw/ui/pages/ve.ui.MWTemplatePlaceholderPage.js
@@ -71,10 +71,9 @@
ve.ui.MWTemplatePlaceholderPage.prototype.onAddTemplate = function () {
var transclusion = this.placeholder.getTransclusion(),
- parts = this.placeholder.getTransclusion().getParts(),
part = ve.dm.MWTemplateModel.newFromName( transclusion,
this.addTemplateInput.getValue() );
- transclusion.replacePart( this.placeholder, part, ve.indexOf(
this.placeholder, parts ) );
+ transclusion.replacePart( this.placeholder, part );
this.addTemplateInput.pushPending();
this.addTemplateButton.setDisabled( true );
this.removeButton.setDisabled( true );
--
To view, visit https://gerrit.wikimedia.org/r/111389
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I299053b63045ec933747831f1b4aa63493760f8b
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Trevor Parscal <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits