diff --git a/js/tbl_zoom_plot.js b/js/tbl_zoom_plot.js index 63428d2726..caa341440b 100644 --- a/js/tbl_zoom_plot.js +++ b/js/tbl_zoom_plot.js @@ -187,19 +187,85 @@ $(document).ready(function() { ** Input form submit on field change **/ $('#tableid_0').change(function() { - $('#zoom_search_form').submit(); + //AJAX request for field type, collation, operators, and value field + $.post('tbl_zoom_select.php',{ + 'ajax_request' : true, + 'change_tbl_info' : true, + 'db' : window.parent.db, + 'table' : window.parent.table, + 'field' : $('#tableid_0').val(), + 'it' : 0, + 'token' : window.parent.token, + },function(data) { + $('#tabId tr:eq(1) td:eq(0)').html(data.field_type); + $('#tabId tr:eq(1) td:eq(1)').html(data.field_collation); + $('#tabId tr:eq(1) td:eq(2)').html(data.field_operators); + $('#tabId tr:eq(1) td:eq(3)').html(data.field_value); + xLabel = $('#tableid_0').val(); + $('#types_0').val(data.field_type); + $('#collations_0').val(data.field_collations); + }); }); $('#tableid_1').change(function() { - $('#zoom_search_form').submit(); + //AJAX request for field type, collation, operators, and value field + $.post('tbl_zoom_select.php',{ + 'ajax_request' : true, + 'change_tbl_info' : true, + 'db' : window.parent.db, + 'table' : window.parent.table, + 'field' : $('#tableid_1').val(), + 'it' : 1, + 'token' : window.parent.token, + },function(data) { + $('#tabId tr:eq(3) td:eq(0)').html(data.field_type); + $('#tabId tr:eq(3) td:eq(1)').html(data.field_collation); + $('#tabId tr:eq(3) td:eq(2)').html(data.field_operators); + $('#tabId tr:eq(3) td:eq(3)').html(data.field_value); + yLabel = $('#tableid_1').val(); + $('#types_1').val(data.field_type); + $('#collations_1').val(data.field_collations); + }); }); $('#tableid_2').change(function() { - $('#zoom_search_form').submit(); + //AJAX request for field type, collation, operators, and value field + $.post('tbl_zoom_select.php',{ + 'ajax_request' : true, + 'change_tbl_info' : true, + 'db' : window.parent.db, + 'table' : window.parent.table, + 'field' : $('#tableid_2').val(), + 'it' : 2, + 'token' : window.parent.token, + },function(data) { + $('#tabId tr:eq(6) td:eq(0)').html(data.field_type); + $('#tabId tr:eq(6) td:eq(1)').html(data.field_collation); + $('#tabId tr:eq(6) td:eq(2)').html(data.field_operators); + $('#tabId tr:eq(6) td:eq(3)').html(data.field_value); + $('#types_2').val(data.field_type); + $('#collations_2').val(data.field_collations); + }); }); $('#tableid_3').change(function() { - $('#zoom_search_form').submit(); + //AJAX request for field type, collation, operators, and value field + $.post('tbl_zoom_select.php',{ + 'ajax_request' : true, + 'change_tbl_info' : true, + 'db' : window.parent.db, + 'table' : window.parent.table, + 'field' : $('#tableid_3').val(), + 'it' : 3, + 'token' : window.parent.token, + },function(data) { + $('#tabId tr:eq(8) td:eq(0)').html(data.field_type); + $('#tabId tr:eq(8) td:eq(1)').html(data.field_collation); + $('#tabId tr:eq(8) td:eq(2)').html(data.field_operators); + $('#tabId tr:eq(8) td:eq(3)').html(data.field_value); + $('#types_3').val(data.field_type); + $('#collations_3').val(data.field_collations); + }); }); /** diff --git a/tbl_zoom_select.php b/tbl_zoom_select.php index 9e52a6cc15..078041b6a7 100644 --- a/tbl_zoom_select.php +++ b/tbl_zoom_select.php @@ -55,6 +55,75 @@ if (isset($_REQUEST['get_data_row']) && $_REQUEST['get_data_row'] == true) { PMA_ajaxResponse(null, true, $extra_data); } +/** + * Handle AJAX request for changing field information(value,collation,operators,field values) + * in input form + * @var post_params Object containing parameters for the POST request + */ + +if (isset($_REQUEST['change_tbl_info']) && $_REQUEST['change_tbl_info'] == true) { + $extra_data = array(); + $field = $_REQUEST['field']; + if($field == 'pma_null') { + $extra_data['field_type'] = ''; + $extra_data['field_collation'] = ''; + $extra_data['field_operators'] = ''; + PMA_ajaxResponse(NULL, true, $extra_data); + } + + + // Gets the list and number of fields + list($fields_list, $fields_type, $fields_collation, $fields_null) = PMA_tbl_getFields($_REQUEST['db'],$_REQUEST['table']); + + $foreigners = PMA_getForeigners($db, $table); + $titles['Browse'] = PMA_getIcon('b_browse.png', __('Browse foreign values')); + $key = array_search($field,$fields_list); + $extra_data['field_type'] = $fields_type[$key]; + $extra_data['field_collation'] = $fields_collation[$key]; + + // HTML for operators + $html = ''; + $extra_data['field_operators'] = $html; + + // retrieve keys into foreign fields, if any + // check also foreigners even if relwork is FALSE (to get + // foreign keys from innodb) + $foreignData = PMA_getForeignData($foreigners, $field, false, '', ''); + + // HTML for field values + $html = PMA_getForeignFields_Values($foreigners, $foreignData, $field, array($_REQUEST['it'] => $fields_type[$key]), $_REQUEST['it'] ,$_REQUEST['db'], $_REQUEST['table'], $titles, $GLOBALS['cfg']['ForeignKeyMaxLimit'], ''); + $extra_data['field_value'] = $html; + PMA_ajaxResponse(NULL, true, $extra_data); +} + $titles['Browse'] = PMA_getIcon('b_browse.png', __('Browse foreign values')); /** * Not selection yet required -> displays the selection form @@ -133,7 +202,7 @@ if (isset($inputs) && ($inputs[0] != 'pma_null' || $inputs[1] != 'pma_null')) {
- +
- - - - - - - + + + + -
- - - - - -
- - + +