jenkins-bot has submitted this change and it was merged.
Change subject: Use promise pattern inside MWTemplateDialog in order to
download TemplateData (currently just mocked) asynchronously.
......................................................................
Use promise pattern inside MWTemplateDialog in order to download TemplateData
(currently just mocked) asynchronously.
Change-Id: Ib23521cf40a80cc82872de82d3935414ef385d21
---
M modules/ve/ui/dialogs/ve.ui.MWTemplateDialog.js
1 file changed, 56 insertions(+), 52 deletions(-)
Approvals:
Catrope: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/ve/ui/dialogs/ve.ui.MWTemplateDialog.js
b/modules/ve/ui/dialogs/ve.ui.MWTemplateDialog.js
index ae61241..3ea15ec 100644
--- a/modules/ve/ui/dialogs/ve.ui.MWTemplateDialog.js
+++ b/modules/ve/ui/dialogs/ve.ui.MWTemplateDialog.js
@@ -49,27 +49,27 @@
* @method
*/
ve.ui.MWTemplateDialog.prototype.onOpen = function () {
- var mwAttr = this.surface.view.focusedNode.model.getAttribute( 'mw' ),
- templateData = this.getTemplateData( mwAttr.target.wt ),
- param;
+ var mwAttr = this.surface.view.focusedNode.model.getAttribute( 'mw' );
+ this.getTemplateData( mwAttr.target.wt ).done( ve.bind( function(
templateData ) {
+ var param;
+ this.paramsKeys = [];
+ this.paramsToInputs = {};
- this.paramsKeys = [];
- this.paramsToInputs = {};
+ // Parent method
+ ve.ui.PagedDialog.prototype.onOpen.call( this );
- // Parent method
- ve.ui.PagedDialog.prototype.onOpen.call( this );
+ // Add template page
+ this.addPage( 'template', mwAttr.target.wt, 'template' );
- // Add template page
- this.addPage( 'template', mwAttr.target.wt, 'template' );
-
- // Loop through parameters
- for ( param in mwAttr.params ) {
- this.createPage(
- param,
- mwAttr.params[param],
- templateData && templateData.params[param]
- );
- }
+ // Loop through parameters
+ for ( param in mwAttr.params ) {
+ this.createPage(
+ param,
+ mwAttr.params[param],
+ templateData && templateData.params[param]
+ );
+ }
+ }, this ) );
};
/**
@@ -105,42 +105,46 @@
};
ve.ui.MWTemplateDialog.prototype.getTemplateData = function ( /*templateName*/
) {
- var templateData = {
- 'title': 'Template:Unsigned',
- 'params': {
- 'user': {
- 'label': {
- 'en': 'User'
+ var promise = $.Deferred(),
+ templateData = {
+ 'title': 'Template:Unsigned',
+ 'params': {
+ 'user': {
+ 'label': {
+ 'en': 'User'
+ },
+ 'description': {
+ 'en': 'Name or IP of user who
left the comment'
+ },
+ 'required': true,
+ 'type': 'string/wiki-user-name',
+ 'aliases': [
+ '1'
+ ],
+ 'deprecated': false,
+ 'default': ''
},
- 'description': {
- 'en': 'Name or IP of user who left the
comment'
- },
- 'required': true,
- 'type': 'string/wiki-user-name',
- 'aliases': [
- '1'
- ],
- 'deprecated': false,
- 'default': ''
- },
- 'param1': {
- 'label': {
- 'en': 'Time stamp'
- },
- 'description': {
- 'en': 'datestamp from edit history
(remember to label it UTC)'
- },
- 'aliases': [
- '2'
- ],
- 'required': false,
- 'deprecated': false,
- 'default': '',
- 'type': 'unknown'
+ 'param1': {
+ 'label': {
+ 'en': 'Time stamp'
+ },
+ 'description': {
+ 'en': 'datestamp from edit
history (remember to label it UTC)'
+ },
+ 'aliases': [
+ '2'
+ ],
+ 'required': false,
+ 'deprecated': false,
+ 'default': '',
+ 'type': 'unknown'
+ }
}
- }
- };
- return templateData;
+ };
+ setTimeout( function() {
+ promise.resolve( templateData );
+ }, 500 );
+ return promise;
};
/**
--
To view, visit https://gerrit.wikimedia.org/r/64255
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib23521cf40a80cc82872de82d3935414ef385d21
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Inez <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Trevor Parscal <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits