Skip to content

Commit 9f55283

Browse files
When Add New is used from within a selected chart type tab, that chart type should be auto selected #263
1 parent ded3ab4 commit 9f55283

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

classes/Visualizer/Module/Admin.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@ public function renderLibraryPage() {
469469
array(
470470
'action' => Visualizer_Plugin::ACTION_CREATE_CHART,
471471
'library' => 'yes',
472+
'type' => isset( $_GET['type'] ) ? $_GET['type'] : '',
472473
), $ajaxurl
473474
),
474475
'edit' => add_query_arg(

classes/Visualizer/Module/Chart.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ public function renderChartPages() {
211211
// check chart, if chart not exists, will create new one and redirects to the same page with proper chart id
212212
$chart_id = isset( $_GET['chart'] ) ? filter_var( $_GET['chart'], FILTER_VALIDATE_INT ) : '';
213213
if ( ! $chart_id || ! ( $chart = get_post( $chart_id ) ) || $chart->post_type != Visualizer_Plugin::CPT_VISUALIZER ) {
214-
$default_type = 'line';
214+
$default_type = isset( $_GET['type'] ) && ! empty( $_GET['type'] ) ? $_GET['type'] : 'line';
215215
$source = new Visualizer_Source_Csv( VISUALIZER_ABSPATH . DIRECTORY_SEPARATOR . 'samples' . DIRECTORY_SEPARATOR . $default_type . '.csv' );
216216
$source->fetch();
217217
$chart_id = wp_insert_post(

js/frame.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
/* global alert */
44

55
(function ($) {
6+
$(window).load(function(){
7+
// scroll to the selected chart type.
8+
if($('label.type-label.type-label-selected').length > 0) {
9+
$('label.type-label.type-label-selected')[0].scrollIntoView();
10+
}
11+
});
12+
613
$(document).ready(function () {
714
init_permissions();
815

0 commit comments

Comments
 (0)