RCLFilters: UI tweaks
authorStephane Bisson <sbisson@wikimedia.org>
Wed, 6 Dec 2017 12:05:24 +0000 (07:05 -0500)
committerStephane Bisson <sbisson@wikimedia.org>
Wed, 6 Dec 2017 16:33:45 +0000 (11:33 -0500)
Follow-up to I96af7ba583d03e6ff9833ac3b5f4b80cfd0ee626

* Reword 'Recentchangeslinked-summary'
* Bold ToOrFrom selector label
* Bold 'FROM' in 'rcfilters-filter-showlinkedfrom-option-label'
* Bold 'TO' in 'rcfilters-filter-showlinkedto-option-label'
* Reword target page selector placeholder
* Prevent title suggestions from showing duplicate entries
* Show a specific message when there is no results
  because no target page is specified.

Bug: T172161
Change-Id: I1b1ee793b3eff4183039acc27fe6cca042ee57d0

includes/specials/SpecialRecentchangeslinked.php
languages/i18n/en.json
languages/i18n/qqq.json
resources/Resources.php
resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js
resources/src/mediawiki.rcfilters/mw.rcfilters.init.js
resources/src/mediawiki.rcfilters/styles/mw.rcfilters.less
resources/src/mediawiki.rcfilters/styles/mw.rcfilters.ui.RclToOrFromWidget.less
resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.ChangesListWrapperWidget.js
resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.RclTargetPageWidget.js
resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.RclToOrFromWidget.js

index 2eeeb0b..9e0daf5 100644 (file)
@@ -310,4 +310,16 @@ class SpecialRecentChangesLinked extends SpecialRecentChanges {
 
                return parent::getPageTitle( $subpage );
        }
+
+       protected function outputNoResults() {
+               if ( $this->getTargetTitle() === false ) {
+                       $this->getOutput()->addHTML(
+                               '<div class="mw-changeslist-notargetpage">' .
+                               $this->msg( 'recentchanges-notargetpage' )->parse() .
+                               '</div>'
+                       );
+               } else {
+                       parent::outputNoResults();
+               }
+       }
 }
index 7254b92..4b65fbc 100644 (file)
        "recentchanges-noresult": "No changes during the given period match these criteria.",
        "recentchanges-timeout": "This search has timed out. You may wish to try different search parameters.",
        "recentchanges-network": "Due to a technical error, no results could be loaded. Please try refreshing the page.",
+       "recentchanges-notargetpage": "Enter a page name above to see changes related to that page.",
        "recentchanges-feed-description": "Track the most recent changes to the wiki in this feed.",
        "recentchanges-label-newpage": "This edit created a new page",
        "recentchanges-label-minor": "This is a minor edit",
        "rcfilters-watchlist-showupdated": "Changes to pages you haven't visited since the changes occurred are in <strong>bold</strong>, with solid markers.",
        "rcfilters-preference-label": "Hide the improved version of Recent Changes",
        "rcfilters-preference-help": "Rolls back the 2017 interface redesign and all tools added then and since.",
-       "rcfilters-filter-showlinkedfrom-label": "Show changes on pages linked from:",
-       "rcfilters-filter-showlinkedfrom-option-label": "Show changes on pages linked FROM a page",
-       "rcfilters-filter-showlinkedto-label": "Show changes on pages linked to:",
-       "rcfilters-filter-showlinkedto-option-label": "Show changes on pages linked TO a page",
-       "rcfilters-target-page-placeholder": "Select a page",
+       "rcfilters-filter-showlinkedfrom-label": "Show changes on pages linked from",
+       "rcfilters-filter-showlinkedfrom-option-label": "Show changes on pages linked <strong>FROM</strong> a page",
+       "rcfilters-filter-showlinkedto-label": "Show changes on pages linked to",
+       "rcfilters-filter-showlinkedto-option-label": "Show changes on pages linked <strong>TO</strong> a page",
+       "rcfilters-target-page-placeholder": "Enter a page name",
        "rcnotefrom": "Below {{PLURAL:$5|is the change|are the changes}} since <strong>$3, $4</strong> (up to <strong>$1</strong> shown).",
        "rclistfromreset": "Reset date selection",
        "rclistfrom": "Show new changes starting from $2, $3",
        "recentchangeslinked-feed": "Related changes",
        "recentchangeslinked-toolbox": "Related changes",
        "recentchangeslinked-title": "Changes related to \"$1\"",
