From 3a2d3e3c4eab717140526ca8ba5e6a234244c7d5 Mon Sep 17 00:00:00 2001 From: Thilanka Kaushalya Date: Thu, 21 Jul 2011 23:53:37 +0530 Subject: [PATCH 1/5] Ajaxified add columns option in table structure --- js/functions.js | 4 +++ js/messages.php | 3 +++ js/tbl_structure.js | 63 +++++++++++++++++++++++++++++++++++++++++++++ tbl_addfield.php | 6 +++++ tbl_structure.php | 2 +- 5 files changed, 77 insertions(+), 1 deletion(-) diff --git a/js/functions.js b/js/functions.js index 045296d181..ab43c0eaea 100644 --- a/js/functions.js +++ b/js/functions.js @@ -1870,16 +1870,20 @@ $(document).ready(function() { $("#result_query").prepend((data.message)); if ($("#change_column_dialog").length > 0) { $("#change_column_dialog").dialog("close").remove(); + } else if ($("#add_columns").length > 0) { + $("#add_columns").dialog("close").remove(); } /*Reload the field form*/ $.post($("#fieldsForm").attr('action'), $("#fieldsForm").serialize()+"&ajax_request=true", function(form_data) { $("#fieldsForm").remove(); + $("#addColumns").remove(); var $temp_div = $("
").append(form_data); if ($("#sqlqueryresults").length != 0) { $temp_div.find("#fieldsForm").insertAfter("#sqlqueryresults"); } else { $temp_div.find("#fieldsForm").insertAfter(".error"); } + $temp_div.find("#addColumns").insertBefore("iframe.IE_hack"); /*Call the function to display the more options in table*/ displayMoreTableOpts(); }); diff --git a/js/messages.php b/js/messages.php index 5b91d791d9..4cfa7e7e44 100644 --- a/js/messages.php +++ b/js/messages.php @@ -207,6 +207,9 @@ $js_messages['strShowSearchCriteria'] = __('Show search criteria'); /* For tbl_change.js */ $js_messages['strIgnore'] = __('Ignore'); +/* For tbl_structure.js */ +$js_messages['strAddColumns'] = __('Add columns'); + /* Designer (pmd/scripts/move.js) */ $js_messages['strSelectReferencedKey'] = __('Select referenced key'); $js_messages['strSelectForeignKey'] = __('Select Foreign Key'); diff --git a/js/tbl_structure.js b/js/tbl_structure.js index a9b9adae77..38503892cc 100644 --- a/js/tbl_structure.js +++ b/js/tbl_structure.js @@ -336,6 +336,67 @@ $(document).ready(function() { }); } //end show/hide table index + /** + *Ajax event handler for Add column(s) + **/ + $("#addColumns.ajax input[value=Go]").live('click', function(event){ + event.preventDefault(); + + /*Remove the hidden dialogs if there are*/ + if ($('#add_columns').length != 0) { + $('#add_columns').remove(); + } + var $div = $('
'); + + var $form = $("#addColumns"); + + /** + * @var button_options Object that stores the options passed to jQueryUI + * dialog + */ + var button_options = {}; + // in the following function we need to use $(this) + button_options[PMA_messages['strCancel']] = function() {$(this).dialog('close').remove();} + + var button_options_error = {}; + button_options_error[PMA_messages['strOK']] = function() {$(this).dialog('close').remove();} + var $msgbox = PMA_ajaxShowMessage(); + + $.get( $form.attr('action') , $form.serialize()+"&ajax_request=true" , function(data) { + //in the case of an error, show the error message returned. + if (data.success != undefined && data.success == false) { + $div + .append(data.error) + .dialog({ + title: PMA_messages['strAddColumns'], + height: 230, + width: 900, + open: PMA_verifyTypeOfAllColumns, + modal: true, + buttons : button_options_error + })// end dialog options + } else { + $div + .append(data) + .dialog({ + title: PMA_messages['strAddColumns'], + height: 600, + width: 900, + open: PMA_verifyTypeOfAllColumns, + modal: true, + buttons : button_options + }) + //Remove the top menu container from the dialog + .find("#topmenucontainer").hide() + ; // end dialog options + $div = $("#add_columns"); + PMA_convertFootnotesToTooltips($div); + } + PMA_ajaxRemoveMessage($msgbox); + }) // end $.get() + }); + + }) // end $(document).ready() @@ -396,6 +457,8 @@ function changeColumns(action,url) { $("#append_fields_form input[name=do_save_data]").addClass("ajax"); /*changed the z-index of the enum editor to allow the edit*/ $("#enum_editor").css("z-index", "1100"); + $div = $("#change_column_dialog"); + PMA_convertFootnotesToTooltips($div); } PMA_ajaxRemoveMessage($msgbox); }) // end $.get() diff --git a/tbl_addfield.php b/tbl_addfield.php index ec910fdf4b..a866fef7a9 100644 --- a/tbl_addfield.php +++ b/tbl_addfield.php @@ -184,6 +184,12 @@ if (isset($_REQUEST['do_save_data'])) { // Go back to the structure sub-page $message = PMA_Message::success(__('Table %1$s has been altered successfully')); $message->addParam($table); + + if( $GLOBALS['is_ajax_request'] == true) { + $extra_data['sql_query'] = PMA_showMessage(NULL, $sql_query); + PMA_ajaxResponse($message, $message->isSuccess(),$extra_data); + } + $active_page = 'tbl_structure.php'; require './tbl_structure.php'; } else { diff --git a/tbl_structure.php b/tbl_structure.php index afca2ea36e..6c5a778049 100644 --- a/tbl_structure.php +++ b/tbl_structure.php @@ -668,7 +668,7 @@ if (! $tbl_is_view && ! $db_is_information_schema) { ?>
-
onsubmit="return checkFormElementInRange(this, 'num_fields', '', 1)"> Date: Fri, 22 Jul 2011 07:40:14 +0530 Subject: [PATCH 2/5] Fixed issues of Add Columns --- js/functions.js | 4 ++-- js/tbl_structure.js | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/js/functions.js b/js/functions.js index c08dbf2f6d..7c76b0fc25 100644 --- a/js/functions.js +++ b/js/functions.js @@ -1836,12 +1836,12 @@ $(document).ready(function() { }, 'top.frame_content'); //end $(document).ready for 'Create Table' /** - * jQuery coding for 'Change Table'. Used on tbl_structure.php * + * jQuery coding for 'Change Table' and 'Add Column'. Used on tbl_structure.php * * Attach Ajax Event handlers for Change Table */ $(document).ready(function() { /** - *Ajax action for submitting the column change form + *Ajax action for submitting the "Column Change" and "Add Column" form **/ $("#append_fields_form input[name=do_save_data]").live('click', function(event) { event.preventDefault(); diff --git a/js/tbl_structure.js b/js/tbl_structure.js index 0d2f051c01..a453e3281c 100644 --- a/js/tbl_structure.js +++ b/js/tbl_structure.js @@ -389,7 +389,10 @@ $(document).ready(function() { //Remove the top menu container from the dialog .find("#topmenucontainer").hide() ; // end dialog options + $div = $("#add_columns"); + /*changed the z-index of the enum editor to allow the edit*/ + $("#enum_editor").css("z-index", "1100"); PMA_convertFootnotesToTooltips($div); } PMA_ajaxRemoveMessage($msgbox); From 710362f869da38590ae507ee86c11c49c49387fa Mon Sep 17 00:00:00 2001 From: Thilanka Kaushalya Date: Fri, 22 Jul 2011 23:31:44 +0530 Subject: [PATCH 3/5] Fixed issues in enum editor in table insert column option --- js/functions.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/js/functions.js b/js/functions.js index 7c76b0fc25..c5ace1b34a 100644 --- a/js/functions.js +++ b/js/functions.js @@ -2111,6 +2111,10 @@ $(document).ready(function() { $("#popup_background").css({"opacity":"0.7"}); $("#popup_background").fadeIn("fast"); $("#enum_editor").fadeIn("fast"); + /**Replacing the column name in the enum editor hearder*/ + var column_name = $("#append_fields_form").find("input[id=field_0_1]").attr("value"); + var h3_text = $("#enum_editor h3").html(); + $("#enum_editor h3").html(h3_text.split('"')[0]+'"'+column_name+'"'); // Get the values var values = $(this).parent().prev("input").attr("value").split(","); From 97055ad6fe4f13dccdf2288050e8c433a0db2be6 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Fri, 22 Jul 2011 14:33:28 -0400 Subject: [PATCH 4/5] Typo --- js/functions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/functions.js b/js/functions.js index 295996ac1f..7b36e516ad 100644 --- a/js/functions.js +++ b/js/functions.js @@ -2111,7 +2111,7 @@ $(document).ready(function() { $("#popup_background").css({"opacity":"0.7"}); $("#popup_background").fadeIn("fast"); $("#enum_editor").fadeIn("fast"); - /**Replacing the column name in the enum editor hearder*/ + /**Replacing the column name in the enum editor header*/ var column_name = $("#append_fields_form").find("input[id=field_0_1]").attr("value"); var h3_text = $("#enum_editor h3").html(); $("#enum_editor h3").html(h3_text.split('"')[0]+'"'+column_name+'"'); From 5bc41ef1dc31019daaa0933bec967ebff63b55e0 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Fri, 22 Jul 2011 14:34:46 -0400 Subject: [PATCH 5/5] ChangeLog for "AJAX for table Structure column Add" --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 38ac1e8af1..16e3cac510 100644 --- a/ChangeLog +++ b/ChangeLog @@ -39,6 +39,7 @@ phpMyAdmin - ChangeLog + [interface] Improved support for events + [interface] Improved support for triggers + [interface] Improved server monitoring ++ AJAX for table Structure column Add 3.4.4.0 (not yet released) - bug #3323060 [parser] SQL parser breaks AJAX requests if query has unclosed quotes