Skip to content

Commit 115b205

Browse files
Merge pull request #664 from contactashish13/issue-254-pro
Open headers tab by default if credentials are saved
2 parents b3e8b16 + 46acda8 commit 115b205

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

classes/Visualizer/Render/Layout.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ public static function _renderJsonScreen( $args ) {
148148
$headers['method'] = 'get';
149149
}
150150
$methods = apply_filters( 'visualizer_json_request_methods', array( 'GET', 'POST' ) );
151+
152+
// open the headers by default?
153+
$headers_open = $headers && array_key_exists( 'auth', $headers ) && ( array_key_exists( 'username', $headers['auth'] ) && ! empty( $headers['auth']['username'] ) ) || ( ! empty( $headers['auth'] ) && is_string( $headers['auth'] ) );
151154
?>
152155
<div id="visualizer-json-screen" style="display: none">
153156
<div class="visualizer-json-form">
@@ -170,7 +173,7 @@ class="visualizer-input json-form-element">
170173
<button class="button button-secondary button-small" id="visualizer-json-fetch"><?php esc_html_e( 'Fetch Endpoint', 'visualizer' ); ?></button>
171174

172175
<div class="visualizer-json-subform">
173-
<h3 class="viz-substep"><?php _e( 'Headers', 'visualizer' ); ?></h3>
176+
<h3 class="viz-substep <?php echo $headers_open ? 'open' : ''; ?>"><?php _e( 'Headers', 'visualizer' ); ?></h3>
174177
<div class="json-wizard-headers">
175178
<div class="json-wizard-header">
176179
<div><?php _e( 'Request Type', 'visualizer' ); ?></div>
@@ -213,7 +216,7 @@ class="json-form-element">
213216
type="text"
214217
id="vz-import-json-auth"
215218
name="auth"
216-
value="<?php echo ( ! empty( $headers ) && array_key_exists( 'auth', $headers ) ? $headers['auth']['auth'] : '' ); ?>"
219+
value="<?php echo ( array_key_exists( 'auth', $headers ) && is_string( $headers['auth'] ) ? $headers['auth'] : '' ); ?>"
217220
placeholder="<?php esc_html_e( 'e.g. SharedKey <AccountName>:<Signature>', 'visualizer' ); ?>"
218221
class="visualizer-input json-form-element">
219222
</div>

js/frame.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,11 @@
376376
active: false,
377377
collapsible: true
378378
});
379+
380+
// open the accordions by default if they are indicated with the 'open' class.
381+
$('.visualizer-json-subform .viz-substep.open').each(function(i, e){
382+
$('.visualizer-json-subform').accordion( "option", "active", i );
383+
});
379384

380385
// toggle between chart and create/modify parameters
381386
$( '#json-chart-button' ).on( 'click', function(){

0 commit comments

Comments
 (0)