From 7beaefd1c6eb9e3b9e70c2bd72358a9de7d6f888 Mon Sep 17 00:00:00 2001 From: Ashesh Vashi Date: Tue, 5 Jan 2016 12:36:33 +0530 Subject: [PATCH] Resolving few issues with the drop/drop cascade object function at front-end. Also, modified the translation messages as per Dave (Thanks Akshay Joshi for the patch). Modified the way, we show the error message dialog. --- .../browser/templates/browser/js/error.js | 6 +-- .../browser/templates/browser/js/node.js | 46 +++++++++++-------- web/pgadmin/templates/base.html | 2 +- 3 files changed, 30 insertions(+), 24 deletions(-) diff --git a/web/pgadmin/browser/templates/browser/js/error.js b/web/pgadmin/browser/templates/browser/js/error.js index 6e448970f..5fb326369 100644 --- a/web/pgadmin/browser/templates/browser/js/error.js +++ b/web/pgadmin/browser/templates/browser/js/error.js @@ -4,7 +4,7 @@ function(_, alertify, pgAdmin) { pgAdmin.Browser = pgAdmin.Browser || {}; _.extend(pgAdmin.Browser, { - report_error: function(message, info) { + report_error: function(title, message, info) { text = '
\
\ ' } - text += '
' + text += '
'; alertify.alert( - "{{ _('An error has occurred') }}", + title, text ) }, diff --git a/web/pgadmin/browser/templates/browser/js/node.js b/web/pgadmin/browser/templates/browser/js/node.js index 28dfed595..31cc38315 100644 --- a/web/pgadmin/browser/templates/browser/js/node.js +++ b/web/pgadmin/browser/templates/browser/js/node.js @@ -388,16 +388,22 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, Backform) { p.focus(); }, // Delete the selected object - delete_obj: function(args) { + delete_obj: function(args, item) { var input = args || {}; obj = this, t = pgBrowser.tree, - i = input.item || t.selected(), + i = input.item || item || t.selected(), d = i && i.length == 1 ? t.itemData(i) : undefined; if (!d) return; + /* + * Make sure - we're using the correct version of node + */ + obj = pgBrowser.Nodes[d._type]; + var objName = d.label; + var msg, title; if (input.url == 'delete') { @@ -405,27 +411,28 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, Backform) { .sprintf(obj.label, d.label).value(); title = S('{{ _('Drop CASACDE %%s?') }}').sprintf(obj.label).value(); - if (!pgBrowser.Nodes[d._type].canDropCascade(d, i)) { + if (!(_.isFunction(obj.canDropCascade) ? + obj.canDropCascade.apply(obj, [d, i]) : obj.canDropCascade)) { Alertify.notify( - S('The %s - "%s" can not be deleted!') - .sprintf(obj.label, d.label).value(), - 'error', - 10 - ); + S('The %s - "%s" can not be deleted!') + .sprintf(obj.label, d.label).value(), + 'error', + 10 + ); return; } } else { - msg = S('{{ _('Are you sure you wish to drop the %%s - "%%s"?') }}') + msg = S('{{ _('Are you sure you want to drop %%s "%%s"?') }}') .sprintf(obj.label, d.label).value(); title = S('{{ _('Drop %%s?') }}').sprintf(obj.label).value(); - if (!pgBrowser.Nodes[d._type].canDropCascade(d, i)) { + if (!(_.isFunction(obj.canDrop) ? + obj.canDrop.apply(obj, [d, i]) : obj.canDrop)) { Alertify.notify( - S('The %s - "%s" can not be deleted!') - .sprintf(obj.label, d.label).value(), - 'error', - 10 - ); + S('The %s - "%s" can not be deleted!') + .sprintf(obj.label, d.label).value(), + 'error', 10 + ); return; } } @@ -451,16 +458,15 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, Backform) { error: function(jqx) { var msg = jqx.responseText; /* Error from the server */ - if (jqx.status == 410) { + if (jqx.status == 410 || jqx.status == 500) { try { - var data = $.parseJSON( - jqx.responseText); + var data = $.parseJSON(jqx.responseText); msg = data.errormsg; } catch (e) {} } pgBrowser.report_error( - S('{{ _('Error droping the %%s - "%%s"') }}') - .sprintf(obj.label, d.label) + S('{{ _('Error dropping %%s: "%%s"') }}') + .sprintf(obj.label, objName) .value(), msg); } }); diff --git a/web/pgadmin/templates/base.html b/web/pgadmin/templates/base.html index 9c67e5750..a7d248496 100755 --- a/web/pgadmin/templates/base.html +++ b/web/pgadmin/templates/base.html @@ -78,7 +78,7 @@ pgadmin: "{{ url_for('static', filename='js/pgadmin') }}", modernizr: "{{ url_for('static', filename='js/modernizr-2.6.2-respond-1.1.0.min') }}", jquery: "{{ url_for('static', filename='js/' + ('jquery-1.11.2' if config.DEBUG else 'jquery-1.11.2.min')) }}", - select2: "{{ url_for('static', filename='js/select2/' + ('select2.full' if config.DEBUG else 'select2.min.full')) }}", + select2: "{{ url_for('static', filename='js/select2/' + ('select2.full' if config.DEBUG else 'select2.full.min')) }}", underscore: "{{ url_for('static', filename='js/' + ('underscore' if config.DEBUG else 'underscore-min')) }}", "underscore.string": "{{ url_for('static', filename='js/' + ('underscore.string' if config.DEBUG else 'underscore.string.min')) }}", bootstrap: "{{ url_for('static', filename='js/' + ('bootstrap' if config.DEBUG else 'bootstrap.min')) }}",