diff options
author | Deven Bansod <devenbansod.bits@gmail.com> | 2015-05-21 00:07:31 +0300 |
---|---|---|
committer | Deven Bansod <devenbansod.bits@gmail.com> | 2015-05-23 01:40:27 +0300 |
commit | 487c3266fc35aa16ba3101f7ad530d0748e3c5c3 (patch) | |
tree | 30c8976b2acf4ebc97f7c448600d1c087bb8013e /js/tbl_structure.js | |
parent | b4f477377c06b605455a747c691522b97204e658 (diff) |
RFE#946 : Change Collation w/o changing data and Confirm before changing
Signed-off-by: Deven Bansod <devenbansod.bits@gmail.com>
Diffstat (limited to 'js/tbl_structure.js')
-rw-r--r-- | js/tbl_structure.js | 85 |
1 files changed, 61 insertions, 24 deletions
diff --git a/js/tbl_structure.js b/js/tbl_structure.js index d734b55104..f110c59587 100644 --- a/js/tbl_structure.js +++ b/js/tbl_structure.js @@ -102,6 +102,7 @@ AJAX.registerOnload('tbl_structure.js', function () { * @var the_form object referring to the export form */ var $form = $(this); + var field_cnt = $form.find('input[name=orig_num_fields]').val(); /* * First validate the form; if there is a problem, avoid submitting it @@ -110,35 +111,71 @@ AJAX.registerOnload('tbl_structure.js', function () { * this is why we pass $form[0] as a parameter (the jQuery object * is actually an array of DOM elements) */ - if (checkTableEditForm($form[0], $form.find('input[name=orig_num_fields]').val())) { + if (checkTableEditForm($form[0], field_cnt)) { // OK, form passed validation step + PMA_prepareForAjaxRequest($form); if (PMA_checkReservedWordColumns($form)) { //User wants to submit the form - $msg = PMA_ajaxShowMessage(); - $.post($form.attr('action'), $form.serialize() + '&do_save_data=1', function (data) { - if ($(".sqlqueryresults").length !== 0) { - $(".sqlqueryresults").remove(); - } else if ($(".error:not(.tab)").length !== 0) { - $(".error:not(.tab)").remove(); - } - if (typeof data.success != 'undefined' && data.success === true) { - $("#page_content") - .empty() - .append(data.message) - .show(); - PMA_highlightSQL($('#page_content')); - $(".result_query .notice").remove(); - reloadFieldForm(); - $form.remove(); - PMA_ajaxRemoveMessage($msg); - PMA_init_slider(); - PMA_reloadNavigation(); - } else { - PMA_ajaxShowMessage(data.error, false); - } - }); // end $.post() + + // If Collation is changed, Warn and Confirm + if (checkIfConfirmRequired($form, field_cnt)){ + var question = sprintf( + PMA_messages.strChangeColumnCollation, 'http://wiki.phpmyadmin.net/pma/Garbled_data' + ); + $form.PMA_confirm(question, $form.attr('action'), function (url) { + submitForm(); + }); + } else { + submitForm(); + } + } + } + + function submitForm(){ + $msg = PMA_ajaxShowMessage(PMA_messages.strProcessingRequest); + $.post($form.attr('action'), $form.serialize() + '&do_save_data=1', function (data) { + if ($(".sqlqueryresults").length !== 0) { + $(".sqlqueryresults").remove(); + } else if ($(".error:not(.tab)").length !== 0) { + $(".error:not(.tab)").remove(); + } + if (typeof data.success != 'undefined' && data.success === true) { + $("#page_content") + .empty() + .append(data.message) + .show(); + PMA_highlightSQL($('#page_content')); + $(".result_query .notice").remove(); + reloadFieldForm(); + $form.remove(); + PMA_ajaxRemoveMessage($msg); + PMA_init_slider(); + PMA_reloadNavigation(); + } else { + PMA_ajaxShowMessage(data.error, false); + } + }); // end $.post() + } + + function checkIfConfirmRequired($form, $field_cnt) { + var i = 0, id, elm, val, name_orig, elm_orig, val_orig; + var checkRequired = false; + for (i = 0; i < field_cnt; i++) { + id = "#field_" + i + "_5"; + elm = $(id); + val = elm.val(); + + name_orig = "input[name=field_collation_orig\\[" + i + "\\]]"; + elm_orig = $form.find(name_orig); + val_orig = elm_orig.val(); + + if (val && val_orig && val !== val_orig){ + checkRequired = true; + break; + } } + return checkRequired; } }); // end change table button "do_save_data" |