Allow subsection issues
Depends-On: Iaa35317cdd96a1ad306ab38dc3ab2f18cc7bb31f Bug: T197932 Change-Id: I84649dc80192729934f7bbb23a8e78296717bf36
This commit is contained in:
parent
6718bc4351
commit
6a5b2e284d
|
@ -93,7 +93,7 @@
|
||||||
* will be rendered above the heading.
|
* will be rendered above the heading.
|
||||||
* This function comes with side effects. It will populate a global "allIssues" object which
|
* This function comes with side effects. It will populate a global "allIssues" object which
|
||||||
* will link section numbers to issues.
|
* will link section numbers to issues.
|
||||||
* @param {JQuery.Object} $container to render the page issues banner inside.
|
* @param {Page} page to search for page issues inside
|
||||||
* @param {string} labelText what the label of the page issues banner should say
|
* @param {string} labelText what the label of the page issues banner should say
|
||||||
* @param {number|string} section that the banner and its issues belong to.
|
* @param {number|string} section that the banner and its issues belong to.
|
||||||
* If string KEYWORD_ALL_SECTIONS banner should apply to entire page.
|
* If string KEYWORD_ALL_SECTIONS banner should apply to entire page.
|
||||||
|
@ -104,15 +104,20 @@
|
||||||
*
|
*
|
||||||
* @return {JQuery.Object}
|
* @return {JQuery.Object}
|
||||||
*/
|
*/
|
||||||
function createBanner( $container, labelText, section, inline, overlayManager ) {
|
function createBanner( page, labelText, section, inline, overlayManager ) {
|
||||||
var $learnMore,
|
var $learnMore, $metadata,
|
||||||
issueUrl = section === KEYWORD_ALL_SECTIONS ? '#/issues/' + KEYWORD_ALL_SECTIONS : '#/issues/' + section,
|
issueUrl = section === KEYWORD_ALL_SECTIONS ? '#/issues/' + KEYWORD_ALL_SECTIONS : '#/issues/' + section,
|
||||||
selector = 'table.ambox, table.tmbox, table.cmbox, table.fmbox',
|
selector = 'table.ambox, table.tmbox, table.cmbox, table.fmbox',
|
||||||
$metadata = $container.find( selector ),
|
|
||||||
issues = [],
|
issues = [],
|
||||||
$link,
|
$link,
|
||||||
severity;
|
severity;
|
||||||
|
|
||||||
|
if ( section === KEYWORD_ALL_SECTIONS ) {
|
||||||
|
$metadata = page.$( selector );
|
||||||
|
} else {
|
||||||
|
// find heading associated with the section
|
||||||
|
$metadata = page.findChildInSectionLead( parseInt( section, 10 ), selector );
|
||||||
|
}
|
||||||
// clean it up a little
|
// clean it up a little
|
||||||
$metadata.find( '.NavFrame' ).remove();
|
$metadata.find( '.NavFrame' ).remove();
|
||||||
$metadata.each( function () {
|
$metadata.each( function () {
|
||||||
|
@ -231,31 +236,30 @@
|
||||||
headingText = getNamespaceHeadingText( CURRENT_NS ),
|
headingText = getNamespaceHeadingText( CURRENT_NS ),
|
||||||
$lead = page.getLeadSectionElement(),
|
$lead = page.getLeadSectionElement(),
|
||||||
issueOverlayShowAll = CURRENT_NS === NS_CATEGORY || CURRENT_NS === NS_TALK || !$lead,
|
issueOverlayShowAll = CURRENT_NS === NS_CATEGORY || CURRENT_NS === NS_TALK || !$lead,
|
||||||
inline = newTreatmentEnabled && CURRENT_NS === 0,
|
inline = newTreatmentEnabled && CURRENT_NS === 0;
|
||||||
$container = $( '#bodyContent' );
|
|
||||||
|
|
||||||
// set A-B test class.
|
// set A-B test class.
|
||||||
$( 'html' ).addClass( newTreatmentEnabled ? 'issues-group-B' : 'issues-group-A' );
|
$( 'html' ).addClass( newTreatmentEnabled ? 'issues-group-B' : 'issues-group-A' );
|
||||||
|
|
||||||
if ( CURRENT_NS === NS_TALK || CURRENT_NS === NS_CATEGORY ) {
|
if ( CURRENT_NS === NS_TALK || CURRENT_NS === NS_CATEGORY ) {
|
||||||
// e.g. Template:English variant category; Template:WikiProject
|
// e.g. Template:English variant category; Template:WikiProject
|
||||||
createBanner( $container, mw.msg( 'mobile-frontend-meta-data-issues-header-talk' ),
|
createBanner( page, mw.msg( 'mobile-frontend-meta-data-issues-header-talk' ),
|
||||||
KEYWORD_ALL_SECTIONS, inline, overlayManager );
|
KEYWORD_ALL_SECTIONS, inline, overlayManager );
|
||||||
} else if ( CURRENT_NS === NS_MAIN ) {
|
} else if ( CURRENT_NS === NS_MAIN ) {
|
||||||
label = mw.msg( 'mobile-frontend-meta-data-issues-header' );
|
label = mw.msg( 'mobile-frontend-meta-data-issues-header' );
|
||||||
if ( issueOverlayShowAll ) {
|
if ( issueOverlayShowAll ) {
|
||||||
createBanner( $container, label, KEYWORD_ALL_SECTIONS, inline, overlayManager );
|
createBanner( page, label, KEYWORD_ALL_SECTIONS, inline, overlayManager );
|
||||||
} else {
|
} else {
|
||||||
// parse lead
|
// parse lead
|
||||||
createBanner( $lead, label, 0, inline, overlayManager );
|
createBanner( page, label, 0, inline, overlayManager );
|
||||||
if ( newTreatmentEnabled ) {
|
if ( newTreatmentEnabled ) {
|
||||||
// parse other sections but only in group B. In treatment A no issues are shown for sections.
|
// parse other sections but only in group B. In treatment A no issues are shown for sections.
|
||||||
$lead.nextAll( Page.HEADING_SELECTOR ).each( function ( i, headingEl ) {
|
page.$( Page.HEADING_SELECTOR ).each( function ( i, headingEl ) {
|
||||||
var $headingEl = $( headingEl ),
|
var $headingEl = $( headingEl ),
|
||||||
$section = $headingEl.next(),
|
|
||||||
sectionNum = $headingEl.find( '.edit-page' ).data( 'section' );
|
sectionNum = $headingEl.find( '.edit-page' ).data( 'section' );
|
||||||
|
|
||||||
createBanner( $section, label, sectionNum, inline, overlayManager );
|
// Render banner for sectionNum associated with headingEl inside Page
|
||||||
|
createBanner( page, label, sectionNum, inline, overlayManager );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
( function ( M ) {
|
( function ( M ) {
|
||||||
var createBanner = M.require( 'skins.minerva.scripts/cleanuptemplates' ).test.createBanner,
|
var createBanner = M.require( 'skins.minerva.scripts/cleanuptemplates' ).test.createBanner,
|
||||||
OverlayManager = M.require( 'mobile.startup/OverlayManager' ),
|
OverlayManager = M.require( 'mobile.startup/OverlayManager' ),
|
||||||
|
Page = M.require( 'mobile.startup/Page' ),
|
||||||
overlayManager = new OverlayManager( require( 'mediawiki.router' ) ),
|
overlayManager = new OverlayManager( require( 'mediawiki.router' ) ),
|
||||||
$mockContainer = $(
|
$mockContainer = $(
|
||||||
'<div id=\'bodyContent\'>' +
|
'<div id=\'bodyContent\'>' +
|
||||||
|
@ -14,7 +15,10 @@
|
||||||
labelText = 'label text',
|
labelText = 'label text',
|
||||||
section = 0,
|
section = 0,
|
||||||
inline = true,
|
inline = true,
|
||||||
processedAmbox = createBanner( $mockContainer, labelText, section, inline, overlayManager );
|
processedAmbox = createBanner(
|
||||||
|
new Page( { el: $mockContainer } ),
|
||||||
|
labelText, section, inline, overlayManager
|
||||||
|
);
|
||||||
|
|
||||||
QUnit.module( 'Minerva cleanuptemplates' );
|
QUnit.module( 'Minerva cleanuptemplates' );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue