From 37641b3404be795d894852829045da1f5db3fa17 Mon Sep 17 00:00:00 2001 From: Thilanka Kaushalya Date: Wed, 6 Jul 2011 19:55:57 +0530 Subject: [PATCH 1/7] Fixed bugs in index edit --- js/indexes.js | 4 ++-- js/tbl_structure.js | 9 ++++++--- tbl_indexes.php | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/js/indexes.js b/js/indexes.js index ef6f877bdd..076bf6f230 100644 --- a/js/indexes.js +++ b/js/indexes.js @@ -56,7 +56,7 @@ function checkIndexType() /** * @var Object Table header for the size column. */ - $size_header = $('thead tr th:nth-child(2)'); + $size_header = $('#index_columns thead tr th:nth-child(2)'); /** * @var Object Inputs to specify the columns for the index. */ @@ -132,7 +132,7 @@ function checkIndexType() */ $(document).ready(function() { checkIndexType(); - $('#select_index_type').bind('change', checkIndexType); + $('#select_index_type').live('change', checkIndexType); }); /**#@- */ diff --git a/js/tbl_structure.js b/js/tbl_structure.js index d4ef1cdf97..b7124cacbb 100644 --- a/js/tbl_structure.js +++ b/js/tbl_structure.js @@ -269,10 +269,10 @@ $(document).ready(function() { */ var button_options = {}; // in the following function we need to use $(this) - button_options[PMA_messages['strCancel']] = function() {$(this).parent().dialog('close').remove();} + button_options[PMA_messages['strCancel']] = function() {$(this).dialog('close').remove();} var button_options_error = {}; - button_options_error[PMA_messages['strOK']] = function() {$(this).parent().dialog('close').remove();} + button_options_error[PMA_messages['strOK']] = function() {$(this).dialog('close').remove();} var $msgbox = PMA_ajaxShowMessage(); $.get( "tbl_indexes.php" , url , function(data) { @@ -300,6 +300,7 @@ $(document).ready(function() { //Remove the top menu container from the dialog .find("#topmenucontainer").hide() ; // end dialog options + checkIndexName(); } PMA_ajaxRemoveMessage($msgbox); }) // end $.get() @@ -360,7 +361,7 @@ $(document).ready(function() { $.post($form.attr('action'), $form.serialize()+"&add_fields=Go", function(data) { $("#index_columns").remove(); var temp_div = $("
").append(data); - $(temp_div).find("#index_columns").insertAfter("#index_frm fieldset .error"); + $(temp_div).find("#index_columns").appendTo("#index_edit_fields"); }) // end $.post() }) // end insert table button "Go" @@ -390,6 +391,8 @@ $(document).ready(function() { return false; }); } //end show/hide table index + + $('#select_index_type').live('change', checkIndexType); }) // end $(document).ready() diff --git a/tbl_indexes.php b/tbl_indexes.php index 7e9bec60f2..e9f33f1791 100644 --- a/tbl_indexes.php +++ b/tbl_indexes.php @@ -158,7 +158,7 @@ if (isset($_REQUEST['create_index'])) { echo PMA_generate_common_hidden_inputs($form_params); ?> -
+
Date: Thu, 7 Jul 2011 23:52:22 +0530 Subject: [PATCH 2/7] Moved checkIndexName function to functions js file and rewrite it using jquery --- js/functions.js | 39 ++++++++++++++++++++++++++++++++++++++ js/indexes.js | 46 ++++++--------------------------------------- js/tbl_structure.js | 6 ++---- tbl_indexes.php | 2 +- 4 files changed, 48 insertions(+), 45 deletions(-) diff --git a/js/functions.js b/js/functions.js index 9cdb44e751..d34570b7ec 100644 --- a/js/functions.js +++ b/js/functions.js @@ -2152,9 +2152,48 @@ function displayMoreTableOpts() { } }); } + } $(document).ready(initTooltips); +/** + * Ensures indexes names are valid according to their type and, for a primary + * key, lock index name to 'PRIMARY' + * + * @return boolean false if there is no index form, true else + */ +function checkIndexName(form_name) +{ + if ($("#"+form_name).length == 0) { + return false + } + + // Gets the elements pointers + var the_idx_name = $("#input_index_name"); + var the_idx_type = $("#select_index_type"); + + // Index is a primary key + if (the_idx_type.find("option:selected").attr("value") == 'PRIMARY') { + $("#input_index_name").attr("value", 'PRIMARY'); + if (the_idx_name.attr("disabled") != 'undefined') { + $("#input_index_name").attr("disabled", true); + } + } + + // Other cases + else { + if (the_idx_name.attr("value") == 'PRIMARY') { + $("#input_index_name").attr("value", ''); + } + if (the_idx_name.attr("disabled") != 'undefined') { + $("#input_index_name").attr("disabled", false); + } + } + + return true; +} // end of the 'checkIndexName()' function + + /* Displays tooltips */ function initTooltips() { // Hide the footnotes from the footer (which are displayed for diff --git a/js/indexes.js b/js/indexes.js index 076bf6f230..abbf4d8b49 100644 --- a/js/indexes.js +++ b/js/indexes.js @@ -4,45 +4,6 @@ * */ -/** - * Ensures indexes names are valid according to their type and, for a primary - * key, lock index name to 'PRIMARY' - * - * @return boolean false if there is no index form, true else - */ -function checkIndexName() -{ - if (typeof(document.forms['index_frm']) == 'undefined') { - return false; - } - - // Gets the elements pointers - var the_idx_name = document.forms['index_frm'].elements['index[Key_name]']; - var the_idx_type = document.forms['index_frm'].elements['index[Index_type]']; - - // Index is a primary key - if (the_idx_type.options[0].value == 'PRIMARY' && the_idx_type.options[0].selected) { - document.forms['index_frm'].elements['index[Key_name]'].value = 'PRIMARY'; - if (typeof(the_idx_name.disabled) != 'undefined') { - document.forms['index_frm'].elements['index[Key_name]'].disabled = true; - } - } - - // Other cases - else { - if (the_idx_name.value == 'PRIMARY') { - document.forms['index_frm'].elements['index[Key_name]'].value = ''; - } - if (typeof(the_idx_name.disabled) != 'undefined') { - document.forms['index_frm'].elements['index[Key_name]'].disabled = false; - } - } - - return true; -} // end of the 'checkIndexName()' function - -onload = checkIndexName; - /** * Hides/shows the inputs and submits appropriately depending * on whether the index type chosen is 'SPATIAL' or not. @@ -132,7 +93,12 @@ function checkIndexType() */ $(document).ready(function() { checkIndexType(); - $('#select_index_type').live('change', checkIndexType); + checkIndexName("index_frm"); + $('#select_index_type').live('change', function(event){ + event.preventDefault(); + checkIndexType(); + checkIndexName("index_frm"); + }); }); /**#@- */ diff --git a/js/tbl_structure.js b/js/tbl_structure.js index b7124cacbb..3f49260fef 100644 --- a/js/tbl_structure.js +++ b/js/tbl_structure.js @@ -300,12 +300,12 @@ $(document).ready(function() { //Remove the top menu container from the dialog .find("#topmenucontainer").hide() ; // end dialog options - checkIndexName(); + checkIndexName("index_frm"); } PMA_ajaxRemoveMessage($msgbox); }) // end $.get() }); - + /** *Ajax action for submiting the index form **/ @@ -392,7 +392,5 @@ $(document).ready(function() { }); } //end show/hide table index - $('#select_index_type').live('change', checkIndexType); - }) // end $(document).ready() diff --git a/tbl_indexes.php b/tbl_indexes.php index e9f33f1791..d93018c76d 100644 --- a/tbl_indexes.php +++ b/tbl_indexes.php @@ -179,7 +179,7 @@ PMA_Message::notice(__('("PRIMARY" must be the name of and only of
- generateIndexSelector(); ?> From 499dbe1ae67057fa869942697df9b7a5f385f608 Mon Sep 17 00:00:00 2001 From: Thilanka Kaushalya Date: Fri, 8 Jul 2011 09:27:10 +0530 Subject: [PATCH 3/7] Fixed bugs in checkIndexName --- js/functions.js | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/js/functions.js b/js/functions.js index d34570b7ec..a718929814 100644 --- a/js/functions.js +++ b/js/functions.js @@ -2159,13 +2159,14 @@ $(document).ready(initTooltips); /** * Ensures indexes names are valid according to their type and, for a primary * key, lock index name to 'PRIMARY' - * - * @return boolean false if there is no index form, true else + * @param string form_id Variable which parses the form name as + * the input + * @return boolean false if there is no index form, true else */ -function checkIndexName(form_name) +function checkIndexName(form_id) { - if ($("#"+form_name).length == 0) { - return false + if ($("#"+form_id).length == 0) { + return false; } // Gets the elements pointers @@ -2174,20 +2175,16 @@ function checkIndexName(form_name) // Index is a primary key if (the_idx_type.find("option:selected").attr("value") == 'PRIMARY') { - $("#input_index_name").attr("value", 'PRIMARY'); - if (the_idx_name.attr("disabled") != 'undefined') { - $("#input_index_name").attr("disabled", true); - } + the_idx_name.attr("value", 'PRIMARY'); + the_idx_name.attr("disabled", true); } // Other cases else { if (the_idx_name.attr("value") == 'PRIMARY') { - $("#input_index_name").attr("value", ''); - } - if (the_idx_name.attr("disabled") != 'undefined') { - $("#input_index_name").attr("disabled", false); + the_idx_name.attr("value", ''); } + the_idx_name.attr("disabled", false); } return true; From ddb776901307b33bd0d2efc378ba1472fb3f4f36 Mon Sep 17 00:00:00 2001 From: Thilanka Kaushalya Date: Fri, 8 Jul 2011 14:04:57 +0530 Subject: [PATCH 4/7] Fixed bugs od index edit in table structure --- js/tbl_structure.js | 10 ++++++++-- tbl_indexes.php | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/js/tbl_structure.js b/js/tbl_structure.js index 3f49260fef..fb510353cc 100644 --- a/js/tbl_structure.js +++ b/js/tbl_structure.js @@ -338,8 +338,14 @@ $(document).ready(function() { } } else { - var temp_div = $("
").append(data.error); - var error = $(temp_div).find(".error code").addClass("error"); + if(data.error != undefined) { + var temp_div = $("
").append(data.error); + if($(temp_div).find(".error code").length != 0) { + var error = $(temp_div).find(".error code").addClass("error"); + } else { + var error = temp_div; + } + } PMA_ajaxShowMessage(error); } diff --git a/tbl_indexes.php b/tbl_indexes.php index d93018c76d..39205f24df 100644 --- a/tbl_indexes.php +++ b/tbl_indexes.php @@ -108,6 +108,10 @@ if (isset($_REQUEST['do_save_data'])) { require './tbl_structure.php'; exit; } else { + if( $GLOBALS['is_ajax_request'] == true) { + $extra_data['error'] = $error; + PMA_ajaxResponse($error,false); + } $error->display(); } } // end builds the new index From 526c72652fefca7025614552f5f5ad80d912462c Mon Sep 17 00:00:00 2001 From: Thilanka Kaushalya Date: Fri, 8 Jul 2011 15:35:28 +0530 Subject: [PATCH 5/7] Fixed bugs in index edit in table structure --- js/tbl_structure.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/js/tbl_structure.js b/js/tbl_structure.js index fb510353cc..49e3fe08f5 100644 --- a/js/tbl_structure.js +++ b/js/tbl_structure.js @@ -179,6 +179,7 @@ $(document).ready(function() { height: 230, width: 900, open: PMA_verifyTypeOfAllColumns, + modal: true, buttons : button_options_error })// end dialog options } else { @@ -189,6 +190,7 @@ $(document).ready(function() { height: 600, width: 900, open: PMA_verifyTypeOfAllColumns, + modal: true, buttons : button_options }) //Remove the top menu container from the dialog @@ -285,6 +287,7 @@ $(document).ready(function() { height: 230, width: 900, open: PMA_verifyTypeOfAllColumns, + modal: true, buttons : button_options_error })// end dialog options } else { @@ -295,6 +298,7 @@ $(document).ready(function() { height: 600, width: 900, open: PMA_verifyTypeOfAllColumns, + modal: true, buttons : button_options }) //Remove the top menu container from the dialog From f778dfc5af9756e6ab438a279d3ec1d60af57add Mon Sep 17 00:00:00 2001 From: Thilanka Kaushalya Date: Fri, 8 Jul 2011 21:09:13 +0530 Subject: [PATCH 6/7] Fixed the variable names in checkIndexName function --- js/functions.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/js/functions.js b/js/functions.js index a718929814..ae5cdbad8f 100644 --- a/js/functions.js +++ b/js/functions.js @@ -2170,21 +2170,21 @@ function checkIndexName(form_id) } // Gets the elements pointers - var the_idx_name = $("#input_index_name"); - var the_idx_type = $("#select_index_type"); + var $the_idx_name = $("#input_index_name"); + var $the_idx_type = $("#select_index_type"); // Index is a primary key - if (the_idx_type.find("option:selected").attr("value") == 'PRIMARY') { - the_idx_name.attr("value", 'PRIMARY'); - the_idx_name.attr("disabled", true); + if ($the_idx_type.find("option:selected").attr("value") == 'PRIMARY') { + $the_idx_name.attr("value", 'PRIMARY'); + $the_idx_name.attr("disabled", true); } // Other cases else { - if (the_idx_name.attr("value") == 'PRIMARY') { - the_idx_name.attr("value", ''); + if ($the_idx_name.attr("value") == 'PRIMARY') { + $the_idx_name.attr("value", ''); } - the_idx_name.attr("disabled", false); + $the_idx_name.attr("disabled", false); } return true; From 65c8f659e0adc68e698d9d9be13a1092cb716d7a Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Fri, 8 Jul 2011 16:31:06 -0400 Subject: [PATCH 7/7] ChangeLog entry for table Structure Index Edit --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 4df55e5fd7..b03cafbb35 100644 --- a/ChangeLog +++ b/ChangeLog @@ -34,6 +34,7 @@ phpMyAdmin - ChangeLog + Show/hide column in table Browse - bug #3353856 [AJAX] AJAX dialogs use wrong font-size - bug #3354356 [interface] Timepicker does not work in AJAX dialogs ++ AJAX for table Structure Indexes Edit 3.4.4.0 (not yet released) - bug #3323060 [parser] SQL parser breaks AJAX requests if query has unclosed quotes