Skip to content

Commit 17e86fd

Browse files
Show chart automatically when user clicks on another menu item
1 parent a837c2d commit 17e86fd

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

classes/Visualizer/Render/Page/Data.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ class="visualizer-select">
221221
?>
222222
</div>
223223

224-
<input type="button" id="json-chart-button" class="button button-secondary "
224+
<input type="button" id="json-chart-button" class="button button-secondary show-chart-toggle"
225225
value="<?php echo $bttn_label; ?>" data-current="chart"
226226
data-t-filter="<?php _e( 'Show Chart', 'visualizer' ); ?>"
227227
data-t-chart="<?php echo $bttn_label; ?>">
@@ -334,7 +334,7 @@ class="dashicons dashicons-lock"></span></h2>
334334
?>
335335
</select>
336336

337-
<input type="button" id="filter-chart-button" class="button button-secondary" value="<?php echo $bttn_label; ?>" data-current="chart" data-t-filter="<?php _e( 'Show Chart', 'visualizer' ); ?>" data-t-chart="<?php echo $bttn_label; ?>">
337+
<input type="button" id="filter-chart-button" class="button button-secondary show-chart-toggle" value="<?php echo $bttn_label; ?>" data-current="chart" data-t-filter="<?php _e( 'Show Chart', 'visualizer' ); ?>" data-t-chart="<?php echo $bttn_label; ?>">
338338
<input type="button" id="db-filter-save-button" class="button button-primary" value="<?php _e( 'Save Schedule', 'visualizer' ); ?>">
339339
<?php echo apply_filters( 'visualizer_pro_upsell', '', 'db-query' ); ?>
340340
</form>
@@ -384,7 +384,7 @@ class="dashicons dashicons-lock"></span></h2>
384384
</select>
385385
<input type="hidden" name="params" id="viz-db-wizard-params">
386386

387-
<input type="button" id="db-chart-button" class="button button-secondary" value="<?php echo $bttn_label; ?>" data-current="chart" data-t-filter="<?php _e( 'Show Chart', 'visualizer' ); ?>" data-t-chart="<?php echo $bttn_label; ?>">
387+
<input type="button" id="db-chart-button" class="button button-secondary show-chart-toggle" value="<?php echo $bttn_label; ?>" data-current="chart" data-t-filter="<?php _e( 'Show Chart', 'visualizer' ); ?>" data-t-chart="<?php echo $bttn_label; ?>">
388388
<input type="button" id="db-chart-save-button" class="button button-primary" value="<?php _e( 'Save Schedule', 'visualizer' ); ?>">
389389
<?php echo apply_filters( 'visualizer_pro_upsell', '', 'db-query' ); ?>
390390
</form>

js/frame.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@
6767

6868
return false;
6969
});
70+
71+
// collapse other open sections of this group
7072
$('.viz-group-title').click(function () {
7173
var parent = $(this).parent();
7274

@@ -76,7 +78,16 @@
7678
parent.parent().find('.viz-group.open').removeClass('open');
7779
parent.addClass('open');
7880
}
81+
82+
// if the user wanted to perform an action
83+
// and the chart is no longer showing because that particular screen is showing
84+
// e.g. create parameters
85+
// and then the user decided to click on another action
86+
// let's invoke the show chart of the previous action so that the chart shows
87+
// and the user does not get confused
88+
$('input[type="button"][data-current!="chart"].show-chart-toggle').trigger('click');
7989
});
90+
8091
$('#view-remote-file').click(function () {
8192
var url = $(this).parent().find('#remote-data').val();
8293

@@ -330,8 +341,13 @@
330341
} );
331342

332343
$( '#db-chart-save-button' ).on( 'click', function(){
333-
$('#viz-db-wizard-params').val($('#db-query-form').serialize());
334-
$('#vz-db-wizard').submit();
344+
// submit only if a query has been provided.
345+
if($('#db-query-form .visualizer-db-query').val().length > 0){
346+
$('#viz-db-wizard-params').val($('#db-query-form').serialize());
347+
$('#vz-db-wizard').submit();
348+
}else{
349+
$('#canvas').unlock();
350+
}
335351
});
336352
}
337353

0 commit comments

Comments
 (0)