From 486da5e12c607c1ffd6efb3b669b00dd10294f2c Mon Sep 17 00:00:00 2001 From: Ashesh Vashi Date: Thu, 2 Jun 2016 13:15:24 +0530 Subject: [PATCH] Fixed issue only coming in the runtime. * Do not need to translate an empty string. (that results into the translation header inclusion in the javacript module). * String.prototype.StartsWith is not an well received function, it has not been available in the QWebkit for linux. --- .../tables/rules/templates/rules/js/rules.js | 4 +- .../schemas/types/templates/type/js/type.js | 2 +- .../schemas/views/templates/mview/js/mview.js | 2 +- .../misc/templates/explain/js/explain.js | 6 +- .../templates/sqleditor/js/sqleditor.js | 95 ++++++++++++++----- 5 files changed, 80 insertions(+), 29 deletions(-) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/templates/rules/js/rules.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/templates/rules/js/rules.js index c6ab579ec..dfc32c4de 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/templates/rules/js/rules.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/templates/rules/js/rules.js @@ -128,14 +128,14 @@ function($, _, S, pgAdmin, pgBrowser, CodeMirror) { type: 'text', disabled: true, mode: ['properties'] }, { - id: 'schema', label:'{{ _("") }}', + id: 'schema', label:'', type: 'text', visible: false, disabled: function(m) { // It is used while generating sql m.set('schema', m.node_info.schema.label); } }, { - id: 'view', label:'{{ _("") }}', + id: 'view', label:'', type: 'text', visible: false, disabled: function(m){ // It is used while generating sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/templates/type/js/type.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/templates/type/js/type.js index c478452aa..3f2803581 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/templates/type/js/type.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/templates/type/js/type.js @@ -392,7 +392,7 @@ function($, _, S, pgAdmin, pgBrowser, alertify, Backgrid) { mode: ['edit', 'create'], visible: function(m) { return m.get('typtype') === 'r'; - }, deps: ['typtype'], label: '{{ _('') }}', + }, deps: ['typtype'], label: '', schema:[{ id: 'typname', label:'{{ _('Sub-type') }}', cell: 'string', control: 'node-ajax-options', diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/js/mview.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/js/mview.js index e873f7d08..2c02a716d 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/js/mview.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/js/mview.js @@ -156,7 +156,7 @@ function($, _, S, pgAdmin, alertify, pgBrowser, CodeMirror) { id: 'comment', label:'{{ _("Comment") }}', cell: 'string', type: 'multiline' },{ - id: 'definition', label:'{{ _("") }}', cell: 'string', + id: 'definition', label:'', cell: 'string', type: 'text', mode: ['create', 'edit'], group: 'Definition', control: Backform.SqlFieldControl, extraClasses:['sql_field_width_full'] },{ diff --git a/web/pgadmin/misc/templates/explain/js/explain.js b/web/pgadmin/misc/templates/explain/js/explain.js index fd9a5e593..6c2299a67 100644 --- a/web/pgadmin/misc/templates/explain/js/explain.js +++ b/web/pgadmin/misc/templates/explain/js/explain.js @@ -170,12 +170,12 @@ var imageMapper = { command = data['Command']; if(strategy == "Hashed") { - if(command.startsWith("Intersect")) { + if(S.startsWith(command, "Intersect")) { if(command == "Intersect All") return {"image":"ex_hash_setop_intersect_all.png","image_text":"Hashed Intersect All"}; return {"image":"ex_hash_setop_intersect.png","image_text":"Hashed Intersect"}; } - else if (command.startsWith("Except")) { + else if (S.startsWith(command, "Except")) { if(command == "Except All") return {"image":"ex_hash_setop_except_all.png","image_text":"Hashed Except All"}; return {"image":"ex_hash_setop_except.png","image_text":"Hash Except"}; @@ -254,7 +254,7 @@ var PlanModel = Backbone.Model.extend({ ypos += yMargin; } - if(node_type.startsWith("(slice")) + if(S.startsWith(node_type, "(slice")) node_type = node_type.substring(0,7); // Get the image information for current node diff --git a/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js b/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js index b6ae5fe79..f0490b28c 100644 --- a/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js +++ b/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js @@ -565,10 +565,28 @@ define( ); }, + _stopEventPropogation: function(ev) { + ev = ev || window.event; + ev.cancelBubble = true; + ev.stopPropagation(); + ev.stopImmediatePropagation(); + ev.preventDefault(); + }, + + _closeDropDown: function(ev) { + var target = ev && (ev.currentTarget || ev.target); + if (target) { + $(target).closest('.open').removeClass('open').find('.dropdown-backdrop').remove(); + } + }, + // Callback function for Save button click. - on_save: function() { + on_save: function(ev) { var self = this; + this._stopEventPropogation(ev); + this._closeDropDown(ev); + // Trigger the save signal to the SqlEditorController class self.handler.trigger( 'pgadmin-sqleditor:button:save', @@ -590,9 +608,12 @@ define( }, // Callback function for include filter button click. - on_include_filter: function() { + on_include_filter: function(ev) { var self = this; + this._stopEventPropogation(ev); + this._closeDropDown(ev); + // Trigger the include_filter signal to the SqlEditorController class self.handler.trigger( 'pgadmin-sqleditor:button:include_filter', @@ -602,9 +623,12 @@ define( }, // Callback function for exclude filter button click. - on_exclude_filter: function() { + on_exclude_filter: function(ev) { var self = this; + this._stopEventPropogation(ev); + this._closeDropDown(ev); + // Trigger the exclude_filter signal to the SqlEditorController class self.handler.trigger( 'pgadmin-sqleditor:button:exclude_filter', @@ -614,9 +638,12 @@ define( }, // Callback function for remove filter button click. - on_remove_filter: function() { + on_remove_filter: function(ev) { var self = this; + this._stopEventPropogation(ev); + this._closeDropDown(ev); + // Trigger the remove_filter signal to the SqlEditorController class self.handler.trigger( 'pgadmin-sqleditor:button:remove_filter', @@ -716,25 +743,31 @@ define( }, // Callback function for the clear button click. - on_clear: function() { - var self = this; - self.query_tool_obj.setValue(''); + on_clear: function(ev) { + ev = ev || window.event; + ev.cancelBubble = true; + ev.stopPropagation(); + + this.query_tool_obj.setValue(''); }, // Callback function for the clear history button click. - on_clear_history: function() { - var self = this; + on_clear_history: function(ev) { + this._stopEventPropogation(ev); + this._closeDropDown(ev); // Remove any existing grid first - if (self.history_grid) { - self.history_collection.reset(); + if (this.history_grid) { + this.history_collection.reset(); } }, // Callback function for the auto commit button click. - on_auto_commit: function() { + on_auto_commit: function(ev) { var self = this; + this._stopEventPropogation(ev); + // Trigger the auto-commit signal to the SqlEditorController class self.handler.trigger( 'pgadmin-sqleditor:button:auto_commit', @@ -744,9 +777,11 @@ define( }, // Callback function for the auto rollback button click. - on_auto_rollback: function() { + on_auto_rollback: function(ev) { var self = this; + this._stopEventPropogation(ev); + // Trigger the download signal to the SqlEditorController class self.handler.trigger( 'pgadmin-sqleditor:button:auto_rollback', @@ -756,9 +791,12 @@ define( }, // Callback function for explain button click. - on_explain: function() { + on_explain: function(ev) { var self = this; + this._stopEventPropogation(ev); + this._closeDropDown(ev); + // Trigger the explain signal to the SqlEditorController class self.handler.trigger( 'pgadmin-sqleditor:button:explain', @@ -768,9 +806,12 @@ define( }, // Callback function for explain analyze button click. - on_explain_analyze: function() { + on_explain_analyze: function(ev) { var self = this; + this._stopEventPropogation(ev); + this._closeDropDown(ev); + // Trigger the explain analyze signal to the SqlEditorController class self.handler.trigger( 'pgadmin-sqleditor:button:explain-analyze', @@ -780,9 +821,11 @@ define( }, // Callback function for explain option "verbose" button click - on_explain_verbose: function() { + on_explain_verbose: function(ev) { var self = this; + this._stopEventPropogation(ev); + // Trigger the explain "verbose" signal to the SqlEditorController class self.handler.trigger( 'pgadmin-sqleditor:button:explain-verbose', @@ -792,9 +835,11 @@ define( }, // Callback function for explain option "costs" button click - on_explain_costs: function() { + on_explain_costs: function(ev) { var self = this; + this._stopEventPropogation(ev); + // Trigger the explain "costs" signal to the SqlEditorController class self.handler.trigger( 'pgadmin-sqleditor:button:explain-costs', @@ -804,9 +849,11 @@ define( }, // Callback function for explain option "buffers" button click - on_explain_buffers: function() { + on_explain_buffers: function(ev) { var self = this; + this._stopEventPropogation(ev); + // Trigger the explain "buffers" signal to the SqlEditorController class self.handler.trigger( 'pgadmin-sqleditor:button:explain-buffers', @@ -816,9 +863,11 @@ define( }, // Callback function for explain option "timing" button click - on_explain_timing: function() { + on_explain_timing: function(ev) { var self = this; + this._stopEventPropogation(ev); + // Trigger the explain "timing" signal to the SqlEditorController class self.handler.trigger( 'pgadmin-sqleditor:button:explain-timing', @@ -832,17 +881,19 @@ define( }, // callback function for load file button click. - on_file_load: function() { + on_file_load: function(ev) { var self = this; + this._stopEventPropogation(ev); + this._closeDropDown(ev); + // Trigger the save signal to the SqlEditorController class self.handler.trigger( 'pgadmin-sqleditor:button:load_file', self, self.handler ); - }, - + } }); /* Defining controller class for data grid, which actually