Added ajax dialog for table row change

This commit is contained in:
Thilanka Kaushalya 2011-06-18 22:36:54 +05:30
parent 81ebc00206
commit a8f258cb8d
4 changed files with 134 additions and 2 deletions

View File

@ -117,6 +117,8 @@ $js_messages['strInlineEdit'] = __('Inline Edit');
$js_messages['strEdit'] = __('Edit');
$js_messages['strSave'] = __('Save');
$js_messages['strHide'] = __('Hide');
$js_messages['strNoRowSelected'] = __('No rows has selected. Please select rows to change');
$js_messages['strChangeTbl'] = __('Change Table');
/* For tbl_select.js */
$js_messages['strHideSearchCriteria'] = __('Hide search criteria');

127
js/sql.js
View File

@ -937,7 +937,7 @@ $(document).ready(function() {
}
}
})
rowsDeleteForm
/*
* update the where_clause, remove the last appended ' AND '
* */
@ -1013,6 +1013,131 @@ $(document).ready(function() {
PMA_unInlineEditRow($del_hide, $chg_submit, $this_td, $input_siblings, '', disp_mode);
}
}) // End After editing, clicking again should post data
/** Ajax Event for table row change*/
$("#resultsForm.ajax .mult_submit[value=edit]").live('click', function(event){
event.preventDefault();
/*Check whether atleast one row is selected for change*/
if($("#table_results tbody tr").hasClass("marked")){
var div = $('<div id="change_row_dialog"></div>');
/**
* @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).parent().dialog('close').remove();}
var button_options_error = {};
button_options_error[PMA_messages['strOK']] = function() {$(this).parent().dialog('close').remove();}
var $form = $("#resultsForm");
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['strChangeTbl'],
height: 230,
width: 900,
open: PMA_verifyTypeOfAllColumns,
buttons : button_options_error
})// end dialog options
} else {
div
.append(data)
.dialog({
title: PMA_messages['strChangeTbl'],
height: 600,
width: 900,
open: PMA_verifyTypeOfAllColumns,
buttons : button_options
})
//Remove the top menu container from the dialog
.find("#topmenucontainer").hide()
; // end dialog options
$(".insertRowTable").addClass("ajax");
$("#buttonYes").addClass("ajax");
}
PMA_ajaxRemoveMessage($msgbox);
}) // end $.get()
} else {
PMA_ajaxShowMessage(PMA_messages['strNoRowSelected']);
}
});
$("#insertForm .insertRowTable.ajax input[value=Go]").live('click', function(event) {
event.preventDefault();
/**
* @var the_form object referring to the insert form
*/
var $form = $("#insertForm");
PMA_prepareForAjaxRequest($form);
//User wants to submit the form
$.post($form.attr('action'), $form.serialize() , function(data) {
if(data.success == true) {
PMA_ajaxShowMessage(data.message);
$("#pageselector").trigger('change');
} else {
PMA_ajaxShowMessage(data.error);
$("#table_results tbody tr.marked .multi_checkbox").prop("checked", false);
$("#table_results tbody tr.marked .multi_checkbox").removeClass("last_clicked");
$("#table_results tbody tr").removeClass("marked");
}
if ($("#change_row_dialog").length > 0) {
$("#change_row_dialog").dialog("close").remove();
}
/**Update the row count at the tableForm*/
$("#result_query").remove();
$("#sqlqueryresults").prepend(data.sql_query);
}) // end $.post()
}) // end insert table button "Go"
$("#buttonYes.ajax").live('click', function(event){
event.preventDefault();
/**
* @var the_form object referring to the insert form
*/
var $form = $("#insertForm");
/**Get the submit type and the after insert type in the form*/
var selected_submit_type = $("#insertForm").find("#actions_panel .control_at_footer option:selected").attr('value');
var selected_after_insert = $("#insertForm").find("#actions_panel select[name=after_insert] option:selected").attr('value');
$("#result_query").remove();
PMA_prepareForAjaxRequest($form);
//User wants to submit the form
$.post($form.attr('action'), $form.serialize() , function(data) {
if(data.success == true) {
PMA_ajaxShowMessage(data.message);
if (selected_submit_type == "showinsert") {
$("#sqlqueryresults").prepend(data.sql_query);
$("#result_query .notice").remove();
$("#result_query").prepend(data.message);
$("#table_results tbody tr.marked .multi_checkbox").prop("checked", false);
$("#table_results tbody tr.marked .multi_checkbox").removeClass("last_clicked");
$("#table_results tbody tr").removeClass("marked");
} else {
$("#pageselector").trigger('change');
$("#result_query").remove();
$("#sqlqueryresults").prepend(data.sql_query);
}
} else {
PMA_ajaxShowMessage(data.error);
$("#table_results tbody tr.marked .multi_checkbox").prop("checked", false);
$("#table_results tbody tr.marked .multi_checkbox").removeClass("last_clicked");
$("#table_results tbody tr").removeClass("marked");
}
if ($("#change_row_dialog").length > 0) {
$("#change_row_dialog").dialog("close").remove();
}
}) // end $.post()
});
}, 'top.frame_content') // end $(document).ready()

View File

@ -611,7 +611,11 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
// Start of form for multi-rows edit/delete/export
if ($is_display['del_lnk'] == 'dr' || $is_display['del_lnk'] == 'kp') {
echo '<form method="post" action="tbl_row_action.php" name="rowsDeleteForm" id="rowsDeleteForm">' . "\n";
echo '<form method="post" action="tbl_row_action.php" name="resultsForm" id="resultsForm"';
if ($GLOBALS['cfg']['AjaxEnable']) {
echo ' class="ajax" ';
}
echo '>' . "\n";
echo PMA_generate_common_hidden_inputs($db, $table, 1);
echo '<input type="hidden" name="goto" value="sql.php" />' . "\n";
}

View File

@ -15,6 +15,7 @@ require_once './libraries/check_user_privileges.lib.php';
require_once './libraries/bookmark.lib.php';
$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js';
$GLOBALS['js_include'][] = 'tbl_change.js';
if(isset($_SESSION['profiling'])) {
$GLOBALS['js_include'][] = 'highcharts/highcharts.js';