Skip to content

Commit b243307

Browse files
Merge pull request #487 from contactashish13/issue-486
Show chart automatically when user clicks on another menu item
2 parents a837c2d + 4c73c21 commit b243307

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-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: 25 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,23 @@
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');
89+
});
90+
91+
// collapse other open subsections of this section
92+
$('.viz-section-title').click(function () {
93+
var grandparent = $(this).parent().parent();
94+
grandparent.find('.viz-section-title.open ~ .viz-section-items').hide();
95+
grandparent.find('.viz-section-title.open').removeClass('open');
7996
});
97+
8098
$('#view-remote-file').click(function () {
8199
var url = $(this).parent().find('#remote-data').val();
82100

@@ -330,8 +348,13 @@
330348
} );
331349

332350
$( '#db-chart-save-button' ).on( 'click', function(){
333-
$('#viz-db-wizard-params').val($('#db-query-form').serialize());
334-
$('#vz-db-wizard').submit();
351+
// submit only if a query has been provided.
352+
if($('#db-query-form .visualizer-db-query').val().length > 0){
353+
$('#viz-db-wizard-params').val($('#db-query-form').serialize());
354+
$('#vz-db-wizard').submit();
355+
}else{
356+
$('#canvas').unlock();
357+
}
335358
});
336359
}
337360

0 commit comments

Comments
 (0)