Inez has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/64007


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(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor 
refs/changes/07/64007/1

diff --git a/modules/ve/ui/dialogs/ve.ui.MWTemplateDialog.js 
b/modules/ve/ui/dialogs/ve.ui.MWTemplateDialog.js
index 4879a09..7cd6b95 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 = 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: newchange
Gerrit-Change-Id: I4a1acdadcd1486ddd5dafcfc794c9b3b93e92592
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Inez <[email protected]>

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

Reply via email to