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.
This commit is contained in:
Ashesh Vashi 2016-01-05 12:36:33 +05:30
parent 1945872e3f
commit 7beaefd1c6
3 changed files with 30 additions and 24 deletions

View File

@ -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 = '<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">\
<div class="panel panel-default">\
<div class="panel-heading" role="tab" id="headingOne">\
@ -34,9 +34,9 @@ function(_, alertify, pgAdmin) {
</div>'
}
text += '</div>'
text += '</div>';
alertify.alert(
"{{ _('An error has occurred') }}",
title,
text
)
},

View File

@ -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);
}
});

View File

@ -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')) }}",