Add a check-all checkbox per namespace in Special:EditWatchlist
Bug: T334252 Change-Id: I9be7be32238184cb9b21a8bcc410a4188417ce01
This commit is contained in:
parent
c45fc57303
commit
dcbefc28ce
5 changed files with 37 additions and 2 deletions
|
|
@ -143,6 +143,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
|
|||
'mediawiki.interface.helpers.styles',
|
||||
'mediawiki.special'
|
||||
] );
|
||||
$out->addModules( [ 'mediawiki.special.watchlist' ] );
|
||||
|
||||
$mode = self::getMode( $this->getRequest(), $mode, self::EDIT_NORMAL );
|
||||
$this->currentMode = $mode;
|
||||
|
|
@ -657,8 +658,11 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
|
|||
$removed = [];
|
||||
|
||||
foreach ( $data as $titles ) {
|
||||
$this->unwatchTitles( $titles );
|
||||
$removed = array_merge( $removed, $titles );
|
||||
// ignore the 'check all' checkbox, which is a boolean value
|
||||
if ( is_array( $titles ) ) {
|
||||
$this->unwatchTitles( $titles );
|
||||
$removed = array_merge( $removed, $titles );
|
||||
}
|
||||
}
|
||||
|
||||
if ( count( $removed ) > 0 ) {
|
||||
|
|
@ -700,7 +704,16 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
|
|||
|
||||
// checkTitle can filter some options out, avoid empty sections
|
||||
if ( count( $options ) > 0 ) {
|
||||
// add a checkbox to select all entries in namespace
|
||||
$fields['CheckAllNs' . $namespace] = [
|
||||
'cssclass' => 'mw-watchlistedit-checkall',
|
||||
'type' => 'check',
|
||||
'section' => "ns$namespace",
|
||||
'label' => $this->msg( 'watchlistedit-normal-check-all' )->text()
|
||||
];
|
||||
|
||||
$fields['TitlesNs' . $namespace] = [
|
||||
'cssclass' => 'mw-watchlistedit-check' . $namespace,
|
||||
'class' => EditWatchlistCheckboxSeriesField::class,
|
||||
'options' => $options,
|
||||
'section' => "ns$namespace",
|
||||
|
|
|
|||
|
|
@ -3632,6 +3632,7 @@
|
|||
"watchlistedit-normal-legend": "Remove titles from watchlist",
|
||||
"watchlistedit-normal-explain": "Titles on your watchlist are shown below.\nTo remove a title, check the box next to it, and click \"{{int:Watchlistedit-normal-submit}}\".\nYou can also [[Special:EditWatchlist/raw|edit the raw list]].",
|
||||
"watchlistedit-normal-submit": "Remove titles",
|
||||
"watchlistedit-normal-check-all": "Check all",
|
||||
"watchlistedit-normal-done": "{{PLURAL:$1|A single title was|$1 titles were}} removed from your watchlist:",
|
||||
"watchlistedit-raw-title": "Edit raw watchlist",
|
||||
"watchlistedit-raw-legend": "Edit raw watchlist",
|
||||
|
|
|
|||
|
|
@ -3879,6 +3879,7 @@
|
|||
"lag-warn-normal": "Used as warning about replica lag. Parameters:\n* $1 - number of seconds\nSee also:\n* {{msg-mw|Lag-warn-high}}",
|
||||
"lag-warn-high": "Used as warning about replica lag. Parameters:\n* $1 - number of seconds\nSee also:\n* {{msg-mw|Lag-warn-normal}}",
|
||||
"editwatchlist-summary": "{{doc-specialpagesummary|editwatchlist}}",
|
||||
"watchlistedit-normal-check-all": "Label for checkbox to select all items in a namespace",
|
||||
"watchlistedit-normal-title": "Title of [[Special:Watchlist/edit|special page]].",
|
||||
"watchlistedit-normal-legend": "Heading of dialogue box on [[Special:Watchlist/edit]]",
|
||||
"watchlistedit-normal-explain": "An introduction/explanation about the [[Special:Watchlist/edit|normal edit watchlist function]].\n\nRefers to {{msg-mw|Watchlistedit-normal-submit}}.",
|
||||
|
|
|
|||
|
|
@ -2321,6 +2321,7 @@ return [
|
|||
'scripts' => [
|
||||
'resources/src/mediawiki.special.watchlist/watchlist.js',
|
||||
'resources/src/mediawiki.special.watchlist/visitedstatus.js',
|
||||
'resources/src/mediawiki.special.watchlist/editwatchlist.js'
|
||||
],
|
||||
'messages' => [
|
||||
'addedwatchtext',
|
||||
|
|
@ -2333,6 +2334,7 @@ return [
|
|||
'tooltip-ca-unwatch-expiring-hours',
|
||||
'watchlist-unwatch',
|
||||
'watchlist-unwatch-undo',
|
||||
'watchlistedit-normal-check-all'
|
||||
],
|
||||
'dependencies' => [
|
||||
'mediawiki.api',
|
||||
|
|
|
|||
18
resources/src/mediawiki.special.watchlist/editwatchlist.js
Normal file
18
resources/src/mediawiki.special.watchlist/editwatchlist.js
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/*!
|
||||
* JavaScript for Special:EditWatchlist
|
||||
*/
|
||||
( function () {
|
||||
$( function () {
|
||||
var $checkAllCheckboxes = $( 'span.mw-watchlistedit-checkall' );
|
||||
|
||||
$checkAllCheckboxes.each( function ( index, el ) {
|
||||
var checkbox = OO.ui.infuse( el );
|
||||
checkbox.on( 'change', function ( e ) {
|
||||
var status = e;
|
||||
var namespace = checkbox.elementId.split( 'CheckAllNs' )[ 1 ];
|
||||
var $itemsToCheck = $( '.mw-watchlistedit-check' + namespace ).find( 'input[type="checkbox"]' );
|
||||
$itemsToCheck.prop( 'checked', status );
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
}() );
|
||||
Loading…
Reference in a new issue