Do not send the incomplete definition of a node object to the server

instead show proper message.

Tweaked by Ashesh for adding the proper message
This commit is contained in:
Khushboo Vashi 2016-05-10 12:34:20 +05:30 committed by Ashesh Vashi
parent e8b4bb909b
commit 7a400bacf3
2 changed files with 33 additions and 27 deletions

View File

@ -12,6 +12,7 @@ function(_, S, pgAdmin) {
'CLICK_FOR_DETAILED_MSG': '%s<br><br>' + '{{ _('Click here for details.')|safe }}', 'CLICK_FOR_DETAILED_MSG': '%s<br><br>' + '{{ _('Click here for details.')|safe }}',
'GENERAL_CATEGORY': '{{ _("General")|safe }}', 'GENERAL_CATEGORY': '{{ _("General")|safe }}',
'SQL_TAB': '{{ _('SQL') }}', 'SQL_TAB': '{{ _('SQL') }}',
'SQL_INCOMPLETE': '{{ _('Incomplete definition') }}',
'SQL_NO_CHANGE': '-- ' + '{{ _('Nothing changed')|safe }}', 'SQL_NO_CHANGE': '-- ' + '{{ _('Nothing changed')|safe }}',
'MUST_BE_INT' : "{{ _("'%%s' must be an integer.")|safe }}", 'MUST_BE_INT' : "{{ _("'%%s' must be an integer.")|safe }}",
'MUST_BE_NUM' : "{{ _("'%%s' must be a numeric.")|safe }}", 'MUST_BE_NUM' : "{{ _("'%%s' must be a numeric.")|safe }}",

View File

@ -1394,38 +1394,43 @@
// Fetch the information only if the SQL tab is visible at the moment. // Fetch the information only if the SQL tab is visible at the moment.
if (this.dialog && obj.shown == this.tabIndex) { if (this.dialog && obj.shown == this.tabIndex) {
// We will send request to sever only if something is changed in model // We will send a request to the sever only if something has changed
// in a model and also it does not contain any error.
if(this.model.sessChanged()) { if(this.model.sessChanged()) {
if (_.size(this.model.errorModel.attributes) == 0) {
var self = this,
node = self.field.get('schema_node'),
msql_url = node.generate_url.apply(
node, [
null, 'msql', this.field.get('node_data'), !self.model.isNew(),
this.field.get('node_info')
]);
var self = this, // Fetching the modified SQL
node = self.field.get('schema_node'), self.model.trigger('pgadmin-view:msql:fetching', self.method, node);
msql_url = node.generate_url.apply(
node, [
null, 'msql', this.field.get('node_data'), !self.model.isNew(),
this.field.get('node_info')
]);
// Fetching the modified SQL $.ajax({
self.model.trigger('pgadmin-view:msql:fetching', self.method, node); url: msql_url,
type: 'GET',
$.ajax({ cache: false,
url: msql_url, data: self.model.toJSON(true, 'GET'),
type: 'GET', dataType: "json",
cache: false, contentType: "application/json"
data: self.model.toJSON(true, 'GET'), }).done(function(res) {
dataType: "json", self.sqlCtrl.clearHistory();
contentType: "application/json" self.sqlCtrl.setValue(res.data);
}).done(function(res) { }).fail(function() {
self.sqlCtrl.clearHistory(); self.model.trigger('pgadmin-view:msql:error', self.method, node, arguments);
self.sqlCtrl.setValue(res.data); }).always(function() {
}).fail(function() { self.model.trigger('pgadmin-view:msql:fetched', self.method, node, arguments);
self.model.trigger('pgadmin-view:msql:error', self.method, node, arguments); });
}).always(function() { } else {
self.model.trigger('pgadmin-view:msql:fetched', self.method, node, arguments); this.sqlCtrl.clearHistory();
}); this.sqlCtrl.setValue('-- ' + window.pgAdmin.Browser.messages.SQL_INCOMPLETE);
}
} else { } else {
this.sqlCtrl.clearHistory(); this.sqlCtrl.clearHistory();
this.sqlCtrl.setValue(window.pgAdmin.Browser.messages.SQL_NO_CHANGE); this.sqlCtrl.setValue('-- ' + window.pgAdmin.Browser.messages.SQL_NO_CHANGE);
} }
this.sqlCtrl.refresh.apply(this.sqlCtrl); this.sqlCtrl.refresh.apply(this.sqlCtrl);
} }