-       "recentchangeslinked-summary": "This is a list of changes made recently to pages linked from a specified page (or to members of a specified category).\nPages on [[Special:Watchlist|your watchlist]] are <strong>bold</strong>.",
+       "recentchangeslinked-summary": "Enter a page name to see changes on pages linked to or from that page. (To see members of a category, enter Category:Name of category). Changes to pages on [[Special:Watchlist|your Watchlist]] are in <strong>bold</strong>.",
        "recentchangeslinked-page": "Page name:",
        "recentchangeslinked-to": "Show changes to pages linked to the given page instead",
        "recentchanges-page-added-to-category": "[[:$1]] added to category",
index 0497396..072a93c 100644 (file)
        "recentchanges-noresult": "Used in [[Special:RecentChanges]], [[Special:RecentChangesLinked]], and [[Special:Watchlist]] when there are no changes to be shown.",
        "recentchanges-timeout": "Used in [[Special:RecentChanges]], [[Special:RecentChangesLinked]], and [[Special:Watchlist]] when a query times out.",
        "recentchanges-network": "Used in [[Special:RecentChanges]], [[Special:RecentChangesLinked]] and [[Special:Watchlist]] when network error occurs.",
+       "recentchanges-notargetpage": "Used in [[Special:RecentChangesLinked]] to explain why no results are shown when no target page is specified.",
        "recentchanges-feed-description": "Used in feed of RecentChanges. See example [{{canonicalurl:Special:RecentChanges|feed=atom}} feed].",
        "recentchanges-label-newpage": "# Used as tooltip for {{msg-mw|Newpageletter}}.\n# Also used as legend. Preceded by {{msg-mw|Newpageletter}} and followed by {{msg-mw|Recentchanges-legend-newpage}}.",
        "recentchanges-label-minor": "# Used as tooltip for {{msg-mw|Minoreditletter}}\n# Also used as legend. Preceded by {{msg-mw|Minoreditletter}}",
index 7beb775..fbc4dbb 100644 (file)
@@ -1923,6 +1923,7 @@ return [
                        'recentchanges-noresult',
                        'recentchanges-timeout',
                        'recentchanges-network',
+                       'recentchanges-notargetpage',
                        'quotation-marks',
                ],
                'dependencies' => [
index c1ffde2..8d5b815 100644 (file)
         * @return {jQuery} return.fieldset Fieldset
         */
        mw.rcfilters.Controller.prototype._extractChangesListInfo = function ( $root ) {
-               var info, isTimeout,
+               var info,
                        $changesListContents = $root.find( '.mw-changeslist' ).first().contents(),
                        areResults = !!$changesListContents.length;
 
                };
 
                if ( !areResults ) {
-                       isTimeout = !!$root.find( '.mw-changeslist-timeout' ).length;
-                       info.noResultsDetails = isTimeout ? 'NO_RESULTS_TIMEOUT' : 'NO_RESULTS_NORMAL';
+                       if ( $root.find( '.mw-changeslist-timeout' ).length ) {
+                               info.noResultsDetails = 'NO_RESULTS_TIMEOUT';
+                       } else if ( $root.find( '.mw-changeslist-notargetpage' ).length ) {
+                               info.noResultsDetails = 'NO_RESULTS_NO_TARGET_PAGE';
+                       } else {
+                               info.noResultsDetails = 'NO_RESULTS_NORMAL';
+                       }
                }
 
                return info;
index 6ec1200..2744b8b 100644 (file)
                                        controller, savedQueriesModel, { $overlay: $overlay }
                                ),
                                specialPage = mw.config.get( 'wgCanonicalSpecialPageName' ),
-                               $changesListRoot = $( '.mw-changeslist, .mw-changeslist-empty, .mw-changeslist-timeout' );
+                               $changesListRoot = $( [
+                                       '.mw-changeslist',
+                                       '.mw-changeslist-empty',
+                                       '.mw-changeslist-timeout',
+                                       '.mw-changeslist-notargetpage'
+                               ].join( ', ' ) );
 
                        // TODO: The changesListWrapperWidget should be able to initialize
                        // after the model is ready.
index 74b81fa..fea0c0a 100644 (file)
                }
        }
 
