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.categoryWidget.addItems( this.getCategoryItems() );
|
||||||
|
|
||||||
this.defaultSortInput.setValue(
|
this.defaultSortInput.setValue(
|
||||||
defaultSortKeyItem ? defaultSortKeyItem.getAttribute( 'content' ) : ''
|
defaultSortKeyItem ? defaultSortKeyItem.getAttribute( 'content' ) : this.fallbackDefaultSortKey
|
||||||
);
|
);
|
||||||
this.defaultSortKeyTouched = false;
|
this.defaultSortKeyTouched = false;
|
||||||
|
|
||||||
|
@ -290,7 +290,7 @@ ve.ui.MWCategoriesPage.prototype.teardown = function ( data ) {
|
||||||
if ( data && data.action === 'apply' ) {
|
if ( data && data.action === 'apply' ) {
|
||||||
// Alter the default sort key iff it's been touched & is actually different
|
// Alter the default sort key iff it's been touched & is actually different
|
||||||
if ( this.defaultSortKeyTouched ) {
|
if ( this.defaultSortKeyTouched ) {
|
||||||
if ( newDefaultSortKey === '' ) {
|
if ( newDefaultSortKey === '' || newDefaultSortKey === this.fallbackDefaultSortKey ) {
|
||||||
if ( currentDefaultSortKeyItem ) {
|
if ( currentDefaultSortKeyItem ) {
|
||||||
currentDefaultSortKeyItem.remove();
|
currentDefaultSortKeyItem.remove();
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ ve.ui.MWCategoryPopupWidget = function VeUiMWCategoryPopupWidget( config ) {
|
||||||
this.removed = false;
|
this.removed = false;
|
||||||
this.$title = $( '<label>' );
|
this.$title = $( '<label>' );
|
||||||
this.$menu = $( '<div>' );
|
this.$menu = $( '<div>' );
|
||||||
|
this.fallbackSortKey = mw.config.get( 'wgTitle' );
|
||||||
this.removeButton = new OO.ui.ButtonWidget( {
|
this.removeButton = new OO.ui.ButtonWidget( {
|
||||||
framed: false,
|
framed: false,
|
||||||
icon: 'trash',
|
icon: 'trash',
|
||||||
|
@ -134,7 +135,11 @@ ve.ui.MWCategoryPopupWidget.prototype.onToggle = function ( show ) {
|
||||||
}
|
}
|
||||||
newSortkey = this.sortKeyInput.$input.val();
|
newSortkey = this.sortKeyInput.$input.val();
|
||||||
if ( !this.removed && newSortkey !== ( this.origSortkey || '' ) ) {
|
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
|
* @param {ve.ui.MWCategoryItemWidget} item Category item
|
||||||
*/
|
*/
|
||||||
ve.ui.MWCategoryPopupWidget.prototype.loadCategoryIntoPopup = function ( item ) {
|
ve.ui.MWCategoryPopupWidget.prototype.loadCategoryIntoPopup = function ( item ) {
|
||||||
this.origSortkey = item.sortKey;
|
this.origSortkey = item.sortKey || this.fallbackSortKey;
|
||||||
if ( item.isHidden ) {
|
if ( item.isHidden ) {
|
||||||
this.$hiddenStatus.text( ve.msg( 'visualeditor-dialog-meta-categories-hidden' ) );
|
this.$hiddenStatus.text( ve.msg( 'visualeditor-dialog-meta-categories-hidden' ) );
|
||||||
} else if ( item.isMissing ) {
|
} else if ( item.isMissing ) {
|
||||||
|
@ -153,7 +158,7 @@ ve.ui.MWCategoryPopupWidget.prototype.loadCategoryIntoPopup = function ( item )
|
||||||
} else {
|
} else {
|
||||||
this.$hiddenStatus.empty();
|
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
|
* @param {string} value Default sort key value
|
||||||
*/
|
*/
|
||||||
ve.ui.MWCategoryPopupWidget.prototype.setDefaultSortKey = function ( value ) {
|
ve.ui.MWCategoryPopupWidget.prototype.setDefaultSortKey = function ( value ) {
|
||||||
this.sortKeyInput.$input.attr( 'placeholder', value );
|
this.fallbackSortKey = value;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue