From 58d97f87eec2291f6762894a858cf60ceeb77c8a Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Fri, 1 Jul 2011 16:45:03 +0100 Subject: [PATCH] Fix broken trigger links after edit operation --- js/db_routines.js | 59 +++++++++++++++++------------- libraries/rte/rte_triggers.lib.php | 15 ++++---- 2 files changed, 41 insertions(+), 33 deletions(-) diff --git a/js/db_routines.js b/js/db_routines.js index 0bf4e01c58..4491df9713 100644 --- a/js/db_routines.js +++ b/js/db_routines.js @@ -265,34 +265,41 @@ $(document).ready(function() { if (mode == 'edit') { $edit_row.remove(); } - // Insert the new row at the correct location in the list of routines - /** - * @var text Contains the name of a routine from the list - * that is used in comparisons to find the correct - * location where to insert a new row. - */ - var text = ''; - /** - * @var inserted Whether a new has been inserted - * in the list of routines or not. - */ - var inserted = false; - $('table.data').find('tr').each(function() { - text = $(this).children('td').eq(0).find('strong').text().toUpperCase(); - if (text != '' && text > data.name) { - $(this).before(data.new_row); - inserted = true; - return false; + + if (editor != 'trigger' || data.sameTable == true) { + // Insert the new row at the correct location in the list of routines + /** + * @var text Contains the name of a routine from the list + * that is used in comparisons to find the correct + * location where to insert a new row. + */ + var text = ''; + /** + * @var inserted Whether a new has been inserted + * in the list of routines or not. + */ + var inserted = false; + $('table.data').find('tr').each(function() { + text = $(this).children('td').eq(0).find('strong').text().toUpperCase(); + if (text != '' && text > data.name) { + $(this).before(data.new_row); + inserted = true; + return false; + } + }); + if (! inserted) { + $('table.data').append(data.new_row); } - }); - if (! inserted) { - $('table.data').append(data.new_row); + // Fade-in the new row + $('.ajaxInsert').show('slow').removeClass('ajaxInsert'); + // Now we have inserted the row at the correct position, but surely + // at least some row classes are wrong now. So we will itirate + // throught all rows and assign correct classes to them. + } else if ($('table.data').find('tr').has('td').length == 0) { + $('table.data').hide("slow", function () { + $('#nothing2display').show("slow"); + }); } - // Fade-in the new row - $('.ajaxInsert').show('slow').removeClass('ajaxInsert'); - // Now we have inserted the row at the correct position, but surely - // at least some row classes are wrong now. So we will itirate - // throught all rows and assign correct classes to them. /** * @var ct Count of processed rows. */ diff --git a/libraries/rte/rte_triggers.lib.php b/libraries/rte/rte_triggers.lib.php index c3b89f4d52..ef6d6c5ceb 100644 --- a/libraries/rte/rte_triggers.lib.php +++ b/libraries/rte/rte_triggers.lib.php @@ -120,14 +120,15 @@ function PMA_TRI_handleEditor() if ($GLOBALS['is_ajax_request']) { $extra_data = array(); if ($message->isSuccess()) { - $triggers = PMA_DBI_get_triggers($db, $table); - foreach ($triggers as $key => $value) { - if ($value['name'] == $_REQUEST['item_name']) { - $trigger = $value; - } + $trigger = PMA_TRI_getDataFromName($_REQUEST['item_name']); + $extra_data['name'] = htmlspecialchars(strtoupper($_REQUEST['item_name'])); + $extra_data['sameTable'] = false; + if (empty($table)) { + $extra_data['sameTable'] = true; + } else if ($table == $trigger['table']) { + $extra_data['sameTable'] = true; } - $extra_data['name'] = htmlspecialchars(strtoupper($_REQUEST['item_name'])); - $extra_data['new_row'] = PMA_RTE_getRowForList('trigger', $trigger, 0); + $extra_data['new_row'] = PMA_RTE_getRowForList('trigger', $trigger, 0); $response = $output; } else { $response = $message;