From b37b479da03b02cab23ce039ecb299496afa6b6d Mon Sep 17 00:00:00 2001 From: Hugues Peccatte Date: Wed, 21 Aug 2019 23:05:15 +0200 Subject: [PATCH 1/2] Display an error when trying to import in designer a table that's already imported Signed-off-by: Hugues Peccatte --- js/designer/move.js | 12 ++++++++++++ js/messages.php | 3 +++ 2 files changed, 15 insertions(+) diff --git a/js/designer/move.js b/js/designer/move.js index 3fb8cd3cb7..b37d03fdda 100644 --- a/js/designer/move.js +++ b/js/designer/move.js @@ -554,6 +554,18 @@ function Add_Other_db_tables () { button_options[PMA_messages.strGo] = function () { var db = $('#add_table_from').val(); var table = $('#add_table').val(); + + //Check if table already imported or not. + var $table = $('[id="' + encodeURIComponent(db) + '.' + encodeURIComponent(table) + '"]'); + if ($table.length !== 0) { + PMA_ajaxShowMessage( + PMA_sprintf(PMA_messages.strTableAlreadyExists, db + '.' + table), + undefined, + 'error' + ); + return; + } + $.post('db_designer.php', { 'ajax_request' : true, 'dialog' : 'add_table', diff --git a/js/messages.php b/js/messages.php index 2bf1822cb9..6e4383d7ff 100644 --- a/js/messages.php +++ b/js/messages.php @@ -751,6 +751,9 @@ $js_messages['strStrong'] = __('Strong'); $js_messages['strU2FTimeout'] = __('Timed out waiting for security key activation.'); $js_messages['strU2FError'] = __('Failed security key activation (%s).'); +/* Designer */ +$js_messages['strTableAlreadyExists'] = __('Table %s already exists!'); + echo "var PMA_messages = new Array();\n"; foreach ($js_messages as $name => $js_message) { Sanitize::printJsValue("PMA_messages['" . $name . "']", $js_message); From 58e3b71ae251a6234551af6892f49942577cfacb Mon Sep 17 00:00:00 2001 From: Hugues Peccatte Date: Thu, 22 Aug 2019 10:05:13 +0200 Subject: [PATCH 2/2] Update js/messages.php add context for translators Co-Authored-By: William Desportes Signed-off-by: Hugues Peccatte --- js/messages.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/messages.php b/js/messages.php index 6e4383d7ff..72bff5f107 100644 --- a/js/messages.php +++ b/js/messages.php @@ -752,7 +752,7 @@ $js_messages['strU2FTimeout'] = __('Timed out waiting for security key activatio $js_messages['strU2FError'] = __('Failed security key activation (%s).'); /* Designer */ -$js_messages['strTableAlreadyExists'] = __('Table %s already exists!'); +$js_messages['strTableAlreadyExists'] = _pgettext('The table already exists in the designer and can not be added once more.', 'Table %s already exists!'); echo "var PMA_messages = new Array();\n"; foreach ($js_messages as $name => $js_message) {