mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-25 14:56:20 +00:00
MWTableDialog: Extend initial values so 'done' button behaves correctly
Depends-On: I608431365f2a482536affe1dae3fe21bc20e16b4 Change-Id: Idd468caa9417ffd8e0475083c884ef6c554ee152
This commit is contained in:
parent
444ed0b7d8
commit
08b3f73f16
|
@ -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 );
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue