From 08b3f73f16340dbd6f2bdc85aeadf626630a52ce Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Sun, 12 Feb 2017 17:58:12 +0000 Subject: [PATCH] MWTableDialog: Extend initial values so 'done' button behaves correctly Depends-On: I608431365f2a482536affe1dae3fe21bc20e16b4 Change-Id: Idd468caa9417ffd8e0475083c884ef6c554ee152 --- .../ve-mw/ui/dialogs/ve.ui.MWTableDialog.js | 31 +++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWTableDialog.js b/modules/ve-mw/ui/dialogs/ve.ui.MWTableDialog.js index 1ecc55b3b6..6d69ff4e90 100644 --- a/modules/ve-mw/ui/dialogs/ve.ui.MWTableDialog.js +++ b/modules/ve-mw/ui/dialogs/ve.ui.MWTableDialog.js @@ -24,6 +24,18 @@ OO.inheritClass( ve.ui.MWTableDialog, ve.ui.TableDialog ); /* Methods */ +/** + * @inheritdoc + */ +ve.ui.MWTableDialog.prototype.getValues = function () { + // Parent method + var values = ve.ui.MWTableDialog.super.prototype.getValues.call( this ); + return ve.extendObject( values, { + wikitable: this.wikitableToggle.getValue(), + sortable: this.sortableToggle.getValue() + } ); +}; + /** * @inheritdoc */ @@ -37,12 +49,16 @@ ve.ui.MWTableDialog.prototype.initialize = function () { label: ve.msg( 'visualeditor-dialog-table-wikitable' ) } ); + this.wikitableToggle.connect( this, { change: 'updateActions' } ); + this.sortableToggle = new OO.ui.ToggleSwitchWidget(); this.sortableField = new OO.ui.FieldLayout( this.sortableToggle, { align: 'left', label: ve.msg( 'visualeditor-dialog-table-sortable' ) } ); + this.sortableToggle.connect( this, { change: 'updateActions' } ); + this.panel.$element.prepend( this.wikitableField.$element, this.sortableField.$element ); }; @@ -52,10 +68,19 @@ ve.ui.MWTableDialog.prototype.initialize = function () { ve.ui.MWTableDialog.prototype.getSetupProcess = function ( data ) { return ve.ui.MWTableDialog.super.prototype.getSetupProcess.call( this, data ) .next( function () { - var tableNode = this.getFragment().getSelection().getTableNode(); + var tableNode = this.getFragment().getSelection().getTableNode(), + wikitable = !!tableNode.getAttribute( 'wikitable' ), + sortable = !!tableNode.getAttribute( 'sortable' ); - this.wikitableToggle.setValue( !!tableNode.getAttribute( 'wikitable' ) ); - this.sortableToggle.setValue( !!tableNode.getAttribute( 'sortable' ) ); + this.wikitableToggle.setValue( wikitable ); + this.sortableToggle.setValue( sortable ); + + ve.extendObject( this.initialValues, { + wikitable: wikitable, + sortable: sortable + } ); + + this.updateActions(); }, this ); };