Florianschmidtwelzow has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/255806

Change subject: SpecialWatchlist: Add an option to automatically reload the 
page when a filter was changed
......................................................................

SpecialWatchlist: Add an option to automatically reload the page when a filter 
was changed

The biggest negative point (as far as I can tell) with the change mentioned in 
the follow-up
is, that a user needs at least 3 clicks to change an option, which before it 
required only
one click. This option adds a new preference for the watchlist (which can be 
enabled/disabled
using Special:Preferences) which, if enabled, loads a new, tiny module with a 
script, that
listens on all input and select fields in the header form of Special:Watchlist. 
Whenever one
of these elements get changed, the watchlist form will be submitted 
automatically.

The default for this option is false (disabled).

Follow up: I3bcd27596c21aa4

Bug: T50615
Bug: T119322
Change-Id: Icab1a5143df24a06f468165421d40db8fa57e73c
---
M includes/Preferences.php
M includes/specials/SpecialWatchlist.php
M languages/i18n/en.json
M languages/i18n/qqq.json
M resources/Resources.php
A resources/src/mediawiki.special/mediawiki.special.watchlist.js
6 files changed, 33 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/06/255806/1

diff --git a/includes/Preferences.php b/includes/Preferences.php
index 096f8e3..c7ab9cd 100644
--- a/includes/Preferences.php
+++ b/includes/Preferences.php
@@ -1006,6 +1006,11 @@
                        'section' => 'watchlist/advancedwatchlist',
                        'label-message' => 'tog-watchlisthideliu',
                );
+               $defaultPreferences['watchlistreloadautomatically'] = array(
+                       'type' => 'toggle',
+                       'section' => 'watchlist/advancedwatchlist',
+                       'label-message' => 'tog-watchlistreloadautomatically',
+               );
 
                if ( $config->get( 'RCWatchCategoryMembership' ) ) {
                        $defaultPreferences['watchlisthidecategorization'] = 
array(
diff --git a/includes/specials/SpecialWatchlist.php 
b/includes/specials/SpecialWatchlist.php
index 32d4552..34c44d4 100644
--- a/includes/specials/SpecialWatchlist.php
+++ b/includes/specials/SpecialWatchlist.php
@@ -403,8 +403,15 @@
         */
        public function doHeader( $opts, $numRows ) {
                $user = $this->getUser();
+               $out = $this->getOutput();
 
-               $this->getOutput()->addSubtitle(
+               // if the user wishes, that the watchlist is reloaded, whenever 
a filter changes,
+               // add the module for that
+               if ( $user->getBoolOption( 'watchlistreloadautomatically' ) ) {
+                       $out->addModules( array( 'mediawiki.special.watchlist' 
) );
+               }
+
+               $out->addSubtitle(
                        $this->msg( 'watchlistfor2', $user->getName() )
                                ->rawParams( SpecialEditWatchlist::buildTools( 
null ) )
                );
diff --git a/languages/i18n/en.json b/languages/i18n/en.json
index a274fac..9bc0249 100644
--- a/languages/i18n/en.json
+++ b/languages/i18n/en.json
@@ -35,6 +35,7 @@
        "tog-watchlisthidebots": "Hide bot edits from the watchlist",
        "tog-watchlisthideminor": "Hide minor edits from the watchlist",
        "tog-watchlisthideliu": "Hide edits by logged in users from the 
watchlist",
+       "tog-watchlistreloadautomatically": "Reload the Watchlist automatically 
whenever a filter is changed (JavaScript required)",
        "tog-watchlisthideanons": "Hide edits by anonymous users from the 
watchlist",
        "tog-watchlisthidepatrolled": "Hide patrolled edits from the watchlist",
        "tog-watchlisthidecategorization": "Hide categorization of pages",
diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json
index bd3776e..ebc4b68 100644
--- a/languages/i18n/qqq.json
+++ b/languages/i18n/qqq.json
@@ -209,6 +209,7 @@
        "tog-watchlisthidebots": "[[Special:Preferences]], tab 'Watchlist'. 
Offers user to hide bot edits from watchlist. 
{{Gender}}\n\n{{Related|Preferences-watchlistrc-toggle}}",
        "tog-watchlisthideminor": "[[Special:Preferences]], tab 'Watchlist'. 
Offers user to hide minor edits from watchlist. 
{{Gender}}\n\n{{Related|Preferences-watchlistrc-toggle}}",
        "tog-watchlisthideliu": "Option in tab 'Watchlist' of 
[[Special:Preferences]]. 
{{Gender}}\n\n{{Related|Preferences-watchlistrc-toggle}}",
+       "tog-watchlistreloadautomatically": "[[Special:Preferences]], tab 
'Watchlist'. Offers user to to automatically refresh the watchlist page, when a 
filter is changed.",
        "tog-watchlisthideanons": "Option in tab 'Watchlist' of 
[[Special:Preferences]]. 
{{Gender}}\n\n{{Related|Preferences-watchlistrc-toggle}}",
        "tog-watchlisthidepatrolled": "Option in Watchlist tab of 
[[Special:Preferences]]. 
{{Gender}}\n\n{{Related|Preferences-watchlistrc-toggle}}",
        "tog-watchlisthidecategorization": "Option in Watchlist tab of 
[[Special:Preferences]]. Offers user to hide/show categorization of pages. 
Appears next to checkboxes with labels such as 
{{msg-mw|tog-watchlisthideminor}}.",
diff --git a/resources/Resources.php b/resources/Resources.php
index 0eb5118..aba5ce8 100644
--- a/resources/Resources.php
+++ b/resources/Resources.php
@@ -1834,6 +1834,9 @@
                        'mediawiki.util',
                ),
        ),
+       'mediawiki.special.watchlist' => array(
+               'scripts' => 
'resources/src/mediawiki.special/mediawiki.special.watchlist.js',
+       ),
        'mediawiki.special.javaScriptTest' => array(
                'scripts' => 
'resources/src/mediawiki.special/mediawiki.special.javaScriptTest.js',
                'messages' => array_merge( Skin::getSkinNameMessages(), array(
diff --git a/resources/src/mediawiki.special/mediawiki.special.watchlist.js 
b/resources/src/mediawiki.special/mediawiki.special.watchlist.js
new file mode 100644
index 0000000..c3f1d90
--- /dev/null
+++ b/resources/src/mediawiki.special/mediawiki.special.watchlist.js
@@ -0,0 +1,15 @@
+/*!
+ * JavaScript for Special:Watchlist
+ *
+ * This script is only loaded, if the user opt-in a setting in 
Special:Preferences,
+ * that the watchlist should be automatically reloaded, when a filter option is
+ * changed in the header form.
+ */
+( function ( $ ) {
+       // add a listener on all form elements in the header form
+       $( '#mw-watchlist-form input, #mw-watchlist-form select' ).on( 
'change', function () {
+               // submit the form, when one of the input fields was changed
+               $( '#mw-watchlist-form' ).submit();
+       } );
+
+}( jQuery ) );

-- 
To view, visit https://gerrit.wikimedia.org/r/255806
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icab1a5143df24a06f468165421d40db8fa57e73c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Florianschmidtwelzow <florian.schmidt.stargatewis...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to