adjust totals when dropping a table

This commit is contained in:
Marc Delisle
2010-11-14 08:08:14 -05:00
parent 5a72c4ea7d
commit d9d5abee08

View File

@@ -17,6 +17,39 @@
* Drop Table * Drop Table
* *
*/ */
/**
* Adjust number of rows and total size in the summary
* when emptying or dropping a table
*
* @param jQuery object $this_anchor
*/
function PMA_adjustTotals($this_anchor) {
var $parent_tr = $this_anchor.closest('tr');
var $rows_td = $parent_tr.find('.tbl_rows');
var $size_td = $parent_tr.find('.tbl_size');
var num_rows = parseInt($rows_td.text());
// set number of rows to 0
// (not really needed in case we are dropping the table)
$rows_td.text('0');
// set size to unknown (not sure how to get the exact
// value here, as an empty InnoDB table would have a size)
$size_td.text('-');
// try to compute a new total row number
if (! isNaN(num_rows)) {
$total_rows_td = $('#tbl_summary_row').find('.tbl_rows');
var total_rows = parseInt($total_rows_td.text());
if (! isNaN(total_rows)) {
$total_rows_td.text(total_rows - num_rows);
}
}
// prefix total size with "~"
var $total_size_td = $('#tbl_summary_row').find('.tbl_size');
$total_size_td.text($total_size_td.text().replace(/^/,'~'));
}
$(document).ready(function() { $(document).ready(function() {
/** /**
@@ -53,28 +86,7 @@ $(document).ready(function() {
//Fetch inner span of this anchor //Fetch inner span of this anchor
//and replace the icon with its disabled version //and replace the icon with its disabled version
var span = $this_anchor.html().replace(/b_empty.png/, 'bd_empty.png'); var span = $this_anchor.html().replace(/b_empty.png/, 'bd_empty.png');
var $parent_tr = $this_anchor.closest('tr'); PMA_adjustTotals($this_anchor);
var $rows_td = $parent_tr.find('.tbl_rows');
var $size_td = $parent_tr.find('.tbl_size');
var num_rows = parseInt($rows_td.text());
// set number of rows to 0
$rows_td.text('0');
// set size to unknown (not sure how to get the exact
// value here, as an empty InnoDB table would have a size)
$size_td.text('-');
// try to compute a new total row number
if (! isNaN(num_rows)) {
$total_rows_td = $('#tbl_summary_row').find('.tbl_rows');
var total_rows = parseInt($total_rows_td.text());
if (! isNaN(total_rows)) {
$total_rows_td.text(total_rows - num_rows);
}
}
// prefix total size with "~"
var $total_size_td = $('#tbl_summary_row').find('.tbl_size');
$total_size_td.text($total_size_td.text().replace(/^/,'~'));
//To disable further attempts to truncate the table, //To disable further attempts to truncate the table,
//replace the a element with its inner span (modified) //replace the a element with its inner span (modified)
@@ -120,7 +132,7 @@ $(document).ready(function() {
$.get(url, {'is_js_confirmed' : 1, 'ajax_request' : true}, function(data) { $.get(url, {'is_js_confirmed' : 1, 'ajax_request' : true}, function(data) {
if (data.success == true) { if (data.success == true) {
PMA_ajaxShowMessage(data.message); PMA_ajaxShowMessage(data.message);
//need to find a better solution here. The icon should be replaced PMA_adjustTotals($this_anchor);
$curr_row.hide("medium").remove(); $curr_row.hide("medium").remove();
if (window.parent && window.parent.frame_navigation) { if (window.parent && window.parent.frame_navigation) {