ApiSandbox: Support 'all' specifiers
authorBrad Jorsch <bjorsch@wikimedia.org>
Tue, 22 Nov 2016 17:19:12 +0000 (12:19 -0500)
committerBrad Jorsch <bjorsch@wikimedia.org>
Tue, 22 Nov 2016 17:19:12 +0000 (12:19 -0500)
Change-Id: I43972b6a4236c87772ed50a7787c43edb795bed8

languages/i18n/en.json
languages/i18n/qqq.json
resources/Resources.php
resources/src/mediawiki.special/mediawiki.special.apisandbox.js

index 28ccbf3..8428f20 100644 (file)
        "apisandbox-continue-clear": "Clear",
        "apisandbox-continue-help": "{{int:apisandbox-continue}} will [https://www.mediawiki.org/wiki/API:Query#Continuing_queries continue] the last request; {{int:apisandbox-continue-clear}} will clear continuation-related parameters.",
        "apisandbox-param-limit": "Enter <kbd>max</kbd> to use the maximum limit.",
+       "apisandbox-multivalue-all-namespaces": "$1 (All namespaces)",
+       "apisandbox-multivalue-all-values": "$1 (All values)",
        "booksources": "Book sources",
        "booksources-summary": "",
        "booksources-search-legend": "Search for book sources",
index e1b6c9b..a71bdd2 100644 (file)
        "apisandbox-continue-clear": "Button text for clearing query continuation parameters.\n{{Identical|Clear}}",
        "apisandbox-continue-help": "Help text for the continue and clear buttons.",
        "apisandbox-param-limit": "Additional documentation text for 'limit'-type parameters.",
+       "apisandbox-multivalue-all-namespaces": "Used as an entry in a multiple-namespace widget to select all available namespaces. Parameters:\n* $1 - API input value meaning \"all namespaces\".",
+       "apisandbox-multivalue-all-values": "Used as an entry in a multiple-value widget to select all available values. Parameters:\n* $1 - API input value meaning \"all values\".",
        "booksources": "{{doc-special|BookSources}}\n\n'''This message shouldn't be changed unless it has serious mistakes.'''\n\nIt's used as the page name of the configuration page of [[Special:BookSources]]. Changing it breaks existing sites using the default version of this message.\n\nSee also:\n* {{msg-mw|Booksources|title}}\n* {{msg-mw|Booksources-text|text}}",
        "booksources-summary": "{{doc-specialpagesummary|booksources}}",
        "booksources-search-legend": "Box heading on [[Special:BookSources|book sources]] special page. The box is for searching for places where a particular book can be bought or viewed.",
index e619771..86589e2 100644 (file)
@@ -1837,6 +1837,8 @@ return [
                        'apisandbox-continue-clear',
                        'apisandbox-continue-help',
                        'apisandbox-param-limit',
+                       'apisandbox-multivalue-all-namespaces',
+                       'apisandbox-multivalue-all-values',
                        'api-format-prettyprint-status',
                        'blanknamespace',
                ],
index 217bd92..2254b65 100644 (file)
                                }
                        },
                        apiCheckValid: function () {
-                               var ok = this.getApiValue() !== undefined || suppressErrors;
+                               var ok = true,
+                                       pi = this.paramInfo;
+
+                               if ( !suppressErrors ) {
+                                       ok = this.getApiValue() !== undefined && !(
+                                               pi.allspecifier !== undefined &&
+                                               this.getItemsData().length > 1 &&
+                                               this.getItemsData().indexOf( pi.allspecifier ) !== -1
+                                       );
+                               }
+
                                this.setIcon( ok ? null : 'alert' );
                                this.setIconTitle( ok ? '' : mw.message( 'apisandbox-alert-field' ).plain() );
                                return $.Deferred().resolve( ok ).promise();
                                                return a.data - b.data;
                                        } );
                                        if ( Util.apiBool( pi.multi ) ) {
+                                               if ( pi.allspecifier !== undefined ) {
+                                                       items.unshift( new OO.ui.MenuOptionWidget( {
+                                                               data: pi.allspecifier,
+                                                               label: mw.message( 'apisandbox-multivalue-all-namespaces', pi.allspecifier ).text()
+                                                       } ) );
+                                               }
+
                                                widget = new OO.ui.CapsuleMultiselectWidget( {
                                                        menu: { items: items }
                                                } );
                                                return new OO.ui.MenuOptionWidget( { data: String( v ), label: String( v ) } );
                                        } );
                                        if ( Util.apiBool( pi.multi ) ) {
+                                               if ( pi.allspecifier !== undefined ) {
+                                                       items.unshift( new OO.ui.MenuOptionWidget( {
+                                                               data: pi.allspecifier,
+                                                               label: mw.message( 'apisandbox-multivalue-all-values', pi.allspecifier ).text()
+                                                       } ) );
+                                               }
+
                                                widget = new OO.ui.CapsuleMultiselectWidget( {
                                                        menu: { items: items }
                                                } );