Skip to content

Commit c02786e

Browse files
Merge branch 'development' of https://github.com/codeinwp/visualizer into issue-655
2 parents 3ca94b8 + 5934972 commit c02786e

File tree

2 files changed

+51
-8
lines changed

2 files changed

+51
-8
lines changed

js/frame.js

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,15 @@
7777
parent.addClass('open');
7878
}
7979

80-
// if the user wanted to perform an action
81-
// and the chart is no longer showing because that particular screen is showing
82-
// e.g. create parameters
83-
// and then the user decided to click on another action
84-
// let's invoke the show chart of the previous action so that the chart shows
85-
// and the user does not get confused
86-
$('input[type="button"][data-current!="chart"].show-chart-toggle').trigger('click');
80+
/*
81+
* if the user wants to perform an action and click that tab to change the source
82+
* and the chart is no longer showing because that particular LHS screen is showing
83+
* e.g. create parameters, import json, db query box etc.
84+
* we need to make sure we cancel the current process WITHOUT saving
85+
* and then show the chart as it was
86+
* let's close the LHS window and show the chart that is hidden
87+
*/
88+
$('body').trigger('visualizer:change:action');
8789
});
8890

8991
// collapse other open subsections of this section
@@ -307,6 +309,16 @@
307309
});
308310

309311
$( '#db-chart-button' ).on( 'click', function(){
312+
313+
$('body').off('visualizer:change:action').on('visualizer:change:action', function(e){
314+
var filter_button = $( '#db-chart-button' );
315+
$( '#visualizer-db-query' ).css("z-index", "-1").hide();
316+
filter_button.val( filter_button.attr( 'data-t-chart' ) );
317+
filter_button.html( filter_button.attr( 'data-t-chart' ) );
318+
filter_button.attr( 'data-current', 'chart' );
319+
$( '#canvas' ).css("z-index", "1").show();
320+
});
321+
310322
$('#content').css('width', 'calc(100% - 300px)');
311323
if( $(this).attr( 'data-current' ) === 'chart'){
312324
$(this).val( $(this).attr( 'data-t-filter' ) );
@@ -359,7 +371,16 @@
359371

360372
// toggle between chart and create/modify parameters
361373
$( '#json-chart-button' ).on( 'click', function(){
362-
var $bttn = $(this);
374+
375+
$('body').off('visualizer:change:action').on('visualizer:change:action', function(e){
376+
var filter_button = $( '#json-chart-button' );
377+
$( '#visualizer-json-screen' ).css("z-index", "-1").hide();
378+
filter_button.val( filter_button.attr( 'data-t-chart' ) );
379+
filter_button.html( filter_button.attr( 'data-t-chart' ) );
380+
filter_button.attr( 'data-current', 'chart' );
381+
$( '#canvas' ).css("z-index", "1").show();
382+
});
383+
363384
$('#content').css('width', 'calc(100% - 100px)');
364385
if( $(this).attr( 'data-current' ) === 'chart'){
365386
// toggle from chart to LHS form

js/simple-editor.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@
2424

2525
function showTextEditor(button) {
2626
if( button.attr( 'data-current' ) === 'chart'){
27+
28+
$('body').off('visualizer:change:action').on('visualizer:change:action', function(e){
29+
button.val( button.attr( 'data-t-chart' ) );
30+
button.html( button.attr( 'data-t-chart' ) );
31+
button.attr( 'data-current', 'chart' );
32+
$('p.viz-editor-selection').show();
33+
$('.viz-text-editor').hide();
34+
$('.viz-simple-editor').hide();
35+
$( '#canvas' ).css('z-index', '1').show();
36+
});
37+
2738
// showing the editor
2839
button.val( button.attr( 'data-t-editor' ) );
2940
button.html( button.attr( 'data-t-editor' ) );
@@ -57,6 +68,17 @@
5768

5869
function showTableEditor(button) {
5970
if( button.attr( 'data-current' ) === 'chart'){
71+
72+
$('body').off('visualizer:change:action').on('visualizer:change:action', function(e){
73+
button.val( button.attr( 'data-t-chart' ) );
74+
button.html( button.attr( 'data-t-chart' ) );
75+
button.attr( 'data-current', 'chart' );
76+
$('p.viz-editor-selection').show();
77+
$('.viz-table-editor').hide();
78+
$('.viz-simple-editor').hide();
79+
$( '#canvas' ).css('z-index', '1').show();
80+
});
81+
6082
// showing the editor
6183
button.val( button.attr( 'data-t-editor' ) );
6284
button.html( button.attr( 'data-t-editor' ) );

0 commit comments

Comments
 (0)