diff --git a/includes/specials/SpecialEditWatchlist.php b/includes/specials/SpecialEditWatchlist.php index 57816eeeb4c..5f1c0398585 100644 --- a/includes/specials/SpecialEditWatchlist.php +++ b/includes/specials/SpecialEditWatchlist.php @@ -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", diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 9b0e42e500d..c58553826a5 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -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", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index a3698830bf0..13e67f54269 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -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}}.", diff --git a/resources/Resources.php b/resources/Resources.php index 682cc932dcc..89d6b941ae6 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -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', diff --git a/resources/src/mediawiki.special.watchlist/editwatchlist.js b/resources/src/mediawiki.special.watchlist/editwatchlist.js new file mode 100644 index 00000000000..4148009295d --- /dev/null +++ b/resources/src/mediawiki.special.watchlist/editwatchlist.js @@ -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 ); + } ); + } ); + } ); +}() );