mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-09-24 02:38:40 +00:00
Show category items as red if they don't have description pages
Also fix some lies I wrote in related code/docs Bug: 65517 Change-Id: Iafacee7d8e460913d84808fe38ecc8da4a1817c0
This commit is contained in:
parent
3ebbfe6953
commit
de73246ee1
|
@ -1063,6 +1063,7 @@ $wgResourceModules += array(
|
|||
'visualeditor-dialog-meta-categories-input-movecategorylabel',
|
||||
'visualeditor-dialog-meta-categories-input-newcategorylabel',
|
||||
'visualeditor-dialog-meta-categories-input-placeholder',
|
||||
'visualeditor-dialog-meta-categories-missing',
|
||||
'visualeditor-dialog-meta-categories-options',
|
||||
'visualeditor-dialog-meta-categories-section',
|
||||
'visualeditor-dialog-meta-categories-sortkey-label',
|
||||
|
|
|
@ -107,6 +107,7 @@
|
|||
"visualeditor-dialog-meta-categories-input-movecategorylabel": "Move this category here",
|
||||
"visualeditor-dialog-meta-categories-input-newcategorylabel": "New category",
|
||||
"visualeditor-dialog-meta-categories-input-placeholder": "Add a category",
|
||||
"visualeditor-dialog-meta-categories-missing": "This category lacks a description page.",
|
||||
"visualeditor-dialog-meta-categories-options": "Options",
|
||||
"visualeditor-dialog-meta-categories-section": "Categories",
|
||||
"visualeditor-dialog-meta-categories-sortkey-label": "Sort this page as if it is called",
|
||||
|
|
|
@ -116,6 +116,7 @@
|
|||
"visualeditor-dialog-meta-categories-input-movecategorylabel": "Label for moving a given category or categories to end of list",
|
||||
"visualeditor-dialog-meta-categories-input-newcategorylabel": "Label for a suggested uncreated category",
|
||||
"visualeditor-dialog-meta-categories-input-placeholder": "Placeholder text for category input\n{{Identical|Add category}}",
|
||||
"visualeditor-dialog-meta-categories-missing": "Text shown on the category popup if the category does not have a description page.",
|
||||
"visualeditor-dialog-meta-categories-options": "Label for the category options sub-section.\n{{Identical|Options}}",
|
||||
"visualeditor-dialog-meta-categories-section": "Label for the categories dialog section.\n{{Identical|Category}}",
|
||||
"visualeditor-dialog-meta-categories-sortkey-label": "[[Image:VisualEditor - Category editing 1.png|thumb|Screenshot of the feature]]\nLabel for setting the page's sort key for a given category; the new value of the sort key flows immediately from this label – effectively, \"Sort this page as if it is called 'Foo'.\"",
|
||||
|
|
|
@ -86,7 +86,7 @@
|
|||
/**
|
||||
* Requests information about the title, then adds classes to the provided element as appropriate.
|
||||
*
|
||||
* @param {string} title Defaults to 'href' attribute of $element
|
||||
* @param {string} title
|
||||
* @param {jQuery} $element Element to style
|
||||
*/
|
||||
ve.init.mw.LinkCache.prototype.styleElement = function ( title, $element ) {
|
||||
|
|
|
@ -55,6 +55,10 @@
|
|||
color: #333;
|
||||
}
|
||||
|
||||
.ve-ui-mwCategoryItemWidget-label.new {
|
||||
color: #BA0000;
|
||||
}
|
||||
|
||||
.ve-ui-mwCategoryItemWidget-button:active {
|
||||
border-color: #ddd;
|
||||
box-shadow: inset 0 1px 4px 0 rgba(0, 0, 0, 0.07);
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
* @param {Object} [config] Configuration options
|
||||
* @cfg {Object} [item] Category item
|
||||
* @cfg {boolean} [hidden] Whether the category is hidden or not
|
||||
* @cfg {boolean} [missing] Whether the category's description page is missing
|
||||
* @cfg {string} [redirectTo] The name of the category this category's page redirects to.
|
||||
*/
|
||||
ve.ui.MWCategoryItemWidget = function VeUiMWCategoryItemWidget( config ) {
|
||||
|
@ -35,6 +36,7 @@ ve.ui.MWCategoryItemWidget = function VeUiMWCategoryItemWidget( config ) {
|
|||
this.sortKey = config.item.sortKey || '';
|
||||
this.metaItem = config.item.metaItem;
|
||||
this.isHidden = config.hidden;
|
||||
this.isMissing = config.missing;
|
||||
this.menuOpen = false;
|
||||
this.$label = this.$( '<span>' );
|
||||
this.$categoryItem = this.$( '<div>' );
|
||||
|
@ -49,6 +51,15 @@ ve.ui.MWCategoryItemWidget = function VeUiMWCategoryItemWidget( config ) {
|
|||
this.$label
|
||||
.addClass( 've-ui-mwCategoryItemWidget-label' )
|
||||
.text( config.redirectTo || this.value );
|
||||
if ( config.redirectTo ) {
|
||||
ve.init.platform.linkCache.styleElement( mw.Title.newFromText(
|
||||
config.redirectTo,
|
||||
mw.config.get( 'wgNamespaceIds' ).category
|
||||
).getPrefixedText(), this.$label );
|
||||
} else {
|
||||
ve.init.platform.linkCache.styleElement( this.name, this.$label );
|
||||
}
|
||||
|
||||
this.$categoryItem
|
||||
.addClass( 've-ui-mwCategoryItemWidget-button' )
|
||||
.append( this.$label, this.$indicator );
|
||||
|
|
|
@ -147,6 +147,8 @@ ve.ui.MWCategoryPopupWidget.prototype.loadCategoryIntoPopup = function ( item )
|
|||
this.origSortkey = item.sortkey;
|
||||
if ( item.isHidden ) {
|
||||
this.$hiddenStatus.text( ve.msg( 'visualeditor-dialog-meta-categories-hidden' ) );
|
||||
} else if ( item.isMissing ) {
|
||||
this.$hiddenStatus.text( ve.msg( 'visualeditor-dialog-meta-categories-missing' ) );
|
||||
} else {
|
||||
this.$hiddenStatus.empty();
|
||||
}
|
||||
|
|
|
@ -206,7 +206,7 @@ ve.ui.MWCategoryWidget.prototype.queryCategoryHiddenStatus = function ( category
|
|||
if ( result && result.query && result.query.pages ) {
|
||||
$.each( result.query.pages, function ( index, pageInfo ) {
|
||||
linkCacheUpdate[pageInfo.title] = {
|
||||
missing: false,
|
||||
missing: Object.prototype.hasOwnProperty.call( pageInfo, 'missing' ),
|
||||
hidden: pageInfo.pageprops &&
|
||||
Object.prototype.hasOwnProperty.call( pageInfo.pageprops, 'hiddencat' )
|
||||
};
|
||||
|
@ -239,7 +239,7 @@ ve.ui.MWCategoryWidget.prototype.addItems = function ( items, index ) {
|
|||
categoryWidget = this;
|
||||
|
||||
return this.queryCategoryHiddenStatus( categoryNames ).then( function () {
|
||||
var itemTitle, config;
|
||||
var itemTitle, config, cachedData;
|
||||
for ( i = 0, len = items.length; i < len; i++ ) {
|
||||
item = items[i];
|
||||
|
||||
|
@ -254,9 +254,13 @@ ve.ui.MWCategoryWidget.prototype.addItems = function ( items, index ) {
|
|||
categoryWidget.categoryRedirects[itemTitle],
|
||||
mw.config.get( 'wgNamespaceIds' ).category
|
||||
).getMainText();
|
||||
config.hidden = ve.init.platform.linkCache.getCached( categoryWidget.categoryRedirects[itemTitle] ).hidden;
|
||||
cachedData = ve.init.platform.linkCache.getCached( categoryWidget.categoryRedirects[itemTitle] );
|
||||
config.hidden = cachedData.hidden;
|
||||
config.missing = cachedData.missing;
|
||||
} else {
|
||||
config.hidden = ve.init.platform.linkCache.getCached( item.name ).hidden;
|
||||
cachedData = ve.init.platform.linkCache.getCached( item.name );
|
||||
config.hidden = cachedData.hidden;
|
||||
config.missing = cachedData.missing;
|
||||
}
|
||||
categoryItem = new ve.ui.MWCategoryItemWidget( config );
|
||||
categoryItem.connect( categoryWidget, {
|
||||
|
|
Loading…
Reference in a new issue