-       // Temporarily hide any 'empty' or 'timeout' message while we
-       // load rcfilters.
+       // Temporarily hide any specific 'no result' message while we load rcfilters.
        .mw-changeslist-empty,
-       .mw-changeslist-timeout {
+       .mw-changeslist-timeout,
+       .mw-changeslist-notargetpage {
                display: none;
        }
 
index 577c254..af01f68 100644 (file)
@@ -6,6 +6,7 @@
                .oo-ui-dropdownWidget-handle {
                        border: 0;
                        background-color: transparent;
+                       font-weight: bold;
                }
        }
 }
index 98a7d8c..cd0b8ae 100644 (file)
        mw.rcfilters.ui.ChangesListWrapperWidget.prototype.onModelUpdate = function (
                $changesListContent, $fieldset, noResultsDetails, isInitialDOM, from
        ) {
-               var conflictItem, noResultsKey,
+               var conflictItem,
                        $message = $( '<div>' )
                                .addClass( 'mw-rcfilters-ui-changesListWrapperWidget-results' ),
                        isEmpty = $changesListContent === 'NO_RESULTS',
                                                        .text( mw.message( conflictItem.getCurrentConflictResultMessage() ).text() )
                                        );
                        } else {
-                               noResultsKey =
-                                       ( noResultsDetails === 'NO_RESULTS_TIMEOUT' ) ?
-                                               'recentchanges-timeout' :
-                                               ( noResultsDetails === 'NO_RESULTS_NETWORK_ERROR' ) ?
-                                                       'recentchanges-network' :
-                                                       'recentchanges-noresult';
-
                                $message
                                        .append(
                                                $( '<div>' )
                                                        .addClass( 'mw-rcfilters-ui-changesListWrapperWidget-results-noresult' )
-                                                       .text( mw.message( noResultsKey ).text() )
+                                                       .text( mw.msg( this.getMsgKeyForNoResults( noResultsDetails ) ) )
                                        );
 
                                this.$element.removeClass( 'mw-changeslist-timeout' );
+                               this.$element.removeClass( 'mw-changeslist-notargetpage' );
                        }
 
                        this.$element.append( $message );
                } );
        };
 
+       /**
+        * Map a reason for having no results to its message key
+        *
+        * @param {string} reason One of the NO_RESULTS_* "constant" that represent
+        *      a reason for having no results
+        * @return {string} Key for the message that explains why there is no results in this case
+        */
+       mw.rcfilters.ui.ChangesListWrapperWidget.prototype.getMsgKeyForNoResults = function ( reason ) {
+               var reasonMsgKeyMap = {
+                       NO_RESULTS_NORMAL: 'recentchanges-noresult',
+                       NO_RESULTS_TIMEOUT: 'recentchanges-timeout',
+                       NO_RESULTS_NETWORK_ERROR: 'recentchanges-network',
+                       NO_RESULTS_NO_TARGET_PAGE: 'recentchanges-notargetpage'
+               };
+               return reasonMsgKeyMap[ reason ];
+       };
        /**
         * Emphasize the elements (or groups) newer than the 'from' parameter
         * @param {string} from Anything newer than this is considered 'new'
index 31be3ad..6673c08 100644 (file)
@@ -24,7 +24,8 @@
                        validate: false,
                        placeholder: mw.msg( 'rcfilters-target-page-placeholder' ),
                        showImages: true,
-                       showDescriptions: true
+                       showDescriptions: true,
+                       addQueryInput: false
                } );
 
                // Events
index e91fe9b..4fce08c 100644 (file)
 
                this.showLinkedFrom = new OO.ui.MenuOptionWidget( {
                        data: 'from', // default (showlinkedto=0)
-                       label: mw.msg( 'rcfilters-filter-showlinkedfrom-option-label' )
+                       label: new OO.ui.HtmlSnippet( mw.msg( 'rcfilters-filter-showlinkedfrom-option-label' ) )
                } );
                this.showLinkedTo = new OO.ui.MenuOptionWidget( {
                        data: 'to', // showlinkedto=1
-                       label: mw.msg( 'rcfilters-filter-showlinkedto-option-label' )
+                       label: new OO.ui.HtmlSnippet( mw.msg( 'rcfilters-filter-showlinkedto-option-label' ) )
                } );
 
                // Parent