mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 22:35:41 +00:00
Merge "Add using the article title as the default value for sorting in categories"
This commit is contained in:
commit
a9365a7fe4
|
@ -257,7 +257,7 @@ ve.ui.MWCategoriesPage.prototype.setup = function ( metaList ) {
|
|||
this.categoryWidget.addItems( this.getCategoryItems() );
|
||||
|
||||
this.defaultSortInput.setValue(
|
||||
defaultSortKeyItem ? defaultSortKeyItem.getAttribute( 'content' ) : ''
|
||||
defaultSortKeyItem ? defaultSortKeyItem.getAttribute( 'content' ) : this.fallbackDefaultSortKey
|
||||
);
|
||||
this.defaultSortKeyTouched = false;
|
||||
|
||||
|
@ -290,7 +290,7 @@ ve.ui.MWCategoriesPage.prototype.teardown = function ( data ) {
|
|||
if ( data && data.action === 'apply' ) {
|
||||
// Alter the default sort key iff it's been touched & is actually different
|
||||
if ( this.defaultSortKeyTouched ) {
|
||||
if ( newDefaultSortKey === '' ) {
|
||||
if ( newDefaultSortKey === '' || newDefaultSortKey === this.fallbackDefaultSortKey ) {
|
||||
if ( currentDefaultSortKeyItem ) {
|
||||
currentDefaultSortKeyItem.remove();
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ ve.ui.MWCategoryPopupWidget = function VeUiMWCategoryPopupWidget( config ) {
|
|||
this.removed = false;
|
||||
this.$title = $( '<label>' );
|
||||
this.$menu = $( '<div>' );
|
||||
this.fallbackSortKey = mw.config.get( 'wgTitle' );
|
||||
this.removeButton = new OO.ui.ButtonWidget( {
|
||||
framed: false,
|
||||
icon: 'trash',
|
||||
|
@ -134,7 +135,11 @@ ve.ui.MWCategoryPopupWidget.prototype.onToggle = function ( show ) {
|
|||
}
|
||||
newSortkey = this.sortKeyInput.$input.val();
|
||||
if ( !this.removed && newSortkey !== ( this.origSortkey || '' ) ) {
|
||||
this.emit( 'updateSortkey', this.category, this.sortKeyInput.$input.val() );
|
||||
if ( newSortkey === this.fallbackSortKey ) {
|
||||
this.emit( 'updateSortkey', this.category, '' );
|
||||
} else {
|
||||
this.emit( 'updateSortkey', this.category, this.sortKeyInput.$input.val() );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -145,7 +150,7 @@ ve.ui.MWCategoryPopupWidget.prototype.onToggle = function ( show ) {
|
|||
* @param {ve.ui.MWCategoryItemWidget} item Category item
|
||||
*/
|
||||
ve.ui.MWCategoryPopupWidget.prototype.loadCategoryIntoPopup = function ( item ) {
|
||||
this.origSortkey = item.sortKey;
|
||||
this.origSortkey = item.sortKey || this.fallbackSortKey;
|
||||
if ( item.isHidden ) {
|
||||
this.$hiddenStatus.text( ve.msg( 'visualeditor-dialog-meta-categories-hidden' ) );
|
||||
} else if ( item.isMissing ) {
|
||||
|
@ -153,7 +158,7 @@ ve.ui.MWCategoryPopupWidget.prototype.loadCategoryIntoPopup = function ( item )
|
|||
} else {
|
||||
this.$hiddenStatus.empty();
|
||||
}
|
||||
this.sortKeyInput.$input.val( item.sortKey );
|
||||
this.sortKeyInput.$input.val( this.origSortkey );
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -176,7 +181,7 @@ ve.ui.MWCategoryPopupWidget.prototype.closePopup = function () {
|
|||
* @param {string} value Default sort key value
|
||||
*/
|
||||
ve.ui.MWCategoryPopupWidget.prototype.setDefaultSortKey = function ( value ) {
|
||||
this.sortKeyInput.$input.attr( 'placeholder', value );
|
||||
this.fallbackSortKey = value;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue