From 5f154503d00f94a2247e370455e0b720ef8526a8 Mon Sep 17 00:00:00 2001 From: Aris Feryanto Date: Tue, 2 Aug 2011 13:02:05 +0800 Subject: [PATCH 1/2] Grid edit: fix bug - (1) update delete confirmation message after grid editing, (2) change wrongly named variable, 'nonunique', copied from inline edit code --- js/makegrid.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/js/makegrid.js b/js/makegrid.js index 417e0ead8f..81ee236481 100644 --- a/js/makegrid.js +++ b/js/makegrid.js @@ -869,9 +869,9 @@ */ var full_where_clause = Array(); /** - * @var nonunique Boolean, whether the rows in this table is unique or not + * @var is_unique Boolean, whether the rows in this table is unique or not */ - var nonunique = $('.inline_edit_anchor').is('.nonunique') ? 0 : 1; + var is_unique = $('.inline_edit_anchor').is('.nonunique') ? 0 : 1; /** * multi edit variables */ @@ -973,7 +973,7 @@ 'server' : g.server, 'db' : g.db, 'table' : g.table, - 'clause_is_unique' : nonunique, + 'clause_is_unique' : is_unique, 'where_clause' : full_where_clause, 'fields[multi_edit]' : me_fields, 'fields_name[multi_edit]' : me_fields_name, @@ -1019,6 +1019,15 @@ // update Edit, Copy, and Delete links also $(this).parent('tr').find('a').each(function() { $(this).attr('href', $(this).attr('href').replace(old_clause, new_clause)); + // update delete confirmation in Delete link + if ($(this).attr('href').indexOf('DELETE') > -1) { + $(this).removeAttr('onclick') + .unbind('click') + .bind('click', function() { + return confirmLink(this, 'DELETE FROM `' + g.db + '`.`' + g.table + '` WHERE ' + + PMA_urldecode(new_clause) + (is_unique ? '' : ' LIMIT 1')); + }); + } }); } }); From 65bea22f1faa7dda9ffa9bd04d00b7fb47a01907 Mon Sep 17 00:00:00 2001 From: Aris Feryanto Date: Tue, 2 Aug 2011 13:07:25 +0800 Subject: [PATCH 2/2] Grid edit: fix bug - multi rows edit not work correctly on grid edited rows, if the primary key changed (case if there is a primary key) or some field changed (case if there is no primary key) --- js/makegrid.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/js/makegrid.js b/js/makegrid.js index 81ee236481..e24c39ade8 100644 --- a/js/makegrid.js +++ b/js/makegrid.js @@ -1015,6 +1015,9 @@ if (new_clause != '') { var $where_clause = $(this).parent('tr').find('.where_clause'); var old_clause = $where_clause.attr('value'); + var decoded_old_clause = PMA_urldecode(old_clause); + var decoded_new_clause = PMA_urldecode(new_clause); + $where_clause.attr('value', new_clause); // update Edit, Copy, and Delete links also $(this).parent('tr').find('a').each(function() { @@ -1025,10 +1028,19 @@ .unbind('click') .bind('click', function() { return confirmLink(this, 'DELETE FROM `' + g.db + '`.`' + g.table + '` WHERE ' + - PMA_urldecode(new_clause) + (is_unique ? '' : ' LIMIT 1')); + decoded_new_clause + (is_unique ? '' : ' LIMIT 1')); }); } }); + // update the multi edit checkboxes + $(this).parent('tr').find('input[type=checkbox]').each(function() { + var $checkbox = $(this); + var checkbox_name = $checkbox.attr('name'); + var checkbox_value = $checkbox.attr('value'); + + $checkbox.attr('name', checkbox_name.replace(old_clause, new_clause)); + $checkbox.attr('value', checkbox_value.replace(decoded_old_clause, decoded_new_clause)); + }); } }); // remove possible previous feedback message