Merge "ApiSandbox: Support 'all' specifiers"

This commit is contained in:
jenkins-bot 2016-11-23 19:00:27 +00:00 committed by Gerrit Code Review
commit 3290c9e151
4 changed files with 31 additions and 1 deletions

View file

@ -1924,6 +1924,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 <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",

View file

@ -2108,6 +2108,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.",

View 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',
],

View file

@ -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 }
} );