bug #4521 Initially allowed chart types do not match selected data

Signed-off-by: Madhura Jayaratne <madhura.cj@gmail.com>
This commit is contained in:
Madhura Jayaratne 2014-08-21 19:24:33 +05:30
parent 70e52f3cb3
commit fae3858669
2 changed files with 54 additions and 39 deletions

View File

@ -5,6 +5,7 @@ phpMyAdmin - ChangeLog
- bug #4516 Odd export behavior
- bug #4519 Uncaught TypeError: Cannot read property 'success' of null
- bug #4520 sql.js: cannot read property
- bug #4521 Initially allowed chart types do not match selected data
4.2.7.1 (2014-08-17)
- bug #4501 [security] XSS in table browse page

View File

@ -6,6 +6,9 @@ var temp_chart_title;
var currentChart = null;
var currentSettings = null;
var dateTimeCols = [];
var numericCols = [];
function extractDate(dateString) {
var matches, match;
var dateTimeRegExp = /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/;
@ -134,6 +137,51 @@ function getSelectedSeries() {
return ret;
}
function onXAxisChange() {
var $xAxisSelect = $('select[name="chartXAxis"]');
currentSettings.mainAxis = parseInt($xAxisSelect.val(), 10);
if (dateTimeCols.indexOf(currentSettings.mainAxis) != -1) {
$('span.span_timeline').show();
} else {
$('span.span_timeline').hide();
if (currentSettings.type == 'timeline') {
$('input#radio_line').prop('checked', true);
currentSettings.type = 'line';
}
}
if (numericCols.indexOf(currentSettings.mainAxis) != -1) {
$('span.span_scatter').show();
} else {
$('span.span_scatter').hide();
if (currentSettings.type == 'scatter') {
$('input#radio_line').prop('checked', true);
currentSettings.type = 'line';
}
}
var xaxis_title = $xAxisSelect.children('option:selected').text();
$('input[name="xaxis_label"]').val(xaxis_title);
currentSettings.xaxisLabel = xaxis_title;
}
function onDataSeriesChange() {
var $seriesSelect = $('select[name="chartSeries"]');
currentSettings.selectedSeries = getSelectedSeries();
var yaxis_title;
if (currentSettings.selectedSeries.length == 1) {
$('span.span_pie').show();
yaxis_title = $seriesSelect.children('option:selected').text();
} else {
$('span.span_pie').hide();
if (currentSettings.type == 'pie') {
$('input#radio_line').prop('checked', true);
currentSettings.type = 'line';
}
yaxis_title = PMA_messages.strYValues;
}
$('input[name="yaxis_label"]').val(yaxis_title);
currentSettings.yaxisLabel = yaxis_title;
}
/**
* Unbind all event handlers before tearing down a page
*/
@ -220,13 +268,11 @@ AJAX.registerOnload('tbl_chart.js', function () {
}
});
var dateTimeCols = [];
var vals = $('input[name="dateTimeCols"]').val().split(' ');
$.each(vals, function (i, v) {
dateTimeCols.push(parseInt(v, 10));
});
var numericCols = [];
var vals = $('input[name="numericCols"]').val().split(' ');
$.each(vals, function (i, v) {
numericCols.push(parseInt(v, 10));
@ -234,48 +280,13 @@ AJAX.registerOnload('tbl_chart.js', function () {
// handle changing the x-axis
$('select[name="chartXAxis"]').change(function () {
currentSettings.mainAxis = parseInt($(this).val(), 10);
if (dateTimeCols.indexOf(currentSettings.mainAxis) != -1) {
$('span.span_timeline').show();
} else {
$('span.span_timeline').hide();
if (currentSettings.type == 'timeline') {
$('input#radio_line').prop('checked', true);
currentSettings.type = 'line';
}
}
if (numericCols.indexOf(currentSettings.mainAxis) != -1) {
$('span.span_scatter').show();
} else {
$('span.span_scatter').hide();
if (currentSettings.type == 'scatter') {
$('input#radio_line').prop('checked', true);
currentSettings.type = 'line';
}
}
var xaxis_title = $(this).children('option:selected').text();
$('input[name="xaxis_label"]').val(xaxis_title);
currentSettings.xaxisLabel = xaxis_title;
onXAxisChange();
drawChart();
});
// handle changing the selected data series
$('select[name="chartSeries"]').change(function () {
currentSettings.selectedSeries = getSelectedSeries();
var yaxis_title;
if (currentSettings.selectedSeries.length == 1) {
$('span.span_pie').show();
yaxis_title = $(this).children('option:selected').text();
} else {
$('span.span_pie').hide();
if (currentSettings.type == 'pie') {
$('input#radio_line').prop('checked', true);
currentSettings.type = 'line';
}
yaxis_title = PMA_messages.strYValues;
}
$('input[name="yaxis_label"]').val(yaxis_title);
currentSettings.yaxisLabel = yaxis_title;
onDataSeriesChange();
drawChart();
});
@ -289,6 +300,9 @@ AJAX.registerOnload('tbl_chart.js', function () {
drawChart();
});
onXAxisChange();
onDataSeriesChange();
$("#tblchartform").submit();
});