jenkins-bot has submitted this change and it was merged.

Change subject: Create and commit transaction after attributes of the template 
are changed and applied.
......................................................................


Create and commit transaction after attributes of the template are changed and 
applied.

Change-Id: I4a1acdadcd1486ddd5dafcfc794c9b3b93e92592
---
M modules/ve/ui/dialogs/ve.ui.MWTemplateDialog.js
1 file changed, 27 insertions(+), 1 deletion(-)

Approvals:
  Christian: 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 4879a09..ae61241 100644
--- a/modules/ve/ui/dialogs/ve.ui.MWTemplateDialog.js
+++ b/modules/ve/ui/dialogs/ve.ui.MWTemplateDialog.js
@@ -53,6 +53,9 @@
                templateData = this.getTemplateData( mwAttr.target.wt ),
                param;
 
+       this.paramsKeys = [];
+       this.paramsToInputs = {};
+
        // Parent method
        ve.ui.PagedDialog.prototype.onOpen.call( this );
 
@@ -96,6 +99,9 @@
        textInput.setValue( value.wt );
        this.addPage( pageName, label, 'parameter', 1 );
        this.pages[pageName].$.append( fieldset.$ );
+
+       this.paramsKeys.push( key );
+       this.paramsToInputs[key] = textInput;
 };
 
 ve.ui.MWTemplateDialog.prototype.getTemplateData = function ( /*templateName*/ 
) {
@@ -143,9 +149,29 @@
  * @method
  * @param {string} action Action that caused the window to be closed
  */
-ve.ui.MWTemplateDialog.prototype.onClose = function () {
+ve.ui.MWTemplateDialog.prototype.onClose = function ( action ) {
+       var mwAttr, i;
        // Parent method
        ve.ui.PagedDialog.prototype.onOpen.call( this );
+
+       if ( action === 'apply' ) {
+               mwAttr = ve.cloneObject( 
this.surface.view.focusedNode.model.getAttribute( 'mw' ) );
+               mwAttr.params = {};
+               for ( i = 0; i < this.paramsKeys.length; i++ ) {
+                       mwAttr.params[this.paramsKeys[i]] = {
+                               'wt': 
this.paramsToInputs[this.paramsKeys[i]].getValue()
+                       };
+               }
+               this.surface.model.change(
+                       ve.dm.Transaction.newFromAttributeChange(
+                               this.surface.model.documentModel,
+                               this.surface.view.focusedNode.getOffset(),
+                               'mw',
+                               mwAttr
+                       )
+               );
+       }
+
        this.clearPages();
 };
 

-- 
To view, visit https://gerrit.wikimedia.org/r/64007
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I4a1acdadcd1486ddd5dafcfc794c9b3b93e92592
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Inez <[email protected]>
Gerrit-Reviewer: Christian <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to