Skip to content

Commit 95cc24b

Browse files
Features that show parameters screen on LHS (json, db, editor, wp) cannot be cancelled
1 parent 556ed88 commit 95cc24b

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
@@ -79,13 +79,15 @@
7979
parent.addClass('open');
8080
}
8181

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');
82+
/*
83+
* if the user wants to perform an action and click that tab to change the source
84+
* and the chart is no longer showing because that particular LHS screen is showing
85+
* e.g. create parameters, import json, db query box etc.
86+
* we need to make sure we cancel the current process WITHOUT saving
87+
* and then show the chart as it was
88+
* let's close the LHS window and show the chart that is hidden
89+
*/
90+
$('body').trigger('visualizer:change:action');
8991
});
9092

9193
// collapse other open subsections of this section
@@ -338,6 +340,16 @@
338340
});
339341

340342
$( '#db-chart-button' ).on( 'click', function(){
343+
344+
$('body').off('visualizer:change:action').on('visualizer:change:action', function(e){
345+
var filter_button = $( '#db-chart-button' );
346+
$( '#visualizer-db-query' ).css("z-index", "-1").hide();
347+
filter_button.val( filter_button.attr( 'data-t-chart' ) );
348+
filter_button.html( filter_button.attr( 'data-t-chart' ) );
349+
filter_button.attr( 'data-current', 'chart' );
350+
$( '#canvas' ).css("z-index", "1").show();
351+
});
352+
341353
$('#content').css('width', 'calc(100% - 300px)');
342354
if( $(this).attr( 'data-current' ) === 'chart'){
343355
$(this).val( $(this).attr( 'data-t-filter' ) );
@@ -390,7 +402,16 @@
390402

391403
// toggle between chart and create/modify parameters
392404
$( '#json-chart-button' ).on( 'click', function(){
393-
var $bttn = $(this);
405+
406+
$('body').off('visualizer:change:action').on('visualizer:change:action', function(e){
407+
var filter_button = $( '#json-chart-button' );
408+
$( '#visualizer-json-screen' ).css("z-index", "-1").hide();
409+
filter_button.val( filter_button.attr( 'data-t-chart' ) );
410+
filter_button.html( filter_button.attr( 'data-t-chart' ) );
411+
filter_button.attr( 'data-current', 'chart' );
412+
$( '#canvas' ).css("z-index", "1").show();
413+
});
414+
394415
$('#content').css('width', 'calc(100% - 100px)');
395416
if( $(this).attr( 'data-current' ) === 'chart'){
396417
// 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)