mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 22:35:41 +00:00
Delete default sort key if set to empty string
Bug: 49724 Change-Id: Ie3caaf4811f87911444462f83d511c0cc46c0716
This commit is contained in:
parent
1ea9016cf8
commit
7b1df21aeb
|
@ -179,18 +179,22 @@ ve.ui.MWMetaDialog.prototype.onClose = function ( action ) {
|
|||
}
|
||||
|
||||
if ( this.defaultSortKeyChanged ) {
|
||||
newDefaultSortKeyItemData = {
|
||||
'type': 'mwDefaultSort',
|
||||
'attributes': { 'content': this.defaultSortInput.getValue() }
|
||||
};
|
||||
if ( currentDefaultSortKeyItem ) {
|
||||
newDefaultSortKeyItem = new ve.dm.MWDefaultSortMetaItem(
|
||||
ve.extendObject( {}, currentDefaultSortKeyItem.getElement(), newDefaultSortKeyItemData )
|
||||
);
|
||||
currentDefaultSortKeyItem.replaceWith( newDefaultSortKeyItem );
|
||||
} else {
|
||||
newDefaultSortKeyItem = new ve.dm.MWDefaultSortMetaItem( newDefaultSortKeyItemData );
|
||||
this.metaList.insertMeta( newDefaultSortKeyItem );
|
||||
if ( this.defaultSortInput.getValue() !== '' ) {
|
||||
newDefaultSortKeyItemData = {
|
||||
'type': 'mwDefaultSort',
|
||||
'attributes': { 'content': this.defaultSortInput.getValue() }
|
||||
};
|
||||
if ( currentDefaultSortKeyItem ) {
|
||||
newDefaultSortKeyItem = new ve.dm.MWDefaultSortMetaItem(
|
||||
ve.extendObject( {}, currentDefaultSortKeyItem.getElement(), newDefaultSortKeyItemData )
|
||||
);
|
||||
currentDefaultSortKeyItem.replaceWith( newDefaultSortKeyItem );
|
||||
} else {
|
||||
newDefaultSortKeyItem = new ve.dm.MWDefaultSortMetaItem( newDefaultSortKeyItemData );
|
||||
this.metaList.insertMeta( newDefaultSortKeyItem );
|
||||
}
|
||||
} else if ( currentDefaultSortKeyItem ) {
|
||||
currentDefaultSortKeyItem.remove();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue