Merge "ApiSandbox: Display params as JSON on request page"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 3 Jan 2017 20:47:06 +0000 (20:47 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 3 Jan 2017 20:47:06 +0000 (20:47 +0000)
languages/i18n/en.json
languages/i18n/qqq.json
resources/Resources.php
resources/src/mediawiki.special/mediawiki.special.apisandbox.css
resources/src/mediawiki.special/mediawiki.special.apisandbox.js

index 2d7a53e..f2b27fc 100644 (file)
        "apisandbox-sending-request": "Sending API request...",
        "apisandbox-loading-results": "Receiving API results...",
        "apisandbox-results-error": "An error occurred while loading the API query response: $1.",
+       "apisandbox-request-params-json": "JSON parameters:",
        "apisandbox-request-url-label": "Request URL:",
        "apisandbox-request-time": "Request time: {{PLURAL:$1|$1 ms}}",
        "apisandbox-results-fixtoken": "Correct token and resubmit",
index 33e2a8c..99f7679 100644 (file)
        "apisandbox-sending-request": "JavaScript message displayed while the request is being sent.",
        "apisandbox-loading-results": "JavaScript message displayed while the response is being read.",
        "apisandbox-results-error": "Displayed as an error message from JavaScript when the request failed.\n\nParameters:\n* $1 - Error message",
+       "apisandbox-request-params-json": "Label for text field display the request parameters as JSON.",
        "apisandbox-request-url-label": "Label for the text field displaying the URL used to make this request.",
        "apisandbox-request-time": "Label and value for displaying the time taken by the request.\n\nParameters:\n* $1 - Time taken in milliseconds",
        "apisandbox-results-fixtoken": "JavaScript button label",
index ae95c78..92013ec 100644 (file)
@@ -1826,6 +1826,7 @@ return [
                        'apisandbox-sending-request',
                        'apisandbox-loading-results',
                        'apisandbox-results-error',
+                       'apisandbox-request-params-json',
                        'apisandbox-request-url-label',
                        'apisandbox-request-time',
                        'apisandbox-results-fixtoken',
index 99f6c13..707a579 100644 (file)
 .oo-ui-textInputWidget.oo-ui-widget-enabled > .oo-ui-indicatorElement-indicator.mw-apisandbox-clickable-indicator {
        cursor: pointer;
 }
+
+.mw-apisandbox-textInputCode .oo-ui-inputWidget-input {
+       font-family: monospace, 'Courier';
+       font-size: 0.8125em;
+       -moz-tab-size: 4;
+       -o-tab-size: 4;
+       tab-size: 4;
+}
index 43321fe..f108e50 100644 (file)
                        }
 
                        $.when.apply( $, deferreds ).done( function () {
+                               var jsonInput;
+
                                if ( $.inArray( false, arguments ) !== -1 ) {
                                        windowManager.openWindow( 'errorAlert', {
                                                title: Util.parseMsg( 'apisandbox-submit-invalid-fields-title' ),
                                                                label: Util.parseMsg( 'apisandbox-request-url-label' )
                                                        }
                                                ).$element,
+                                               new OO.ui.FieldLayout(
+                                                       jsonInput = new OO.ui.TextInputWidget( {
+                                                               classes: [ 'mw-apisandbox-textInputCode' ],
+                                                               readOnly: true,
+                                                               multiline: true,
+                                                               autosize: true,
+                                                               maxRows: 6,
+                                                               value: JSON.stringify( displayParams, null, '\t' )
+                                                       } ), {
+                                                               label: Util.parseMsg( 'apisandbox-request-params-json' )
+                                                       }
+                                               ).$element,
                                                $result
                                        );
                                ApiSandbox.updateUI();
                                booklet.setPage( '|results|' );
 
+                               // Resize the multiline input once visible
+                               jsonInput.adjustSize();
+
                                location.href = oldhash = '#' + query;
 
                                api.post( params, {