Merge "Delete default sort key if set to empty string"

This commit is contained in:
jenkins-bot 2013-06-21 20:10:12 +00:00 committed by Gerrit Code Review
commit c32378b571

View file

@ -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();
}
}