From: Brad Jorsch Date: Tue, 22 Nov 2016 17:19:12 +0000 (-0500) Subject: ApiSandbox: Support 'all' specifiers X-Git-Tag: 1.31.0-rc.0~4777^2 X-Git-Url: http://git.cyclocoop.org/url?a=commitdiff_plain;h=25bbaf41c57b6ece688490df4fc4ffb40e674951;p=lhc%2Fweb%2Fwiklou.git ApiSandbox: Support 'all' specifiers Change-Id: I43972b6a4236c87772ed50a7787c43edb795bed8 --- diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 28ccbf3d81..8428f20c09 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -1929,6 +1929,8 @@ "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 max 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", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index e1b6c9b67f..a71bdd241b 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -2113,6 +2113,8 @@ "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.", diff --git a/resources/Resources.php b/resources/Resources.php index e619771789..86589e2e37 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -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', ], diff --git a/resources/src/mediawiki.special/mediawiki.special.apisandbox.js b/resources/src/mediawiki.special/mediawiki.special.apisandbox.js index 217bd92358..2254b6582e 100644 --- a/resources/src/mediawiki.special/mediawiki.special.apisandbox.js +++ b/resources/src/mediawiki.special/mediawiki.special.apisandbox.js @@ -144,7 +144,17 @@ } }, 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(); @@ -442,6 +452,13 @@ 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 } } ); @@ -465,6 +482,13 @@ 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 } } );