mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fix script options which were inadvertently broken in the query tool tab naming patch.
This commit is contained in:
parent
d70c3003d3
commit
2a87585665
@ -714,8 +714,9 @@ define([
|
|||||||
sql_url = 'sql';
|
sql_url = 'sql';
|
||||||
}
|
}
|
||||||
// Open data grid & pass the URL for fetching
|
// Open data grid & pass the URL for fetching
|
||||||
pgAdmin.DataGrid.show_query_tool.apply(
|
pgAdmin.DataGrid.show_query_tool(
|
||||||
this, [obj.generate_url(i, sql_url, d, true), i]
|
obj.generate_url(i, sql_url, d, true),
|
||||||
|
i, scriptType
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -52,6 +52,9 @@ define(['jquery'],
|
|||||||
$('#pg_text').remove(); // remove element
|
$('#pg_text').remove(); // remove element
|
||||||
|
|
||||||
return width;
|
return width;
|
||||||
|
},
|
||||||
|
capitalizeFirstLetter: function (string) {
|
||||||
|
return string.charAt(0).toUpperCase() + string.slice(1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return sqlEditorUtils;
|
return sqlEditorUtils;
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
define([
|
define([
|
||||||
'sources/gettext', 'jquery','alertify', 'pgadmin','codemirror',
|
'sources/gettext', 'jquery','alertify', 'pgadmin','codemirror',
|
||||||
|
'sources/sqleditor_utils',
|
||||||
'codemirror/mode/sql/sql', 'pgadmin.browser', 'wcdocker'
|
'codemirror/mode/sql/sql', 'pgadmin.browser', 'wcdocker'
|
||||||
], function(gettext, $, alertify, pgAdmin, CodeMirror) {
|
], function(gettext, $, alertify, pgAdmin, CodeMirror, sqlEditorUtils) {
|
||||||
// Some scripts do export their object in the window only.
|
// Some scripts do export their object in the window only.
|
||||||
// Generally the one, which do no have AMD support.
|
// Generally the one, which do no have AMD support.
|
||||||
var wcDocker = window.wcDocker,
|
var wcDocker = window.wcDocker,
|
||||||
@ -307,7 +308,7 @@ define([
|
|||||||
|
|
||||||
get_panel_title: function() {
|
get_panel_title: function() {
|
||||||
// Get the parent data from the tree node hierarchy.
|
// Get the parent data from the tree node hierarchy.
|
||||||
var tree = pgAdmin.Browser.tree,
|
var tree = pgAdmin.Browser.tree,
|
||||||
selected_item = tree.selected(),
|
selected_item = tree.selected(),
|
||||||
item_data = tree.itemData(selected_item);
|
item_data = tree.itemData(selected_item);
|
||||||
var self = this;
|
var self = this;
|
||||||
@ -401,9 +402,10 @@ define([
|
|||||||
},
|
},
|
||||||
|
|
||||||
// This is a callback function to show query tool when user click on menu item.
|
// This is a callback function to show query tool when user click on menu item.
|
||||||
show_query_tool: function(url, i) {
|
show_query_tool: function(url, i, panel_title) {
|
||||||
var self = this,
|
var self = this,
|
||||||
sURL = url || '',
|
sURL = url || '',
|
||||||
|
panel_title = panel_title || '';
|
||||||
d = pgAdmin.Browser.tree.itemData(i);
|
d = pgAdmin.Browser.tree.itemData(i);
|
||||||
if (d === undefined) {
|
if (d === undefined) {
|
||||||
alertify.alert(
|
alertify.alert(
|
||||||
@ -436,19 +438,25 @@ define([
|
|||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
success: function(res) {
|
success: function(res) {
|
||||||
|
|
||||||
var grid_title = self.get_panel_title();
|
var grid_title = self.get_panel_title();
|
||||||
// Open the panel if frame is initialized
|
// Open the panel if frame is initialized
|
||||||
baseUrl = "{{ url_for('datagrid.index') }}" + "panel/" + res.data.gridTransId + "/true/"
|
baseUrl = "{{ url_for('datagrid.index') }}" + "panel/" + res.data.gridTransId + "/true/"
|
||||||
+ encodeURIComponent(grid_title) + '?' + "query_url=" + encodeURI(sURL);
|
+ encodeURIComponent(grid_title) + '?' + "query_url=" + encodeURI(sURL);
|
||||||
|
// Create title for CREATE/DELETE scripts
|
||||||
|
if (panel_title) {
|
||||||
|
panel_title =
|
||||||
|
sqlEditorUtils.capitalizeFirstLetter(panel_title) + ' script';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
panel_title = gettext('Query - ') + grid_title;
|
||||||
|
}
|
||||||
|
|
||||||
grid_title = gettext('Query - ') + grid_title;
|
|
||||||
if (res.data.newBrowserTab) {
|
if (res.data.newBrowserTab) {
|
||||||
var newWin = window.open(baseUrl, '_blank');
|
var newWin = window.open(baseUrl, '_blank');
|
||||||
|
|
||||||
// add a load listener to the window so that the title gets changed on page load
|
// add a load listener to the window so that the title gets changed on page load
|
||||||
newWin.addEventListener("load", function() {
|
newWin.addEventListener("load", function() {
|
||||||
newWin.document.title = grid_title;
|
newWin.document.title = panel_title;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
/* On successfully initialization find the dashboard panel,
|
/* On successfully initialization find the dashboard panel,
|
||||||
@ -456,7 +464,7 @@ define([
|
|||||||
*/
|
*/
|
||||||
var dashboardPanel = pgBrowser.docker.findPanels('dashboard');
|
var dashboardPanel = pgBrowser.docker.findPanels('dashboard');
|
||||||
queryToolPanel = pgBrowser.docker.addPanel('frm_datagrid', wcDocker.DOCK.STACKED, dashboardPanel[0]);
|
queryToolPanel = pgBrowser.docker.addPanel('frm_datagrid', wcDocker.DOCK.STACKED, dashboardPanel[0]);
|
||||||
queryToolPanel.title('<span title="'+grid_title+'">'+grid_title+'</span>');
|
queryToolPanel.title('<span title="'+panel_title+'">'+panel_title+'</span>');
|
||||||
queryToolPanel.icon('fa fa-bolt');
|
queryToolPanel.icon('fa fa-bolt');
|
||||||
queryToolPanel.focus();
|
queryToolPanel.focus();
|
||||||
|
|
||||||
|
@ -23,5 +23,10 @@ function (SqlEditorUtils) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('Capitalize the first letter of given string', function () {
|
||||||
|
it('returns string with First letter Capital', function () {
|
||||||
|
expect(SqlEditorUtils.capitalizeFirstLetter('create script')).toEqual('Create script');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user